pidgin/gtkconv.c

changeset 33051
2e75223c078e
parent 33005
65e95df8daea
child 33076
b0f6d6dadb10
child 33149
e1b50abc07bb
equal deleted inserted replaced
33050:721fb658ee46 33051:2e75223c078e
5086 if (text == NULL || *text == '\0') 5086 if (text == NULL || *text == '\0')
5087 return NULL; 5087 return NULL;
5088 5088
5089 str = g_string_new(NULL); 5089 str = g_string_new(NULL);
5090 while ((cur = strchr(cur, '%'))) { 5090 while ((cur = strchr(cur, '%'))) {
5091 char *freeval = NULL;
5091 const char *replace = NULL; 5092 const char *replace = NULL;
5092 const char *fin = NULL; 5093 const char *fin = NULL;
5093 5094
5094 if (g_str_has_prefix(cur, "%chatName%")) { 5095 if (g_str_has_prefix(cur, "%chatName%")) {
5095 replace = purple_conversation_get_name(conv); 5096 replace = purple_conversation_get_name(conv);
5115 } else if (g_str_has_prefix(cur, "%outgoingIconPath%")) { 5116 } else if (g_str_has_prefix(cur, "%outgoingIconPath%")) {
5116 replace = purple_account_get_buddy_icon_path(account); 5117 replace = purple_account_get_buddy_icon_path(account);
5117 5118
5118 } else if (g_str_has_prefix(cur, "%timeOpened")) { 5119 } else if (g_str_has_prefix(cur, "%timeOpened")) {
5119 const char *tmp = cur + strlen("%timeOpened"); 5120 const char *tmp = cur + strlen("%timeOpened");
5120 char *format = NULL;
5121 5121
5122 if (*tmp == '{') { 5122 if (*tmp == '{') {
5123 const char *end; 5123 const char *end;
5124 tmp++; 5124 tmp++;
5125 end = strstr(tmp, "}%"); 5125 end = strstr(tmp, "}%");
5126 if (!end) /* Invalid string */ 5126 if (!end) /* Invalid string */
5127 continue; 5127 continue;
5128 format = g_strndup(tmp, end - tmp); 5128 if (!tm) {
5129 mtime = time(NULL);
5130 tm = localtime(&mtime);
5131 }
5132 replace = freeval = purple_uts35_to_str(tmp, end - tmp, tm);
5129 fin = end + 1; 5133 fin = end + 1;
5134 } else {
5135 if (!tm) {
5136 mtime = time(NULL);
5137 tm = localtime(&mtime);
5138 }
5139
5140 replace = purple_utf8_strftime("%X", tm);
5130 } 5141 }
5131
5132 if (!tm) {
5133 mtime = time(NULL);
5134 tm = localtime(&mtime);
5135 }
5136
5137 replace = purple_utf8_strftime(format ? format : "%X", tm);
5138 g_free(format);
5139 5142
5140 } else if (g_str_has_prefix(cur, "%dateOpened%")) { 5143 } else if (g_str_has_prefix(cur, "%dateOpened%")) {
5141 if (!tm) { 5144 if (!tm) {
5142 mtime = time(NULL); 5145 mtime = time(NULL);
5143 tm = localtime(&mtime); 5146 tm = localtime(&mtime);
5159 if (fin) { 5162 if (fin) {
5160 prev = cur = fin + 1; 5163 prev = cur = fin + 1;
5161 } else { 5164 } else {
5162 prev = cur = strchr(cur + 1, '%') + 1; 5165 prev = cur = strchr(cur + 1, '%') + 1;
5163 } 5166 }
5167 g_free(freeval);
5168 freeval = NULL;
5164 } 5169 }
5165 5170
5166 /* And wrap it up */ 5171 /* And wrap it up */
5167 g_string_append(str, prev); 5172 g_string_append(str, prev);
5168 return g_string_free(str, FALSE); 5173 return g_string_free(str, FALSE);
6188 6193
6189 replace = freeval = g_string_free(classes, FALSE); 6194 replace = freeval = g_string_free(classes, FALSE);
6190 6195
6191 } else if (g_str_has_prefix(cur, "%time")) { 6196 } else if (g_str_has_prefix(cur, "%time")) {
6192 const char *tmp = cur + strlen("%time"); 6197 const char *tmp = cur + strlen("%time");
6193 char *format = NULL;
6194 6198
6195 if (*tmp == '{') { 6199 if (*tmp == '{') {
6196 char *end; 6200 char *end;
6197 tmp++; 6201 tmp++;
6198 end = strstr(tmp, "}%"); 6202 end = strstr(tmp, "}%");
6199 if (!end) /* Invalid string */ 6203 if (!end) /* Invalid string */
6200 continue; 6204 continue;
6201 format = g_strndup(tmp, end - tmp); 6205 if (!tm)
6206 tm = localtime(&mtime);
6207 replace = freeval = purple_uts35_to_str(tmp, end - tmp, tm);
6202 fin = end + 1; 6208 fin = end + 1;
6209 } else {
6210 if (!tm)
6211 tm = localtime(&mtime);
6212
6213 replace = purple_utf8_strftime("%X", tm);
6203 } 6214 }
6204
6205 if (!tm)
6206 tm = localtime(&mtime);
6207
6208 replace = purple_utf8_strftime(format ? format : "%X", tm);
6209 g_free(format);
6210 6215
6211 } else if (g_str_has_prefix(cur, "%shortTime%")) { 6216 } else if (g_str_has_prefix(cur, "%shortTime%")) {
6212 if (!tm) 6217 if (!tm)
6213 tm = localtime(&mtime); 6218 tm = localtime(&mtime);
6214 6219

mercurial