Changeset 62f51ee9 for skype


Ignore:
Timestamp:
2009-01-07T02:29:07Z (15 years ago)
Author:
Miklos Vajna <vmiklos@…>
Branches:
master
Children:
16304ab
Parents:
6b9d22a
Message:

last whitespace fixes

  • checkpatch is now happy ;)
  • hit me, i also seem to correct away status handling (it set away when the user was online|skype and not the opposite)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • skype/skype.c

    r6b9d22a r62f51ee9  
    307307                ptr = g_strdup_printf("%s@skype.com", user);
    308308                imcb_add_buddy(ic, ptr, NULL);
    309                 if (strcmp(status, "OFFLINE") && (strcmp(status, "SKYPEOUT") || !set_getbool(&ic->acc->set, "skypeout_offline")))
     309                if (strcmp(status, "OFFLINE") && (strcmp(status, "SKYPEOUT") ||
     310                        !set_getbool(&ic->acc->set, "skypeout_offline")))
    310311                        flags |= OPT_LOGGED_IN;
    311                 if (strcmp(status, "ONLINE") != 0 && strcmp(status, "SKYPEME") != 0)
     312                if (strcmp(status, "ONLINE") && strcmp(status, "SKYPEME"))
    312313                        flags |= OPT_AWAY;
    313314                imcb_buddy_status(ic, ptr, flags, NULL, NULL);
     
    359360                if (sd->info_fullname) {
    360361                        if (strlen(sd->info_fullname))
    361                                 g_string_append_printf(st, "Full Name: %s\n", sd->info_fullname);
     362                                g_string_append_printf(st, "Full Name: %s\n",
     363                                        sd->info_fullname);
    362364                        g_free(sd->info_fullname);
    363365                }
    364366                if (sd->info_phonehome) {
    365367                        if (strlen(sd->info_phonehome))
    366                                 g_string_append_printf(st, "Home Phone: %s\n", sd->info_phonehome);
     368                                g_string_append_printf(st, "Home Phone: %s\n",
     369                                        sd->info_phonehome);
    367370                        g_free(sd->info_phonehome);
    368371                }
    369372                if (sd->info_phoneoffice) {
    370373                        if (strlen(sd->info_phoneoffice))
    371                                 g_string_append_printf(st, "Office Phone: %s\n", sd->info_phoneoffice);
     374                                g_string_append_printf(st, "Office Phone: %s\n",
     375                                        sd->info_phoneoffice);
    372376                        g_free(sd->info_phoneoffice);
    373377                }
    374378                if (sd->info_phonemobile) {
    375379                        if (strlen(sd->info_phonemobile))
    376                                 g_string_append_printf(st, "Mobile Phone: %s\n", sd->info_phonemobile);
     380                                g_string_append_printf(st, "Mobile Phone: %s\n",
     381                                        sd->info_phonemobile);
    377382                        g_free(sd->info_phonemobile);
    378383                }
     
    380385                if (sd->info_nrbuddies) {
    381386                        if (strlen(sd->info_nrbuddies))
    382                                 g_string_append_printf(st, "Contacts: %s\n", sd->info_nrbuddies);
     387                                g_string_append_printf(st,
     388                                        "Contacts: %s\n", sd->info_nrbuddies);
    383389                        g_free(sd->info_nrbuddies);
    384390                }
     
    390396                                struct tm *gt = gmtime(&t);
    391397                                strftime(ib, 256, "%H:%M:%S", gt);
    392                                 g_string_append_printf(st, "Local Time: %s\n", ib);
     398                                g_string_append_printf(st,
     399                                        "Local Time: %s\n", ib);
    393400                        }
    394401                        g_free(sd->info_tz);
     
    400407                                struct tm *tm = localtime(&it);
    401408                                strftime(ib, 256, ("%Y. %m. %d. %H:%M"), tm);
    402                                 g_string_append_printf(st, "Last Seen: %s\n", ib);
     409                                g_string_append_printf(st,
     410                                        "Last Seen: %s\n", ib);
    403411                        }
    404412                        g_free(sd->info_seen);
    405413                }
    406414                if (sd->info_birthday) {
    407                         if (strlen(sd->info_birthday) && strcmp(sd->info_birthday, "0")) {
     415                        if (strlen(sd->info_birthday) &&
     416                                strcmp(sd->info_birthday, "0")) {
    408417                                char ib[256];
    409418                                struct tm tm;
    410419                                strptime(sd->info_birthday, "%Y%m%d", &tm);
    411420                                strftime(ib, 256, "%B %d, %Y", &tm);
    412                                 g_string_append_printf(st, "Birthday: %s\n", ib);
     421                                g_string_append_printf(st,
     422                                        "Birthday: %s\n", ib);
    413423
    414424                                strftime(ib, 256, "%Y", &tm);
     
    416426                                time_t t = time(NULL);
    417427                                struct tm *lt = localtime(&t);
    418                                 g_string_append_printf(st, "Age: %d\n", lt->tm_year+1900-year);
     428                                g_string_append_printf(st,
     429                                        "Age: %d\n", lt->tm_year+1900-year);
    419430                        }
    420431                        g_free(sd->info_birthday);
     
    425436                                while (*iptr++)
    426437                                        *iptr = tolower(*iptr);
    427                                 g_string_append_printf(st, "Gender: %s\n", sd->info_sex);
     438                                g_string_append_printf(st,
     439                                        "Gender: %s\n", sd->info_sex);
    428440                        }
    429441                        g_free(sd->info_sex);
     
    436448                                else
    437449                                        iptr = sd->info_language;
    438                                 g_string_append_printf(st, "Language: %s\n", iptr);
     450                                g_string_append_printf(st,
     451                                        "Language: %s\n", iptr);
    439452                        }
    440453                        g_free(sd->info_language);
     
    447460                                else
    448461                                        iptr = sd->info_country;
    449                                 g_string_append_printf(st, "Country: %s\n", iptr);
     462                                g_string_append_printf(st,
     463                                        "Country: %s\n", iptr);
    450464                        }
    451465                        g_free(sd->info_country);
     
    453467                if (sd->info_province) {
    454468                        if (strlen(sd->info_province))
    455                                 g_string_append_printf(st, "Region: %s\n", sd->info_province);
     469                                g_string_append_printf(st,
     470                                        "Region: %s\n", sd->info_province);
    456471                        g_free(sd->info_province);
    457472                }
    458473                if (sd->info_city) {
    459474                        if (strlen(sd->info_city))
    460                                 g_string_append_printf(st, "City: %s\n", sd->info_city);
     475                                g_string_append_printf(st,
     476                                        "City: %s\n", sd->info_city);
    461477                        g_free(sd->info_city);
    462478                }
    463479                if (sd->info_homepage) {
    464480                        if (strlen(sd->info_homepage))
    465                                 g_string_append_printf(st, "Homepage: %s\n", sd->info_homepage);
     481                                g_string_append_printf(st,
     482                                        "Homepage: %s\n", sd->info_homepage);
    466483                        g_free(sd->info_homepage);
    467484                }
    468485                if (sd->info_about) {
    469486                        if (strlen(sd->info_about))
    470                                 g_string_append_printf(st, "%s\n", sd->info_about);
     487                                g_string_append_printf(st, "%s\n",
     488                                        sd->info_about);
    471489                        g_free(sd->info_about);
    472490                }
     
    536554                        for (i = 0; i < g_list_length(sd->body); i++) {
    537555                                char *body = g_list_nth_data(sd->body, i);
    538                                 if (!strcmp(sd->type, "SAID") || !strcmp(sd->type, "EMOTED")) {
     556                                if (!strcmp(sd->type, "SAID") ||
     557                                        !strcmp(sd->type, "EMOTED")) {
    539558                                        if (!strcmp(sd->type, "SAID"))
    540                                                 g_snprintf(buf, 1024, "%s", body);
     559                                                g_snprintf(buf, 1024, "%s",
     560                                                        body);
    541561                                        else
    542                                                 g_snprintf(buf, 1024, "/me %s", body);
     562                                                g_snprintf(buf, 1024, "/me %s",
     563                                                        body);
    543564                                        if (!gc)
    544565                                                /* Private message */
    545                                                 imcb_buddy_msg(ic, sd->handle, buf, 0, 0);
     566                                                imcb_buddy_msg(ic,
     567                                                        sd->handle, buf, 0, 0);
    546568                                        else
    547569                                                /* Groupchat message */
    548                                                 imcb_chat_msg(gc, sd->handle, buf, 0, 0);
    549                                 } else if (!strcmp(sd->type, "SETTOPIC")) {
    550                                         if (gc)
    551                                                 imcb_chat_topic(gc, sd->handle, body, 0);
    552                                 } else if (!strcmp(sd->type, "LEFT")) {
    553                                         if (gc)
    554                                                 imcb_chat_remove_buddy(gc, sd->handle, NULL);
    555                                 }
     570                                                imcb_chat_msg(gc,
     571                                                        sd->handle, buf, 0, 0);
     572                                } else if (!strcmp(sd->type, "SETTOPIC") && gc)
     573                                        imcb_chat_topic(gc,
     574                                                sd->handle, body, 0);
     575                                else if (!strcmp(sd->type, "LEFT") && gc)
     576                                        imcb_chat_remove_buddy(gc,
     577                                                sd->handle, NULL);
    556578                        }
    557579                        g_list_free(sd->body);
     
    607629                sd->call_out = TRUE;
    608630        } else if (!strcmp(info, "STATUS FAILED")) {
    609                 imcb_error(ic, "Call failed: %s", skype_call_strerror(sd->failurereason));
     631                imcb_error(ic, "Call failed: %s",
     632                        skype_call_strerror(sd->failurereason));
    610633                sd->call_id = NULL;
    611634        } else if (!strncmp(info, "DURATION ", 9)) {
     
    615638        } else if (!strncmp(info, "PARTNER_HANDLE ", 15)) {
    616639                info += 15;
    617                 if (sd->call_status) {
    618                         switch (sd->call_status) {
    619                         case SKYPE_CALL_RINGING:
    620                                 if (sd->call_out)
    621                                         imcb_log(ic, "You are currently ringing the user %s.", info);
    622                                 else {
    623                                         g_snprintf(buf, 1024, "The user %s is currently ringing you.", info);
    624                                         skype_call_ask(ic, sd->call_id, buf);
    625                                 }
    626                                 break;
    627                         case SKYPE_CALL_MISSED:
    628                                 imcb_log(ic, "You have missed a call from user %s.", info);
    629                                 break;
    630                         case SKYPE_CALL_CANCELLED:
    631                                 imcb_log(ic, "You cancelled the call to the user %s.", info);
    632                                 sd->call_status = 0;
    633                                 sd->call_out = FALSE;
    634                                 break;
    635                         case SKYPE_CALL_REFUSED:
    636                                 if (sd->call_out)
    637                                         imcb_log(ic, "The user %s refused the call.", info);
    638                                 else
    639                                         imcb_log(ic, "You refused the call from user %s.", info);
    640                                 sd->call_out = FALSE;
    641                                 break;
    642                         case SKYPE_CALL_FINISHED:
    643                                 if (sd->call_duration)
    644                                         imcb_log(ic, "You finished the call to the user %s (duration: %s seconds).", info, sd->call_duration);
    645                                 else
    646                                         imcb_log(ic, "You finished the call to the user %s.", info);
    647                                 sd->call_out = FALSE;
    648                                 break;
    649                         default:
    650                                 /* Don't be noisy, ignore other statuses for now. */
    651                                 break;
     640                if (!sd->call_status)
     641                        return;
     642                switch (sd->call_status) {
     643                case SKYPE_CALL_RINGING:
     644                        if (sd->call_out)
     645                                imcb_log(ic, "You are currently ringing "
     646                                        "the user %s.", info);
     647                        else {
     648                                g_snprintf(buf, 1024,
     649                                        "The user %s is currently ringing you.",
     650                                        info);
     651                                skype_call_ask(ic, sd->call_id, buf);
    652652                        }
     653                        break;
     654                case SKYPE_CALL_MISSED:
     655                        imcb_log(ic, "You have missed a call from user %s.",
     656                                info);
     657                        break;
     658                case SKYPE_CALL_CANCELLED:
     659                        imcb_log(ic, "You cancelled the call to the user %s.",
     660                                info);
    653661                        sd->call_status = 0;
    654                 }
     662                        sd->call_out = FALSE;
     663                        break;
     664                case SKYPE_CALL_REFUSED:
     665                        if (sd->call_out)
     666                                imcb_log(ic, "The user %s refused the call.",
     667                                        info);
     668                        else
     669                                imcb_log(ic,
     670                                        "You refused the call from user %s.",
     671                                        info);
     672                        sd->call_out = FALSE;
     673                        break;
     674                case SKYPE_CALL_FINISHED:
     675                        if (sd->call_duration)
     676                                imcb_log(ic,
     677                                        "You finished the call to the user %s "
     678                                        "(duration: %s seconds).",
     679                                        info, sd->call_duration);
     680                        else
     681                                imcb_log(ic,
     682                                        "You finished the call to the user %s.",
     683                                        info);
     684                        sd->call_out = FALSE;
     685                        break;
     686                default:
     687                        /* Don't be noisy, ignore other statuses for now. */
     688                        break;
     689                }
     690                sd->call_status = 0;
    655691        }
    656692}
     
    671707        info++;
    672708        if (!strcmp(info, "STATUS NEW")) {
    673                 g_snprintf(buf, 1024, "GET FILETRANSFER %s PARTNER_HANDLE\n", id);
     709                g_snprintf(buf, 1024, "GET FILETRANSFER %s PARTNER_HANDLE\n",
     710                        id);
    674711                skype_write(ic, buf);
    675712                sd->filetransfer_status = SKYPE_FILETRANSFER_NEW;
    676713        } else if (!strcmp(info, "STATUS FAILED")) {
    677                 g_snprintf(buf, 1024, "GET FILETRANSFER %s PARTNER_HANDLE\n", id);
     714                g_snprintf(buf, 1024, "GET FILETRANSFER %s PARTNER_HANDLE\n",
     715                        id);
    678716                skype_write(ic, buf);
    679717                sd->filetransfer_status = SKYPE_FILETRANSFER_FAILED;
    680718        } else if (!strncmp(info, "PARTNER_HANDLE ", 15)) {
    681719                info += 15;
    682                 if (sd->filetransfer_status) {
    683                         switch (sd->filetransfer_status) {
    684                         case SKYPE_FILETRANSFER_NEW:
    685                                 imcb_log(ic, "The user %s offered a new file for you.", info);
    686                                 break;
    687                         case SKYPE_FILETRANSFER_FAILED:
    688                                 imcb_log(ic, "Failed to transfer file from user %s.", info);
    689                                 break;
    690                         }
    691                         sd->filetransfer_status = 0;
    692                 }
     720                if (!sd->filetransfer_status)
     721                        return;
     722                switch (sd->filetransfer_status) {
     723                case SKYPE_FILETRANSFER_NEW:
     724                        imcb_log(ic, "The user %s offered a new file for you.",
     725                                info);
     726                        break;
     727                case SKYPE_FILETRANSFER_FAILED:
     728                        imcb_log(ic, "Failed to transfer file from user %s.",
     729                                info);
     730                        break;
     731                }
     732                sd->filetransfer_status = 0;
    693733        }
    694734}
     
    765805                 * so that we won't rejoin
    766806                 * after a /part. */
    767                 if (gc && !gc->data) {
    768                         char **members = g_strsplit(info, " ", 0);
    769                         int i;
    770                         for (i = 0; members[i]; i++) {
    771                                 if (!strcmp(members[i], sd->username))
    772                                         continue;
    773                                 g_snprintf(buf, 1024, "%s@skype.com", members[i]);
    774                                 if (!g_list_find_custom(gc->in_room, buf, (GCompareFunc)strcmp))
    775                                         imcb_chat_add_buddy(gc, buf);
    776                         }
    777                         imcb_chat_add_buddy(gc, sd->username);
    778                         g_strfreev(members);
    779                 }
     807                if (!gc || gc->data)
     808                        return;
     809                char **members = g_strsplit(info, " ", 0);
     810                int i;
     811                for (i = 0; members[i]; i++) {
     812                        if (!strcmp(members[i], sd->username))
     813                                continue;
     814                        g_snprintf(buf, 1024, "%s@skype.com", members[i]);
     815                        if (!g_list_find_custom(gc->in_room, buf,
     816                                (GCompareFunc)strcmp))
     817                                imcb_chat_add_buddy(gc, buf);
     818                }
     819                imcb_chat_add_buddy(gc, sd->username);
     820                g_strfreev(members);
    780821        }
    781822}
Note: See TracChangeset for help on using the changeset viewer.