comparison src/gtkaccount.c @ 7015:dece74f05509

[gaim-migrate @ 7578] Further core/UI splittage. show_got_added() -> gaim_account_notify_added() committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Mon, 29 Sep 2003 15:28:20 +0000
parents a14200b24371
children 9946001989a3
comparison
equal deleted inserted replaced
7014:67c4e9d39242 7015:dece74f05509
24 24
25 #include "account.h" 25 #include "account.h"
26 #include "accountopt.h" 26 #include "accountopt.h"
27 #include "core.h" 27 #include "core.h"
28 #include "debug.h" 28 #include "debug.h"
29 #include "notify.h"
29 #include "plugin.h" 30 #include "plugin.h"
30 #include "prefs.h" 31 #include "prefs.h"
31 #include "request.h" 32 #include "request.h"
32 #include "signals.h" 33 #include "signals.h"
33 #include "util.h" 34 #include "util.h"
48 COLUMN_AUTOLOGIN, 49 COLUMN_AUTOLOGIN,
49 COLUMN_PROTOCOL, 50 COLUMN_PROTOCOL,
50 COLUMN_DATA, 51 COLUMN_DATA,
51 NUM_COLUMNS 52 NUM_COLUMNS
52 }; 53 };
54
55 typedef struct
56 {
57 GaimAccount *account;
58 char *username;
59 char *alias;
60
61 } GaimGtkAccountAddUserData;
53 62
54 typedef struct 63 typedef struct
55 { 64 {
56 GtkWidget *window; 65 GtkWidget *window;
57 GtkWidget *treeview; 66 GtkWidget *treeview;
1904 mainwindow == NULL && gaim_connections_get_all() == NULL) { 1913 mainwindow == NULL && gaim_connections_get_all() == NULL) {
1905 1914
1906 gaim_core_quit(); 1915 gaim_core_quit();
1907 } 1916 }
1908 } 1917 }
1918
1919 static void
1920 free_add_user_data(GaimGtkAccountAddUserData *data)
1921 {
1922 g_free(data->username);
1923
1924 if (data->alias != NULL)
1925 g_free(data->alias);
1926
1927 g_free(data);
1928 }
1929
1930 static void
1931 add_user_cb(GaimGtkAccountAddUserData *data)
1932 {
1933 GaimConnection *gc = gaim_account_get_connection(data->account);
1934
1935 if (g_list_find(gaim_connections_get_all(), gc))
1936 show_add_buddy(gc, data->username, NULL, data->alias);
1937
1938 free_add_user_data(data);
1939 }
1940
1941 static void
1942 gaim_gtk_accounts_notify_added(GaimAccount *account, const char *remote_user,
1943 const char *id, const char *alias,
1944 const char *msg)
1945 {
1946 char *buffer;
1947 GaimConnection *gc;
1948 GaimGtkAccountAddUserData *data;
1949 GaimBuddy *buddy;
1950
1951 gc = gaim_account_get_connection(account);
1952
1953 buddy = gaim_find_buddy(account, remote_user);
1954
1955 data = g_new0(GaimGtkAccountAddUserData, 1);
1956 data->account = account;
1957 data->username = g_strdup(remote_user);
1958 data->alias = (alias != NULL ? g_strdup(alias) : NULL);
1959
1960 buffer = g_strdup_printf(_("%s%s%s%s has made %s his or her buddy%s%s%s"),
1961 remote_user,
1962 (alias != NULL ? " (" : ""),
1963 (alias != NULL ? alias : ""),
1964 (alias != NULL ? ")" : ""),
1965 (id != NULL
1966 ? id
1967 : (gaim_connection_get_display_name(gc) != NULL
1968 ? gaim_connection_get_display_name(gc)
1969 : gaim_account_get_username(account))),
1970 (msg != NULL ? ": " : "."),
1971 (msg != NULL ? msg : ""),
1972 (buddy != NULL
1973 ? ""
1974 : _("\n\nDo you wish to add him or her to your buddy list?")));
1975
1976 if (buddy != NULL)
1977 {
1978 gaim_notify_info(NULL, NULL, _("Gaim - Information"), buffer);
1979 }
1980 else
1981 {
1982 gaim_request_action(NULL, NULL, _("Add buddy to your list?"),
1983 buffer, 0, data, 2,
1984 _("Add"), G_CALLBACK(add_user_cb),
1985 _("Cancel"), G_CALLBACK(free_add_user_data));
1986 }
1987
1988 g_free(buffer);
1989 }
1990
1991 static GaimAccountUiOps ui_ops =
1992 {
1993 gaim_gtk_accounts_notify_added
1994 };
1995
1996 GaimAccountUiOps *
1997 gaim_gtk_accounts_get_ui_ops(void)
1998 {
1999 return &ui_ops;
2000 }