Mercurial > pidgin
comparison libpurple/plugins/log_reader.c @ 16430:f8eb3e7c4fbd
Fix GTK Plugin prefs
| author | Sean Egan <seanegan@gmail.com> |
|---|---|
| date | Thu, 26 Apr 2007 01:41:35 +0000 |
| parents | 4999bbc52881 |
| children | 5205dd2bd035 |
comparison
equal
deleted
inserted
replaced
| 16429:f9597f375b07 | 16430:f8eb3e7c4fbd |
|---|---|
| 69 GDir *dir; | 69 GDir *dir; |
| 70 | 70 |
| 71 g_return_val_if_fail(sn != NULL, list); | 71 g_return_val_if_fail(sn != NULL, list); |
| 72 g_return_val_if_fail(account != NULL, list); | 72 g_return_val_if_fail(account != NULL, list); |
| 73 | 73 |
| 74 logdir = purple_prefs_get_string("/plugins/purple/log_reader/adium/log_directory"); | 74 logdir = purple_prefs_get_string("/plugins/core/log_reader/adium/log_directory"); |
| 75 | 75 |
| 76 /* By clearing the log directory path, this logger can be (effectively) disabled. */ | 76 /* By clearing the log directory path, this logger can be (effectively) disabled. */ |
| 77 if (!*logdir) | 77 if (!*logdir) |
| 78 return list; | 78 return list; |
| 79 | 79 |
| 293 | 293 |
| 294 g_return_val_if_fail(log != NULL, 0); | 294 g_return_val_if_fail(log != NULL, 0); |
| 295 | 295 |
| 296 data = log->logger_data; | 296 data = log->logger_data; |
| 297 | 297 |
| 298 if (purple_prefs_get_bool("/plugins/purple/log_reader/fast_sizes")) { | 298 if (purple_prefs_get_bool("/plugins/core/log_reader/fast_sizes")) { |
| 299 struct stat st; | 299 struct stat st; |
| 300 | 300 |
| 301 if (!data->path || stat(data->path, &st)) | 301 if (!data->path || stat(data->path, &st)) |
| 302 st.st_size = 0; | 302 st.st_size = 0; |
| 303 | 303 |
| 357 | 357 |
| 358 static int fire_logger_size (PurpleLog *log) | 358 static int fire_logger_size (PurpleLog *log) |
| 359 { | 359 { |
| 360 g_return_val_if_fail(log != NULL, 0); | 360 g_return_val_if_fail(log != NULL, 0); |
| 361 | 361 |
| 362 if (purple_prefs_get_bool("/plugins/purple/log_reader/fast_sizes")) | 362 if (purple_prefs_get_bool("/plugins/core/log_reader/fast_sizes")) |
| 363 return 0; | 363 return 0; |
| 364 | 364 |
| 365 /* TODO: Do something here. */ | 365 /* TODO: Do something here. */ |
| 366 return 0; | 366 return 0; |
| 367 } | 367 } |
| 409 | 409 |
| 410 static int messenger_plus_logger_size (PurpleLog *log) | 410 static int messenger_plus_logger_size (PurpleLog *log) |
| 411 { | 411 { |
| 412 g_return_val_if_fail(log != NULL, 0); | 412 g_return_val_if_fail(log != NULL, 0); |
| 413 | 413 |
| 414 if (purple_prefs_get_bool("/plugins/purple/log_reader/fast_sizes")) | 414 if (purple_prefs_get_bool("/plugins/core/log_reader/fast_sizes")) |
| 415 return 0; | 415 return 0; |
| 416 | 416 |
| 417 /* TODO: Do something here. */ | 417 /* TODO: Do something here. */ |
| 418 return 0; | 418 return 0; |
| 419 } | 419 } |
| 634 g_return_val_if_fail(account != NULL, list); | 634 g_return_val_if_fail(account != NULL, list); |
| 635 | 635 |
| 636 if (strcmp(account->protocol_id, "prpl-msn")) | 636 if (strcmp(account->protocol_id, "prpl-msn")) |
| 637 return list; | 637 return list; |
| 638 | 638 |
| 639 logdir = purple_prefs_get_string("/plugins/purple/log_reader/msn/log_directory"); | 639 logdir = purple_prefs_get_string("/plugins/core/log_reader/msn/log_directory"); |
| 640 | 640 |
| 641 /* By clearing the log directory path, this logger can be (effectively) disabled. */ | 641 /* By clearing the log directory path, this logger can be (effectively) disabled. */ |
| 642 if (!*logdir) | 642 if (!*logdir) |
| 643 return list; | 643 return list; |
| 644 | 644 |
| 966 to_name = NULL; | 966 to_name = NULL; |
| 967 } | 967 } |
| 968 } | 968 } |
| 969 | 969 |
| 970 their_name = from_name; | 970 their_name = from_name; |
| 971 if (from_name && purple_prefs_get_bool("/plugins/purple/log_reader/use_name_heuristics")) { | 971 if (from_name && purple_prefs_get_bool("/plugins/core/log_reader/use_name_heuristics")) { |
| 972 const char *friendly_name = purple_connection_get_display_name(log->account->gc); | 972 const char *friendly_name = purple_connection_get_display_name(log->account->gc); |
| 973 | 973 |
| 974 if (friendly_name != NULL) { | 974 if (friendly_name != NULL) { |
| 975 int friendly_name_length = strlen(friendly_name); | 975 int friendly_name_length = strlen(friendly_name); |
| 976 const char *alias; | 976 const char *alias; |
| 1151 char *text; | 1151 char *text; |
| 1152 size_t size; | 1152 size_t size; |
| 1153 | 1153 |
| 1154 g_return_val_if_fail(log != NULL, 0); | 1154 g_return_val_if_fail(log != NULL, 0); |
| 1155 | 1155 |
| 1156 if (purple_prefs_get_bool("/plugins/purple/log_reader/fast_sizes")) | 1156 if (purple_prefs_get_bool("/plugins/core/log_reader/fast_sizes")) |
| 1157 return 0; | 1157 return 0; |
| 1158 | 1158 |
| 1159 text = msn_logger_read(log, NULL); | 1159 text = msn_logger_read(log, NULL); |
| 1160 size = strlen(text); | 1160 size = strlen(text); |
| 1161 g_free(text); | 1161 g_free(text); |
| 1214 gchar *c; | 1214 gchar *c; |
| 1215 | 1215 |
| 1216 g_return_val_if_fail(sn != NULL, list); | 1216 g_return_val_if_fail(sn != NULL, list); |
| 1217 g_return_val_if_fail(account != NULL, list); | 1217 g_return_val_if_fail(account != NULL, list); |
| 1218 | 1218 |
| 1219 logdir = purple_prefs_get_string("/plugins/purple/log_reader/trillian/log_directory"); | 1219 logdir = purple_prefs_get_string("/plugins/core/log_reader/trillian/log_directory"); |
| 1220 | 1220 |
| 1221 /* By clearing the log directory path, this logger can be (effectively) disabled. */ | 1221 /* By clearing the log directory path, this logger can be (effectively) disabled. */ |
| 1222 if (!*logdir) | 1222 if (!*logdir) |
| 1223 return list; | 1223 return list; |
| 1224 | 1224 |
| 1685 | 1685 |
| 1686 g_return_val_if_fail(log != NULL, 0); | 1686 g_return_val_if_fail(log != NULL, 0); |
| 1687 | 1687 |
| 1688 data = log->logger_data; | 1688 data = log->logger_data; |
| 1689 | 1689 |
| 1690 if (purple_prefs_get_bool("/plugins/purple/log_reader/fast_sizes")) { | 1690 if (purple_prefs_get_bool("/plugins/core/log_reader/fast_sizes")) { |
| 1691 return data ? data->length : 0; | 1691 return data ? data->length : 0; |
| 1692 } | 1692 } |
| 1693 | 1693 |
| 1694 text = trillian_logger_read(log, NULL); | 1694 text = trillian_logger_read(log, NULL); |
| 1695 size = strlen(text); | 1695 size = strlen(text); |
| 1725 gboolean found = FALSE; | 1725 gboolean found = FALSE; |
| 1726 #endif | 1726 #endif |
| 1727 | 1727 |
| 1728 g_return_if_fail(plugin != NULL); | 1728 g_return_if_fail(plugin != NULL); |
| 1729 | 1729 |
| 1730 purple_prefs_add_none("/plugins/purple/log_reader"); | 1730 purple_prefs_add_none("/plugins/core/log_reader"); |
| 1731 | 1731 |
| 1732 | 1732 |
| 1733 /* Add general preferences. */ | 1733 /* Add general preferences. */ |
| 1734 | 1734 |
| 1735 purple_prefs_add_bool("/plugins/purple/log_reader/fast_sizes", FALSE); | 1735 purple_prefs_add_bool("/plugins/core/log_reader/fast_sizes", FALSE); |
| 1736 purple_prefs_add_bool("/plugins/purple/log_reader/use_name_heuristics", TRUE); | 1736 purple_prefs_add_bool("/plugins/core/log_reader/use_name_heuristics", TRUE); |
| 1737 | 1737 |
| 1738 | 1738 |
| 1739 /* Add Adium log directory preference. */ | 1739 /* Add Adium log directory preference. */ |
| 1740 purple_prefs_add_none("/plugins/purple/log_reader/adium"); | 1740 purple_prefs_add_none("/plugins/core/log_reader/adium"); |
| 1741 | 1741 |
| 1742 /* Calculate default Adium log directory. */ | 1742 /* Calculate default Adium log directory. */ |
| 1743 #ifdef _WIN32 | 1743 #ifdef _WIN32 |
| 1744 path = ""; | 1744 path = ""; |
| 1745 #else | 1745 #else |
| 1746 path = g_build_filename(purple_home_dir(), "Library", "Application Support", | 1746 path = g_build_filename(purple_home_dir(), "Library", "Application Support", |
| 1747 "Adium 2.0", "Users", "Default", "Logs", NULL); | 1747 "Adium 2.0", "Users", "Default", "Logs", NULL); |
| 1748 #endif | 1748 #endif |
| 1749 | 1749 |
| 1750 purple_prefs_add_string("/plugins/purple/log_reader/adium/log_directory", path); | 1750 purple_prefs_add_string("/plugins/core/log_reader/adium/log_directory", path); |
| 1751 | 1751 |
| 1752 #ifndef _WIN32 | 1752 #ifndef _WIN32 |
| 1753 g_free(path); | 1753 g_free(path); |
| 1754 #endif | 1754 #endif |
| 1755 | 1755 |
| 1756 | 1756 |
| 1757 /* Add Fire log directory preference. */ | 1757 /* Add Fire log directory preference. */ |
| 1758 purple_prefs_add_none("/plugins/purple/log_reader/fire"); | 1758 purple_prefs_add_none("/plugins/core/log_reader/fire"); |
| 1759 | 1759 |
| 1760 /* Calculate default Fire log directory. */ | 1760 /* Calculate default Fire log directory. */ |
| 1761 #ifdef _WIN32 | 1761 #ifdef _WIN32 |
| 1762 path = ""; | 1762 path = ""; |
| 1763 #else | 1763 #else |
| 1764 path = g_build_filename(purple_home_dir(), "Library", "Application Support", | 1764 path = g_build_filename(purple_home_dir(), "Library", "Application Support", |
| 1765 "Fire", "Sessions", NULL); | 1765 "Fire", "Sessions", NULL); |
| 1766 #endif | 1766 #endif |
| 1767 | 1767 |
| 1768 purple_prefs_add_string("/plugins/purple/log_reader/fire/log_directory", path); | 1768 purple_prefs_add_string("/plugins/core/log_reader/fire/log_directory", path); |
| 1769 | 1769 |
| 1770 #ifndef _WIN32 | 1770 #ifndef _WIN32 |
| 1771 g_free(path); | 1771 g_free(path); |
| 1772 #endif | 1772 #endif |
| 1773 | 1773 |
| 1774 | 1774 |
| 1775 /* Add Messenger Plus! log directory preference. */ | 1775 /* Add Messenger Plus! log directory preference. */ |
| 1776 purple_prefs_add_none("/plugins/purple/log_reader/messenger_plus"); | 1776 purple_prefs_add_none("/plugins/core/log_reader/messenger_plus"); |
| 1777 | 1777 |
| 1778 /* Calculate default Messenger Plus! log directory. */ | 1778 /* Calculate default Messenger Plus! log directory. */ |
| 1779 #ifdef _WIN32 | 1779 #ifdef _WIN32 |
| 1780 folder = wpurple_get_special_folder(CSIDL_PERSONAL); | 1780 folder = wpurple_get_special_folder(CSIDL_PERSONAL); |
| 1781 if (folder) { | 1781 if (folder) { |
| 1792 g_free(folder); | 1792 g_free(folder); |
| 1793 } else /* !folder */ | 1793 } else /* !folder */ |
| 1794 path = g_strdup(""); | 1794 path = g_strdup(""); |
| 1795 #endif | 1795 #endif |
| 1796 | 1796 |
| 1797 purple_prefs_add_string("/plugins/purple/log_reader/messenger_plus/log_directory", path); | 1797 purple_prefs_add_string("/plugins/core/log_reader/messenger_plus/log_directory", path); |
| 1798 g_free(path); | 1798 g_free(path); |
| 1799 | 1799 |
| 1800 | 1800 |
| 1801 /* Add MSN Messenger log directory preference. */ | 1801 /* Add MSN Messenger log directory preference. */ |
| 1802 purple_prefs_add_none("/plugins/purple/log_reader/msn"); | 1802 purple_prefs_add_none("/plugins/core/log_reader/msn"); |
| 1803 | 1803 |
| 1804 /* Calculate default MSN message history directory. */ | 1804 /* Calculate default MSN message history directory. */ |
| 1805 #ifdef _WIN32 | 1805 #ifdef _WIN32 |
| 1806 folder = wpurple_get_special_folder(CSIDL_PERSONAL); | 1806 folder = wpurple_get_special_folder(CSIDL_PERSONAL); |
| 1807 if (folder) { | 1807 if (folder) { |
| 1818 g_free(folder); | 1818 g_free(folder); |
| 1819 } else /* !folder */ | 1819 } else /* !folder */ |
| 1820 path = g_strdup(""); | 1820 path = g_strdup(""); |
| 1821 #endif | 1821 #endif |
| 1822 | 1822 |
| 1823 purple_prefs_add_string("/plugins/purple/log_reader/msn/log_directory", path); | 1823 purple_prefs_add_string("/plugins/core/log_reader/msn/log_directory", path); |
| 1824 g_free(path); | 1824 g_free(path); |
| 1825 | 1825 |
| 1826 | 1826 |
| 1827 /* Add Trillian log directory preference. */ | 1827 /* Add Trillian log directory preference. */ |
| 1828 purple_prefs_add_none("/plugins/purple/log_reader/trillian"); | 1828 purple_prefs_add_none("/plugins/core/log_reader/trillian"); |
| 1829 | 1829 |
| 1830 #ifdef _WIN32 | 1830 #ifdef _WIN32 |
| 1831 /* XXX: While a major hack, this is the most reliable way I could | 1831 /* XXX: While a major hack, this is the most reliable way I could |
| 1832 * think of to determine the Trillian installation directory. | 1832 * think of to determine the Trillian installation directory. |
| 1833 */ | 1833 */ |
| 1890 } | 1890 } |
| 1891 | 1891 |
| 1892 if (logdir) { | 1892 if (logdir) { |
| 1893 g_strchomp(logdir); | 1893 g_strchomp(logdir); |
| 1894 purple_prefs_add_string( | 1894 purple_prefs_add_string( |
| 1895 "/plugins/purple/log_reader/trillian/log_directory", logdir); | 1895 "/plugins/core/log_reader/trillian/log_directory", logdir); |
| 1896 found = TRUE; | 1896 found = TRUE; |
| 1897 } | 1897 } |
| 1898 | 1898 |
| 1899 g_key_file_free(key_file); | 1899 g_key_file_free(key_file); |
| 1900 } | 1900 } |
| 1918 /* XXX: This assumes the first Directory key is under [Logging]. */ | 1918 /* XXX: This assumes the first Directory key is under [Logging]. */ |
| 1919 if (purple_str_has_prefix(line, "Directory=")) { | 1919 if (purple_str_has_prefix(line, "Directory=")) { |
| 1920 line += (sizeof("Directory=") - 1); | 1920 line += (sizeof("Directory=") - 1); |
| 1921 g_strchomp(line); | 1921 g_strchomp(line); |
| 1922 purple_prefs_add_string( | 1922 purple_prefs_add_string( |
| 1923 "/plugins/purple/log_reader/trillian/log_directory", | 1923 "/plugins/core/log_reader/trillian/log_directory", |
| 1924 line); | 1924 line); |
| 1925 found = TRUE; | 1925 found = TRUE; |
| 1926 } | 1926 } |
| 1927 | 1927 |
| 1928 contents++; | 1928 contents++; |
| 1955 g_free(folder); | 1955 g_free(folder); |
| 1956 } else /* !folder */ | 1956 } else /* !folder */ |
| 1957 path = g_strdup(""); | 1957 path = g_strdup(""); |
| 1958 #endif | 1958 #endif |
| 1959 | 1959 |
| 1960 purple_prefs_add_string("/plugins/purple/log_reader/trillian/log_directory", path); | 1960 purple_prefs_add_string("/plugins/core/log_reader/trillian/log_directory", path); |
| 1961 g_free(path); | 1961 g_free(path); |
| 1962 | 1962 |
| 1963 #ifdef _WIN32 | 1963 #ifdef _WIN32 |
| 1964 } /* !found */ | 1964 } /* !found */ |
| 1965 #endif | 1965 #endif |
| 2066 | 2066 |
| 2067 ppref = purple_plugin_pref_new_with_label(_("General Log Reading Configuration")); | 2067 ppref = purple_plugin_pref_new_with_label(_("General Log Reading Configuration")); |
| 2068 purple_plugin_pref_frame_add(frame, ppref); | 2068 purple_plugin_pref_frame_add(frame, ppref); |
| 2069 | 2069 |
| 2070 ppref = purple_plugin_pref_new_with_name_and_label( | 2070 ppref = purple_plugin_pref_new_with_name_and_label( |
| 2071 "/plugins/purple/log_reader/fast_sizes", _("Fast size calculations")); | 2071 "/plugins/core/log_reader/fast_sizes", _("Fast size calculations")); |
| 2072 purple_plugin_pref_frame_add(frame, ppref); | 2072 purple_plugin_pref_frame_add(frame, ppref); |
| 2073 | 2073 |
| 2074 ppref = purple_plugin_pref_new_with_name_and_label( | 2074 ppref = purple_plugin_pref_new_with_name_and_label( |
| 2075 "/plugins/purple/log_reader/use_name_heuristics", _("Use name heuristics")); | 2075 "/plugins/core/log_reader/use_name_heuristics", _("Use name heuristics")); |
| 2076 purple_plugin_pref_frame_add(frame, ppref); | 2076 purple_plugin_pref_frame_add(frame, ppref); |
| 2077 | 2077 |
| 2078 | 2078 |
| 2079 /* Add Log Directory preferences. */ | 2079 /* Add Log Directory preferences. */ |
| 2080 | 2080 |
| 2081 ppref = purple_plugin_pref_new_with_label(_("Log Directory")); | 2081 ppref = purple_plugin_pref_new_with_label(_("Log Directory")); |
| 2082 purple_plugin_pref_frame_add(frame, ppref); | 2082 purple_plugin_pref_frame_add(frame, ppref); |
| 2083 | 2083 |
| 2084 ppref = purple_plugin_pref_new_with_name_and_label( | 2084 ppref = purple_plugin_pref_new_with_name_and_label( |
| 2085 "/plugins/purple/log_reader/adium/log_directory", _("Adium")); | 2085 "/plugins/core/log_reader/adium/log_directory", _("Adium")); |
| 2086 purple_plugin_pref_frame_add(frame, ppref); | 2086 purple_plugin_pref_frame_add(frame, ppref); |
| 2087 | 2087 |
| 2088 #if 0 | 2088 #if 0 |
| 2089 ppref = purple_plugin_pref_new_with_name_and_label( | 2089 ppref = purple_plugin_pref_new_with_name_and_label( |
| 2090 "/plugins/purple/log_reader/fire/log_directory", _("Fire")); | 2090 "/plugins/core/log_reader/fire/log_directory", _("Fire")); |
| 2091 purple_plugin_pref_frame_add(frame, ppref); | 2091 purple_plugin_pref_frame_add(frame, ppref); |
| 2092 | 2092 |
| 2093 ppref = purple_plugin_pref_new_with_name_and_label( | 2093 ppref = purple_plugin_pref_new_with_name_and_label( |
| 2094 "/plugins/purple/log_reader/messenger_plus/log_directory", _("Messenger Plus!")); | 2094 "/plugins/core/log_reader/messenger_plus/log_directory", _("Messenger Plus!")); |
| 2095 purple_plugin_pref_frame_add(frame, ppref); | 2095 purple_plugin_pref_frame_add(frame, ppref); |
| 2096 #endif | 2096 #endif |
| 2097 | 2097 |
| 2098 ppref = purple_plugin_pref_new_with_name_and_label( | 2098 ppref = purple_plugin_pref_new_with_name_and_label( |
| 2099 "/plugins/purple/log_reader/msn/log_directory", _("MSN Messenger")); | 2099 "/plugins/core/log_reader/msn/log_directory", _("MSN Messenger")); |
| 2100 purple_plugin_pref_frame_add(frame, ppref); | 2100 purple_plugin_pref_frame_add(frame, ppref); |
| 2101 | 2101 |
| 2102 ppref = purple_plugin_pref_new_with_name_and_label( | 2102 ppref = purple_plugin_pref_new_with_name_and_label( |
| 2103 "/plugins/purple/log_reader/trillian/log_directory", _("Trillian")); | 2103 "/plugins/core/log_reader/trillian/log_directory", _("Trillian")); |
| 2104 purple_plugin_pref_frame_add(frame, ppref); | 2104 purple_plugin_pref_frame_add(frame, ppref); |
| 2105 | 2105 |
| 2106 return frame; | 2106 return frame; |
| 2107 } | 2107 } |
| 2108 | 2108 |
