Sat, 10 Nov 2007 04:52:20 +0000
propagate from branch 'im.pidgin.pidgin.next.minor' (head 2f91b326b3f073672c2475a8c30a06826da9b82f)
to branch 'im.pidgin.pidgin' (head 326d5b91950b3d78c445722f6d726cfa6b1c525d)
|
17674
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
1 | /* |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
2 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
3 | silcpurple_util.c |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
4 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
5 | Author: Pekka Riikonen <priikone@silcnet.org> |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
6 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
7 | Copyright (C) 2004 - 2005 Pekka Riikonen |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
8 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
9 | This program is free software; you can redistribute it and/or modify |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
10 | it under the terms of the GNU General Public License as published by |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
11 | the Free Software Foundation; version 2 of the License. |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
12 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
13 | This program is distributed in the hope that it will be useful, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
16 | GNU General Public License for more details. |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
17 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
18 | */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
19 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
20 | #include "silcincludes.h" |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
21 | #include "silcclient.h" |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
22 | #include "silcpurple.h" |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
23 | #include "imgstore.h" |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
24 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
25 | /**************************** Utility Routines *******************************/ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
26 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
27 | static char str[256], str2[256]; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
28 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
29 | const char *silcpurple_silcdir(void) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
30 | { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
31 | const char *hd = purple_home_dir(); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
32 | memset(str, 0, sizeof(str)); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
33 | g_snprintf(str, sizeof(str) - 1, "%s" G_DIR_SEPARATOR_S ".silc", hd ? hd : "/tmp"); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
34 | return (const char *)str; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
35 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
36 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
37 | const char *silcpurple_session_file(const char *account) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
38 | { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
39 | memset(str2, 0, sizeof(str2)); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
40 | g_snprintf(str2, sizeof(str2) - 1, "%s" G_DIR_SEPARATOR_S "%s_session", |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
41 | silcpurple_silcdir(), account); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
42 | return (const char *)str2; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
43 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
44 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
45 | gboolean silcpurple_ip_is_private(const char *ip) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
46 | { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
47 | if (silc_net_is_ip4(ip)) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
48 | if (!strncmp(ip, "10.", 3)) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
49 | return TRUE; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
50 | } else if (!strncmp(ip, "172.", 4) && strlen(ip) > 6) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
51 | char tmp[3]; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
52 | int s; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
53 | memset(tmp, 0, sizeof(tmp)); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
54 | strncpy(tmp, ip + 4, 2); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
55 | s = atoi(tmp); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
56 | if (s >= 16 && s <= 31) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
57 | return TRUE; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
58 | } else if (!strncmp(ip, "192.168.", 8)) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
59 | return TRUE; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
60 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
61 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
62 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
63 | return FALSE; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
64 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
65 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
66 | /* This checks stats for various SILC files and directories. First it |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
67 | checks if ~/.silc directory exist and is owned by the correct user. If |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
68 | it doesn't exist, it will create the directory. After that it checks if |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
69 | user's Public and Private key files exists and creates them if needed. */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
70 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
71 | gboolean silcpurple_check_silc_dir(PurpleConnection *gc) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
72 | { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
73 | char filename[256], file_public_key[256], file_private_key[256]; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
74 | char servfilename[256], clientfilename[256], friendsfilename[256]; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
75 | char pkd[256], prd[256]; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
76 | struct stat st; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
77 | struct passwd *pw; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
78 | int fd; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
79 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
80 | pw = getpwuid(getuid()); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
81 | if (!pw) { |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
17674
diff
changeset
|
82 | purple_debug_error("silc", "silc: %s\n", g_strerror(errno)); |
|
17674
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
83 | return FALSE; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
84 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
85 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
86 | g_snprintf(filename, sizeof(filename) - 1, "%s", silcpurple_silcdir()); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
87 | g_snprintf(servfilename, sizeof(servfilename) - 1, "%s" G_DIR_SEPARATOR_S "serverkeys", |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
88 | silcpurple_silcdir()); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
89 | g_snprintf(clientfilename, sizeof(clientfilename) - 1, "%s" G_DIR_SEPARATOR_S "clientkeys", |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
90 | silcpurple_silcdir()); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
91 | g_snprintf(friendsfilename, sizeof(friendsfilename) - 1, "%s" G_DIR_SEPARATOR_S "friends", |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
92 | silcpurple_silcdir()); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
93 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
94 | /* |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
95 | * Check ~/.silc directory |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
96 | */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
97 | if ((g_stat(filename, &st)) == -1) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
98 | /* If dir doesn't exist */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
99 | if (errno == ENOENT) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
100 | if (pw->pw_uid == geteuid()) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
101 | if ((g_mkdir(filename, 0755)) == -1) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
102 | purple_debug_error("silc", "Couldn't create '%s' directory\n", filename); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
103 | return FALSE; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
104 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
105 | } else { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
106 | purple_debug_error("silc", "Couldn't create '%s' directory due to a wrong uid!\n", |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
107 | filename); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
108 | return FALSE; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
109 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
110 | } else { |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
17674
diff
changeset
|
111 | purple_debug_error("silc", "Couldn't stat '%s' directory, error: %s\n", filename, g_strerror(errno)); |
|
17674
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
112 | return FALSE; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
113 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
114 | } else { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
115 | #ifndef _WIN32 |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
116 | /* Check the owner of the dir */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
117 | if (st.st_uid != 0 && st.st_uid != pw->pw_uid) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
118 | purple_debug_error("silc", "You don't seem to own '%s' directory\n", |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
119 | filename); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
120 | return FALSE; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
121 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
122 | #endif |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
123 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
124 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
125 | /* |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
126 | * Check ~./silc/serverkeys directory |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
127 | */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
128 | if ((g_stat(servfilename, &st)) == -1) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
129 | /* If dir doesn't exist */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
130 | if (errno == ENOENT) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
131 | if (pw->pw_uid == geteuid()) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
132 | if ((g_mkdir(servfilename, 0755)) == -1) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
133 | purple_debug_error("silc", "Couldn't create '%s' directory\n", servfilename); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
134 | return FALSE; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
135 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
136 | } else { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
137 | purple_debug_error("silc", "Couldn't create '%s' directory due to a wrong uid!\n", |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
138 | servfilename); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
139 | return FALSE; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
140 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
141 | } else { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
142 | purple_debug_error("silc", "Couldn't stat '%s' directory, error: %s\n", |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
17674
diff
changeset
|
143 | servfilename, g_strerror(errno)); |
|
17674
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
144 | return FALSE; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
145 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
146 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
147 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
148 | /* |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
149 | * Check ~./silc/clientkeys directory |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
150 | */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
151 | if ((g_stat(clientfilename, &st)) == -1) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
152 | /* If dir doesn't exist */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
153 | if (errno == ENOENT) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
154 | if (pw->pw_uid == geteuid()) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
155 | if ((g_mkdir(clientfilename, 0755)) == -1) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
156 | purple_debug_error("silc", "Couldn't create '%s' directory\n", clientfilename); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
157 | return FALSE; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
158 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
159 | } else { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
160 | purple_debug_error("silc", "Couldn't create '%s' directory due to a wrong uid!\n", |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
161 | clientfilename); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
162 | return FALSE; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
163 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
164 | } else { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
165 | purple_debug_error("silc", "Couldn't stat '%s' directory, error: %s\n", |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
17674
diff
changeset
|
166 | clientfilename, g_strerror(errno)); |
|
17674
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
167 | return FALSE; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
168 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
169 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
170 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
171 | /* |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
172 | * Check ~./silc/friends directory |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
173 | */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
174 | if ((g_stat(friendsfilename, &st)) == -1) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
175 | /* If dir doesn't exist */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
176 | if (errno == ENOENT) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
177 | if (pw->pw_uid == geteuid()) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
178 | if ((g_mkdir(friendsfilename, 0755)) == -1) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
179 | purple_debug_error("silc", "Couldn't create '%s' directory\n", friendsfilename); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
180 | return FALSE; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
181 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
182 | } else { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
183 | purple_debug_error("silc", "Couldn't create '%s' directory due to a wrong uid!\n", |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
184 | friendsfilename); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
185 | return FALSE; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
186 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
187 | } else { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
188 | purple_debug_error("silc", "Couldn't stat '%s' directory, error: %s\n", |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
17674
diff
changeset
|
189 | friendsfilename, g_strerror(errno)); |
|
17674
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
190 | return FALSE; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
191 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
192 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
193 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
194 | /* |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
195 | * Check Public and Private keys |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
196 | */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
197 | g_snprintf(pkd, sizeof(pkd), "%s" G_DIR_SEPARATOR_S "public_key.pub", silcpurple_silcdir()); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
198 | g_snprintf(prd, sizeof(prd), "%s" G_DIR_SEPARATOR_S "private_key.prv", silcpurple_silcdir()); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
199 | g_snprintf(file_public_key, sizeof(file_public_key) - 1, "%s", |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
200 | purple_account_get_string(gc->account, "public-key", pkd)); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
201 | g_snprintf(file_private_key, sizeof(file_public_key) - 1, "%s", |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
202 | purple_account_get_string(gc->account, "private-key", prd)); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
203 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
204 | if ((g_stat(file_public_key, &st)) == -1) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
205 | /* If file doesn't exist */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
206 | if (errno == ENOENT) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
207 | purple_connection_update_progress(gc, _("Creating SILC key pair..."), 1, 5); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
208 | if (!silc_create_key_pair(SILCPURPLE_DEF_PKCS, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
209 | SILCPURPLE_DEF_PKCS_LEN, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
210 | file_public_key, file_private_key, NULL, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
211 | (gc->password == NULL) ? "" : gc->password, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
212 | NULL, NULL, NULL, FALSE)) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
213 | purple_debug_error("silc", "Couldn't create key pair\n"); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
214 | return FALSE; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
215 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
216 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
217 | if ((g_stat(file_public_key, &st)) == -1) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
218 | purple_debug_error("silc", "Couldn't stat '%s' public key, error: %s\n", |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
17674
diff
changeset
|
219 | file_public_key, g_strerror(errno)); |
|
17674
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
220 | return FALSE; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
221 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
222 | } else { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
223 | purple_debug_error("silc", "Couldn't stat '%s' public key, error: %s\n", |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
17674
diff
changeset
|
224 | file_public_key, g_strerror(errno)); |
|
17674
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
225 | return FALSE; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
226 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
227 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
228 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
229 | #ifndef _WIN32 |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
230 | /* Check the owner of the public key */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
231 | if (st.st_uid != 0 && st.st_uid != pw->pw_uid) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
232 | purple_debug_error("silc", "You don't seem to own your public key!?\n"); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
233 | return FALSE; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
234 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
235 | #endif |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
236 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
237 | if ((fd = g_open(file_private_key, O_RDONLY, 0)) != -1) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
238 | if ((fstat(fd, &st)) == -1) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
239 | purple_debug_error("silc", "Couldn't stat '%s' private key, error: %s\n", |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
17674
diff
changeset
|
240 | file_private_key, g_strerror(errno)); |
|
17674
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
241 | close(fd); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
242 | return FALSE; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
243 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
244 | } else if ((g_stat(file_private_key, &st)) == -1) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
245 | /* If file doesn't exist */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
246 | if (errno == ENOENT) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
247 | purple_connection_update_progress(gc, _("Creating SILC key pair..."), 1, 5); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
248 | if (!silc_create_key_pair(SILCPURPLE_DEF_PKCS, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
249 | SILCPURPLE_DEF_PKCS_LEN, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
250 | file_public_key, file_private_key, NULL, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
251 | (gc->password == NULL) ? "" : gc->password, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
252 | NULL, NULL, NULL, FALSE)) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
253 | purple_debug_error("silc", "Couldn't create key pair\n"); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
254 | return FALSE; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
255 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
256 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
257 | if ((fd = g_open(file_private_key, O_RDONLY, 0)) != -1) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
258 | if ((fstat(fd, &st)) == -1) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
259 | purple_debug_error("silc", "Couldn't stat '%s' private key, error: %s\n", |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
17674
diff
changeset
|
260 | file_private_key, g_strerror(errno)); |
|
17674
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
261 | close(fd); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
262 | return FALSE; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
263 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
264 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
265 | /* This shouldn't really happen because silc_create_key_pair() |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
266 | * will set the permissions */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
267 | else if ((g_stat(file_private_key, &st)) == -1) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
268 | purple_debug_error("silc", "Couldn't stat '%s' private key, error: %s\n", |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
17674
diff
changeset
|
269 | file_private_key, g_strerror(errno)); |
|
17674
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
270 | return FALSE; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
271 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
272 | } else { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
273 | purple_debug_error("silc", "Couldn't stat '%s' private key, error: %s\n", |
|
21389
e1dd8142bb87
replace most calls to strerror with calls to g_strerror. strerror will return
Nathan Walp <nwalp@pidgin.im>
parents:
17674
diff
changeset
|
274 | file_private_key, g_strerror(errno)); |
|
17674
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
275 | return FALSE; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
276 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
277 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
278 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
279 | #ifndef _WIN32 |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
280 | /* Check the owner of the private key */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
281 | if (st.st_uid != 0 && st.st_uid != pw->pw_uid) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
282 | purple_debug_error("silc", "You don't seem to own your private key!?\n"); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
283 | if (fd != -1) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
284 | close(fd); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
285 | return FALSE; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
286 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
287 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
288 | /* Check the permissions for the private key */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
289 | if ((st.st_mode & 0777) != 0600) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
290 | purple_debug_warning("silc", "Wrong permissions in your private key file `%s'!\n" |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
291 | "Trying to change them ...\n", file_private_key); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
292 | if ((fd == -1) || (fchmod(fd, S_IRUSR | S_IWUSR)) == -1) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
293 | purple_debug_error("silc", |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
294 | "Failed to change permissions for private key file!\n" |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
295 | "Permissions for your private key file must be 0600.\n"); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
296 | if (fd != -1) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
297 | close(fd); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
298 | return FALSE; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
299 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
300 | purple_debug_warning("silc", "Done.\n\n"); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
301 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
302 | #endif |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
303 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
304 | if (fd != -1) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
305 | close(fd); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
306 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
307 | return TRUE; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
308 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
309 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
310 | #ifdef _WIN32 |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
311 | struct passwd *getpwuid(uid_t uid) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
312 | struct passwd *pwd = calloc(1, sizeof(struct passwd)); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
313 | return pwd; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
314 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
315 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
316 | uid_t getuid() { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
317 | return 0; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
318 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
319 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
320 | uid_t geteuid() { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
321 | return 0; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
322 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
323 | #endif |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
324 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
325 | void silcpurple_show_public_key(SilcPurple sg, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
326 | const char *name, SilcPublicKey public_key, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
327 | GCallback callback, void *context) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
328 | { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
329 | SilcPublicKeyIdentifier ident; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
330 | SilcPKCS pkcs; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
331 | char *fingerprint, *babbleprint; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
332 | unsigned char *pk; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
333 | SilcUInt32 pk_len, key_len = 0; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
334 | GString *s; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
335 | char *buf; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
336 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
337 | ident = silc_pkcs_decode_identifier(public_key->identifier); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
338 | if (!ident) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
339 | return; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
340 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
341 | pk = silc_pkcs_public_key_encode(public_key, &pk_len); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
342 | fingerprint = silc_hash_fingerprint(NULL, pk, pk_len); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
343 | babbleprint = silc_hash_babbleprint(NULL, pk, pk_len); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
344 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
345 | if (silc_pkcs_alloc((unsigned char *)public_key->name, &pkcs)) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
346 | key_len = silc_pkcs_public_key_set(pkcs, public_key); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
347 | silc_pkcs_free(pkcs); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
348 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
349 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
350 | s = g_string_new(""); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
351 | if (ident->realname) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
352 | /* Hint for translators: Please check the tabulator width here and in |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
353 | the next strings (short strings: 2 tabs, longer strings 1 tab, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
354 | sum: 3 tabs or 24 characters) */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
355 | g_string_append_printf(s, _("Real Name: \t%s\n"), ident->realname); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
356 | if (ident->username) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
357 | g_string_append_printf(s, _("User Name: \t%s\n"), ident->username); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
358 | if (ident->email) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
359 | g_string_append_printf(s, _("E-Mail: \t\t%s\n"), ident->email); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
360 | if (ident->host) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
361 | g_string_append_printf(s, _("Host Name: \t%s\n"), ident->host); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
362 | if (ident->org) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
363 | g_string_append_printf(s, _("Organization: \t%s\n"), ident->org); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
364 | if (ident->country) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
365 | g_string_append_printf(s, _("Country: \t%s\n"), ident->country); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
366 | g_string_append_printf(s, _("Algorithm: \t%s\n"), public_key->name); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
367 | g_string_append_printf(s, _("Key Length: \t%d bits\n"), (int)key_len); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
368 | g_string_append_printf(s, "\n"); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
369 | g_string_append_printf(s, _("Public Key Fingerprint:\n%s\n\n"), fingerprint); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
370 | g_string_append_printf(s, _("Public Key Babbleprint:\n%s"), babbleprint); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
371 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
372 | buf = g_string_free(s, FALSE); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
373 | |
|
21174
8ba833993a11
disapproval of revision 'c6934783d152f5c2a6904849fbe602ad04a32f14'
Richard Laager <rlaager@pidgin.im>
parents:
21171
diff
changeset
|
374 | purple_request_action_with_hint(sg->gc, _("Public Key Information"), |
|
17674
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
375 | _("Public Key Information"), |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
376 | buf, 0, purple_connection_get_account(sg->gc), |
|
21233
e75de8db4f2b
Re-namespace the #defines to all be PURPLE_REQUEST_UI_HINT_*. I see no
Richard Laager <rlaager@pidgin.im>
parents:
21225
diff
changeset
|
377 | NULL, NULL, context, PURPLE_REQUEST_UI_HINT_BLIST, 1, _("Close"), callback); |
|
17674
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
378 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
379 | g_free(buf); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
380 | silc_free(fingerprint); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
381 | silc_free(babbleprint); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
382 | silc_free(pk); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
383 | silc_pkcs_free_identifier(ident); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
384 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
385 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
386 | SilcAttributePayload |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
387 | silcpurple_get_attr(SilcDList attrs, SilcAttribute attribute) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
388 | { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
389 | SilcAttributePayload attr = NULL; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
390 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
391 | if (!attrs) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
392 | return NULL; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
393 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
394 | silc_dlist_start(attrs); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
395 | while ((attr = silc_dlist_get(attrs)) != SILC_LIST_END) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
396 | if (attribute == silc_attribute_get_attribute(attr)) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
397 | break; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
398 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
399 | return attr; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
400 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
401 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
402 | void silcpurple_get_umode_string(SilcUInt32 mode, char *buf, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
403 | SilcUInt32 buf_size) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
404 | { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
405 | memset(buf, 0, buf_size); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
406 | if ((mode & SILC_UMODE_SERVER_OPERATOR) || |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
407 | (mode & SILC_UMODE_ROUTER_OPERATOR)) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
408 | strcat(buf, (mode & SILC_UMODE_SERVER_OPERATOR) ? |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
409 | "[server operator] " : |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
410 | (mode & SILC_UMODE_ROUTER_OPERATOR) ? |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
411 | "[SILC operator] " : "[unknown mode] "); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
412 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
413 | if (mode & SILC_UMODE_GONE) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
414 | strcat(buf, "[away] "); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
415 | if (mode & SILC_UMODE_INDISPOSED) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
416 | strcat(buf, "[indisposed] "); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
417 | if (mode & SILC_UMODE_BUSY) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
418 | strcat(buf, "[busy] "); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
419 | if (mode & SILC_UMODE_PAGE) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
420 | strcat(buf, "[wake me up] "); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
421 | if (mode & SILC_UMODE_HYPER) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
422 | strcat(buf, "[hyperactive] "); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
423 | if (mode & SILC_UMODE_ROBOT) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
424 | strcat(buf, "[robot] "); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
425 | if (mode & SILC_UMODE_ANONYMOUS) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
426 | strcat(buf, "[anonymous] "); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
427 | if (mode & SILC_UMODE_BLOCK_PRIVMSG) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
428 | strcat(buf, "[blocks private messages] "); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
429 | if (mode & SILC_UMODE_DETACHED) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
430 | strcat(buf, "[detached] "); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
431 | if (mode & SILC_UMODE_REJECT_WATCHING) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
432 | strcat(buf, "[rejects watching] "); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
433 | if (mode & SILC_UMODE_BLOCK_INVITE) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
434 | strcat(buf, "[blocks invites] "); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
435 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
436 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
437 | void silcpurple_get_chmode_string(SilcUInt32 mode, char *buf, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
438 | SilcUInt32 buf_size) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
439 | { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
440 | memset(buf, 0, buf_size); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
441 | if (mode & SILC_CHANNEL_MODE_FOUNDER_AUTH) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
442 | strcat(buf, "[permanent] "); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
443 | if (mode & SILC_CHANNEL_MODE_PRIVATE) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
444 | strcat(buf, "[private] "); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
445 | if (mode & SILC_CHANNEL_MODE_SECRET) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
446 | strcat(buf, "[secret] "); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
447 | if (mode & SILC_CHANNEL_MODE_PRIVKEY) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
448 | strcat(buf, "[private key] "); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
449 | if (mode & SILC_CHANNEL_MODE_INVITE) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
450 | strcat(buf, "[invite only] "); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
451 | if (mode & SILC_CHANNEL_MODE_TOPIC) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
452 | strcat(buf, "[topic restricted] "); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
453 | if (mode & SILC_CHANNEL_MODE_ULIMIT) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
454 | strcat(buf, "[user count limit] "); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
455 | if (mode & SILC_CHANNEL_MODE_PASSPHRASE) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
456 | strcat(buf, "[passphrase auth] "); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
457 | if (mode & SILC_CHANNEL_MODE_CHANNEL_AUTH) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
458 | strcat(buf, "[public key auth] "); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
459 | if (mode & SILC_CHANNEL_MODE_SILENCE_USERS) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
460 | strcat(buf, "[users silenced] "); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
461 | if (mode & SILC_CHANNEL_MODE_SILENCE_OPERS) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
462 | strcat(buf, "[operators silenced] "); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
463 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
464 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
465 | void silcpurple_get_chumode_string(SilcUInt32 mode, char *buf, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
466 | SilcUInt32 buf_size) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
467 | { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
468 | memset(buf, 0, buf_size); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
469 | if (mode & SILC_CHANNEL_UMODE_CHANFO) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
470 | strcat(buf, "[founder] "); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
471 | if (mode & SILC_CHANNEL_UMODE_CHANOP) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
472 | strcat(buf, "[operator] "); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
473 | if (mode & SILC_CHANNEL_UMODE_BLOCK_MESSAGES) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
474 | strcat(buf, "[blocks messages] "); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
475 | if (mode & SILC_CHANNEL_UMODE_BLOCK_MESSAGES_USERS) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
476 | strcat(buf, "[blocks user messages] "); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
477 | if (mode & SILC_CHANNEL_UMODE_BLOCK_MESSAGES_ROBOTS) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
478 | strcat(buf, "[blocks robot messages] "); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
479 | if (mode & SILC_CHANNEL_UMODE_QUIET) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
480 | strcat(buf, "[quieted] "); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
481 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
482 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
483 | void |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
484 | silcpurple_parse_attrs(SilcDList attrs, char **moodstr, char **statusstr, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
485 | char **contactstr, char **langstr, char **devicestr, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
486 | char **tzstr, char **geostr) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
487 | { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
488 | SilcAttributePayload attr; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
489 | SilcAttributeMood mood = 0; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
490 | SilcAttributeContact contact; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
491 | SilcAttributeObjDevice device; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
492 | SilcAttributeObjGeo geo; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
493 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
494 | char tmp[1024]; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
495 | GString *s; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
496 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
497 | *moodstr = NULL; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
498 | *statusstr = NULL; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
499 | *contactstr = NULL; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
500 | *langstr = NULL; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
501 | *devicestr = NULL; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
502 | *tzstr = NULL; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
503 | *geostr = NULL; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
504 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
505 | if (!attrs) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
506 | return; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
507 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
508 | s = g_string_new(""); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
509 | attr = silcpurple_get_attr(attrs, SILC_ATTRIBUTE_STATUS_MOOD); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
510 | if (attr && silc_attribute_get_object(attr, &mood, sizeof(mood))) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
511 | if (mood & SILC_ATTRIBUTE_MOOD_HAPPY) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
512 | g_string_append_printf(s, "[%s] ", _("Happy")); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
513 | if (mood & SILC_ATTRIBUTE_MOOD_SAD) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
514 | g_string_append_printf(s, "[%s] ", _("Sad")); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
515 | if (mood & SILC_ATTRIBUTE_MOOD_ANGRY) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
516 | g_string_append_printf(s, "[%s] ", _("Angry")); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
517 | if (mood & SILC_ATTRIBUTE_MOOD_JEALOUS) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
518 | g_string_append_printf(s, "[%s] ", _("Jealous")); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
519 | if (mood & SILC_ATTRIBUTE_MOOD_ASHAMED) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
520 | g_string_append_printf(s, "[%s] ", _("Ashamed")); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
521 | if (mood & SILC_ATTRIBUTE_MOOD_INVINCIBLE) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
522 | g_string_append_printf(s, "[%s] ", _("Invincible")); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
523 | if (mood & SILC_ATTRIBUTE_MOOD_INLOVE) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
524 | g_string_append_printf(s, "[%s] ", _("In Love")); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
525 | if (mood & SILC_ATTRIBUTE_MOOD_SLEEPY) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
526 | g_string_append_printf(s, "[%s] ", _("Sleepy")); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
527 | if (mood & SILC_ATTRIBUTE_MOOD_BORED) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
528 | g_string_append_printf(s, "[%s] ", _("Bored")); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
529 | if (mood & SILC_ATTRIBUTE_MOOD_EXCITED) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
530 | g_string_append_printf(s, "[%s] ", _("Excited")); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
531 | if (mood & SILC_ATTRIBUTE_MOOD_ANXIOUS) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
532 | g_string_append_printf(s, "[%s] ", _("Anxious")); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
533 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
534 | if (strlen(s->str)) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
535 | *moodstr = s->str; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
536 | g_string_free(s, FALSE); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
537 | } else |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
538 | g_string_free(s, TRUE); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
539 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
540 | attr = silcpurple_get_attr(attrs, SILC_ATTRIBUTE_STATUS_FREETEXT); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
541 | memset(tmp, 0, sizeof(tmp)); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
542 | if (attr && silc_attribute_get_object(attr, tmp, sizeof(tmp))) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
543 | *statusstr = g_strdup(tmp); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
544 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
545 | s = g_string_new(""); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
546 | attr = silcpurple_get_attr(attrs, SILC_ATTRIBUTE_PREFERRED_CONTACT); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
547 | if (attr && silc_attribute_get_object(attr, &contact, sizeof(contact))) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
548 | if (contact & SILC_ATTRIBUTE_CONTACT_CHAT) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
549 | g_string_append_printf(s, "[%s] ", _("Chat")); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
550 | if (contact & SILC_ATTRIBUTE_CONTACT_EMAIL) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
551 | g_string_append_printf(s, "[%s] ", _("E-Mail")); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
552 | if (contact & SILC_ATTRIBUTE_CONTACT_CALL) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
553 | g_string_append_printf(s, "[%s] ", _("Phone")); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
554 | if (contact & SILC_ATTRIBUTE_CONTACT_PAGE) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
555 | g_string_append_printf(s, "[%s] ", _("Paging")); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
556 | if (contact & SILC_ATTRIBUTE_CONTACT_SMS) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
557 | g_string_append_printf(s, "[%s] ", _("SMS")); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
558 | if (contact & SILC_ATTRIBUTE_CONTACT_MMS) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
559 | g_string_append_printf(s, "[%s] ", _("MMS")); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
560 | if (contact & SILC_ATTRIBUTE_CONTACT_VIDEO) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
561 | g_string_append_printf(s, "[%s] ", _("Video Conferencing")); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
562 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
563 | if (strlen(s->str)) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
564 | *contactstr = s->str; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
565 | g_string_free(s, FALSE); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
566 | } else |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
567 | g_string_free(s, TRUE); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
568 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
569 | attr = silcpurple_get_attr(attrs, SILC_ATTRIBUTE_PREFERRED_LANGUAGE); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
570 | memset(tmp, 0, sizeof(tmp)); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
571 | if (attr && silc_attribute_get_object(attr, tmp, sizeof(tmp))) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
572 | *langstr = g_strdup(tmp); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
573 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
574 | s = g_string_new(""); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
575 | attr = silcpurple_get_attr(attrs, SILC_ATTRIBUTE_DEVICE_INFO); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
576 | memset(&device, 0, sizeof(device)); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
577 | if (attr && silc_attribute_get_object(attr, &device, sizeof(device))) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
578 | if (device.type == SILC_ATTRIBUTE_DEVICE_COMPUTER) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
579 | g_string_append_printf(s, "%s: ", _("Computer")); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
580 | if (device.type == SILC_ATTRIBUTE_DEVICE_MOBILE_PHONE) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
581 | g_string_append_printf(s, "%s: ", _("Mobile Phone")); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
582 | if (device.type == SILC_ATTRIBUTE_DEVICE_PDA) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
583 | g_string_append_printf(s, "%s: ", _("PDA")); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
584 | if (device.type == SILC_ATTRIBUTE_DEVICE_TERMINAL) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
585 | g_string_append_printf(s, "%s: ", _("Terminal")); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
586 | g_string_append_printf(s, "%s %s %s %s", |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
587 | device.manufacturer ? device.manufacturer : "", |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
588 | device.version ? device.version : "", |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
589 | device.model ? device.model : "", |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
590 | device.language ? device.language : ""); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
591 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
592 | if (strlen(s->str)) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
593 | *devicestr = s->str; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
594 | g_string_free(s, FALSE); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
595 | } else |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
596 | g_string_free(s, TRUE); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
597 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
598 | attr = silcpurple_get_attr(attrs, SILC_ATTRIBUTE_TIMEZONE); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
599 | memset(tmp, 0, sizeof(tmp)); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
600 | if (attr && silc_attribute_get_object(attr, tmp, sizeof(tmp))) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
601 | *tzstr = g_strdup(tmp); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
602 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
603 | attr = silcpurple_get_attr(attrs, SILC_ATTRIBUTE_GEOLOCATION); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
604 | memset(&geo, 0, sizeof(geo)); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
605 | if (attr && silc_attribute_get_object(attr, &geo, sizeof(geo))) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
606 | *geostr = g_strdup_printf("%s %s %s (%s)", |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
607 | geo.longitude ? geo.longitude : "", |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
608 | geo.latitude ? geo.latitude : "", |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
609 | geo.altitude ? geo.altitude : "", |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
610 | geo.accuracy ? geo.accuracy : ""); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
611 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
612 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
613 | #ifdef HAVE_SILCMIME_H |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
614 | /* Returns MIME type of filetype */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
615 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
616 | char *silcpurple_file2mime(const char *filename) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
617 | { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
618 | const char *ct; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
619 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
620 | ct = strrchr(filename, '.'); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
621 | if (!ct) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
622 | return NULL; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
623 | else if (!g_ascii_strcasecmp(".png", ct)) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
624 | return strdup("image/png"); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
625 | else if (!g_ascii_strcasecmp(".jpg", ct)) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
626 | return strdup("image/jpeg"); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
627 | else if (!g_ascii_strcasecmp(".jpeg", ct)) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
628 | return strdup("image/jpeg"); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
629 | else if (!g_ascii_strcasecmp(".gif", ct)) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
630 | return strdup("image/gif"); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
631 | else if (!g_ascii_strcasecmp(".tiff", ct)) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
632 | return strdup("image/tiff"); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
633 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
634 | return NULL; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
635 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
636 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
637 | /* Checks if message has images, and assembles MIME message if it has. |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
638 | If only one image is present, creates simple MIME image message. If |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
639 | there are multiple images and/or text with images multipart MIME |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
640 | message is created. */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
641 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
642 | SilcDList silcpurple_image_message(const char *msg, SilcUInt32 *mflags) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
643 | { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
644 | SilcMime mime = NULL, p; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
645 | SilcDList list, parts = NULL; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
646 | const char *start, *end, *last; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
647 | GData *attribs; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
648 | char *type; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
649 | gboolean images = FALSE; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
650 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
651 | last = msg; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
652 | while (last && *last && purple_markup_find_tag("img", last, &start, |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
653 | &end, &attribs)) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
654 | PurpleStoredImage *image = NULL; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
655 | const char *id; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
656 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
657 | /* Check if there is text before image */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
658 | if (start - last) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
659 | char *text, *tmp; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
660 | p = silc_mime_alloc(); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
661 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
662 | /* Add content type */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
663 | silc_mime_add_field(p, "Content-Type", |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
664 | "text/plain; charset=utf-8"); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
665 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
666 | tmp = g_strndup(last, start - last); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
667 | text = purple_unescape_html(tmp); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
668 | g_free(tmp); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
669 | /* Add text */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
670 | silc_mime_add_data(p, text, strlen(text)); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
671 | g_free(text); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
672 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
673 | if (!parts) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
674 | parts = silc_dlist_init(); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
675 | silc_dlist_add(parts, p); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
676 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
677 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
678 | id = g_datalist_get_data(&attribs, "id"); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
679 | if (id && (image = purple_imgstore_find_by_id(atoi(id)))) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
680 | unsigned long imglen = purple_imgstore_get_size(image); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
681 | gconstpointer img = purple_imgstore_get_data(image); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
682 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
683 | p = silc_mime_alloc(); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
684 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
685 | /* Add content type */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
686 | type = silcpurple_file2mime(purple_imgstore_get_filename(image)); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
687 | if (!type) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
688 | g_datalist_clear(&attribs); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
689 | last = end + 1; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
690 | continue; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
691 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
692 | silc_mime_add_field(p, "Content-Type", type); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
693 | silc_free(type); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
694 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
695 | /* Add content transfer encoding */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
696 | silc_mime_add_field(p, "Content-Transfer-Encoding", "binary"); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
697 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
698 | /* Add image data */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
699 | silc_mime_add_data(p, img, imglen); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
700 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
701 | if (!parts) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
702 | parts = silc_dlist_init(); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
703 | silc_dlist_add(parts, p); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
704 | images = TRUE; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
705 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
706 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
707 | g_datalist_clear(&attribs); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
708 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
709 | /* Continue after tag */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
710 | last = end + 1; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
711 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
712 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
713 | /* Check for text after the image(s) */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
714 | if (images && last && *last) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
715 | char *tmp = purple_unescape_html(last); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
716 | p = silc_mime_alloc(); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
717 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
718 | /* Add content type */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
719 | silc_mime_add_field(p, "Content-Type", |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
720 | "text/plain; charset=utf-8"); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
721 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
722 | /* Add text */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
723 | silc_mime_add_data(p, tmp, strlen(tmp)); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
724 | g_free(tmp); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
725 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
726 | if (!parts) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
727 | parts = silc_dlist_init(); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
728 | silc_dlist_add(parts, p); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
729 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
730 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
731 | /* If there weren't any images, don't return anything. */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
732 | if (!images) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
733 | if (parts) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
734 | silc_dlist_uninit(parts); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
735 | return NULL; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
736 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
737 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
738 | if (silc_dlist_count(parts) > 1) { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
739 | /* Multipart MIME message */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
740 | char b[32]; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
741 | mime = silc_mime_alloc(); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
742 | silc_mime_add_field(mime, "MIME-Version", "1.0"); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
743 | g_snprintf(b, sizeof(b), "b%4X%4X", |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
744 | (unsigned int)time(NULL), |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
745 | silc_dlist_count(parts)); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
746 | silc_mime_set_multipart(mime, "mixed", b); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
747 | silc_dlist_start(parts); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
748 | while ((p = silc_dlist_get(parts)) != SILC_LIST_END) |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
749 | silc_mime_add_multipart(mime, p); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
750 | } else { |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
751 | /* Simple MIME message */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
752 | silc_dlist_start(parts); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
753 | mime = silc_dlist_get(parts); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
754 | silc_mime_add_field(mime, "MIME-Version", "1.0"); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
755 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
756 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
757 | *mflags &= ~SILC_MESSAGE_FLAG_UTF8; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
758 | *mflags |= SILC_MESSAGE_FLAG_DATA; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
759 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
760 | /* Encode message. Fragment if it is too large */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
761 | list = silc_mime_encode_partial(mime, 0xfc00); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
762 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
763 | silc_dlist_uninit(parts); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
764 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
765 | /* Added multiparts gets freed here */ |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
766 | silc_mime_free(mime); |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
767 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
768 | return list; |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
769 | } |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
770 | |
|
aafdd7bed36d
Duplicate the current SILC prpl as silc10 for backwards compatibility with
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
diff
changeset
|
771 | #endif /* HAVE_SILCMIME_H */ |