Changeset 46e9822


Ignore:
Timestamp:
2011-01-03T02:47:40Z (13 years ago)
Author:
Miklos Vajna <vmiklos@…>
Branches:
master
Children:
46641bf
Parents:
a5e6aa1
Message:

Make /invite work for existing groups

File:
1 edited

Legend:

Unmodified
Added
Removed
  • skype/skype.c

    ra5e6aa1 r46e9822  
    291291                                return sg->name;
    292292                }
     293        }
     294        return NULL;
     295}
     296
     297static struct skype_group *skype_group_by_name(struct im_connection *ic, char *name)
     298{
     299        struct skype_data *sd = ic->proto_data;
     300        int i;
     301
     302        for (i = 0; i < g_list_length(sd->groups); i++) {
     303                struct skype_group *sg = g_list_nth_data(sd->groups, i);
     304                if (!strcmp(sg->name, name))
     305                        return sg;
    293306        }
    294307        return NULL;
     
    9981011}
    9991012
     1013static void skype_parse_alter_group(struct im_connection *ic, char *line)
     1014{
     1015        char *id = line + strlen("ALTER GROUP");
     1016
     1017        if (!++id)
     1018                return;
     1019
     1020        char *info = strchr(id, ' ');
     1021
     1022        if (!info)
     1023                return;
     1024        *info = '\0';
     1025        info++;
     1026
     1027        if (!strncmp(info, "ADDUSER ", 8)) {
     1028                struct skype_group *sg = skype_group_by_id(ic, atoi(id));
     1029
     1030                info += 8;
     1031                if (sg) {
     1032                        char *buf = g_strdup_printf("%s@skype.com", info);
     1033                        sg->users = g_list_append(sg->users, g_strdup(info));
     1034                        imcb_add_buddy(ic, buf, sg->name);
     1035                        g_free(buf);
     1036                } else
     1037                        log_message(LOGLVL_ERROR,
     1038                                "No skype group with id %s. That's probably a bug.", id);
     1039        }
     1040}
     1041
    10001042typedef void (*skype_parser)(struct im_connection *ic, char *line);
    10011043
     
    10241066                { "CHATS ", skype_parse_chats },
    10251067                { "GROUPS ", skype_parse_groups },
     1068                { "ALTER GROUP ", skype_parse_alter_group },
    10261069        };
    10271070
     
    12701313        char *nick, *ptr;
    12711314
    1272         /* Unused parameter */
    1273         group = group;
    1274 
    12751315        nick = g_strdup(who);
    12761316        ptr = strchr(nick, '@');
    12771317        if (ptr)
    12781318                *ptr = '\0';
    1279         skype_printf(ic, "SET USER %s BUDDYSTATUS 2 Please authorize me\n",
    1280                 nick);
    1281         g_free(nick);
     1319
     1320        if (!group) {
     1321                skype_printf(ic, "SET USER %s BUDDYSTATUS 2 Please authorize me\n",
     1322                                nick);
     1323                g_free(nick);
     1324        } else {
     1325                struct skype_group *sg = skype_group_by_name(ic, group);
     1326
     1327                if (!sg) {
     1328                        // TODO
     1329                        /* No such group, we need to create it, then have to
     1330                         * add the user once it's created. */
     1331                        //skype_printf(ic, "CREATE GROUP %s", group);
     1332                } else {
     1333                        skype_printf(ic, "ALTER GROUP %d ADDUSER %s", sg->id, nick);
     1334                }
     1335        }
    12821336}
    12831337
Note: See TracChangeset for help on using the changeset viewer.