comparison src/protocols/irc/irc.c @ 5791:f5a4a17c58a5

[gaim-migrate @ 6216] IRC works again. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Sat, 07 Jun 2003 05:53:57 +0000
parents 46d7ad0dfa26
children 059d95c67cda
comparison
equal deleted inserted replaced
5790:995e63fb1a5a 5791:f5a4a17c58a5
1870 GaimAccount *account = gaim_connection_get_account(gc); 1870 GaimAccount *account = gaim_connection_get_account(gc);
1871 struct irc_data *idata; 1871 struct irc_data *idata;
1872 char hostname[256]; 1872 char hostname[256];
1873 char buf[IRC_BUF_LEN]; 1873 char buf[IRC_BUF_LEN];
1874 char *test; 1874 char *test;
1875 const char *alias;
1875 const char *charset = gaim_account_get_string(account, "charset", "UTF-8"); 1876 const char *charset = gaim_account_get_string(account, "charset", "UTF-8");
1876 GError *err = NULL; 1877 GError *err = NULL;
1877
1878 if (!g_list_find(gaim_connections_get_all(), gc)) {
1879 close(source);
1880 return;
1881 }
1882 1878
1883 idata = gc->proto_data; 1879 idata = gc->proto_data;
1884 1880
1885 if (source < 0) { 1881 if (source < 0) {
1886 gaim_connection_error(gc, "Write error"); 1882 gaim_connection_error(gc, "Write error");
1900 1896
1901 g_free(test); 1897 g_free(test);
1902 1898
1903 gethostname(hostname, sizeof(hostname) - 1); 1899 gethostname(hostname, sizeof(hostname) - 1);
1904 hostname[sizeof(hostname) - 1] = 0; 1900 hostname[sizeof(hostname) - 1] = 0;
1901
1905 if (!*hostname) 1902 if (!*hostname)
1906 g_snprintf(hostname, sizeof(hostname), "localhost"); 1903 g_snprintf(hostname, sizeof(hostname), "localhost");
1907 1904
1908 if (gc->account->password != NULL) { 1905 if (gaim_account_get_password(account) != NULL) {
1909 g_snprintf(buf, sizeof(buf), "PASS %s\r\n", gaim_account_get_password(account)); 1906 g_snprintf(buf, sizeof(buf), "PASS %s\r\n",
1907 gaim_account_get_password(account));
1910 1908
1911 if (irc_write(idata->fd, buf, strlen(buf)) < 0) { 1909 if (irc_write(idata->fd, buf, strlen(buf)) < 0) {
1912 gaim_connection_error(gc, "Write error"); 1910 gaim_connection_error(gc, "Write error");
1913 return; 1911 return;
1914 } 1912 }
1915 } 1913 }
1916 1914
1915 alias = gaim_account_get_alias(account);
1916
1917 g_snprintf(buf, sizeof(buf), "USER %s %s %s :%s\r\n", 1917 g_snprintf(buf, sizeof(buf), "USER %s %s %s :%s\r\n",
1918 g_get_user_name(), hostname, 1918 g_get_user_name(), hostname,
1919 idata->server, 1919 idata->server,
1920 *gc->account->alias ? gc->account->alias : "gaim"); 1920 (alias == NULL ? "gaim" : alias));
1921
1921 if (irc_write(idata->fd, buf, strlen(buf)) < 0) { 1922 if (irc_write(idata->fd, buf, strlen(buf)) < 0) {
1922 gaim_connection_error(gc, "Write error"); 1923 gaim_connection_error(gc, "Write error");
1923 return; 1924 return;
1924 } 1925 }
1925 1926
1926 g_snprintf(buf, sizeof(buf), "NICK %s\r\n", gaim_connection_get_display_name(gc)); 1927 g_snprintf(buf, sizeof(buf), "NICK %s\r\n",
1928 gaim_connection_get_display_name(gc));
1929
1927 if (irc_write(idata->fd, buf, strlen(buf)) < 0) { 1930 if (irc_write(idata->fd, buf, strlen(buf)) < 0) {
1928 gaim_connection_error(gc, "Write error"); 1931 gaim_connection_error(gc, "Write error");
1929 return; 1932 return;
1930 } 1933 }
1931 1934
1962 1965
1963 rc = gaim_proxy_connect(account, idata->server, 1966 rc = gaim_proxy_connect(account, idata->server,
1964 gaim_account_get_int(account, "port", 6667), 1967 gaim_account_get_int(account, "port", 6667),
1965 irc_login_callback, gc); 1968 irc_login_callback, gc);
1966 1969
1967 if (!account->gc || (rc != 0)) { 1970 if (rc != 0) {
1968 gaim_connection_error(gc, _("Unable to create socket")); 1971 gaim_connection_error(gc, _("Unable to create socket"));
1969 return; 1972 return;
1970 } 1973 }
1971 } 1974 }
1972 1975