comparison libgaim/plugins/log_reader.c @ 14272:7635195195c0

[gaim-migrate @ 16957] -Updated the win32dep debug function to correctly match the core function (the core was apparently changed a while ago and this was never updated). -Updated wgaim_read_reg_string() to deal with non-ascii strings correctly, created corresponding wgaim_write_reg_string(). Use these in various places. -Update some win32dep arguments and return values to be correctly marked as having constant values. committer: Tailor Script <tailor@pidgin.im>
author Daniel Atallah <daniel.atallah@gmail.com>
date Mon, 21 Aug 2006 20:58:20 +0000
parents a54ff7cafc2a
children 5025e146a876
comparison
equal deleted inserted replaced
14271:9e5c28c3b163 14272:7635195195c0
1575 init_plugin(GaimPlugin *plugin) 1575 init_plugin(GaimPlugin *plugin)
1576 { 1576 {
1577 char *path; 1577 char *path;
1578 #ifdef _WIN32 1578 #ifdef _WIN32
1579 char *folder; 1579 char *folder;
1580 gboolean found = FALSE;
1580 #endif 1581 #endif
1581 1582
1582 g_return_if_fail(plugin != NULL); 1583 g_return_if_fail(plugin != NULL);
1583 1584
1584 gaim_prefs_add_none("/plugins/core/log_reader"); 1585 gaim_prefs_add_none("/plugins/core/log_reader");
1683 1684
1684 #ifdef _WIN32 1685 #ifdef _WIN32
1685 /* XXX: While a major hack, this is the most reliable way I could 1686 /* XXX: While a major hack, this is the most reliable way I could
1686 * think of to determine the Trillian installation directory. 1687 * think of to determine the Trillian installation directory.
1687 */ 1688 */
1688 HKEY hKey;
1689 char buffer[1024] = "";
1690 DWORD size = (sizeof(buffer) - 1);
1691 DWORD type;
1692 gboolean found = FALSE;
1693 1689
1694 path = NULL; 1690 path = NULL;
1695 /* TODO: Test this after removing the trailing "\\". */ 1691 if ((folder = wgaim_read_reg_string(HKEY_CLASSES_ROOT, "Trillian.SkinZip\\shell\\Add\\command\\", NULL))) {
1696 if(ERROR_SUCCESS == RegOpenKeyEx(HKEY_CLASSES_ROOT, "Trillian.SkinZip\\shell\\Add\\command\\", 1692 char *value = folder;
1697 0, KEY_QUERY_VALUE, &hKey)) { 1693 char *temp;
1698 1694
1699 if(ERROR_SUCCESS == RegQueryValueEx(hKey, "", NULL, &type, (LPBYTE)buffer, &size)) { 1695 /* Break apart buffer. */
1700 char *value = buffer; 1696 if (*value == '"') {
1701 char *temp; 1697 value++;
1702 1698 temp = value;
1703 /* Ensure the data is null terminated. */ 1699 while (*temp && *temp != '"')
1704 value[size] = '\0'; 1700 temp++;
1705 1701 } else {
1706 /* Break apart buffer. */ 1702 temp = value;
1707 if (*value == '"') { 1703 while (*temp && *temp != ' ')
1708 value++; 1704 temp++;
1709 temp = value; 1705 }
1710 while (*temp && *temp != '"') 1706 *temp = '\0';
1711 temp++; 1707
1712 } else { 1708 /* Set path. */
1713 temp = value; 1709 if (gaim_str_has_suffix(value, "trillian.exe")) {
1714 while (*temp && *temp != ' ') 1710 value[strlen(value) - (sizeof("trillian.exe") - 1)] = '\0';
1715 temp++; 1711 path = g_build_filename(value, "users", "default", "talk.ini", NULL);
1716 } 1712 }
1717 *temp = '\0'; 1713 g_free(folder);
1718
1719 /* Set path. */
1720 if (gaim_str_has_suffix(value, "trillian.exe"))
1721 {
1722 value[strlen(value) - (sizeof("trillian.exe") - 1)] = '\0';
1723 path = g_build_filename(value, "users", "default", "talk.ini", NULL);
1724 }
1725 }
1726 RegCloseKey(hKey);
1727 } 1714 }
1728 1715
1729 if (!path) { 1716 if (!path) {
1730 char *folder = wgaim_get_special_folder(CSIDL_PROGRAM_FILES); 1717 char *folder = wgaim_get_special_folder(CSIDL_PROGRAM_FILES);
1731 if (folder) { 1718 if (folder) {