Changeset 54ca269 for skype


Ignore:
Timestamp:
2011-01-02T02:32:39Z (14 years ago)
Author:
Miklos Vajna <vmiklos@…>
Branches:
master
Children:
fbb15f2
Parents:
89d6845
Message:

Initial support for reading buddy groups

What works: if you have a few buddies in <group>, then /j &<group> will
show just those buddies.

What does not:

  • If you later move buddies using Skype UI, BitlBee is not yet notified.
  • You cannot move buddies using /invite yet.

What won't work in the near future: only the first group of each buddy
is parsed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • skype/skype.c

    r89d6845 r54ca269  
    277277}
    278278
     279static char *skype_group_by_username(struct im_connection *ic, char *username)
     280{
     281        struct skype_data *sd = ic->proto_data;
     282        int i, j;
     283
     284        /* NEEDSWORK: we just search for the first group of the user, multiple
     285         * groups / user is not yet supported by BitlBee. */
     286
     287        for (i = 0; i < g_list_length(sd->groups); i++) {
     288                struct skype_group *sg = g_list_nth_data(sd->groups, i);
     289                for (j = 0; j < g_list_length(sg->users); j++) {
     290                        if (!strcmp(g_list_nth_data(sg->users, j), username))
     291                                return sg->name;
     292                }
     293        }
     294        return NULL;
     295}
     296
    279297static void skype_parse_users(struct im_connection *ic, char *line)
    280298{
     
    308326                                return;
    309327                ptr = g_strdup_printf("%s@skype.com", user);
    310                 imcb_add_buddy(ic, ptr, NULL);
     328                imcb_add_buddy(ic, ptr, skype_group_by_username(ic, user));
    311329                if (strcmp(status, "OFFLINE") && (strcmp(status, "SKYPEOUT") ||
    312330                        !set_getbool(&ic->acc->set, "skypeout_offline")))
     
    324342                if (!strcmp(st, "3")) {
    325343                        char *buf = g_strdup_printf("%s@skype.com", user);
    326                         imcb_add_buddy(ic, buf, NULL);
     344                        imcb_add_buddy(ic, buf, skype_group_by_username(ic, user));
    327345                        g_free(buf);
    328346                }
     
    771789}
    772790
     791/* Update the group of each user in this group */
     792static void skype_group_users(struct im_connection *ic, struct skype_group *sg) {
     793        int i;
     794
     795        for (i = 0; i < g_list_length(sg->users); i++) {
     796                char *user = g_list_nth_data(sg->users, i);
     797                char *buf = g_strdup_printf("%s@skype.com", user);
     798                imcb_add_buddy(ic, buf, sg->name);
     799                g_free(buf);
     800        }
     801}
     802
    773803static void skype_parse_group(struct im_connection *ic, char *line)
    774804{
     
    815845                        }
    816846                        g_strfreev(users);
     847                        skype_group_users(ic, sg);
    817848                } else
    818849                        log_message(LOGLVL_ERROR, "No skype group with id %s. That's probably a bug.", id);
     
    10401071
    10411072        /* This will download all buddies and groups. */
    1042         st = skype_printf(ic, "SEARCH FRIENDS\n");
    1043         skype_printf(ic, "SEARCH GROUPS CUSTOM\n");
     1073        st = skype_printf(ic, "SEARCH GROUPS CUSTOM\n");
     1074        skype_printf(ic, "SEARCH FRIENDS\n");
    10441075
    10451076        skype_printf(ic, "SET USERSTATUS ONLINE\n");
Note: See TracChangeset for help on using the changeset viewer.