changeset 5874:964e4f94fc56

[gaim-migrate @ 6306] Moved gaim_account_find() from util.[ch] to gaim_accounts_find() in account.[ch]. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Sat, 14 Jun 2003 23:50:24 +0000
parents a18e88c4dace
children 448f2f4ca3ec
files src/Makefile.am src/account.c src/account.h src/blist.c src/gaimrc.c src/main.c src/util.c src/util.h
diffstat 8 files changed, 57 insertions(+), 56 deletions(-) [+]
line wrap: on
line diff
--- a/src/Makefile.am	Sat Jun 14 23:25:41 2003 +0000
+++ b/src/Makefile.am	Sat Jun 14 23:50:24 2003 +0000
@@ -38,6 +38,7 @@
 	request.c \
 	request.h \
 	server.c \
+	server.h \
 	sound.c \
 	sound.h \
 	util.c \
--- a/src/account.c	Sat Jun 14 23:25:41 2003 +0000
+++ b/src/account.c	Sat Jun 14 23:50:24 2003 +0000
@@ -117,19 +117,13 @@
 gaim_account_new(const char *username, GaimProtocol protocol)
 {
 	GaimAccount *account;
-	GList *l;
 
 	g_return_val_if_fail(username != NULL, NULL);
 
-	for (l = gaim_accounts_get_all(); l != NULL; l = l->next) {
-		account = l->data;
+	account = gaim_accounts_find(username, protocol);
 
-		if (!strcmp(gaim_account_get_username(account), username) &&
-			gaim_account_get_protocol(account) == protocol) {
-
-			return account;
-		}
-	}
+	if (account != NULL)
+		return account;
 
 	account = g_new0(GaimAccount, 1);
 
@@ -1270,3 +1264,34 @@
 {
 	return accounts;
 }
+
+GaimAccount *
+gaim_accounts_find(const char *name, GaimProtocol protocol)
+{
+	GaimAccount *account = NULL;
+	GList *l;
+	char *who;
+
+	g_return_val_if_fail(name != NULL, NULL);
+
+	who = g_strdup(normalize(name));
+
+	for (l = gaim_accounts_get_all(); l != NULL; l = l->next) {
+		account = (GaimAccount *)l->data;
+
+		if (!strcmp(normalize(gaim_account_get_username(account)), who)) {
+			if (protocol != -1) {
+				if (account->protocol == protocol)
+					break;
+			}
+			else
+				break;
+		}
+
+		account = NULL;
+	}
+
+	g_free(who);
+
+	return account;
+}
--- a/src/account.h	Sat Jun 14 23:25:41 2003 +0000
+++ b/src/account.h	Sat Jun 14 23:50:24 2003 +0000
@@ -491,4 +491,14 @@
  */
 GList *gaim_accounts_get_all(void);
 
+/**
+ * Finds an account with the specified name and protocol.
+ *
+ * @param name     The account username.
+ * @param protocol The account protocol.
+ *
+ * @return The account, if found, or @c FALSE otherwise.
+ */
+GaimAccount *gaim_accounts_find(const char *name, GaimProtocol protocol);
+
 #endif /* _GAIM_ACCOUNTS_H_ */
--- a/src/blist.c	Sat Jun 14 23:25:41 2003 +0000
+++ b/src/blist.c	Sat Jun 14 23:50:24 2003 +0000
@@ -1379,7 +1379,7 @@
 		tag_stack = g_list_delete_link(tag_stack, tag_stack);
 		blist_parser_group_settings = NULL;
 	} else if(!strcmp(element_name, "chat")) {
-		GaimAccount *account = gaim_account_find(blist_parser_account_name,
+		GaimAccount *account = gaim_accounts_find(blist_parser_account_name,
 				blist_parser_account_protocol);
 		if(account) {
 			struct chat *chat = gaim_chat_new(account, blist_parser_chat_alias, blist_parser_chat_components);
@@ -1398,7 +1398,7 @@
 		blist_parser_person_name = NULL;
 		tag_stack = g_list_delete_link(tag_stack, tag_stack);
 	} else if(!strcmp(element_name, "buddy")) {
-		GaimAccount *account = gaim_account_find(blist_parser_account_name,
+		GaimAccount *account = gaim_accounts_find(blist_parser_account_name,
 				blist_parser_account_protocol);
 		if(account) {
 			struct buddy *b = gaim_buddy_new(account, blist_parser_buddy_name, blist_parser_buddy_alias);
@@ -1464,7 +1464,7 @@
 	} else if(!strcmp(element_name, "privacy")) {
 		tag_stack = g_list_delete_link(tag_stack, tag_stack);
 	} else if(!strcmp(element_name, "account")) {
-		GaimAccount *account = gaim_account_find(blist_parser_account_name,
+		GaimAccount *account = gaim_accounts_find(blist_parser_account_name,
 				blist_parser_account_protocol);
 		if(account) {
 			account->perm_deny = blist_parser_privacy_mode;
@@ -1473,7 +1473,7 @@
 		blist_parser_account_name = NULL;
 		tag_stack = g_list_delete_link(tag_stack, tag_stack);
 	} else if(!strcmp(element_name, "permit")) {
-		GaimAccount *account = gaim_account_find(blist_parser_account_name,
+		GaimAccount *account = gaim_accounts_find(blist_parser_account_name,
 				blist_parser_account_protocol);
 		if(account) {
 			gaim_privacy_permit_add(account, blist_parser_buddy_name);
@@ -1482,7 +1482,7 @@
 		blist_parser_buddy_name = NULL;
 		tag_stack = g_list_delete_link(tag_stack, tag_stack);
 	} else if(!strcmp(element_name, "block")) {
-		GaimAccount *account = gaim_account_find(blist_parser_account_name,
+		GaimAccount *account = gaim_accounts_find(blist_parser_account_name,
 				blist_parser_account_protocol);
 		if(account) {
 			gaim_privacy_deny_add(account, blist_parser_buddy_name);
--- a/src/gaimrc.c	Sat Jun 14 23:25:41 2003 +0000
+++ b/src/gaimrc.c	Sat Jun 14 23:50:24 2003 +0000
@@ -1643,7 +1643,7 @@
 		GaimGtkPounceAction actions = GAIM_GTKPOUNCE_NONE;
 		ph = (struct pounce_placeholder *)l->data;
 
-		account = gaim_account_find(ph->pouncer, ph->protocol);
+		account = gaim_accounts_find(ph->pouncer, ph->protocol);
 
 		old_pounce_opts_to_new(ph->options, &events, &actions);
 
--- a/src/main.c	Sat Jun 14 23:25:41 2003 +0000
+++ b/src/main.c	Sat Jun 14 23:50:24 2003 +0000
@@ -237,7 +237,7 @@
 	 * them, they just have to use the account editor to sign in 
 	 * the second one */
 
-	account = gaim_account_find(username, -1);
+	account = gaim_accounts_find(username, -1);
 	if (!account) {
 		account = gaim_account_new(username, GAIM_PROTO_DEFAULT);
 
@@ -265,7 +265,7 @@
 	if (name !=NULL) {	/* list of names given */
 		names = g_strsplit(name, ",", 32);
 		for (n = names; *n != NULL; n++) {
-			account = gaim_account_find(*n, -1);
+			account = gaim_accounts_find(*n, -1);
 			if (account) {	/* found a user */
 				if (gaim_account_get_remember_password(account)) {
 					retval = 0;
@@ -304,7 +304,7 @@
 	const char *txt = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo)->entry));
 	GaimAccount *account;
 
-	account = gaim_account_find(txt, -1);
+	account = gaim_accounts_find(txt, -1);
 
 	if (account && gaim_account_get_remember_password(account)) {
 		gtk_entry_set_text(GTK_ENTRY(pass), account->password);
@@ -548,7 +548,7 @@
 {
 	GaimAccount *account;
 
-	account = gaim_account_find(name, -1);
+	account = gaim_accounts_find(name, -1);
 
 	if (account == NULL)   /* new user */
 		account = gaim_account_new(name, GAIM_PROTO_DEFAULT);
--- a/src/util.c	Sat Jun 14 23:25:41 2003 +0000
+++ b/src/util.c	Sat Jun 14 23:50:24 2003 +0000
@@ -536,32 +536,6 @@
 #endif
 }
 
-GaimAccount *gaim_account_find(const char *name, int protocol)
-{
-	char *who = g_strdup(normalize(name));
-	GList *accts = gaim_accounts_get_all();
-	GaimAccount *account;
-
-	while (accts) {
-		account = (GaimAccount *)accts->data;
-		if (!strcmp(normalize(account->username), who)) {
-			if (protocol != -1) {
-				if (account->protocol == protocol) {
-					g_free(who);
-					return account;
-				}
-			} else {
-				g_free(who);
-				return account;
-			}
-
-		}
-		accts = accts->next;
-	}
-	g_free(who);
-	return NULL;
-}
-
 
 /* Look for %n, %d, or %t in msg, and replace with the sender's name, date,
    or time */
--- a/src/util.h	Sat Jun 14 23:25:41 2003 +0000
+++ b/src/util.h	Sat Jun 14 23:50:24 2003 +0000
@@ -126,16 +126,6 @@
 char *sec_to_text(guint sec);
 
 /**
- * Finds a gaim_account with the specified name and protocol ID.
- *
- * @param name     The name of the account.
- * @param protocol The protocol type.
- *
- * @return The gaim_account, if found, or @c NULL otherwise.
- */
-GaimAccount *gaim_account_find(const char *name, int protocol);
-
-/**
  * Returns the date and time in human-readable form.
  *
  * The returned string is stored in a static buffer, so the result
@@ -329,7 +319,8 @@
  * @param replacement The substring you want inserted in place 
  *        of the delimiting substring.
  */
-gchar *gaim_strreplace(const gchar *string, const gchar *delimiter, const gchar *replacement);
+gchar *gaim_strreplace(const gchar *string, const gchar *delimiter,
+					   const gchar *replacement);
 
 /**
  * Returns a string representing a filesize in the appropriate units (MB, KB, GB, etc.)