~prateek.karandikar/ubuntu/precise/pidgin/add_quicklist

« back to all changes in this revision

Viewing changes to libpurple/protocols/zephyr/zephyr.c

  • Committer: Bazaar Package Importer
  • Author(s): Micah Gersten
  • Date: 2011-04-11 03:27:22 UTC
  • mfrom: (2.3.17 sid)
  • Revision ID: james.westby@ubuntu.com-20110411032722-farsw08i6ouj5dnd
Tags: 1:2.7.11-1ubuntu1
* Merge from Debian unstable (LP: #757146), remaining changes:
  + debian/control:
    - Add libtool and liblaunchpad-integration-dev build depends
    - Bump standards version
    - Relax binary depends on pidgin versions
    - Add pidgin-libnotify as Recommends for pidgin binary
    - Fix description of pidgin binary
    - Don't have libpurple-bin depend on libpurple0
  + debian/libpurple0.symbols: add epoch to appropriate symbols
  + Add debian/patches:
    - 02_lpi.patch
    - 04_let_crasher_for_apport.patch
    - 05_default_to_irc_ubuntu_com.patch
    - 10_docklet_default_off.patch
    - 11_buddy_list_really_show.patch
    - 13_sounds_and_timers.patch
    - 60_1024x600_gtkpounce.c.patch
    - 60_1024x600_gtkprefs.c.patch
  + debian/prefs.xml: add notification prefs
  + debian/rules:
    - Add translation domain to desktop file with gettext
    - Add the launcher for pidgin

* Add configure check for launchpad integration attached to the gtk check since 
  upstream dropped the startup notification check which is where this check was 
  previously
  - update debian/patches/02_lpi.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
 *
10
10
 * Some code borrowed from kzephyr, by
11
11
 * Chris Colohan <colohan+@cs.cmu.edu>
12
 
 * 
 
12
 *
13
13
 * This program is free software; you can redistribute it and/or modify
14
14
 * it under the terms of the GNU General Public License as published by
15
15
 * the Free Software Foundation; either version 2 of the License, or
98
98
        int num_children;
99
99
};
100
100
 
101
 
parse_tree null_parse_tree = { 
102
 
        "", 
103
 
        {NULL}, 
 
101
parse_tree null_parse_tree = {
 
102
        "",
 
103
        {NULL},
104
104
        0,
105
105
};
106
106
 
175
175
                        ZSubscription_t sub;
176
176
                        sub.zsub_class = class;
177
177
                        sub.zsub_classinst = instance;
178
 
                        sub.zsub_recipient = recipient; 
 
178
                        sub.zsub_recipient = recipient;
179
179
                        ret_val = ZSubscribeTo(&sub,1,0);
180
180
                }
181
181
        }
188
188
 
189
189
static char *zephyr_strip_local_realm(zephyr_account* zephyr,const char* user){
190
190
        /*
191
 
          Takes in a username of the form username or username@realm 
 
191
          Takes in a username of the form username or username@realm
192
192
          and returns:
193
193
          username, if there is no realm, or the realm is the local realm
194
194
          or:
255
255
/* returns true if zt1 is a subset of zt2.  This function is used to
256
256
   determine whether a zephyr sent to zt1 should be placed in the chat
257
257
   with triple zt2
258
 
 
259
 
   zt1 is a subset of zt2 
260
 
   iff. the classnames are identical ignoring case 
 
258
 
 
259
   zt1 is a subset of zt2
 
260
   iff. the classnames are identical ignoring case
261
261
   AND. the instance names are identical (ignoring case), or zt2->instance is *.
262
262
   AND. the recipient names are identical
263
263
*/
266
266
{
267
267
 
268
268
        if (!zt2) {
269
 
                purple_debug_error("zephyr","zt2 doesn't exist\n"); 
 
269
                purple_debug_error("zephyr","zt2 doesn't exist\n");
270
270
                return FALSE;
271
271
        }
272
272
        if (!zt1) {
339
339
        return NULL;
340
340
}
341
341
 
342
 
/* 
 
342
/*
343
343
   Converts strings to utf-8 if necessary using user specified encoding
344
344
*/
345
345
 
362
362
        }
363
363
}
364
364
 
365
 
/* This parses HTML formatting (put out by one of the gtkimhtml widgets 
 
365
/* This parses HTML formatting (put out by one of the gtkimhtml widgets
366
366
   And converts it to zephyr formatting.
367
367
   It currently deals properly with <b>, <br>, <i>, <font face=...>, <font color=...>,
368
368
   It ignores <font back=...>
801
801
                                }
802
802
                                for (; nlocs > 0; nlocs--) {
803
803
                                        /* XXX add real error reporting */
804
 
                                        
 
804
 
805
805
                                        ZGetLocations(&locs, &one);
806
 
                                        tmp = g_strdup_printf(_("<br>At %s since %s"), locs.host, locs.time);   
 
806
                                        tmp = g_strdup_printf(_("<br>At %s since %s"), locs.host, locs.time);
807
807
                                        purple_notify_user_info_add_pair(user_info, _("Location"), tmp);
808
808
                                        g_free(tmp);
809
809
                                }
810
 
                                purple_notify_userinfo(gc, (b ? bname : user), 
 
810
                                purple_notify_userinfo(gc, (b ? bname : user),
811
811
                                                     user_info, NULL, NULL);
812
812
                                purple_notify_user_info_destroy(user_info);
813
813
                        } else {
814
 
                                if (nlocs>0) 
 
814
                                if (nlocs>0)
815
815
                                        purple_prpl_got_user_status(gc->account, b ? bname : user, "available", NULL);
816
 
                                else 
 
816
                                else
817
817
                                        purple_prpl_got_user_status(gc->account, b ? bname : user, "offline", NULL);
818
818
                        }
819
819
 
825
825
                PurpleConversation *gconv1;
826
826
                PurpleConvChat *gcc;
827
827
                char *ptr = (char *) notice.z_message + (strlen(notice.z_message) + 1);
828
 
                int len; 
 
828
                int len;
829
829
                char *stripped_sender;
830
830
                int signature_length = strlen(notice.z_message);
831
831
                int message_has_no_body = 0;
839
839
                        len = 0;
840
840
                        purple_debug_info("zephyr","message_size %d %d %d\n",len,notice.z_message_len,signature_length);
841
841
                        buf3 = g_strdup("");
842
 
                                                
 
842
 
843
843
                } else {
844
844
                        len =  notice.z_message_len - ( signature_length +1);
845
845
                        purple_debug_info("zephyr","message_size %d %d %d\n",len,notice.z_message_len,signature_length);
856
856
 
857
857
                stripped_sender = zephyr_strip_local_realm(zephyr,notice.z_sender);
858
858
 
859
 
                if (!g_ascii_strcasecmp(notice.z_class, "MESSAGE") && !g_ascii_strcasecmp(notice.z_class_inst, "PERSONAL") 
 
859
                if (!g_ascii_strcasecmp(notice.z_class, "MESSAGE") && !g_ascii_strcasecmp(notice.z_class_inst, "PERSONAL")
860
860
                    && !g_ascii_strcasecmp(notice.z_recipient,zephyr->username)) {
861
861
                        if (!g_ascii_strcasecmp(notice.z_message, "Automated reply:"))
862
862
                                flags |= PURPLE_MESSAGE_AUTO_RESP;
863
 
                        
 
863
 
864
864
                        if (!g_ascii_strcasecmp(notice.z_opcode,"PING"))
865
865
                                serv_got_typing(gc,stripped_sender,ZEPHYR_TYPING_RECV_TIMEOUT, PURPLE_TYPING);
866
866
                        else
870
870
                        zephyr_triple *zt1, *zt2;
871
871
                        gchar *send_inst_utf8;
872
872
                        zephyr_account *zephyr = gc->proto_data;
873
 
                        zt1 = new_triple(gc->proto_data,notice.z_class, notice.z_class_inst, notice.z_recipient);
874
 
                        zt2 = find_sub_by_triple(gc->proto_data,zt1);
 
873
                        zt1 = new_triple(zephyr,notice.z_class, notice.z_class_inst, notice.z_recipient);
 
874
                        zt2 = find_sub_by_triple(zephyr,zt1);
875
875
                        if (!zt2) {
876
876
                                /* This is a server supplied subscription */
877
877
                                zephyr->subscrips = g_slist_append(zephyr->subscrips, new_triple(zephyr,zt1->class,zt1->instance,zt1->recipient));
878
 
                                zt2 = find_sub_by_triple(gc->proto_data,zt1);
879
 
                        } 
880
 
                                        
 
878
                                zt2 = find_sub_by_triple(zephyr,zt1);
 
879
                        }
 
880
 
881
881
                        if (!zt2->open) {
882
882
                                zt2->open = TRUE;
883
883
                                serv_got_joined_chat(gc, zt2->id, zt2->name);
936
936
                        }
937
937
                }
938
938
                if ((tree != &null_parse_tree) && (tree->contents != NULL))
939
 
                        g_free(tree->contents);   
 
939
                        g_free(tree->contents);
940
940
 
941
941
        }
942
942
        return 0;
954
954
{
955
955
        gchar* tc;
956
956
 
957
 
        if (!ptree || ! key) 
 
957
        if (!ptree || ! key)
958
958
                return &null_parse_tree;
959
959
 
960
960
        tc = tree_child(ptree,0)->contents;
976
976
}
977
977
 
978
978
static parse_tree *parse_buffer(gchar* source, gboolean do_parse) {
979
 
        
 
979
 
980
980
        parse_tree *ptree = g_new0(parse_tree,1);
981
981
        ptree->contents = NULL;
982
982
        ptree->num_children=0;
991
991
                                p++;
992
992
                                continue;
993
993
                        }
994
 
                        
 
994
 
995
995
                        /* Skip comments */
996
996
                        if(source[p] == ';') {
997
997
                                while(source[p] != '\n' && p < strlen(source)) {
999
999
                                }
1000
1000
                                continue;
1001
1001
                        }
1002
 
                        
 
1002
 
1003
1003
                        if(source[p] == '(') {
1004
1004
                                int nesting = 0;
1005
1005
                                gboolean in_quote = FALSE;
1036
1036
                                        p++;
1037
1037
                                } else {
1038
1038
                                        end_char = ' ';
1039
 
                                }                                             
 
1039
                                }
1040
1040
                                do_parse = FALSE;
1041
1041
 
1042
1042
                                end = p;
1043
1043
                                while(source[end] != end_char && end < strlen(source)) {
1044
 
                                        if(source[end] == '\\') 
 
1044
                                        if(source[end] == '\\')
1045
1045
                                                end++;
1046
1046
                                        end++;
1047
1047
                                }
1136
1136
                                /*                                g_free(zsig); */
1137
1137
                                g_free(buf);
1138
1138
                                /* free_parse_tree(msgnode);
1139
 
                                   free_parse_tree(bodynode); 
 
1139
                                   free_parse_tree(bodynode);
1140
1140
                                   g_free(msg);
1141
1141
                                   g_free(zsig);
1142
 
                                   g_free(buf); 
 
1142
                                   g_free(buf);
1143
1143
                                */
1144
1144
                        }
1145
1145
                        else if (!g_ascii_strncasecmp(spewtype,"zlocation",9)) {
1146
1146
                                /* check_loc or zephyr_zloc respectively */
1147
1147
                                /* XXX fix */
1148
 
                                char *user; 
 
1148
                                char *user;
1149
1149
                                PurpleBuddy *b;
1150
1150
                                const char *bname;
1151
1151
                                int nlocs = 0;
1166
1166
                                } else {
1167
1167
                                        nlocs = 1;
1168
1168
                                }
1169
 
        
 
1169
 
1170
1170
                                bname = b ? purple_buddy_get_name(b) : NULL;
1171
1171
                                if ((b && pending_zloc(zephyr,bname)) || pending_zloc(zephyr,user) || pending_zloc(zephyr,local_zephyr_normalize(zephyr,user))){
1172
1172
                                        PurpleNotifyUserInfo *user_info = purple_notify_user_info_new();
1193
1193
                                                             user_info, NULL, NULL);
1194
1194
                                        purple_notify_user_info_destroy(user_info);
1195
1195
                                } else {
1196
 
                                        if (nlocs>0) 
 
1196
                                        if (nlocs>0)
1197
1197
                                                purple_prpl_got_user_status(gc->account, b ? bname : user, "available", NULL);
1198
 
                                        else 
 
1198
                                        else
1199
1199
                                                purple_prpl_got_user_status(gc->account, b ? bname : user, "offline", NULL);
1200
1200
                                }
1201
1201
                        }
1210
1210
                }
1211
1211
        } else {
1212
1212
        }
1213
 
        
 
1213
 
1214
1214
        free_parse_tree(newparsetree);
1215
1215
        return TRUE;
1216
1216
}
1319
1319
                                int i;
1320
1320
                                for(i=0;i<numlocs;i++) {
1321
1321
                                        ZGetLocations(&locations,&one);
1322
 
                                        if (nlocs>0) 
 
1322
                                        if (nlocs>0)
1323
1323
                                                purple_prpl_got_user_status(account,name,"available",NULL);
1324
 
                                        else 
 
1324
                                        else
1325
1325
                                                purple_prpl_got_user_status(account,name,"offline",NULL);
1326
1326
                                }
1327
1327
                        }
1330
1330
                        g_free(ald.user);
1331
1331
                        g_free(ald.version);
1332
1332
#endif /* WIN32 */
1333
 
                } else 
 
1333
                } else
1334
1334
                        if (use_tzc(zephyr)) {
1335
1335
                                gchar *zlocstr = g_strdup_printf("((tzcfodder . zlocate) \"%s\")\n",chk);
1336
1336
                                size_t len = strlen(zlocstr);
1381
1381
{
1382
1382
        /* XXX This code may not be Win32 clean */
1383
1383
        struct hostent *hent;
1384
 
        
 
1384
 
1385
1385
        if (gethostname(zephyr->ourhost, sizeof(zephyr->ourhost)) == -1) {
1386
1386
                purple_debug_error("zephyr", "unable to retrieve hostname, %%host%% and %%canon%% will be wrong in subscriptions and have been set to unknown\n");
1387
1387
                g_strlcpy(zephyr->ourhost, "unknown", sizeof(zephyr->ourhost));
1388
1388
                g_strlcpy(zephyr->ourhostcanon, "unknown", sizeof(zephyr->ourhostcanon));
1389
1389
                return;
1390
1390
        }
1391
 
        
 
1391
 
1392
1392
        if (!(hent = gethostbyname(zephyr->ourhost))) {
1393
1393
                purple_debug_error("zephyr", "unable to resolve hostname, %%canon%% will be wrong in subscriptions.and has been set to the value of %%host%%, %s\n",zephyr->ourhost);
1394
1394
                g_strlcpy(zephyr->ourhostcanon, zephyr->ourhost, sizeof(zephyr->ourhostcanon));
1402
1402
 
1403
1403
static void process_zsubs(zephyr_account *zephyr)
1404
1404
{
1405
 
        /* Loads zephyr chats "(subscriptions) from ~/.zephyr.subs, and 
 
1405
        /* Loads zephyr chats "(subscriptions) from ~/.zephyr.subs, and
1406
1406
           registers (subscribes to) them on the server */
1407
1407
 
1408
1408
        /* XXX deal with unsubscriptions */
1467
1467
                                        } else {
1468
1468
                                                z_class = g_strdup(triple[0]);
1469
1469
                                        }
1470
 
                                        
 
1470
 
1471
1471
                                        if (!g_ascii_strcasecmp(triple[1],"%host%")) {
1472
1472
                                                z_instance = g_strdup(zephyr->ourhost);
1473
1473
                                        } else if (!g_ascii_strcasecmp(triple[1],"%canon%")) {
1499
1499
 
1500
1500
static void process_anyone(PurpleConnection *gc)
1501
1501
{
 
1502
        zephyr_account *zephyr = purple_connection_get_protocol_data(gc);
1502
1503
        FILE *fd;
1503
1504
        gchar buff[BUFSIZ], *filename;
1504
1505
        PurpleGroup *g;
1515
1516
                        strip_comments(buff);
1516
1517
                        if (buff[0]) {
1517
1518
                                if (!(b = purple_find_buddy(gc->account, buff))) {
1518
 
                                        char *stripped_user = zephyr_strip_local_realm(gc->proto_data,buff);
 
1519
                                        char *stripped_user = zephyr_strip_local_realm(zephyr,buff);
1519
1520
                                        purple_debug_info("zephyr","stripped_user %s\n",stripped_user);
1520
1521
                                        if (!(b = purple_find_buddy(gc->account,stripped_user))){
1521
1522
                                                b = purple_buddy_new(gc->account, stripped_user, NULL);
1522
1523
                                                purple_blist_add_buddy(b, NULL, g, NULL);
1523
 
                                        } 
 
1524
                                        }
1524
1525
                                        g_free(stripped_user);
1525
1526
                                }
1526
1527
                        }
1552
1553
{
1553
1554
        PurpleConnection *gc;
1554
1555
        zephyr_account *zephyr;
1555
 
        gboolean read_anyone; 
1556
 
        gboolean read_zsubs; 
 
1556
        gboolean read_anyone;
 
1557
        gboolean read_zsubs;
1557
1558
        gchar *exposure;
1558
1559
 
1559
1560
        gc = purple_account_get_connection(account);
1560
1561
        read_anyone = purple_account_get_bool(gc->account,"read_anyone",TRUE);
1561
1562
        read_zsubs = purple_account_get_bool(gc->account,"read_zsubs",TRUE);
1562
 
        exposure = (gchar *)purple_account_get_string(gc->account, "exposure_level", EXPOSE_REALMVIS); 
 
1563
        exposure = (gchar *)purple_account_get_string(gc->account, "exposure_level", EXPOSE_REALMVIS);
1563
1564
 
1564
1565
#ifdef WIN32
1565
1566
        username = purple_account_get_username(account);
1566
1567
#endif
1567
1568
        gc->flags |= PURPLE_CONNECTION_AUTO_RESP | PURPLE_CONNECTION_HTML | PURPLE_CONNECTION_NO_BGCOLOR | PURPLE_CONNECTION_NO_URLDESC;
1568
 
        gc->proto_data = zephyr=g_new0(zephyr_account,1); 
 
1569
        gc->proto_data = zephyr=g_new0(zephyr_account,1);
1569
1570
 
1570
1571
        zephyr->account = account;
1571
1572
 
1589
1590
                        purple_debug_error("zephyr", "pipe creation failed. killing\n");
1590
1591
                        exit(-1);
1591
1592
                }
1592
 
                
 
1593
 
1593
1594
                pid = fork();
1594
 
                
 
1595
 
1595
1596
                if (pid == -1) {
1596
1597
                        purple_debug_error("zephyr", "forking failed\n");
1597
1598
                        exit(-1);
1618
1619
                        if (close(zephyr->totzc[0]) == -1) {
1619
1620
                                exit(-1);
1620
1621
                        }
1621
 
                        /* tzc_command should really be of the form 
 
1622
                        /* tzc_command should really be of the form
1622
1623
                           path/to/tzc -e %s
1623
1624
                           or
1624
 
                           ssh username@hostname pathtotzc -e %s 
 
1625
                           ssh username@hostname pathtotzc -e %s
1625
1626
                           -- this should not require a password, and ideally should be kerberized ssh --
1626
1627
                           or
1627
1628
                           fsh username@hostname pathtotzc -e %s
1631
1632
                                        /*                                      fprintf(stderr,"replacing %%s with %s\n",zephyr->exposure); */
1632
1633
                                        tzc_cmd_array[i] = g_strdup(zephyr->exposure);
1633
1634
                                        found_ps = TRUE;
1634
 
                                        
 
1635
 
1635
1636
                                } else {
1636
1637
                                        /*                                      fprintf(stderr,"keeping %s\n",tzc_cmd_array[i]); */
1637
1638
                                }
1712
1713
 
1713
1714
                        while(ptr < bufcur) {
1714
1715
                                if (*ptr == '(') {
1715
 
                                        parenlevel++; 
 
1716
                                        parenlevel++;
1716
1717
                                }
1717
1718
                                else if (*ptr == ')') {
1718
1719
                                        parenlevel--;
1719
1720
                                }
1720
1721
                                purple_debug_info("zephyr","tzc parenlevel is %d\n",parenlevel);
1721
1722
                                switch (parenlevel) {
1722
 
                                case 0: 
 
1723
                                case 0:
1723
1724
                                        break;
1724
1725
                                case 1:
1725
1726
                                        /* Search for next beginning (, or for the ending */
1726
1727
                                        ptr++;
1727
 
                                        while((*ptr != '(') && (*ptr != ')') && (ptr <bufcur)) 
 
1728
                                        while((*ptr != '(') && (*ptr != ')') && (ptr <bufcur))
1728
1729
                                                ptr++;
1729
 
                                        if (ptr >= bufcur) 
 
1730
                                        if (ptr >= bufcur)
1730
1731
                                                purple_debug_error("zephyr","tzc parsing error\n");
1731
1732
                                        break;
1732
 
                                case 2: 
 
1733
                                case 2:
1733
1734
                                        /* You are probably at
1734
1735
                                           (foo . bar ) or (foo . "bar") or (foo . chars) or (foo . numbers) or (foo . () )
1735
1736
                                           Parse all the data between the first and last f, and move past )
1749
1750
                                                }
1750
1751
                                        }
1751
1752
                                        purple_debug_info("zephyr","tempstr parsed\n");
1752
 
                                        /* tempstr should now be a tempstridx length string containing all characters 
 
1753
                                        /* tempstr should now be a tempstridx length string containing all characters
1753
1754
                                           from that after the first ( to the one before the last paren ). */
1754
 
                                        /* We should have the following possible lisp strings but we don't care 
 
1755
                                        /* We should have the following possible lisp strings but we don't care
1755
1756
                                           (tzcspew . start) (version . "something") (pid . number)*/
1756
1757
                                        /* We care about 'zephyrid . "username@REALM.NAME"' and 'exposure . "SOMETHING"' */
1757
1758
                                        tempstridx=0;
1766
1767
                                                tempstridx++;
1767
1768
                                                while(tempstr[tempstridx] !='"' && tempstridx < 20000)
1768
1769
                                                        username[username_idx++]=tempstr[tempstridx++];
1769
 
                                                        
 
1770
 
1770
1771
                                                zephyr->username = g_strdup_printf("%s",username);
1771
 
                                                if ((realm = strchr(username,'@'))) 
 
1772
                                                if ((realm = strchr(username,'@')))
1772
1773
                                                        zephyr->realm = g_strdup_printf("%s",realm+1);
1773
1774
                                                else {
1774
1775
                                                        realm = (gchar *)purple_account_get_string(gc->account,"realm","");
1781
1782
                                                /* else {
1782
1783
                                                   zephyr->realm = g_strdup("local-realm");
1783
1784
                                                   }*/
1784
 
                                                        
 
1785
 
1785
1786
                                                g_free(username);
1786
1787
                                        }  else {
1787
1788
                                                purple_debug_info("zephyr", "something that's not zephyr id found %s\n",tempstr);
1788
1789
                                        }
1789
 
                                        
 
1790
 
1790
1791
                                        /* We don't care about anything else yet */
1791
1792
                                        g_free(tempstr);
1792
1793
                                        break;
1850
1851
                zephyr->nottimer = purple_timeout_add(100, check_notify_zeph02, gc);
1851
1852
        } else if (use_tzc(zephyr)) {
1852
1853
                zephyr->nottimer = purple_timeout_add(100, check_notify_tzc, gc);
1853
 
        } 
1854
 
        zephyr->loctimer = purple_timeout_add_seconds(20, check_loc, gc); 
 
1854
        }
 
1855
        zephyr->loctimer = purple_timeout_add_seconds(20, check_loc, gc);
1855
1856
 
1856
1857
}
1857
1858
 
1881
1882
                char *zclass, *zinst, *zrecip;
1882
1883
                zt = s->data;
1883
1884
                triple = g_strsplit(zt->name, ",", 3);
1884
 
                
 
1885
 
1885
1886
                /* deal with classes */
1886
1887
                if (!g_ascii_strcasecmp(triple[0],zephyr->ourhost)) {
1887
1888
                        zclass = g_strdup("%host%");
1913
1914
                }
1914
1915
 
1915
1916
                fprintf(fd, "%s,%s,%s\n",zclass,zinst,zrecip);
1916
 
                 
 
1917
 
1917
1918
                g_free(zclass);
1918
1919
                g_free(zinst);
1919
1920
                g_free(zrecip);
1924
1925
        fclose(fd);
1925
1926
}
1926
1927
 
1927
 
static void write_anyone(PurpleConnection *gc)
 
1928
static void write_anyone(zephyr_account *zephyr)
1928
1929
{
1929
1930
        GSList *buddies;
1930
1931
        char *fname;
1931
1932
        FILE *fd;
1932
1933
        PurpleAccount *account;
1933
 
        zephyr_account* zephyr = gc->proto_data;
1934
1934
        fname = g_strdup_printf("%s/.anyone", purple_home_dir());
1935
1935
        fd = g_fopen(fname, "w");
1936
1936
        if (!fd) {
1938
1938
                return;
1939
1939
        }
1940
1940
 
1941
 
        account = purple_connection_get_account(gc);
 
1941
        account = zephyr->account;
1942
1942
        for (buddies = purple_find_buddies(account, NULL); buddies;
1943
1943
                        buddies = g_slist_delete_link(buddies, buddies)) {
1944
1944
                PurpleBuddy *b = buddies->data;
1966
1966
        g_list_free(zephyr->pending_zloc_names);
1967
1967
 
1968
1968
        if (purple_account_get_bool(gc->account, "write_anyone", FALSE))
1969
 
                write_anyone(gc);
 
1969
                write_anyone(zephyr);
1970
1970
 
1971
1971
        if (purple_account_get_bool(gc->account, "write_zsubs", FALSE))
1972
 
                write_zsubs(gc->proto_data);
 
1972
                write_zsubs(zephyr);
1973
1973
 
1974
1974
        s = zephyr->subscrips;
1975
1975
        while (s) {
1995
1995
                        int err=errno;
1996
1996
                        if (err==EINVAL) {
1997
1997
                                purple_debug_error("zephyr","An invalid signal was specified when killing tzc\n");
1998
 
                        } 
 
1998
                        }
1999
1999
                        else if (err==ESRCH) {
2000
2000
                                purple_debug_error("zephyr","Tzc's pid didn't exist while killing tzc\n");
2001
2001
                        }
2009
2009
        }
2010
2010
}
2011
2011
 
2012
 
static int zephyr_send_message(zephyr_account *zephyr,char* zclass, char* instance, char* recipient, const char *im, 
 
2012
static int zephyr_send_message(zephyr_account *zephyr,char* zclass, char* instance, char* recipient, const char *im,
2013
2013
                               const char *sig, char *opcode) ;
2014
2014
 
2015
2015
static const char * zephyr_get_signature(void)
2032
2032
        char *recipient;
2033
2033
        zephyr_account *zephyr = gc->proto_data;
2034
2034
 
2035
 
        zt = find_sub_by_id(gc->proto_data,id);
 
2035
        zt = find_sub_by_id(zephyr,id);
2036
2036
        if (!zt)
2037
2037
                /* this should never happen. */
2038
2038
                return -EINVAL;
2067
2067
        }
2068
2068
        zephyr_send_message(zephyr,"MESSAGE","PERSONAL",local_zephyr_normalize(zephyr,who),im,sig,"");
2069
2069
 
2070
 
        return 1; 
 
2070
        return 1;
2071
2071
}
2072
2072
 
2073
2073
/* Munge the outgoing zephyr so that any quotes or backslashes are
2091
2091
                                newmsg[pos2]='\\';
2092
2092
                                newmsg[pos2+1]='"';
2093
2093
                                pos2+=2;
2094
 
                        } 
 
2094
                        }
2095
2095
                        else {
2096
2096
                                newmsg[pos2] = message[pos];
2097
2097
                                pos2++;
2128
2128
        return newmsg;
2129
2129
}
2130
2130
 
2131
 
static int zephyr_send_message(zephyr_account *zephyr,char* zclass, char* instance, char* recipient, const char *im, 
2132
 
                               const char *sig, char *opcode) 
 
2131
static int zephyr_send_message(zephyr_account *zephyr,char* zclass, char* instance, char* recipient, const char *im,
 
2132
                               const char *sig, char *opcode)
2133
2133
{
2134
2134
 
2135
 
        /* (From the tzc source) 
 
2135
        /* (From the tzc source)
2136
2136
         * emacs sends something of the form:
2137
 
         * ((class . "MESSAGE") 
 
2137
         * ((class . "MESSAGE")
2138
2138
         *  (auth . t)
2139
2139
         *  (recipients ("PERSONAL" . "bovik") ("test" . ""))
2140
2140
         *  (sender . "bovik")
2169
2169
                ZNotice_t notice;
2170
2170
                char *buf = g_strdup_printf("%s%c%s", sig, '\0', html_buf2);
2171
2171
                memset((char *)&notice, 0, sizeof(notice));
2172
 
                
 
2172
 
2173
2173
                notice.z_kind = ACKED;
2174
2174
                notice.z_port = 0;
2175
2175
                notice.z_opcode = "";
2201
2201
 
2202
2202
char *local_zephyr_normalize(zephyr_account *zephyr,const char *orig)
2203
2203
{
2204
 
        /* 
2205
 
           Basically the inverse of zephyr_strip_local_realm 
2206
 
        */      
 
2204
        /*
 
2205
           Basically the inverse of zephyr_strip_local_realm
 
2206
        */
2207
2207
        char* buf;
2208
 
        
 
2208
 
2209
2209
        if (!g_ascii_strcasecmp(orig, "")) {
2210
2210
                return g_strdup("");
2211
2211
        }
2214
2214
                buf = g_strdup_printf("%s",orig);
2215
2215
        } else {
2216
2216
                buf = g_strdup_printf("%s@%s",orig,zephyr->realm);
2217
 
        } 
 
2217
        }
2218
2218
        return buf;
2219
2219
}
2220
2220
 
2281
2281
 
2282
2282
        if (primitive == PURPLE_STATUS_AWAY) {
2283
2283
                zephyr->away = g_strdup(purple_status_get_attr_string(status,"message"));
2284
 
        } 
 
2284
        }
2285
2285
        else if (primitive == PURPLE_STATUS_AVAILABLE) {
2286
2286
                if (use_zeph02(zephyr)) {
2287
2287
                        ZSetLocation(zephyr->exposure);
2295
2295
                        }
2296
2296
                        g_free(zexpstr);
2297
2297
                }
2298
 
        } 
 
2298
        }
2299
2299
        else if (primitive == PURPLE_STATUS_INVISIBLE) {
2300
2300
                /* XXX handle errors */
2301
2301
                if (use_zeph02(zephyr)) {
2312
2312
        }
2313
2313
}
2314
2314
 
2315
 
static GList *zephyr_status_types(PurpleAccount *account) 
 
2315
static GList *zephyr_status_types(PurpleAccount *account)
2316
2316
{
2317
2317
        PurpleStatusType *type;
2318
2318
        GList *types = NULL;
2319
2319
 
2320
 
        /* zephyr has several exposures 
 
2320
        /* zephyr has several exposures
2321
2321
           NONE (where you are hidden, and zephyrs to you are in practice silently dropped -- yes this is wrong)
2322
2322
           OPSTAFF "hidden"
2323
2323
           REALM-VISIBLE visible to people in local realm
2410
2410
        instname = g_hash_table_lookup(data, "instance");
2411
2411
        recip = g_hash_table_lookup(data, "recipient");
2412
2412
 
2413
 
                
 
2413
 
2414
2414
        if (!classname)
2415
2415
                return;
2416
2416
 
2417
2417
        if (!g_ascii_strcasecmp(classname,"%host%"))
2418
2418
                classname = g_strdup(zephyr->ourhost);
2419
 
        if (!g_ascii_strcasecmp(classname,"%canon%")) 
 
2419
        if (!g_ascii_strcasecmp(classname,"%canon%"))
2420
2420
                classname = g_strdup(zephyr->ourhostcanon);
2421
2421
 
2422
2422
        if (!instname || !strlen(instname))
2424
2424
 
2425
2425
        if (!g_ascii_strcasecmp(instname,"%host%"))
2426
2426
                instname = g_strdup(zephyr->ourhost);
2427
 
        if (!g_ascii_strcasecmp(instname,"%canon%")) 
 
2427
        if (!g_ascii_strcasecmp(instname,"%canon%"))
2428
2428
                instname = g_strdup(zephyr->ourhostcanon);
2429
2429
 
2430
2430
        if (!recip || (*recip == '*'))
2432
2432
        if (!g_ascii_strcasecmp(recip, "%me%"))
2433
2433
                recip = zephyr->username;
2434
2434
 
2435
 
        zt1 = new_triple(gc->proto_data,classname, instname, recip);
2436
 
        zt2 = find_sub_by_triple(gc->proto_data,zt1);
 
2435
        zt1 = new_triple(zephyr,classname, instname, recip);
 
2436
        zt2 = find_sub_by_triple(zephyr,zt1);
2437
2437
        if (zt2) {
2438
2438
                free_triple(zt1);
2439
2439
                if (!zt2->open) {
2440
 
                        if (!g_ascii_strcasecmp(instname,"*")) 
 
2440
                        if (!g_ascii_strcasecmp(instname,"*"))
2441
2441
                                instname = "PERSONAL";
2442
2442
                        serv_got_joined_chat(gc, zt2->id, zt2->name);
2443
2443
                        zephyr_chat_set_topic(gc,zt2->id,instname);
2444
2444
                        zt2->open = TRUE;
2445
 
                }       
 
2445
                }
2446
2446
                return;
2447
2447
        }
2448
 
        
 
2448
 
2449
2449
        /*      sub.zsub_class = zt1->class;
2450
2450
                sub.zsub_classinst = zt1->instance;
2451
2451
                sub.zsub_recipient = zt1->recipient; */
2460
2460
        zephyr->subscrips = g_slist_append(zephyr->subscrips, zt1);
2461
2461
        zt1->open = TRUE;
2462
2462
        serv_got_joined_chat(gc, zt1->id, zt1->name);
2463
 
        if (!g_ascii_strcasecmp(instname,"*")) 
 
2463
        if (!g_ascii_strcasecmp(instname,"*"))
2464
2464
                instname = "PERSONAL";
2465
2465
        zephyr_chat_set_topic(gc,zt1->id,instname);
2466
2466
}
2519
2519
static unsigned int zephyr_send_typing(PurpleConnection *gc, const char *who, PurpleTypingState state) {
2520
2520
        gchar *recipient;
2521
2521
        zephyr_account *zephyr = gc->proto_data;
2522
 
        if (use_tzc(zephyr)) 
 
2522
        if (use_tzc(zephyr))
2523
2523
                return 0;
2524
2524
 
2525
2525
        if (state == PURPLE_NOT_TYPING)
2563
2563
        zephyr_account* zephyr = gc->proto_data;
2564
2564
        char *sender = (char *)zephyr->username;
2565
2565
 
2566
 
        zt = find_sub_by_id(gc->proto_data,id);
 
2566
        zt = find_sub_by_id(zephyr,id);
2567
2567
        /* find_sub_by_id can return NULL */
2568
 
        if (!zt) 
 
2568
        if (!zt)
2569
2569
                return;
2570
2570
        gconv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, zt->name,
2571
2571
                                                                                                gc->account);
2586
2586
        zephyr_account *zephyr = purple_conversation_get_gc(conv)->proto_data;
2587
2587
        if (!g_ascii_strcasecmp(args[0],"*"))
2588
2588
                return PURPLE_CMD_RET_FAILED;  /* "*" is not a valid argument */
2589
 
        else 
 
2589
        else
2590
2590
                recipient = local_zephyr_normalize(zephyr,args[0]);
2591
2591
 
2592
2592
        if (strlen(recipient) < 1)
2594
2594
 
2595
2595
        if (zephyr_send_message(zephyr,"MESSAGE","PERSONAL",recipient,args[1],zephyr_get_signature(),""))
2596
2596
                return PURPLE_CMD_RET_OK;
2597
 
        else 
 
2597
        else
2598
2598
                return PURPLE_CMD_RET_FAILED;
2599
2599
}
2600
2600
 
2638
2638
        zephyr_account *zephyr = purple_conversation_get_gc(conv)->proto_data;
2639
2639
        if ( zephyr_send_message(zephyr,"message",args[0],"",args[1],zephyr_get_signature(),""))
2640
2640
                return PURPLE_CMD_RET_OK;
2641
 
        else 
 
2641
        else
2642
2642
                return PURPLE_CMD_RET_FAILED;
2643
2643
}
2644
2644
 
2649
2649
        zephyr_account *zephyr = purple_conversation_get_gc(conv)->proto_data;
2650
2650
        if ( zephyr_send_message(zephyr,args[0],args[1],"",args[2],zephyr_get_signature(),""))
2651
2651
                return PURPLE_CMD_RET_OK;
2652
 
        else 
 
2652
        else
2653
2653
                return PURPLE_CMD_RET_FAILED;
2654
2654
}
2655
2655
 
2658
2658
{
2659
2659
        /* args = class, instance, recipient, message */
2660
2660
        zephyr_account *zephyr = purple_conversation_get_gc(conv)->proto_data;
2661
 
        if ( zephyr_send_message(zephyr,args[0],args[1],args[2],args[3],zephyr_get_signature(),"")) 
 
2661
        if ( zephyr_send_message(zephyr,args[0],args[1],args[2],args[3],zephyr_get_signature(),""))
2662
2662
                return PURPLE_CMD_RET_OK;
2663
2663
        else
2664
2664
                return PURPLE_CMD_RET_FAILED;
2669
2669
{
2670
2670
        /* args = instance, recipient, message */
2671
2671
        zephyr_account *zephyr = purple_conversation_get_gc(conv)->proto_data;
2672
 
        if ( zephyr_send_message(zephyr,"message",args[0],args[1],args[2],zephyr_get_signature(),"")) 
 
2672
        if ( zephyr_send_message(zephyr,"message",args[0],args[1],args[2],zephyr_get_signature(),""))
2673
2673
                return PURPLE_CMD_RET_OK;
2674
2674
        else
2675
2675
                return PURPLE_CMD_RET_FAILED;
2680
2680
{
2681
2681
        /* args = class, message */
2682
2682
        zephyr_account *zephyr = purple_conversation_get_gc(conv)->proto_data;
2683
 
        if ( zephyr_send_message(zephyr,args[0],"PERSONAL","",args[1],zephyr_get_signature(),"")) 
 
2683
        if ( zephyr_send_message(zephyr,args[0],"PERSONAL","",args[1],zephyr_get_signature(),""))
2684
2684
                return PURPLE_CMD_RET_OK;
2685
2685
        else
2686
2686
                return PURPLE_CMD_RET_FAILED;
2791
2791
        ZSubscription_t subs;
2792
2792
        if (use_zeph02(zephyr)) {
2793
2793
                GString* subout = g_string_new("Subscription list<br>");
2794
 
                
 
2794
 
2795
2795
                title = g_strdup_printf("Server subscriptions for %s", zephyr->username);
2796
 
                
 
2796
 
2797
2797
                if (zephyr->port == 0) {
2798
2798
                        purple_debug_error("zephyr", "error while retrieving port\n");
2799
2799
                        return;
2800
 
                } 
 
2800
                }
2801
2801
                if ((retval = ZRetrieveSubscriptions(zephyr->port,&nsubs)) != ZERR_NONE) {
2802
2802
                        /* XXX better error handling */
2803
2803
                        purple_debug_error("zephyr", "error while retrieving subscriptions from server\n");
2969
2969
 
2970
2970
        option = purple_account_option_bool_new(_("Import from .anyone"), "read_anyone", TRUE);
2971
2971
        prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
2972
 
 
 
2972
 
2973
2973
        option = purple_account_option_bool_new(_("Import from .zephyr.subs"), "read_zsubs", TRUE);
2974
2974
        prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
2975
 
 
 
2975
 
2976
2976
        option = purple_account_option_string_new(_("Realm"), "realm", "");
2977
2977
        prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
2978
 
        
 
2978
 
2979
2979
        option = purple_account_option_string_new(_("Exposure"), "exposure_level", tmp?tmp: EXPOSE_REALMVIS);
2980
2980
        prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
2981
2981