comparison src/account.c @ 11643:eb14bbcf7249

[gaim-migrate @ 13920] sf patch #1293063, from John Bailey Move and rename some functions from server.c to the account API. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Wed, 12 Oct 2005 02:47:31 +0000
parents 3a05b53a589e
children 01647b11ecd3
comparison
equal deleted inserted replaced
11642:58bc500cf226 11643:eb14bbcf7249
1057 gaim_notify_error(account, NULL, 1057 gaim_notify_error(account, NULL,
1058 _("Fill out all fields completely."), NULL); 1058 _("Fill out all fields completely."), NULL);
1059 return; 1059 return;
1060 } 1060 }
1061 1061
1062 serv_change_passwd(gaim_account_get_connection(account), 1062 gaim_account_change_password(account, orig_pass, new_pass_1);
1063 orig_pass, new_pass_1);
1064 gaim_account_set_password(account, new_pass_1); 1063 gaim_account_set_password(account, new_pass_1);
1065 } 1064 }
1066 1065
1067 void 1066 void
1068 gaim_account_request_change_password(GaimAccount *account) 1067 gaim_account_request_change_password(GaimAccount *account)
1896 account->system_log = NULL; 1895 account->system_log = NULL;
1897 } 1896 }
1898 } 1897 }
1899 1898
1900 void 1899 void
1900 gaim_account_add_buddy(GaimAccount *account, GaimBuddy *buddy)
1901 {
1902 GaimPluginProtocolInfo *prpl_info = NULL;
1903 GaimConnection *gc = gaim_account_get_connection(account);
1904
1905 if (gc != NULL && gc->prpl != NULL)
1906 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
1907
1908 if (prpl_info != NULL && g_list_find(gaim_connections_get_all(), gc) &&
1909 prpl_info->add_buddy != NULL)
1910 prpl_info->add_buddy(gc, buddy, gaim_find_buddys_group(buddy));
1911 }
1912
1913 void
1914 gaim_account_add_buddies(GaimAccount *account, GList *buddies)
1915 {
1916 GaimPluginProtocolInfo *prpl_info = NULL;
1917 GaimConnection *gc = gaim_account_get_connection(account);
1918
1919 if (gc != NULL && gc->prpl != NULL)
1920 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
1921
1922 if (prpl_info && g_list_find(gaim_connections_get_all(), gc)) {
1923 GList *cur, *groups = NULL;
1924
1925 /* Make a list of what group each buddy is in */
1926 for (cur = buddies; cur != NULL; cur = cur->next) {
1927 GaimBlistNode *node = cur->data;
1928 groups = g_list_append(groups, node->parent->parent);
1929 }
1930
1931 if (prpl_info->add_buddies != NULL)
1932 prpl_info->add_buddies(gc, buddies, groups);
1933 else if (prpl_info->add_buddy != NULL) {
1934 GList *curb = buddies, *curg = groups;
1935
1936 while ((curb != NULL) && (curg != NULL)) {
1937 prpl_info->add_buddy(gc, curb->data, curg->data);
1938 curb = curb->next;
1939 curg = curg->next;
1940 }
1941 }
1942
1943 g_list_free(groups);
1944 }
1945 }
1946
1947 void
1948 gaim_account_remove_buddy(GaimAccount *account, GaimBuddy *buddy,
1949 GaimGroup *group)
1950 {
1951 GaimPluginProtocolInfo *prpl_info = NULL;
1952 GaimConnection *gc = gaim_account_get_connection(account);
1953
1954 if (gc != NULL && gc->prpl != NULL)
1955 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
1956
1957 if (prpl_info && g_list_find(gaim_connections_get_all(), gc) && prpl_info->remove_buddy)
1958 prpl_info->remove_buddy(gc, buddy, group);
1959 }
1960
1961 void
1962 gaim_account_remove_buddies(GaimAccount *account, GList *buddies, GList *groups)
1963 {
1964 GaimPluginProtocolInfo *prpl_info = NULL;
1965 GaimConnection *gc = gaim_account_get_connection(account);
1966
1967 if (!g_list_find(gaim_connections_get_all(), gc))
1968 return;
1969
1970 if (gc != NULL && gc->prpl != NULL)
1971 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
1972
1973 if (prpl_info && g_list_find(gaim_connections_get_all(), gc)) {
1974 if (prpl_info->remove_buddies)
1975 prpl_info->remove_buddies(gc, buddies, groups);
1976 else {
1977 GList *curb = buddies;
1978 GList *curg = groups;
1979 while ((curb != NULL) && (curg != NULL)) {
1980 gaim_account_remove_buddy(account, curb->data, curg->data);
1981 curb = curb->next;
1982 curg = curg->next;
1983 }
1984 }
1985 }
1986 }
1987
1988 void
1989 gaim_account_remove_group(GaimAccount *account, GaimGroup *group)
1990 {
1991 GaimPluginProtocolInfo *prpl_info = NULL;
1992 GaimConnection *gc = gaim_account_get_connection(account);
1993
1994 if (gc != NULL && gc->prpl != NULL)
1995 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
1996
1997 if (prpl_info && g_list_find(gaim_connections_get_all(), gc) && prpl_info->remove_group)
1998 prpl_info->remove_group(gc, group);
1999 }
2000
2001 void
2002 gaim_account_change_password(GaimAccount *account, const char *orig_pw,
2003 const char *new_pw)
2004 {
2005 GaimPluginProtocolInfo *prpl_info = NULL;
2006 GaimConnection *gc = gaim_account_get_connection(account);
2007
2008 if (gc != NULL && gc->prpl != NULL)
2009 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
2010
2011 if (prpl_info && g_list_find(gaim_connections_get_all(), gc) && prpl_info->change_passwd)
2012 prpl_info->change_passwd(gc, orig_pw, new_pw);
2013 }
2014
2015 void
1901 gaim_accounts_add(GaimAccount *account) 2016 gaim_accounts_add(GaimAccount *account)
1902 { 2017 {
1903 g_return_if_fail(account != NULL); 2018 g_return_if_fail(account != NULL);
1904 2019
1905 if (g_list_find(accounts, account) != NULL) 2020 if (g_list_find(accounts, account) != NULL)