Changeset 5ebff60 for protocols/skype


Ignore:
Timestamp:
2015-02-20T22:50:54Z (9 years ago)
Author:
dequis <dx@…>
Branches:
master
Children:
0b9daac, 3d45471, 7733b8c
Parents:
af359b4
git-author:
Indent <please@…> (19-02-15 05:47:20)
git-committer:
dequis <dx@…> (20-02-15 22:50:54)
Message:

Reindent everything to K&R style with tabs

Used uncrustify, with the configuration file in ./doc/uncrustify.cfg

Commit author set to "Indent <please@…>" so that it's easier to
skip while doing git blame.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/skype/skype.c

    raf359b4 r5ebff60  
    3030#define SKYPE_DEFAULT_PORT "2727"
    3131#define IRC_LINE_SIZE 16384
    32 #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
     32#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
    3333
    3434/*
     
    151151        { "SKYPEME", "Skype Me" },
    152152        { "ONLINE", "Online" },
    153         { NULL, NULL}
     153        { NULL, NULL }
    154154};
    155155
     
    163163        struct pollfd pfd[1];
    164164
    165         if (!sd->ssl)
     165        if (!sd->ssl) {
    166166                return FALSE;
     167        }
    167168
    168169        pfd[0].fd = sd->fd;
     
    196197{
    197198        struct skype_buddy_ask_data *bla = data;
     199
    198200        skype_printf(bla->ic, "SET USER %s ISAUTHORIZED TRUE\n",
    199                 bla->handle);
     201                     bla->handle);
    200202        g_free(bla->handle);
    201203        g_free(bla);
     
    205207{
    206208        struct skype_buddy_ask_data *bla = data;
     209
    207210        skype_printf(bla->ic, "SET USER %s ISAUTHORIZED FALSE\n",
    208                 bla->handle);
     211                     bla->handle);
    209212        g_free(bla->handle);
    210213        g_free(bla);
     
    214217{
    215218        struct skype_buddy_ask_data *bla = g_new0(struct skype_buddy_ask_data,
    216                 1);
     219                                                  1);
    217220        char *buf;
    218221
     
    228231{
    229232        struct skype_buddy_ask_data *bla = data;
     233
    230234        skype_printf(bla->ic, "SET CALL %s STATUS INPROGRESS\n",
    231                 bla->handle);
     235                     bla->handle);
    232236        g_free(bla->handle);
    233237        g_free(bla);
     
    237241{
    238242        struct skype_buddy_ask_data *bla = data;
     243
    239244        skype_printf(bla->ic, "SET CALL %s STATUS FINISHED\n",
    240                 bla->handle);
     245                     bla->handle);
    241246        g_free(bla->handle);
    242247        g_free(bla);
     
    246251{
    247252        struct skype_buddy_ask_data *bla = g_new0(struct skype_buddy_ask_data,
    248                 1);
     253                                                  1);
    249254
    250255        bla->ic = ic;
     
    297302                struct skype_group *sg = g_list_nth_data(sd->groups, i);
    298303                for (j = 0; j < g_list_length(sg->users); j++) {
    299                         if (!strcmp(g_list_nth_data(sg->users, j), username))
     304                        if (!strcmp(g_list_nth_data(sg->users, j), username)) {
    300305                                return sg->name;
     306                        }
    301307                }
    302308        }
     
    311317        for (i = 0; i < g_list_length(sd->groups); i++) {
    312318                struct skype_group *sg = g_list_nth_data(sd->groups, i);
    313                 if (!strcmp(sg->name, name))
     319                if (!strcmp(sg->name, name)) {
    314320                        return sg;
     321                }
    315322        }
    316323        return NULL;
     
    339346        status++;
    340347        ptr = strchr(++user, ' ');
    341         if (!ptr)
     348        if (!ptr) {
    342349                return;
     350        }
    343351        *ptr = '\0';
    344352        ptr++;
    345353        if (!strncmp(ptr, "ONLINESTATUS ", 13)) {
    346                 if (!strlen(user) || !strcmp(user, sd->username))
     354                if (!strlen(user) || !strcmp(user, sd->username)) {
    347355                        return;
     356                }
    348357                if (!set_getbool(&ic->acc->set, "test_join")
    349                                 && !strcmp(user, "echo123"))
     358                    && !strcmp(user, "echo123")) {
    350359                        return;
     360                }
    351361                ptr = g_strdup_printf("%s@skype.com", user);
    352362                imcb_add_buddy(ic, ptr, skype_group_by_username(ic, user));
    353363                if (strcmp(status, "OFFLINE") && (strcmp(status, "SKYPEOUT") ||
    354                         !set_getbool(&ic->acc->set, "skypeout_offline")))
     364                                                  !set_getbool(&ic->acc->set, "skypeout_offline"))) {
    355365                        flags |= OPT_LOGGED_IN;
    356                 if (strcmp(status, "ONLINE") && strcmp(status, "SKYPEME"))
     366                }
     367                if (strcmp(status, "ONLINE") && strcmp(status, "SKYPEME")) {
    357368                        flags |= OPT_AWAY;
     369                }
    358370                imcb_buddy_status(ic, ptr, flags, NULL, NULL);
    359371                g_free(ptr);
    360372        } else if (!strncmp(ptr, "RECEIVEDAUTHREQUEST ", 20)) {
    361373                char *message = ptr + 20;
    362                 if (strlen(message))
     374                if (strlen(message)) {
    363375                        skype_buddy_ask(ic, user, message);
     376                }
    364377        } else if (!strncmp(ptr, "BUDDYSTATUS ", 12)) {
    365378                char *st = ptr + 12;
     
    374387                g_free(buf);
    375388                buf = ptr + 10;
    376                 if (bu)
     389                if (bu) {
    377390                        imcb_buddy_status(ic, bu->handle, bu->flags, NULL,
    378                                         *buf ? buf : NULL);
    379                 if (set_getbool(&ic->acc->set, "show_moods"))
     391                                          *buf ? buf : NULL);
     392                }
     393                if (set_getbool(&ic->acc->set, "show_moods")) {
    380394                        imcb_log(ic, "User `%s' changed mood text to `%s'", user, buf);
     395                }
    381396        } else if (!strncmp(ptr, "FULLNAME ", 9)) {
    382397                char *name = ptr + 9;
     
    389404                        g_free(buf);
    390405                }
    391         } else if (!strncmp(ptr, "PHONE_HOME ", 11))
     406        } else if (!strncmp(ptr, "PHONE_HOME ", 11)) {
    392407                sd->info_phonehome = g_strdup(ptr + 11);
    393         else if (!strncmp(ptr, "PHONE_OFFICE ", 13))
     408        } else if (!strncmp(ptr, "PHONE_OFFICE ", 13)) {
    394409                sd->info_phoneoffice = g_strdup(ptr + 13);
    395         else if (!strncmp(ptr, "PHONE_MOBILE ", 13))
     410        } else if (!strncmp(ptr, "PHONE_MOBILE ", 13)) {
    396411                sd->info_phonemobile = g_strdup(ptr + 13);
    397         else if (!strncmp(ptr, "NROF_AUTHED_BUDDIES ", 20))
     412        } else if (!strncmp(ptr, "NROF_AUTHED_BUDDIES ", 20)) {
    398413                sd->info_nrbuddies = g_strdup(ptr + 20);
    399         else if (!strncmp(ptr, "TIMEZONE ", 9))
     414        } else if (!strncmp(ptr, "TIMEZONE ", 9)) {
    400415                sd->info_tz = g_strdup(ptr + 9);
    401         else if (!strncmp(ptr, "LASTONLINETIMESTAMP ", 20))
     416        } else if (!strncmp(ptr, "LASTONLINETIMESTAMP ", 20)) {
    402417                sd->info_seen = g_strdup(ptr + 20);
    403         else if (!strncmp(ptr, "SEX ", 4))
     418        } else if (!strncmp(ptr, "SEX ", 4)) {
    404419                sd->info_sex = g_strdup(ptr + 4);
    405         else if (!strncmp(ptr, "LANGUAGE ", 9))
     420        } else if (!strncmp(ptr, "LANGUAGE ", 9)) {
    406421                sd->info_language = g_strdup(ptr + 9);
    407         else if (!strncmp(ptr, "COUNTRY ", 8))
     422        } else if (!strncmp(ptr, "COUNTRY ", 8)) {
    408423                sd->info_country = g_strdup(ptr + 8);
    409         else if (!strncmp(ptr, "PROVINCE ", 9))
     424        } else if (!strncmp(ptr, "PROVINCE ", 9)) {
    410425                sd->info_province = g_strdup(ptr + 9);
    411         else if (!strncmp(ptr, "CITY ", 5))
     426        } else if (!strncmp(ptr, "CITY ", 5)) {
    412427                sd->info_city = g_strdup(ptr + 5);
    413         else if (!strncmp(ptr, "HOMEPAGE ", 9))
     428        } else if (!strncmp(ptr, "HOMEPAGE ", 9)) {
    414429                sd->info_homepage = g_strdup(ptr + 9);
    415         else if (!strncmp(ptr, "ABOUT ", 6)) {
     430        } else if (!strncmp(ptr, "ABOUT ", 6)) {
    416431                /* Support multiple about lines. */
    417                 if (!sd->info_about)
     432                if (!sd->info_about) {
    418433                        sd->info_about = g_strdup(ptr + 6);
    419                 else {
     434                } else {
    420435                        GString *st = g_string_new(sd->info_about);
    421436                        g_string_append_printf(st, "\n%s", ptr + 6);
     
    430445                g_string_append_printf(st, "Skype Name: %s\n", user);
    431446                if (sd->info_fullname) {
    432                         if (strlen(sd->info_fullname))
     447                        if (strlen(sd->info_fullname)) {
    433448                                g_string_append_printf(st, "Full Name: %s\n",
    434                                         sd->info_fullname);
     449                                                       sd->info_fullname);
     450                        }
    435451                        g_free(sd->info_fullname);
    436452                        sd->info_fullname = NULL;
    437453                }
    438454                if (sd->info_phonehome) {
    439                         if (strlen(sd->info_phonehome))
     455                        if (strlen(sd->info_phonehome)) {
    440456                                g_string_append_printf(st, "Home Phone: %s\n",
    441                                         sd->info_phonehome);
     457                                                       sd->info_phonehome);
     458                        }
    442459                        g_free(sd->info_phonehome);
    443460                        sd->info_phonehome = NULL;
    444461                }
    445462                if (sd->info_phoneoffice) {
    446                         if (strlen(sd->info_phoneoffice))
     463                        if (strlen(sd->info_phoneoffice)) {
    447464                                g_string_append_printf(st, "Office Phone: %s\n",
    448                                         sd->info_phoneoffice);
     465                                                       sd->info_phoneoffice);
     466                        }
    449467                        g_free(sd->info_phoneoffice);
    450468                        sd->info_phoneoffice = NULL;
    451469                }
    452470                if (sd->info_phonemobile) {
    453                         if (strlen(sd->info_phonemobile))
     471                        if (strlen(sd->info_phonemobile)) {
    454472                                g_string_append_printf(st, "Mobile Phone: %s\n",
    455                                         sd->info_phonemobile);
     473                                                       sd->info_phonemobile);
     474                        }
    456475                        g_free(sd->info_phonemobile);
    457476                        sd->info_phonemobile = NULL;
     
    459478                g_string_append_printf(st, "Personal Information\n");
    460479                if (sd->info_nrbuddies) {
    461                         if (strlen(sd->info_nrbuddies))
     480                        if (strlen(sd->info_nrbuddies)) {
    462481                                g_string_append_printf(st,
    463                                         "Contacts: %s\n", sd->info_nrbuddies);
     482                                                       "Contacts: %s\n", sd->info_nrbuddies);
     483                        }
    464484                        g_free(sd->info_nrbuddies);
    465485                        sd->info_nrbuddies = NULL;
     
    469489                                char ib[256];
    470490                                time_t t = time(NULL);
    471                                 t += atoi(sd->info_tz)-(60*60*24);
     491                                t += atoi(sd->info_tz) - (60 * 60 * 24);
    472492                                struct tm *gt = gmtime(&t);
    473493                                strftime(ib, 256, "%H:%M:%S", gt);
    474494                                g_string_append_printf(st,
    475                                         "Local Time: %s\n", ib);
     495                                                       "Local Time: %s\n", ib);
    476496                        }
    477497                        g_free(sd->info_tz);
     
    485505                                strftime(ib, 256, ("%Y. %m. %d. %H:%M"), tm);
    486506                                g_string_append_printf(st,
    487                                         "Last Seen: %s\n", ib);
     507                                                       "Last Seen: %s\n", ib);
    488508                        }
    489509                        g_free(sd->info_seen);
     
    492512                if (sd->info_birthday) {
    493513                        if (strlen(sd->info_birthday) &&
    494                                 strcmp(sd->info_birthday, "0")) {
     514                            strcmp(sd->info_birthday, "0")) {
    495515                                char ib[256];
    496516                                struct tm tm;
     
    498518                                strftime(ib, 256, "%B %d, %Y", &tm);
    499519                                g_string_append_printf(st,
    500                                         "Birthday: %s\n", ib);
     520                                                       "Birthday: %s\n", ib);
    501521
    502522                                strftime(ib, 256, "%Y", &tm);
     
    505525                                struct tm *lt = localtime(&t);
    506526                                g_string_append_printf(st,
    507                                         "Age: %d\n", lt->tm_year+1900-year);
     527                                                       "Age: %d\n", lt->tm_year + 1900 - year);
    508528                        }
    509529                        g_free(sd->info_birthday);
     
    513533                        if (strlen(sd->info_sex)) {
    514534                                char *iptr = sd->info_sex;
    515                                 while (*iptr++)
     535                                while (*iptr++) {
    516536                                        *iptr = g_ascii_tolower(*iptr);
     537                                }
    517538                                g_string_append_printf(st,
    518                                         "Gender: %s\n", sd->info_sex);
     539                                                       "Gender: %s\n", sd->info_sex);
    519540                        }
    520541                        g_free(sd->info_sex);
     
    524545                        if (strlen(sd->info_language)) {
    525546                                char *iptr = strchr(sd->info_language, ' ');
    526                                 if (iptr)
     547                                if (iptr) {
    527548                                        iptr++;
    528                                 else
     549                                } else {
    529550                                        iptr = sd->info_language;
     551                                }
    530552                                g_string_append_printf(st,
    531                                         "Language: %s\n", iptr);
     553                                                       "Language: %s\n", iptr);
    532554                        }
    533555                        g_free(sd->info_language);
     
    537559                        if (strlen(sd->info_country)) {
    538560                                char *iptr = strchr(sd->info_country, ' ');
    539                                 if (iptr)
     561                                if (iptr) {
    540562                                        iptr++;
    541                                 else
     563                                } else {
    542564                                        iptr = sd->info_country;
     565                                }
    543566                                g_string_append_printf(st,
    544                                         "Country: %s\n", iptr);
     567                                                       "Country: %s\n", iptr);
    545568                        }
    546569                        g_free(sd->info_country);
     
    548571                }
    549572                if (sd->info_province) {
    550                         if (strlen(sd->info_province))
     573                        if (strlen(sd->info_province)) {
    551574                                g_string_append_printf(st,
    552                                         "Region: %s\n", sd->info_province);
     575                                                       "Region: %s\n", sd->info_province);
     576                        }
    553577                        g_free(sd->info_province);
    554578                        sd->info_province = NULL;
    555579                }
    556580                if (sd->info_city) {
    557                         if (strlen(sd->info_city))
     581                        if (strlen(sd->info_city)) {
    558582                                g_string_append_printf(st,
    559                                         "City: %s\n", sd->info_city);
     583                                                       "City: %s\n", sd->info_city);
     584                        }
    560585                        g_free(sd->info_city);
    561586                        sd->info_city = NULL;
    562587                }
    563588                if (sd->info_homepage) {
    564                         if (strlen(sd->info_homepage))
     589                        if (strlen(sd->info_homepage)) {
    565590                                g_string_append_printf(st,
    566                                         "Homepage: %s\n", sd->info_homepage);
     591                                                       "Homepage: %s\n", sd->info_homepage);
     592                        }
    567593                        g_free(sd->info_homepage);
    568594                        sd->info_homepage = NULL;
    569595                }
    570596                if (sd->info_about) {
    571                         if (strlen(sd->info_about))
     597                        if (strlen(sd->info_about)) {
    572598                                g_string_append_printf(st, "%s\n",
    573                                         sd->info_about);
     599                                                       sd->info_about);
     600                        }
    574601                        g_free(sd->info_about);
    575602                        sd->info_about = NULL;
     
    584611        struct skype_data *sd = ic->proto_data;
    585612        char buf[IRC_LINE_SIZE];
     613
    586614        if (!strcmp(sd->type, "SAID")) {
    587                 if (!sd->is_edit)
     615                if (!sd->is_edit) {
    588616                        g_snprintf(buf, IRC_LINE_SIZE, "%s", body);
    589                 else {
     617                } else {
    590618                        g_snprintf(buf, IRC_LINE_SIZE, "%s %s", set_getstr(&ic->acc->set, "edit_prefix"), body);
    591619                        sd->is_edit = 0;
    592620                }
    593         } else
     621        } else {
    594622                g_snprintf(buf, IRC_LINE_SIZE, "/me %s", body);
    595         if (!gc)
     623        }
     624        if (!gc) {
    596625                /* Private message */
    597626                imcb_buddy_msg(ic, sd->handle, buf, 0, 0);
    598         else
     627        } else {
    599628                /* Groupchat message */
    600629                imcb_chat_msg(gc, sd->handle, buf, 0, 0);
     630        }
    601631}
    602632
     
    606636        char *id = strchr(line, ' ');
    607637
    608         if (!++id)
     638        if (!++id) {
    609639                return;
     640        }
    610641        char *info = strchr(id, ' ');
    611642
    612         if (!info)
     643        if (!info) {
    613644                return;
     645        }
    614646        *info = '\0';
    615647        info++;
     
    622654                 */
    623655                skype_printf(ic, "GET CHATMESSAGE %s FROM_HANDLE\n", id);
    624                 if (!strcmp(info, "STATUS RECEIVED"))
     656                if (!strcmp(info, "STATUS RECEIVED")) {
    625657                        skype_printf(ic, "GET CHATMESSAGE %s BODY\n", id);
    626                 else
     658                } else {
    627659                        sd->is_edit = 1;
     660                }
    628661                skype_printf(ic, "GET CHATMESSAGE %s TYPE\n", id);
    629662                skype_printf(ic, "GET CHATMESSAGE %s CHATNAME\n", id);
     
    648681                info += 5;
    649682                sd->body = g_list_append(sd->body, g_strdup(info));
    650         }       else if (!strncmp(info, "TYPE ", 5)) {
     683        } else if (!strncmp(info, "TYPE ", 5)) {
    651684                info += 5;
    652685                g_free(sd->type);
     
    660693                                char *body = g_list_nth_data(sd->body, i);
    661694                                if (!strcmp(sd->type, "SAID") ||
    662                                         !strcmp(sd->type, "EMOTED")) {
     695                                    !strcmp(sd->type, "EMOTED")) {
    663696                                        skype_parse_chatmessage_said_emoted(ic, gc, body);
    664                                 } else if (!strcmp(sd->type, "SETTOPIC") && gc)
     697                                } else if (!strcmp(sd->type, "SETTOPIC") && gc) {
    665698                                        imcb_chat_topic(gc,
    666                                                 sd->handle, body, 0);
    667                                 else if (!strcmp(sd->type, "LEFT") && gc)
     699                                                        sd->handle, body, 0);
     700                                } else if (!strcmp(sd->type, "LEFT") && gc) {
    668701                                        imcb_chat_remove_buddy(gc,
    669                                                 sd->handle, NULL);
     702                                                               sd->handle, NULL);
     703                                }
    670704                        }
    671705                        g_list_free(sd->body);
     
    681715        char buf[IRC_LINE_SIZE];
    682716
    683         if (!++id)
     717        if (!++id) {
    684718                return;
     719        }
    685720        char *info = strchr(id, ' ');
    686721
    687         if (!info)
     722        if (!info) {
    688723                return;
     724        }
    689725        *info = '\0';
    690726        info++;
    691         if (!strncmp(info, "FAILUREREASON ", 14))
     727        if (!strncmp(info, "FAILUREREASON ", 14)) {
    692728                sd->failurereason = atoi(strchr(info, ' '));
    693         else if (!strcmp(info, "STATUS RINGING")) {
    694                 if (sd->call_id)
     729        } else if (!strcmp(info, "STATUS RINGING")) {
     730                if (sd->call_id) {
    695731                        g_free(sd->call_id);
     732                }
    696733                sd->call_id = g_strdup(id);
    697734                skype_printf(ic, "GET CALL %s PARTNER_HANDLE\n", id);
     
    710747                sd->call_status = SKYPE_CALL_REFUSED;
    711748        } else if (!strcmp(info, "STATUS UNPLACED")) {
    712                 if (sd->call_id)
     749                if (sd->call_id) {
    713750                        g_free(sd->call_id);
     751                }
    714752                /* Save the ID for later usage (Cancel/Finish). */
    715753                sd->call_id = g_strdup(id);
     
    717755        } else if (!strcmp(info, "STATUS FAILED")) {
    718756                imcb_error(ic, "Call failed: %s",
    719                         skype_call_strerror(sd->failurereason));
     757                           skype_call_strerror(sd->failurereason));
    720758                sd->call_id = NULL;
    721759        } else if (!strncmp(info, "DURATION ", 9)) {
    722                 if (sd->call_duration)
     760                if (sd->call_duration) {
    723761                        g_free(sd->call_duration);
    724                 sd->call_duration = g_strdup(info+9);
     762                }
     763                sd->call_duration = g_strdup(info + 9);
    725764        } else if (!strncmp(info, "PARTNER_HANDLE ", 15)) {
    726765                info += 15;
    727                 if (!sd->call_status)
     766                if (!sd->call_status) {
    728767                        return;
     768                }
    729769                switch (sd->call_status) {
    730770                case SKYPE_CALL_RINGING:
    731                         if (sd->call_out)
     771                        if (sd->call_out) {
    732772                                imcb_log(ic, "You are currently ringing the user %s.", info);
    733                         else {
     773                        } else {
    734774                                g_snprintf(buf, IRC_LINE_SIZE,
    735                                         "The user %s is currently ringing you.",
    736                                         info);
     775                                           "The user %s is currently ringing you.",
     776                                           info);
    737777                                skype_call_ask(ic, sd->call_id, buf);
    738778                        }
     
    740780                case SKYPE_CALL_MISSED:
    741781                        imcb_log(ic, "You have missed a call from user %s.",
    742                                 info);
     782                                 info);
    743783                        break;
    744784                case SKYPE_CALL_CANCELLED:
    745785                        imcb_log(ic, "You cancelled the call to the user %s.",
    746                                 info);
     786                                 info);
    747787                        sd->call_status = 0;
    748788                        sd->call_out = FALSE;
    749789                        break;
    750790                case SKYPE_CALL_REFUSED:
    751                         if (sd->call_out)
     791                        if (sd->call_out) {
    752792                                imcb_log(ic, "The user %s refused the call.",
    753                                         info);
    754                         else
     793                                         info);
     794                        } else {
    755795                                imcb_log(ic,
    756                                         "You refused the call from user %s.",
    757                                         info);
     796                                         "You refused the call from user %s.",
     797                                         info);
     798                        }
    758799                        sd->call_out = FALSE;
    759800                        break;
    760801                case SKYPE_CALL_FINISHED:
    761                         if (sd->call_duration)
     802                        if (sd->call_duration) {
    762803                                imcb_log(ic,
    763                                         "You finished the call to the user %s "
    764                                         "(duration: %s seconds).",
    765                                         info, sd->call_duration);
    766                         else
     804                                         "You finished the call to the user %s "
     805                                         "(duration: %s seconds).",
     806                                         info, sd->call_duration);
     807                        } else {
    767808                                imcb_log(ic,
    768                                         "You finished the call to the user %s.",
    769                                         info);
     809                                         "You finished the call to the user %s.",
     810                                         info);
     811                        }
    770812                        sd->call_out = FALSE;
    771813                        break;
     
    783825        char *id = strchr(line, ' ');
    784826
    785         if (!++id)
     827        if (!++id) {
    786828                return;
     829        }
    787830        char *info = strchr(id, ' ');
    788831
    789         if (!info)
     832        if (!info) {
    790833                return;
     834        }
    791835        *info = '\0';
    792836        info++;
    793837        if (!strcmp(info, "STATUS NEW")) {
    794838                skype_printf(ic, "GET FILETRANSFER %s PARTNER_HANDLE\n",
    795                         id);
     839                             id);
    796840                sd->filetransfer_status = SKYPE_FILETRANSFER_NEW;
    797841        } else if (!strcmp(info, "STATUS FAILED")) {
    798842                skype_printf(ic, "GET FILETRANSFER %s PARTNER_HANDLE\n",
    799                         id);
     843                             id);
    800844                sd->filetransfer_status = SKYPE_FILETRANSFER_FAILED;
    801845        } else if (!strcmp(info, "STATUS COMPLETED")) {
     
    810854        } else if (!strncmp(info, "PARTNER_HANDLE ", 15)) {
    811855                info += 15;
    812                 if (!sd->filetransfer_status)
     856                if (!sd->filetransfer_status) {
    813857                        return;
     858                }
    814859                switch (sd->filetransfer_status) {
    815860                case SKYPE_FILETRANSFER_NEW:
    816861                        imcb_log(ic, "The user %s offered a new file for you.",
    817                                 info);
     862                                 info);
    818863                        break;
    819864                case SKYPE_FILETRANSFER_FAILED:
    820865                        imcb_log(ic, "Failed to transfer file from user %s.",
    821                                 info);
     866                                 info);
    822867                        break;
    823868                case SKYPE_FILETRANSFER_COMPLETED:
     
    826871                case SKYPE_FILETRANSFER_TRANSFERRING:
    827872                        if (sd->filetransfer_path) {
    828                                 imcb_log(ic, "File transfer from user %s started, saving to %s.", info, sd->filetransfer_path);
     873                                imcb_log(ic, "File transfer from user %s started, saving to %s.", info,
     874                                         sd->filetransfer_path);
    829875                                g_free(sd->filetransfer_path);
    830876                                sd->filetransfer_path = NULL;
     
    842888
    843889        for (i = 0; i < g_list_length(sd->groups); i++) {
    844                 struct skype_group *sg = (struct skype_group *)g_list_nth_data(sd->groups, i);
    845 
    846                 if (sg->id == id)
     890                struct skype_group *sg = (struct skype_group *) g_list_nth_data(sd->groups, i);
     891
     892                if (sg->id == id) {
    847893                        return sg;
     894                }
    848895        }
    849896        return NULL;
     
    859906        }
    860907        sg->users = NULL;
    861         if (usersonly)
     908        if (usersonly) {
    862909                return;
     910        }
    863911        g_free(sg->name);
    864912        g_free(sg);
     
    883931        char *id = strchr(line, ' ');
    884932
    885         if (!++id)
     933        if (!++id) {
    886934                return;
     935        }
    887936
    888937        char *info = strchr(id, ' ');
    889938
    890         if (!info)
     939        if (!info) {
    891940                return;
     941        }
    892942        *info = '\0';
    893943        info++;
     
    923973                        g_strfreev(users);
    924974                        skype_group_users(ic, sg);
    925                 } else
     975                } else {
    926976                        log_message(LOGLVL_ERROR,
    927                                 "No skype group with id %s. That's probably a bug.", id);
     977                                    "No skype group with id %s. That's probably a bug.", id);
     978                }
    928979        } else if (!strncmp(info, "NROFUSERS ", 10)) {
    929980                if (!sd->pending_user) {
     
    942993                        g_free(sd->pending_user);
    943994                        sd->pending_user = NULL;
    944                 } else
     995                } else {
    945996                        log_message(LOGLVL_ERROR,
    946                                         "No skype group with id %s. That's probably a bug.", id);
    947         } else if (!strcmp(info, "TYPE CUSTOM_GROUP"))
     997                                    "No skype group with id %s. That's probably a bug.", id);
     998                }
     999        } else if (!strcmp(info, "TYPE CUSTOM_GROUP")) {
    9481000                /* This one is interesting, query its users. */
    9491001                skype_printf(ic, "GET GROUP %s USERS\n", id);
     1002        }
    9501003}
    9511004
     
    9561009        char *id = strchr(line, ' ');
    9571010
    958         if (!++id)
     1011        if (!++id) {
    9591012                return;
     1013        }
    9601014        struct groupchat *gc;
    9611015        char *info = strchr(id, ' ');
    9621016
    963         if (!info)
     1017        if (!info) {
    9641018                return;
     1019        }
    9651020        *info = '\0';
    9661021        info++;
    9671022        /* Remove fake chat if we created one in skype_chat_with() */
    9681023        gc = bee_chat_by_title(ic->bee, ic, "");
    969         if (gc)
     1024        if (gc) {
    9701025                imcb_chat_free(gc);
     1026        }
    9711027        if (!strcmp(info, "STATUS MULTI_SUBSCRIBED")) {
    9721028                gc = bee_chat_by_title(ic->bee, ic, id);
     
    9881044                /*skype_printf(ic, "OPEN CHAT %s\n", id);*/
    9891045                g_snprintf(buf, IRC_LINE_SIZE, "%s@skype.com",
    990                                 sd->groupchat_with);
     1046                           sd->groupchat_with);
    9911047                imcb_chat_add_buddy(gc, buf);
    9921048                imcb_chat_add_buddy(gc, sd->username);
     
    9971053        } else if (!strcmp(info, "STATUS UNSUBSCRIBED")) {
    9981054                gc = bee_chat_by_title(ic->bee, ic, id);
    999                 if (gc)
    1000                         gc->data = (void *)FALSE;
     1055                if (gc) {
     1056                        gc->data = (void *) FALSE;
     1057                }
    10011058        } else if (!strncmp(info, "ADDER ", 6)) {
    10021059                info += 6;
     
    10151072                        sd->adder = NULL;
    10161073                }
    1017         } else if (!strncmp(info, "MEMBERS ", 8) || !strncmp(info, "ACTIVEMEMBERS ", 14) ) {
    1018                 if (!strncmp(info, "MEMBERS ", 8))
     1074        } else if (!strncmp(info, "MEMBERS ", 8) || !strncmp(info, "ACTIVEMEMBERS ", 14)) {
     1075                if (!strncmp(info, "MEMBERS ", 8)) {
    10191076                        info += 8;
    1020                 else
     1077                } else {
    10211078                        info += 14;
     1079                }
    10221080                gc = bee_chat_by_title(ic->bee, ic, id);
    10231081                /* Hack! We set ->data to TRUE
     
    10251083                 * so that we won't rejoin
    10261084                 * after a /part. */
    1027                 if (!gc || gc->data)
     1085                if (!gc || gc->data) {
    10281086                        return;
     1087                }
    10291088                char **members = g_strsplit(info, " ", 0);
    10301089                int i;
    10311090                for (i = 0; members[i]; i++) {
    1032                         if (!strcmp(members[i], sd->username))
     1091                        if (!strcmp(members[i], sd->username)) {
    10331092                                continue;
     1093                        }
    10341094                        g_snprintf(buf, IRC_LINE_SIZE, "%s@skype.com",
    1035                                         members[i]);
     1095                                   members[i]);
    10361096                        if (!g_list_find_custom(gc->in_room, buf,
    1037                                 (GCompareFunc)strcmp))
     1097                                                (GCompareFunc) strcmp)) {
    10381098                                imcb_chat_add_buddy(gc, buf);
     1099                        }
    10391100                }
    10401101                imcb_chat_add_buddy(gc, sd->username);
     
    10451106static void skype_parse_password(struct im_connection *ic, char *line)
    10461107{
    1047         if (!strncmp(line+9, "OK", 2))
     1108        if (!strncmp(line + 9, "OK", 2)) {
    10481109                imcb_connected(ic);
    1049         else {
     1110        } else {
    10501111                imcb_error(ic, "Authentication Failed");
    10511112                imc_logout(ic, TRUE);
     
    10551116static void skype_parse_profile(struct im_connection *ic, char *line)
    10561117{
    1057         imcb_log(ic, "SkypeOut balance value is '%s'.", line+21);
     1118        imcb_log(ic, "SkypeOut balance value is '%s'.", line + 21);
    10581119}
    10591120
     
    10811142static void skype_parse_groups(struct im_connection *ic, char *line)
    10821143{
    1083         if (!set_getbool(&ic->acc->set, "read_groups"))
     1144        if (!set_getbool(&ic->acc->set, "read_groups")) {
    10841145                return;
     1146        }
    10851147
    10861148        char **i;
     
    11001162        char *id = line + strlen("ALTER GROUP");
    11011163
    1102         if (!++id)
     1164        if (!++id) {
    11031165                return;
     1166        }
    11041167
    11051168        char *info = strchr(id, ' ');
    11061169
    1107         if (!info)
     1170        if (!info) {
    11081171                return;
     1172        }
    11091173        *info = '\0';
    11101174        info++;
     
    11191183                        imcb_add_buddy(ic, buf, sg->name);
    11201184                        g_free(buf);
    1121                 } else
     1185                } else {
    11221186                        log_message(LOGLVL_ERROR,
    1123                                 "No skype group with id %s. That's probably a bug.", id);
     1187                                    "No skype group with id %s. That's probably a bug.", id);
     1188                }
    11241189        }
    11251190}
     
    11281193
    11291194static gboolean skype_read_callback(gpointer data, gint fd,
    1130                                     b_input_condition cond)
     1195                                    b_input_condition cond)
    11311196{
    11321197        struct im_connection *ic = data;
     
    11581223        cond = cond;
    11591224
    1160         if (!sd || sd->fd == -1)
     1225        if (!sd || sd->fd == -1) {
    11611226                return FALSE;
     1227        }
    11621228        /* Read the whole data. */
    11631229        st = ssl_read(sd->ssl, buf, sizeof(buf));
    1164         if (st >= IRC_LINE_SIZE-1) {
     1230        if (st >= IRC_LINE_SIZE - 1) {
    11651231                /* As we don't buffer incoming data, if IRC_LINE_SIZE amount of bytes
    11661232                 * were received, there's a good chance last message was truncated
     
    11751241                lineptr = lines;
    11761242                while ((line = *lineptr)) {
    1177                         if (!strlen(line))
     1243                        if (!strlen(line)) {
    11781244                                break;
    1179                         if (set_getbool(&ic->acc->set, "skypeconsole_receive"))
     1245                        }
     1246                        if (set_getbool(&ic->acc->set, "skypeconsole_receive")) {
    11801247                                imcb_buddy_msg(ic, "skypeconsole", line, 0, 0);
    1181                         for (i = 0; i < ARRAY_SIZE(parsers); i++)
     1248                        }
     1249                        for (i = 0; i < ARRAY_SIZE(parsers); i++) {
    11821250                                if (!strncmp(line, parsers[i].k,
    1183                                         strlen(parsers[i].k))) {
     1251                                             strlen(parsers[i].k))) {
    11841252                                        parsers[i].v(ic, line);
    11851253                                        break;
    11861254                                }
     1255                        }
    11871256                        lineptr++;
    11881257                }
     
    12051274        int st;
    12061275
    1207         if (!sd)
     1276        if (!sd) {
    12081277                return FALSE;
    1209 
    1210         if (sd->bfd <= 0)
     1278        }
     1279
     1280        if (sd->bfd <= 0) {
    12111281                sd->bfd = b_input_add(sd->fd, B_EV_IO_READ,
    1212                         skype_read_callback, ic);
     1282                                      skype_read_callback, ic);
     1283        }
    12131284
    12141285        /* Log in */
     
    12601331        imcb_log(ic, "Connecting");
    12611332        sd->ssl = ssl_connect(set_getstr(&acc->set, "server"),
    1262                 set_getint(&acc->set, "port"), FALSE, skype_connected, ic);
     1333                              set_getint(&acc->set, "port"), FALSE, skype_connected, ic);
    12631334        sd->fd = sd->ssl ? ssl_getfd(sd->ssl) : -1;
    12641335        sd->username = g_strdup(acc->user);
     
    12661337        sd->ic = ic;
    12671338
    1268         if (set_getbool(&acc->set, "skypeconsole"))
     1339        if (set_getbool(&acc->set, "skypeconsole")) {
    12691340                imcb_add_buddy(ic, "skypeconsole", NULL);
     1341        }
    12701342}
    12711343
     
    12771349        skype_printf(ic, "SET USERSTATUS OFFLINE\n");
    12781350
    1279         while (ic->groupchats)
     1351        while (ic->groupchats) {
    12801352                imcb_chat_free(ic->groupchats->data);
     1353        }
    12811354
    12821355        for (i = 0; i < g_list_length(sd->groups); i++) {
    1283                 struct skype_group *sg = (struct skype_group *)g_list_nth_data(sd->groups, i);
     1356                struct skype_group *sg = (struct skype_group *) g_list_nth_data(sd->groups, i);
    12841357                skype_group_free(sg, FALSE);
    12851358        }
    12861359
    1287         if (sd->ssl)
     1360        if (sd->ssl) {
    12881361                ssl_disconnect(sd->ssl);
     1362        }
    12891363
    12901364        g_free(sd->username);
     
    12951369
    12961370static int skype_buddy_msg(struct im_connection *ic, char *who, char *message,
    1297                            int flags)
     1371                           int flags)
    12981372{
    12991373        char *ptr, *nick;
     
    13051379        nick = g_strdup(who);
    13061380        ptr = strchr(nick, '@');
    1307         if (ptr)
     1381        if (ptr) {
    13081382                *ptr = '\0';
    1309 
    1310         if (!strncmp(who, "skypeconsole", 12))
     1383        }
     1384
     1385        if (!strncmp(who, "skypeconsole", 12)) {
    13111386                st = skype_printf(ic, "%s\n", message);
    1312         else
     1387        } else {
    13131388                st = skype_printf(ic, "MESSAGE %s %s\n", nick, message);
     1389        }
    13141390        g_free(nick);
    13151391
     
    13211397        int i;
    13221398
    1323         for (i = 0; skype_away_state_list[i].full_name; i++)
    1324                 if (g_strcasecmp(skype_away_state_list[i].full_name, name) == 0)
     1399        for (i = 0; skype_away_state_list[i].full_name; i++) {
     1400                if (g_strcasecmp(skype_away_state_list[i].full_name, name) == 0) {
    13251401                        return skype_away_state_list + i;
     1402                }
     1403        }
    13261404
    13271405        return NULL;
     
    13291407
    13301408static void skype_set_away(struct im_connection *ic, char *state_txt,
    1331                            char *message)
     1409                           char *message)
    13321410{
    13331411        const struct skype_away_state *state;
     
    13361414        message = message;
    13371415
    1338         if (state_txt == NULL)
     1416        if (state_txt == NULL) {
    13391417                state = skype_away_state_by_name("Online");
    1340         else
     1418        } else {
    13411419                state = skype_away_state_by_name(state_txt);
     1420        }
    13421421        skype_printf(ic, "SET USERSTATUS %s\n", state->code);
    13431422}
     
    13511430        ic = ic;
    13521431
    1353         if (l == NULL)
    1354                 for (i = 0; skype_away_state_list[i].full_name; i++)
     1432        if (l == NULL) {
     1433                for (i = 0; skype_away_state_list[i].full_name; i++) {
    13551434                        l = g_list_append(l,
    1356                                 (void *)skype_away_state_list[i].full_name);
     1435                                          (void *) skype_away_state_list[i].full_name);
     1436                }
     1437        }
    13571438
    13581439        return l;
     
    13911472        char *ptr = strchr(nick, '@');
    13921473
    1393         if (ptr)
     1474        if (ptr) {
    13941475                *ptr = '\0';
     1476        }
    13951477        skype_printf(ic, "CALL %s\n", nick);
    13961478        g_free(nick);
     
    14031485        if (sd->call_id) {
    14041486                skype_printf(ic, "SET CALL %s STATUS FINISHED\n",
    1405                                 sd->call_id);
     1487                             sd->call_id);
    14061488                g_free(sd->call_id);
    14071489                sd->call_id = 0;
    1408         } else
     1490        } else {
    14091491                imcb_error(ic, "There are no active calls currently.");
     1492        }
    14101493}
    14111494
     
    14151498        struct im_connection *ic = acc->ic;
    14161499
    1417         if (value)
     1500        if (value) {
    14181501                skype_call(ic, value);
    1419         else
     1502        } else {
    14201503                skype_hangup(ic);
     1504        }
    14211505        return value;
    14221506}
     
    14291513        nick = g_strdup(who);
    14301514        ptr = strchr(nick, '@');
    1431         if (ptr)
     1515        if (ptr) {
    14321516                *ptr = '\0';
     1517        }
    14331518
    14341519        if (!group) {
    14351520                skype_printf(ic, "SET USER %s BUDDYSTATUS 2 Please authorize me\n",
    1436                                 nick);
     1521                             nick);
    14371522                g_free(nick);
    14381523        } else {
     
    14591544        nick = g_strdup(who);
    14601545        ptr = strchr(nick, '@');
    1461         if (ptr)
     1546        if (ptr) {
    14621547                *ptr = '\0';
     1548        }
    14631549        skype_printf(ic, "SET USER %s BUDDYSTATUS 1\n", nick);
    14641550        g_free(nick);
     
    14781564{
    14791565        struct im_connection *ic = gc->ic;
     1566
    14801567        skype_printf(ic, "ALTER CHAT %s LEAVE\n", gc->title);
    1481         gc->data = (void *)TRUE;
     1568        gc->data = (void *) TRUE;
    14821569}
    14831570
     
    14891576        nick = g_strdup(who);
    14901577        ptr = strchr(nick, '@');
    1491         if (ptr)
     1578        if (ptr) {
    14921579                *ptr = '\0';
     1580        }
    14931581        skype_printf(ic, "ALTER CHAT %s ADDMEMBERS %s\n", gc->title, nick);
    14941582        g_free(nick);
     
    14991587        struct im_connection *ic = gc->ic;
    15001588        struct skype_data *sd = ic->proto_data;
     1589
    15011590        skype_printf(ic, "ALTER CHAT %s SETTOPIC %s\n",
    1502                 gc->title, message);
     1591                     gc->title, message);
    15031592        sd->topic_wait = 1;
    15041593}
     
    15081597        struct skype_data *sd = ic->proto_data;
    15091598        char *ptr, *nick;
     1599
    15101600        nick = g_strdup(who);
    15111601        ptr = strchr(nick, '@');
    1512         if (ptr)
     1602        if (ptr) {
    15131603                *ptr = '\0';
     1604        }
    15141605        skype_printf(ic, "CHAT CREATE %s\n", nick);
    15151606        sd->groupchat_with = g_strdup(nick);
     
    15241615        struct skype_data *sd = ic->proto_data;
    15251616        char *ptr, *nick;
     1617
    15261618        nick = g_strdup(who);
    15271619        ptr = strchr(nick, '@');
    1528         if (ptr)
     1620        if (ptr) {
    15291621                *ptr = '\0';
     1622        }
    15301623        sd->is_info = TRUE;
    15311624        skype_printf(ic, "GET USER %s FULLNAME\n", nick);
     
    15561649
    15571650        s = set_add(&acc->set, "server", SKYPE_DEFAULT_SERVER, set_eval_account,
    1558                 acc);
     1651                    acc);
    15591652        s->flags |= ACC_SET_OFFLINE_ONLY;
    15601653
     
    15631656
    15641657        s = set_add(&acc->set, "display_name", NULL, skype_set_display_name,
    1565                 acc);
     1658                    acc);
    15661659        s->flags |= SET_NOSAVE | ACC_SET_ONLINE_ONLY;
    15671660
     
    15811674
    15821675        s = set_add(&acc->set, "skypeconsole_receive", "false", set_eval_bool,
    1583                 acc);
     1676                    acc);
    15841677        s->flags |= ACC_SET_OFFLINE_ONLY;
    15851678
     
    15931686
    15941687        s = set_add(&acc->set, "edit_prefix", "EDIT:",
    1595                         NULL, acc);
     1688                    NULL, acc);
    15961689
    15971690        s = set_add(&acc->set, "read_groups", "false", set_eval_bool, acc);
     
    16081701        if (ret == NULL) {
    16091702                static const struct buddy_action ba[2] = {
    1610                         {"CALL", "Initiate a call" },
    1611                         {"HANGUP", "Hang up a call" },
     1703                        { "CALL", "Initiate a call" },
     1704                        { "HANGUP", "Hang up a call" },
    16121705                };
    16131706                int i;
    16141707
    1615                 for (i = 0; i < ARRAY_SIZE(ba); i++)
    1616                         ret = g_list_prepend(ret, (void *)(ba + i));
     1708                for (i = 0; i < ARRAY_SIZE(ba); i++) {
     1709                        ret = g_list_prepend(ret, (void *) (ba + i));
     1710                }
    16171711        }
    16181712
     
    16261720        data = data;
    16271721
    1628         if (!g_strcasecmp(action, "CALL"))
     1722        if (!g_strcasecmp(action, "CALL")) {
    16291723                skype_call(bu->ic, bu->handle);
    1630         else if (!g_strcasecmp(action, "HANGUP"))
     1724        } else if (!g_strcasecmp(action, "HANGUP")) {
    16311725                skype_hangup(bu->ic);
     1726        }
    16321727
    16331728        return NULL;
Note: See TracChangeset for help on using the changeset viewer.