annotate src/protocols/silc/util.c @ 11133:1081735edc10

[gaim-migrate @ 13192] keeping in synch with the current plugin code committer: Tailor Script <tailor@pidgin.im>
author Christopher O'Brien <siege@pidgin.im>
date Wed, 20 Jul 2005 12:32:20 +0000
parents cb625efd1071
children 07dc8c6a359f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
1 /*
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
2
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
3 silcgaim_util.c
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
4
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
5 Author: Pekka Riikonen <priikone@silcnet.org>
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
6
10825
cb625efd1071 [gaim-migrate @ 12490]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10751
diff changeset
7 Copyright (C) 2004 - 2005 Pekka Riikonen
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
8
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
9 This program is free software; you can redistribute it and/or modify
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
10 it under the terms of the GNU General Public License as published by
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
11 the Free Software Foundation; version 2 of the License.
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
12
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
13 This program is distributed in the hope that it will be useful,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
16 GNU General Public License for more details.
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
17
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
18 */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
19
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
20 #include "silcincludes.h"
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
21 #include "silcclient.h"
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
22 #include "silcgaim.h"
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
23
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
24 /**************************** Utility Routines *******************************/
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
25
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
26 static char str[256], str2[256];
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
27
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
28 const char *silcgaim_silcdir(void)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
29 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
30 const char *hd = gaim_home_dir();
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
31 memset(str, 0, sizeof(str));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
32 g_snprintf(str, sizeof(str) - 1, "%s" G_DIR_SEPARATOR_S ".silc", hd ? hd : "/tmp");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
33 return (const char *)str;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
34 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
35
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
36 const char *silcgaim_session_file(const char *account)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
37 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
38 memset(str2, 0, sizeof(str2));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
39 g_snprintf(str2, sizeof(str2) - 1, "%s" G_DIR_SEPARATOR_S "%s_session",
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
40 silcgaim_silcdir(), account);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
41 return (const char *)str2;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
42 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
43
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
44 gboolean silcgaim_ip_is_private(const char *ip)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
45 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
46 if (silc_net_is_ip4(ip)) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
47 if (!strncmp(ip, "10.", 3)) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
48 return TRUE;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
49 } else if (!strncmp(ip, "172.", 4) && strlen(ip) > 6) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
50 char tmp[3];
8910
26c9b8761707 [gaim-migrate @ 9680]
Luke Schierer <lschiere@pidgin.im>
parents: 8849
diff changeset
51 int s;
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
52 memset(tmp, 0, sizeof(tmp));
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
53 strncpy(tmp, ip + 4, 2);
8910
26c9b8761707 [gaim-migrate @ 9680]
Luke Schierer <lschiere@pidgin.im>
parents: 8849
diff changeset
54 s = atoi(tmp);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
55 if (s >= 16 && s <= 31)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
56 return TRUE;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
57 } else if (!strncmp(ip, "192.168.", 8)) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
58 return TRUE;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
59 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
60 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
61
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
62 return FALSE;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
63 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
64
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
65 /* This checks stats for various SILC files and directories. First it
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
66 checks if ~/.silc directory exist and is owned by the correct user. If
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
67 it doesn't exist, it will create the directory. After that it checks if
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
68 user's Public and Private key files exists and creates them if needed. */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
69
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
70 gboolean silcgaim_check_silc_dir(GaimConnection *gc)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
71 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
72 char filename[256], file_public_key[256], file_private_key[256];
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
73 char servfilename[256], clientfilename[256], friendsfilename[256];
10825
cb625efd1071 [gaim-migrate @ 12490]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10751
diff changeset
74 char pkd[256], prd[256];
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
75 struct stat st;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
76 struct passwd *pw;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
77
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
78 pw = getpwuid(getuid());
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
79 if (!pw) {
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9183
diff changeset
80 gaim_debug_error("silc", "silc: %s\n", strerror(errno));
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
81 return FALSE;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
82 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
83
9353
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9274
diff changeset
84 g_snprintf(filename, sizeof(filename) - 1, "%s", silcgaim_silcdir());
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
85 g_snprintf(servfilename, sizeof(servfilename) - 1, "%s" G_DIR_SEPARATOR_S "serverkeys",
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
86 silcgaim_silcdir());
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
87 g_snprintf(clientfilename, sizeof(clientfilename) - 1, "%s" G_DIR_SEPARATOR_S "clientkeys",
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
88 silcgaim_silcdir());
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
89 g_snprintf(friendsfilename, sizeof(friendsfilename) - 1, "%s" G_DIR_SEPARATOR_S "friends",
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
90 silcgaim_silcdir());
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
91
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
92 /*
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
93 * Check ~/.silc directory
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
94 */
10589
0f7452b1f777 [gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9488
diff changeset
95 if ((g_stat(filename, &st)) == -1) {
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
96 /* If dir doesn't exist */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
97 if (errno == ENOENT) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
98 if (pw->pw_uid == geteuid()) {
10589
0f7452b1f777 [gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9488
diff changeset
99 if ((g_mkdir(filename, 0755)) == -1) {
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9183
diff changeset
100 gaim_debug_error("silc", "Couldn't create '%s' directory\n", filename);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
101 return FALSE;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
102 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
103 } else {
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9183
diff changeset
104 gaim_debug_error("silc", "Couldn't create '%s' directory due to a wrong uid!\n",
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
105 filename);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
106 return FALSE;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
107 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
108 } else {
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9183
diff changeset
109 gaim_debug_error("silc", "Couldn't stat '%s' directory, error: %s\n", filename, strerror(errno));
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
110 return FALSE;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
111 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
112 } else {
9353
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9274
diff changeset
113 #ifndef _WIN32
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
114 /* Check the owner of the dir */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
115 if (st.st_uid != 0 && st.st_uid != pw->pw_uid) {
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9183
diff changeset
116 gaim_debug_error("silc", "You don't seem to own '%s' directory\n",
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
117 filename);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
118 return FALSE;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
119 }
9353
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9274
diff changeset
120 #endif
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
121 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
122
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
123 /*
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
124 * Check ~./silc/serverkeys directory
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
125 */
10589
0f7452b1f777 [gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9488
diff changeset
126 if ((g_stat(servfilename, &st)) == -1) {
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
127 /* If dir doesn't exist */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
128 if (errno == ENOENT) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
129 if (pw->pw_uid == geteuid()) {
10589
0f7452b1f777 [gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9488
diff changeset
130 if ((g_mkdir(servfilename, 0755)) == -1) {
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9183
diff changeset
131 gaim_debug_error("silc", "Couldn't create '%s' directory\n", servfilename);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
132 return FALSE;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
133 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
134 } else {
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9183
diff changeset
135 gaim_debug_error("silc", "Couldn't create '%s' directory due to a wrong uid!\n",
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
136 servfilename);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
137 return FALSE;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
138 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
139 } else {
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9183
diff changeset
140 gaim_debug_error("silc", "Couldn't stat '%s' directory, error: %s\n",
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9183
diff changeset
141 servfilename, strerror(errno));
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
142 return FALSE;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
143 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
144 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
145
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
146 /*
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
147 * Check ~./silc/clientkeys directory
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
148 */
10589
0f7452b1f777 [gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9488
diff changeset
149 if ((g_stat(clientfilename, &st)) == -1) {
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
150 /* If dir doesn't exist */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
151 if (errno == ENOENT) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
152 if (pw->pw_uid == geteuid()) {
10589
0f7452b1f777 [gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9488
diff changeset
153 if ((g_mkdir(clientfilename, 0755)) == -1) {
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9183
diff changeset
154 gaim_debug_error("silc", "Couldn't create '%s' directory\n", clientfilename);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
155 return FALSE;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
156 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
157 } else {
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9183
diff changeset
158 gaim_debug_error("silc", "Couldn't create '%s' directory due to a wrong uid!\n",
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
159 clientfilename);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
160 return FALSE;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
161 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
162 } else {
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9183
diff changeset
163 gaim_debug_error("silc", "Couldn't stat '%s' directory, error: %s\n",
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9183
diff changeset
164 clientfilename, strerror(errno));
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
165 return FALSE;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
166 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
167 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
168
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
169 /*
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
170 * Check ~./silc/friends directory
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
171 */
10589
0f7452b1f777 [gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9488
diff changeset
172 if ((g_stat(friendsfilename, &st)) == -1) {
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
173 /* If dir doesn't exist */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
174 if (errno == ENOENT) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
175 if (pw->pw_uid == geteuid()) {
10589
0f7452b1f777 [gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9488
diff changeset
176 if ((g_mkdir(friendsfilename, 0755)) == -1) {
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9183
diff changeset
177 gaim_debug_error("silc", "Couldn't create '%s' directory\n", friendsfilename);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
178 return FALSE;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
179 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
180 } else {
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9183
diff changeset
181 gaim_debug_error("silc", "Couldn't create '%s' directory due to a wrong uid!\n",
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
182 friendsfilename);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
183 return FALSE;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
184 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
185 } else {
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9183
diff changeset
186 gaim_debug_error("silc", "Couldn't stat '%s' directory, error: %s\n",
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9183
diff changeset
187 friendsfilename, strerror(errno));
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
188 return FALSE;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
189 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
190 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
191
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
192 /*
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
193 * Check Public and Private keys
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
194 */
10825
cb625efd1071 [gaim-migrate @ 12490]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10751
diff changeset
195 g_snprintf(pkd, sizeof(pkd), "%s" G_DIR_SEPARATOR_S "public_key.pub", silcgaim_silcdir());
cb625efd1071 [gaim-migrate @ 12490]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10751
diff changeset
196 g_snprintf(prd, sizeof(prd), "%s" G_DIR_SEPARATOR_S "private_key.prv", silcgaim_silcdir());
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
197 g_snprintf(file_public_key, sizeof(file_public_key) - 1, "%s",
10825
cb625efd1071 [gaim-migrate @ 12490]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10751
diff changeset
198 gaim_account_get_string(gc->account, "public-key", pkd));
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
199 g_snprintf(file_private_key, sizeof(file_public_key) - 1, "%s",
10825
cb625efd1071 [gaim-migrate @ 12490]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10751
diff changeset
200 gaim_account_get_string(gc->account, "private-key", prd));
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
201
10589
0f7452b1f777 [gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9488
diff changeset
202 if ((g_stat(file_public_key, &st)) == -1) {
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
203 /* If file doesn't exist */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
204 if (errno == ENOENT) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
205 gaim_connection_update_progress(gc, _("Creating SILC key pair..."), 1, 5);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
206 silc_create_key_pair(SILCGAIM_DEF_PKCS,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
207 SILCGAIM_DEF_PKCS_LEN,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
208 file_public_key, file_private_key, NULL,
10751
bf5e48215158 [gaim-migrate @ 12354]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
209 (gc->password == NULL) ? "" : gc->password,
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9183
diff changeset
210 NULL, NULL, NULL, FALSE);
10589
0f7452b1f777 [gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9488
diff changeset
211 g_stat(file_public_key, &st);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
212 } else {
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9183
diff changeset
213 gaim_debug_error("silc", "Couldn't stat '%s' public key, error: %s\n",
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9183
diff changeset
214 file_public_key, strerror(errno));
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
215 return FALSE;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
216 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
217 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
218
9353
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9274
diff changeset
219 #ifndef _WIN32
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
220 /* Check the owner of the public key */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
221 if (st.st_uid != 0 && st.st_uid != pw->pw_uid) {
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9183
diff changeset
222 gaim_debug_error("silc", "You don't seem to own your public key!?\n");
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
223 return FALSE;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
224 }
9353
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9274
diff changeset
225 #endif
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
226
10589
0f7452b1f777 [gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9488
diff changeset
227 if ((g_stat(file_private_key, &st)) == -1) {
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
228 /* If file doesn't exist */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
229 if (errno == ENOENT) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
230 gaim_connection_update_progress(gc, _("Creating SILC key pair..."), 1, 5);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
231 silc_create_key_pair(SILCGAIM_DEF_PKCS,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
232 SILCGAIM_DEF_PKCS_LEN,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
233 file_public_key, file_private_key, NULL,
10751
bf5e48215158 [gaim-migrate @ 12354]
Mark Doliner <mark@kingant.net>
parents: 10589
diff changeset
234 (gc->password == NULL) ? "" : gc->password,
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9183
diff changeset
235 NULL, NULL, NULL, FALSE);
10589
0f7452b1f777 [gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9488
diff changeset
236 g_stat(file_private_key, &st);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
237 } else {
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9183
diff changeset
238 gaim_debug_error("silc", "Couldn't stat '%s' private key, error: %s\n",
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9183
diff changeset
239 file_private_key, strerror(errno));
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
240 return FALSE;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
241 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
242 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
243
9353
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9274
diff changeset
244 #ifndef _WIN32
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
245 /* Check the owner of the private key */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
246 if (st.st_uid != 0 && st.st_uid != pw->pw_uid) {
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9183
diff changeset
247 gaim_debug_error("silc", "You don't seem to own your private key!?\n");
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
248 return FALSE;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
249 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
250
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
251 /* Check the permissions for the private key */
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
252 if ((st.st_mode & 0777) != 0600) {
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9183
diff changeset
253 gaim_debug_warning("silc", "Wrong permissions in your private key file `%s'!\n"
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
254 "Trying to change them ... ", file_private_key);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
255 if ((chmod(file_private_key, 0600)) == -1) {
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9183
diff changeset
256 gaim_debug_error("silc",
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
257 "Failed to change permissions for private key file!\n"
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
258 "Permissions for your private key file must be 0600.\n");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
259 return FALSE;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
260 }
9272
ac4480944fc3 [gaim-migrate @ 10075]
Ethan Blanton <elb@pidgin.im>
parents: 9183
diff changeset
261 gaim_debug_warning("silc", "Done.\n\n");
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
262 }
9353
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9274
diff changeset
263 #endif
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
264
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
265 return TRUE;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
266 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
267
9353
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9274
diff changeset
268 #ifdef _WIN32
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9274
diff changeset
269 struct passwd *getpwuid(uid_t uid) {
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9274
diff changeset
270 struct passwd *pwd = calloc(1, sizeof(struct passwd));
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9274
diff changeset
271 return pwd;
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9274
diff changeset
272 }
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9274
diff changeset
273
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9274
diff changeset
274 uid_t getuid() {
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9274
diff changeset
275 return 0;
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9274
diff changeset
276 }
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9274
diff changeset
277
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9274
diff changeset
278 uid_t geteuid() {
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9274
diff changeset
279 return 0;
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9274
diff changeset
280 }
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9274
diff changeset
281 #endif
b8138f3959dc [gaim-migrate @ 10161]
Ethan Blanton <elb@pidgin.im>
parents: 9274
diff changeset
282
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
283 void silcgaim_show_public_key(SilcGaim sg,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
284 const char *name, SilcPublicKey public_key,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
285 GCallback callback, void *context)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
286 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
287 SilcPublicKeyIdentifier ident;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
288 SilcPKCS pkcs;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
289 char *fingerprint, *babbleprint;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
290 unsigned char *pk;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
291 SilcUInt32 pk_len, key_len = 0;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
292 GString *s;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
293 char *buf;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
294
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
295 ident = silc_pkcs_decode_identifier(public_key->identifier);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
296 if (!ident)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
297 return;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
298
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
299 pk = silc_pkcs_public_key_encode(public_key, &pk_len);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
300 fingerprint = silc_hash_fingerprint(NULL, pk, pk_len);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
301 babbleprint = silc_hash_babbleprint(NULL, pk, pk_len);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
302
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
303 if (silc_pkcs_alloc(public_key->name, &pkcs)) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
304 key_len = silc_pkcs_public_key_set(pkcs, public_key);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
305 silc_pkcs_free(pkcs);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
306 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
307
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
308 s = g_string_new("");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
309 if (ident->realname)
10825
cb625efd1071 [gaim-migrate @ 12490]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10751
diff changeset
310 /* Hint for translators: Please check the tabulator width here and in
cb625efd1071 [gaim-migrate @ 12490]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10751
diff changeset
311 the next strings (short strings: 2 tabs, longer strings 1 tab,
9274
f5c08be60098 [gaim-migrate @ 10077]
Luke Schierer <lschiere@pidgin.im>
parents: 9272
diff changeset
312 sum: 3 tabs or 24 characters) */
f5c08be60098 [gaim-migrate @ 10077]
Luke Schierer <lschiere@pidgin.im>
parents: 9272
diff changeset
313 g_string_append_printf(s, _("Real Name: \t%s\n"), ident->realname);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
314 if (ident->username)
9274
f5c08be60098 [gaim-migrate @ 10077]
Luke Schierer <lschiere@pidgin.im>
parents: 9272
diff changeset
315 g_string_append_printf(s, _("User Name: \t%s\n"), ident->username);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
316 if (ident->email)
9274
f5c08be60098 [gaim-migrate @ 10077]
Luke Schierer <lschiere@pidgin.im>
parents: 9272
diff changeset
317 g_string_append_printf(s, _("EMail: \t\t%s\n"), ident->email);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
318 if (ident->host)
9274
f5c08be60098 [gaim-migrate @ 10077]
Luke Schierer <lschiere@pidgin.im>
parents: 9272
diff changeset
319 g_string_append_printf(s, _("Host Name: \t%s\n"), ident->host);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
320 if (ident->org)
9274
f5c08be60098 [gaim-migrate @ 10077]
Luke Schierer <lschiere@pidgin.im>
parents: 9272
diff changeset
321 g_string_append_printf(s, _("Organization: \t%s\n"), ident->org);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
322 if (ident->country)
9274
f5c08be60098 [gaim-migrate @ 10077]
Luke Schierer <lschiere@pidgin.im>
parents: 9272
diff changeset
323 g_string_append_printf(s, _("Country: \t%s\n"), ident->country);
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
324 g_string_append_printf(s, _("Algorithm: \t%s\n"), public_key->name);
9274
f5c08be60098 [gaim-migrate @ 10077]
Luke Schierer <lschiere@pidgin.im>
parents: 9272
diff changeset
325 g_string_append_printf(s, _("Key Length: \t%d bits\n"), (int)key_len);
f5c08be60098 [gaim-migrate @ 10077]
Luke Schierer <lschiere@pidgin.im>
parents: 9272
diff changeset
326 g_string_append_printf(s, "\n");
f5c08be60098 [gaim-migrate @ 10077]
Luke Schierer <lschiere@pidgin.im>
parents: 9272
diff changeset
327 g_string_append_printf(s, _("Public Key Fingerprint:\n%s\n\n"), fingerprint);
f5c08be60098 [gaim-migrate @ 10077]
Luke Schierer <lschiere@pidgin.im>
parents: 9272
diff changeset
328 g_string_append_printf(s, _("Public Key Babbleprint:\n%s"), babbleprint);
8849
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
329
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
330 buf = g_string_free(s, FALSE);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
331
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
332 gaim_request_action(NULL, _("Public Key Information"),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
333 _("Public Key Information"),
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
334 buf, 0, context, 1,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
335 _("Close"), callback);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
336
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
337 g_free(buf);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
338 silc_free(fingerprint);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
339 silc_free(babbleprint);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
340 silc_free(pk);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
341 silc_pkcs_free_identifier(ident);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
342 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
343
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
344 SilcAttributePayload
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
345 silcgaim_get_attr(SilcDList attrs, SilcAttribute attribute)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
346 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
347 SilcAttributePayload attr = NULL;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
348
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
349 if (!attrs)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
350 return NULL;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
351
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
352 silc_dlist_start(attrs);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
353 while ((attr = silc_dlist_get(attrs)) != SILC_LIST_END)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
354 if (attribute == silc_attribute_get_attribute(attr))
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
355 break;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
356
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
357 return attr;
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
358 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
359
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
360 void silcgaim_get_umode_string(SilcUInt32 mode, char *buf,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
361 SilcUInt32 buf_size)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
362 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
363 memset(buf, 0, buf_size);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
364 if ((mode & SILC_UMODE_SERVER_OPERATOR) ||
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
365 (mode & SILC_UMODE_ROUTER_OPERATOR)) {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
366 strcat(buf, (mode & SILC_UMODE_SERVER_OPERATOR) ?
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
367 "[server operator] " :
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
368 (mode & SILC_UMODE_ROUTER_OPERATOR) ?
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
369 "[SILC operator] " : "[unknown mode] ");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
370 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
371 if (mode & SILC_UMODE_GONE)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
372 strcat(buf, "[away] ");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
373 if (mode & SILC_UMODE_INDISPOSED)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
374 strcat(buf, "[indisposed] ");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
375 if (mode & SILC_UMODE_BUSY)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
376 strcat(buf, "[busy] ");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
377 if (mode & SILC_UMODE_PAGE)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
378 strcat(buf, "[wake me up] ");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
379 if (mode & SILC_UMODE_HYPER)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
380 strcat(buf, "[hyperactive] ");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
381 if (mode & SILC_UMODE_ROBOT)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
382 strcat(buf, "[robot] ");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
383 if (mode & SILC_UMODE_ANONYMOUS)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
384 strcat(buf, "[anonymous] ");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
385 if (mode & SILC_UMODE_BLOCK_PRIVMSG)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
386 strcat(buf, "[blocks private messages] ");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
387 if (mode & SILC_UMODE_DETACHED)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
388 strcat(buf, "[detached] ");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
389 if (mode & SILC_UMODE_REJECT_WATCHING)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
390 strcat(buf, "[rejects watching] ");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
391 if (mode & SILC_UMODE_BLOCK_INVITE)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
392 strcat(buf, "[blocks invites] ");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
393 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
394
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
395 void silcgaim_get_chmode_string(SilcUInt32 mode, char *buf,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
396 SilcUInt32 buf_size)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
397 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
398 memset(buf, 0, buf_size);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
399 if (mode & SILC_CHANNEL_MODE_FOUNDER_AUTH)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
400 strcat(buf, "[permanent] ");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
401 if (mode & SILC_CHANNEL_MODE_PRIVATE)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
402 strcat(buf, "[private] ");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
403 if (mode & SILC_CHANNEL_MODE_SECRET)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
404 strcat(buf, "[secret] ");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
405 if (mode & SILC_CHANNEL_MODE_SECRET)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
406 strcat(buf, "[secret] ");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
407 if (mode & SILC_CHANNEL_MODE_PRIVKEY)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
408 strcat(buf, "[private key] ");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
409 if (mode & SILC_CHANNEL_MODE_INVITE)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
410 strcat(buf, "[invite only] ");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
411 if (mode & SILC_CHANNEL_MODE_TOPIC)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
412 strcat(buf, "[topic restricted] ");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
413 if (mode & SILC_CHANNEL_MODE_ULIMIT)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
414 strcat(buf, "[user count limit] ");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
415 if (mode & SILC_CHANNEL_MODE_PASSPHRASE)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
416 strcat(buf, "[passphrase auth] ");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
417 if (mode & SILC_CHANNEL_MODE_CHANNEL_AUTH)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
418 strcat(buf, "[public key auth] ");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
419 if (mode & SILC_CHANNEL_MODE_SILENCE_USERS)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
420 strcat(buf, "[users silenced] ");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
421 if (mode & SILC_CHANNEL_MODE_SILENCE_OPERS)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
422 strcat(buf, "[operators silenced] ");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
423 }
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
424
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
425 void silcgaim_get_chumode_string(SilcUInt32 mode, char *buf,
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
426 SilcUInt32 buf_size)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
427 {
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
428 memset(buf, 0, buf_size);
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
429 if (mode & SILC_CHANNEL_UMODE_CHANFO)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
430 strcat(buf, "[founder] ");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
431 if (mode & SILC_CHANNEL_UMODE_CHANOP)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
432 strcat(buf, "[operator] ");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
433 if (mode & SILC_CHANNEL_UMODE_BLOCK_MESSAGES)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
434 strcat(buf, "[blocks messages] ");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
435 if (mode & SILC_CHANNEL_UMODE_BLOCK_MESSAGES_USERS)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
436 strcat(buf, "[blocks user messages] ");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
437 if (mode & SILC_CHANNEL_UMODE_BLOCK_MESSAGES_ROBOTS)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
438 strcat(buf, "[blocks robot messages] ");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
439 if (mode & SILC_CHANNEL_UMODE_QUIET)
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
440 strcat(buf, "[quieted] ");
50d0f76639e7 [gaim-migrate @ 9616]
Ethan Blanton <elb@pidgin.im>
parents:
diff changeset
441 }
9488
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
442
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
443 void
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
444 silcgaim_parse_attrs(SilcDList attrs, char **moodstr, char **statusstr,
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
445 char **contactstr, char **langstr, char **devicestr,
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
446 char **tzstr, char **geostr)
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
447 {
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
448 SilcAttributePayload attr;
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
449 SilcAttributeMood mood = 0;
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
450 SilcAttributeContact contact;
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
451 SilcAttributeObjDevice device;
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
452 SilcAttributeObjGeo geo;
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
453
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
454 char tmp[1024];
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
455 GString *s;
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
456
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
457 *moodstr = NULL;
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
458 *statusstr = NULL;
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
459 *contactstr = NULL;
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
460 *langstr = NULL;
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
461 *devicestr = NULL;
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
462 *tzstr = NULL;
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
463 *geostr = NULL;
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
464
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
465 if (!attrs)
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
466 return;
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
467
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
468 s = g_string_new("");
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
469 attr = silcgaim_get_attr(attrs, SILC_ATTRIBUTE_STATUS_MOOD);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
470 if (attr && silc_attribute_get_object(attr, &mood, sizeof(mood))) {
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
471 if (mood & SILC_ATTRIBUTE_MOOD_HAPPY)
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
472 g_string_append_printf(s, "[%s] ", _("Happy"));
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
473 if (mood & SILC_ATTRIBUTE_MOOD_SAD)
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
474 g_string_append_printf(s, "[%s] ", _("Sad"));
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
475 if (mood & SILC_ATTRIBUTE_MOOD_ANGRY)
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
476 g_string_append_printf(s, "[%s] ", _("Angry"));
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
477 if (mood & SILC_ATTRIBUTE_MOOD_JEALOUS)
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
478 g_string_append_printf(s, "[%s] ", _("Jealous"));
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
479 if (mood & SILC_ATTRIBUTE_MOOD_ASHAMED)
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
480 g_string_append_printf(s, "[%s] ", _("Ashamed"));
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
481 if (mood & SILC_ATTRIBUTE_MOOD_INVINCIBLE)
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
482 g_string_append_printf(s, "[%s] ", _("Invincible"));
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
483 if (mood & SILC_ATTRIBUTE_MOOD_INLOVE)
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
484 g_string_append_printf(s, "[%s] ", _("In Love"));
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
485 if (mood & SILC_ATTRIBUTE_MOOD_SLEEPY)
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
486 g_string_append_printf(s, "[%s] ", _("Sleepy"));
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
487 if (mood & SILC_ATTRIBUTE_MOOD_BORED)
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
488 g_string_append_printf(s, "[%s] ", _("Bored"));
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
489 if (mood & SILC_ATTRIBUTE_MOOD_EXCITED)
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
490 g_string_append_printf(s, "[%s] ", _("Excited"));
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
491 if (mood & SILC_ATTRIBUTE_MOOD_ANXIOUS)
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
492 g_string_append_printf(s, "[%s] ", _("Anxious"));
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
493 }
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
494 if (strlen(s->str)) {
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
495 *moodstr = s->str;
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
496 g_string_free(s, FALSE);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
497 } else
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
498 g_string_free(s, TRUE);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
499
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
500 attr = silcgaim_get_attr(attrs, SILC_ATTRIBUTE_STATUS_FREETEXT);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
501 memset(tmp, 0, sizeof(tmp));
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
502 if (attr && silc_attribute_get_object(attr, tmp, sizeof(tmp)))
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
503 *statusstr = g_strdup(tmp);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
504
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
505 s = g_string_new("");
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
506 attr = silcgaim_get_attr(attrs, SILC_ATTRIBUTE_PREFERRED_CONTACT);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
507 if (attr && silc_attribute_get_object(attr, &contact, sizeof(contact))) {
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
508 if (contact & SILC_ATTRIBUTE_CONTACT_CHAT)
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
509 g_string_append_printf(s, "[%s] ", _("Chat"));
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
510 if (contact & SILC_ATTRIBUTE_CONTACT_EMAIL)
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
511 g_string_append_printf(s, "[%s] ", _("Email"));
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
512 if (contact & SILC_ATTRIBUTE_CONTACT_CALL)
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
513 g_string_append_printf(s, "[%s] ", _("Phone"));
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
514 if (contact & SILC_ATTRIBUTE_CONTACT_PAGE)
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
515 g_string_append_printf(s, "[%s] ", _("Paging"));
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
516 if (contact & SILC_ATTRIBUTE_CONTACT_SMS)
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
517 g_string_append_printf(s, "[%s] ", _("SMS"));
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
518 if (contact & SILC_ATTRIBUTE_CONTACT_MMS)
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
519 g_string_append_printf(s, "[%s] ", _("MMS"));
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
520 if (contact & SILC_ATTRIBUTE_CONTACT_VIDEO)
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
521 g_string_append_printf(s, "[%s] ", _("Video Conferencing"));
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
522 }
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
523 if (strlen(s->str)) {
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
524 *contactstr = s->str;
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
525 g_string_free(s, FALSE);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
526 } else
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
527 g_string_free(s, TRUE);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
528
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
529 attr = silcgaim_get_attr(attrs, SILC_ATTRIBUTE_PREFERRED_LANGUAGE);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
530 memset(tmp, 0, sizeof(tmp));
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
531 if (attr && silc_attribute_get_object(attr, tmp, sizeof(tmp)))
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
532 *langstr = g_strdup(tmp);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
533
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
534 s = g_string_new("");
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
535 attr = silcgaim_get_attr(attrs, SILC_ATTRIBUTE_DEVICE_INFO);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
536 memset(&device, 0, sizeof(device));
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
537 if (attr && silc_attribute_get_object(attr, &device, sizeof(device))) {
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
538 if (device.type == SILC_ATTRIBUTE_DEVICE_COMPUTER)
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
539 g_string_append_printf(s, "%s: ", _("Computer"));
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
540 if (device.type == SILC_ATTRIBUTE_DEVICE_MOBILE_PHONE)
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
541 g_string_append_printf(s, "%s: ", _("Mobile Phone"));
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
542 if (device.type == SILC_ATTRIBUTE_DEVICE_PDA)
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
543 g_string_append_printf(s, "%s: ", _("PDA"));
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
544 if (device.type == SILC_ATTRIBUTE_DEVICE_TERMINAL)
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
545 g_string_append_printf(s, "%s: ", _("Terminal"));
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
546 g_string_append_printf(s, "%s %s %s %s",
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
547 device.manufacturer ? device.manufacturer : "",
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
548 device.version ? device.version : "",
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
549 device.model ? device.model : "",
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
550 device.language ? device.language : "");
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
551 }
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
552 if (strlen(s->str)) {
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
553 *devicestr = s->str;
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
554 g_string_free(s, FALSE);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
555 } else
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
556 g_string_free(s, TRUE);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
557
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
558 attr = silcgaim_get_attr(attrs, SILC_ATTRIBUTE_TIMEZONE);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
559 memset(tmp, 0, sizeof(tmp));
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
560 if (attr && silc_attribute_get_object(attr, tmp, sizeof(tmp)))
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
561 *tzstr = g_strdup(tmp);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
562
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
563 attr = silcgaim_get_attr(attrs, SILC_ATTRIBUTE_GEOLOCATION);
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
564 memset(&geo, 0, sizeof(geo));
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
565 if (attr && silc_attribute_get_object(attr, &geo, sizeof(geo)))
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
566 *geostr = g_strdup_printf("%s %s %s (%s)",
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
567 geo.longitude ? geo.longitude : "",
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
568 geo.latitude ? geo.latitude : "",
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
569 geo.altitude ? geo.altitude : "",
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
570 geo.accuracy ? geo.accuracy : "");
2770a0e659ca [gaim-migrate @ 10313]
Ethan Blanton <elb@pidgin.im>
parents: 9353
diff changeset
571 }