comparison libpurple/log.c @ 25918:bc8d1607f9b8

propagate from branch 'im.pidgin.pidgin' (head 566d2e86bfd45c806aba1b32d6f85a9a409ff9ea) to branch 'im.pidgin.pidgin.next.minor' (head ffd76856f93610f7cd6178e943d0b61e4220b549)
author Richard Laager <rlaager@wiktel.com>
date Mon, 26 Jan 2009 02:39:55 +0000
parents a6e3cb32cdd2
children 52b2e7260340
comparison
equal deleted inserted replaced
25372:a8db457c421a 25918:bc8d1607f9b8
198 } 198 }
199 199
200 static guint _purple_logsize_user_equal(struct _purple_logsize_user *lu1, 200 static guint _purple_logsize_user_equal(struct _purple_logsize_user *lu1,
201 struct _purple_logsize_user *lu2) 201 struct _purple_logsize_user *lu2)
202 { 202 {
203 return (lu1->account == lu2->account && (!strcmp(lu1->name, lu2->name))); 203 return (lu1->account == lu2->account && purple_strequal(lu1->name, lu2->name));
204 } 204 }
205 205
206 static void _purple_logsize_user_free_key(struct _purple_logsize_user *lu) 206 static void _purple_logsize_user_free_key(struct _purple_logsize_user *lu)
207 { 207 {
208 g_free(lu->name); 208 g_free(lu->name);
322 { 322 {
323 PurpleLogLogger *logger; 323 PurpleLogLogger *logger;
324 GSList *l = loggers; 324 GSList *l = loggers;
325 while (l) { 325 while (l) {
326 logger = l->data; 326 logger = l->data;
327 if (!strcmp(logger->id, value)) { 327 if (purple_strequal(logger->id, value)) {
328 purple_log_logger_set(logger); 328 purple_log_logger_set(logger);
329 return; 329 return;
330 } 330 }
331 l = l->next; 331 l = l->next;
332 } 332 }
404 { 404 {
405 g_return_if_fail(logger); 405 g_return_if_fail(logger);
406 if (g_slist_find(loggers, logger)) 406 if (g_slist_find(loggers, logger))
407 return; 407 return;
408 loggers = g_slist_append(loggers, logger); 408 loggers = g_slist_append(loggers, logger);
409 if (strcmp(purple_prefs_get_string("/purple/logging/format"), logger->id) == 0) { 409 if (purple_strequal(purple_prefs_get_string("/purple/logging/format"), logger->id)) {
410 purple_prefs_trigger_callback("/purple/logging/format"); 410 purple_prefs_trigger_callback("/purple/logging/format");
411 } 411 }
412 } 412 }
413 413
414 void purple_log_logger_remove (PurpleLogLogger *logger) 414 void purple_log_logger_remove (PurpleLogLogger *logger)
586 void purple_log_init(void) 586 void purple_log_init(void)
587 { 587 {
588 void *handle = purple_log_get_handle(); 588 void *handle = purple_log_get_handle();
589 589
590 purple_prefs_add_none("/purple/logging"); 590 purple_prefs_add_none("/purple/logging");
591 purple_prefs_add_bool("/purple/logging/log_ims", FALSE); 591 purple_prefs_add_bool("/purple/logging/log_ims", TRUE);
592 purple_prefs_add_bool("/purple/logging/log_chats", FALSE); 592 purple_prefs_add_bool("/purple/logging/log_chats", TRUE);
593 purple_prefs_add_bool("/purple/logging/log_system", FALSE); 593 purple_prefs_add_bool("/purple/logging/log_system", FALSE);
594 594
595 purple_prefs_add_string("/purple/logging/format", "txt"); 595 purple_prefs_add_string("/purple/logging/format", "html");
596 596
597 html_logger = purple_log_logger_new("html", _("HTML"), 11, 597 html_logger = purple_log_logger_new("html", _("HTML"), 11,
598 NULL, 598 NULL,
599 html_logger_write, 599 html_logger_write,
600 html_logger_finalize, 600 html_logger_finalize,
1017 prpl = purple_find_prpl(purple_account_get_protocol_id((PurpleAccount *)account_iter->data)); 1017 prpl = purple_find_prpl(purple_account_get_protocol_id((PurpleAccount *)account_iter->data));
1018 if (!prpl) 1018 if (!prpl)
1019 continue; 1019 continue;
1020 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl); 1020 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
1021 1021
1022 if (!strcmp(protocol_unescaped, prpl_info->list_icon((PurpleAccount *)account_iter->data, NULL))) 1022 if (purple_strequal(protocol_unescaped, prpl_info->list_icon((PurpleAccount *)account_iter->data, NULL)))
1023 accounts = g_list_prepend(accounts, account_iter->data); 1023 accounts = g_list_prepend(accounts, account_iter->data);
1024 } 1024 }
1025 g_free(protocol_unescaped); 1025 g_free(protocol_unescaped);
1026 1026
1027 while ((username = g_dir_read_name(protocol_dir)) != NULL) { 1027 while ((username = g_dir_read_name(protocol_dir)) != NULL) {
1037 } 1037 }
1038 1038
1039 /* Find the account for username in the list of accounts for protocol. */ 1039 /* Find the account for username in the list of accounts for protocol. */
1040 username_unescaped = purple_unescape_filename(username); 1040 username_unescaped = purple_unescape_filename(username);
1041 for (account_iter = g_list_first(accounts) ; account_iter != NULL ; account_iter = account_iter->next) { 1041 for (account_iter = g_list_first(accounts) ; account_iter != NULL ; account_iter = account_iter->next) {
1042 if (!strcmp(((PurpleAccount *)account_iter->data)->username, username_unescaped)) { 1042 if (purple_strequal(((PurpleAccount *)account_iter->data)->username, username_unescaped)) {
1043 account = account_iter->data; 1043 account = account_iter->data;
1044 break; 1044 break;
1045 } 1045 }
1046 } 1046 }
1047 1047
1066 set->normalized_name = g_strdup(purple_normalize(account, name)); 1066 set->normalized_name = g_strdup(purple_normalize(account, name));
1067 1067
1068 /* Chat for .chat or .system at the end of the name to determine the type. */ 1068 /* Chat for .chat or .system at the end of the name to determine the type. */
1069 if (len >= 7) { 1069 if (len >= 7) {
1070 gchar *tmp = &name[len - 7]; 1070 gchar *tmp = &name[len - 7];
1071 if (!strcmp(tmp, ".system")) { 1071 if (purple_strequal(tmp, ".system")) {
1072 set->type = PURPLE_LOG_SYSTEM; 1072 set->type = PURPLE_LOG_SYSTEM;
1073 *tmp = '\0'; 1073 *tmp = '\0';
1074 } 1074 }
1075 } 1075 }
1076 if (len > 5) { 1076 if (len > 5) {
1077 gchar *tmp = &name[len - 5]; 1077 gchar *tmp = &name[len - 5];
1078 if (!strcmp(tmp, ".chat")) { 1078 if (purple_strequal(tmp, ".chat")) {
1079 set->type = PURPLE_LOG_CHAT; 1079 set->type = PURPLE_LOG_CHAT;
1080 *tmp = '\0'; 1080 *tmp = '\0';
1081 } 1081 }
1082 } 1082 }
1083 1083
1771 g_snprintf(convostart, length, "%s", temp); 1771 g_snprintf(convostart, length, "%s", temp);
1772 memset(&tm, 0, sizeof(tm)); 1772 memset(&tm, 0, sizeof(tm));
1773 sscanf(convostart, "%*s %s %d %d:%d:%d %d", 1773 sscanf(convostart, "%*s %s %d %d:%d:%d %d",
1774 month, &tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec, &tm.tm_year); 1774 month, &tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec, &tm.tm_year);
1775 /* Ugly hack, in case current locale is not English */ 1775 /* Ugly hack, in case current locale is not English */
1776 if (strcmp(month, "Jan") == 0) { 1776 if (purple_strequal(month, "Jan")) {
1777 tm.tm_mon= 0; 1777 tm.tm_mon= 0;
1778 } else if (strcmp(month, "Feb") == 0) { 1778 } else if (purple_strequal(month, "Feb")) {
1779 tm.tm_mon = 1; 1779 tm.tm_mon = 1;
1780 } else if (strcmp(month, "Mar") == 0) { 1780 } else if (purple_strequal(month, "Mar")) {
1781 tm.tm_mon = 2; 1781 tm.tm_mon = 2;
1782 } else if (strcmp(month, "Apr") == 0) { 1782 } else if (purple_strequal(month, "Apr")) {
1783 tm.tm_mon = 3; 1783 tm.tm_mon = 3;
1784 } else if (strcmp(month, "May") == 0) { 1784 } else if (purple_strequal(month, "May")) {
1785 tm.tm_mon = 4; 1785 tm.tm_mon = 4;
1786 } else if (strcmp(month, "Jun") == 0) { 1786 } else if (purple_strequal(month, "Jun")) {
1787 tm.tm_mon = 5; 1787 tm.tm_mon = 5;
1788 } else if (strcmp(month, "Jul") == 0) { 1788 } else if (purple_strequal(month, "Jul")) {
1789 tm.tm_mon = 6; 1789 tm.tm_mon = 6;
1790 } else if (strcmp(month, "Aug") == 0) { 1790 } else if (purple_strequal(month, "Aug")) {
1791 tm.tm_mon = 7; 1791 tm.tm_mon = 7;
1792 } else if (strcmp(month, "Sep") == 0) { 1792 } else if (purple_strequal(month, "Sep")) {
1793 tm.tm_mon = 8; 1793 tm.tm_mon = 8;
1794 } else if (strcmp(month, "Oct") == 0) { 1794 } else if (purple_strequal(month, "Oct")) {
1795 tm.tm_mon = 9; 1795 tm.tm_mon = 9;
1796 } else if (strcmp(month, "Nov") == 0) { 1796 } else if (purple_strequal(month, "Nov")) {
1797 tm.tm_mon = 10; 1797 tm.tm_mon = 10;
1798 } else if (strcmp(month, "Dec") == 0) { 1798 } else if (purple_strequal(month, "Dec")) {
1799 tm.tm_mon = 11; 1799 tm.tm_mon = 11;
1800 } 1800 }
1801 tm.tm_year -= 1900; 1801 tm.tm_year -= 1900;
1802 lasttime = mktime(&tm); 1802 lasttime = mktime(&tm);
1803 } 1803 }
1928 continue; 1928 continue;
1929 } 1929 }
1930 1930
1931 /* Make sure we're dealing with a log file. */ 1931 /* Make sure we're dealing with a log file. */
1932 ext = &name[len - 4]; 1932 ext = &name[len - 4];
1933 if (strcmp(ext, ".log")) { 1933 if (!purple_strequal(ext, ".log")) {
1934 g_free(name); 1934 g_free(name);
1935 continue; 1935 continue;
1936 } 1936 }
1937 1937
1938 /* IMPORTANT: Always set all members of PurpleLogSet */ 1938 /* IMPORTANT: Always set all members of PurpleLogSet */
1941 /* Chat for .chat at the end of the name to determine the type. */ 1941 /* Chat for .chat at the end of the name to determine the type. */
1942 *ext = '\0'; 1942 *ext = '\0';
1943 set->type = PURPLE_LOG_IM; 1943 set->type = PURPLE_LOG_IM;
1944 if (len > 9) { 1944 if (len > 9) {
1945 char *tmp = &name[len - 9]; 1945 char *tmp = &name[len - 9];
1946 if (!strcmp(tmp, ".chat")) { 1946 if (purple_strequal(tmp, ".chat")) {
1947 set->type = PURPLE_LOG_CHAT; 1947 set->type = PURPLE_LOG_CHAT;
1948 *tmp = '\0'; 1948 *tmp = '\0';
1949 } 1949 }
1950 } 1950 }
1951 1951
1952 set->name = set->normalized_name = name; 1952 set->name = set->normalized_name = name;
1953 1953
1954 /* Search the buddy list to find the account and to determine if this is a buddy. */ 1954 /* Search the buddy list to find the account and to determine if this is a buddy. */
1955 for (gnode = purple_get_blist()->root; !found && gnode != NULL; gnode = gnode->next) 1955 for (gnode = purple_blist_get_root();
1956 !found && gnode != NULL;
1957 gnode = purple_blist_node_get_sibling_next(gnode))
1956 { 1958 {
1957 if (!PURPLE_BLIST_NODE_IS_GROUP(gnode)) 1959 if (!PURPLE_BLIST_NODE_IS_GROUP(gnode))
1958 continue; 1960 continue;
1959 1961
1960 for (cnode = gnode->child; !found && cnode != NULL; cnode = cnode->next) 1962 for (cnode = purple_blist_node_get_first_child(gnode);
1963 !found && cnode != NULL;
1964 cnode = purple_blist_node_get_sibling_next(cnode))
1961 { 1965 {
1962 if (!PURPLE_BLIST_NODE_IS_CONTACT(cnode)) 1966 if (!PURPLE_BLIST_NODE_IS_CONTACT(cnode))
1963 continue; 1967 continue;
1964 1968
1965 for (bnode = cnode->child; !found && bnode != NULL; bnode = bnode->next) 1969 for (bnode = purple_blist_node_get_first_child(cnode);
1970 !found && bnode != NULL;
1971 bnode = purple_blist_node_get_sibling_next(bnode))
1966 { 1972 {
1967 PurpleBuddy *buddy = (PurpleBuddy *)bnode; 1973 PurpleBuddy *buddy = (PurpleBuddy *)bnode;
1968 1974
1969 if (!strcmp(buddy->name, name)) { 1975 if (purple_strequal(purple_buddy_get_name(buddy), name)) {
1970 set->account = buddy->account; 1976 set->account = purple_buddy_get_account(buddy);
1971 set->buddy = TRUE; 1977 set->buddy = TRUE;
1972 found = TRUE; 1978 found = TRUE;
1973 } 1979 }
1974 } 1980 }
1975 } 1981 }