changeset 6239:8d10cdfe1bb1

[gaim-migrate @ 6733] Added some API stuff for setting an account's public IP, which will be used for file transfer and stuff. I won't be doing much with this until after my vacation. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Sun, 20 Jul 2003 03:05:58 +0000
parents 6173354a64dc
children ac191233b816
files src/account.c src/account.h
diffstat 2 files changed, 66 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/src/account.c	Sat Jul 19 20:57:58 2003 +0000
+++ b/src/account.c	Sun Jul 20 03:05:58 2003 +0000
@@ -37,6 +37,7 @@
 	TAG_ALIAS,
 	TAG_USERINFO,
 	TAG_BUDDYICON,
+	TAG_PUBLIC_IP,
 	TAG_SETTING,
 	TAG_TYPE,
 	TAG_HOST,
@@ -333,6 +334,19 @@
 }
 
 void
+gaim_account_set_public_ip(GaimAccount *account, const char *ip)
+{
+	g_return_if_fail(account != NULL);
+
+	if (account->ip != NULL)
+		g_free(account->ip);
+
+	account->ip = (ip == NULL ? NULL : g_strdup(ip));
+
+	schedule_accounts_save();
+}
+
+void
 gaim_account_set_proxy_info(GaimAccount *account, GaimProxyInfo *info)
 {
 	g_return_if_fail(account != NULL);
@@ -600,6 +614,14 @@
 	return gaim_account_get_ui_bool(account, ui, "auto-login", FALSE);
 }
 
+const char *
+gaim_account_get_public_ip(const GaimAccount *account)
+{
+	g_return_val_if_fail(account != NULL, NULL);
+
+	return account->ip;
+}
+
 GaimProxyInfo *
 gaim_account_get_proxy_info(const GaimAccount *account)
 {
@@ -788,6 +810,8 @@
 		data->tag = TAG_USERINFO;
 	else if (!strcmp(element_name, "buddyicon"))
 		data->tag = TAG_BUDDYICON;
+	else if (!strcmp(element_name, "public-ip"))
+		data->tag = TAG_PUBLIC_IP;
 	else if (!strcmp(element_name, "proxy")) {
 		data->in_proxy = TRUE;
 
@@ -876,6 +900,10 @@
 		if (*buffer != '\0')
 			gaim_account_set_buddy_icon(data->account, buffer);
 	}
+	else if (data->tag == TAG_PUBLIC_IP) {
+		if (*buffer != '\0')
+			gaim_account_set_public_ip(data->account, buffer);
+	}
 	else if (data->tag == TAG_TYPE) {
 		if (data->in_proxy) {
 			if (!strcmp(buffer, "global"))
@@ -1080,7 +1108,7 @@
 {
 	GaimProxyInfo *proxy_info;
 	GaimProxyType proxy_type;
-	const char *password, *alias, *user_info, *buddy_icon;
+	const char *password, *alias, *user_info, *buddy_icon, *ip;
 	char *esc;
 
 	fprintf(fp, " <account>\n");
@@ -1114,6 +1142,10 @@
 		g_free(esc);
 	}
 
+	if ((ip = gaim_account_get_public_ip(account)) != NULL) {
+		fprintf(fp, "  <public-ip>%s</public-ip>\n", ip);
+	}
+
 	fprintf(fp, "  <settings>\n");
 	g_hash_table_foreach(account->settings, write_setting, fp);
 	fprintf(fp, "  </settings>\n");
--- a/src/account.h	Sat Jul 19 20:57:58 2003 +0000
+++ b/src/account.h	Sun Jul 20 03:05:58 2003 +0000
@@ -39,27 +39,28 @@
 
 struct _GaimAccount
 {
-	char *username;             /**< The username.               */
-	char *alias;                /**< The current alias.          */
-	char *password;             /**< The account password.       */
-	char *user_info;            /**< User information.           */
+	char *username;             /**< The username.                 */
+	char *alias;                /**< The current alias.            */
+	char *password;             /**< The account password.         */
+	char *user_info;            /**< User information.             */
 
-	char *buddy_icon;           /**< The buddy icon.             */
+	char *buddy_icon;           /**< The buddy icon.               */
 
-	gboolean remember_pass;     /**< Remember the password.      */
+	gboolean remember_pass;     /**< Remember the password.        */
 
-	char *protocol_id;          /**< The ID of the protocol.     */
+	char *protocol_id;          /**< The ID of the protocol.       */
 
-	GaimConnection *gc;         /**< The connection handle.      */
+	GaimConnection *gc;         /**< The connection handle.        */
 
-	GHashTable *settings;       /**< Protocol-specific settings. */
-	GHashTable *ui_settings;    /**< UI-specific settings.       */
+	GHashTable *settings;       /**< Protocol-specific settings.   */
+	GHashTable *ui_settings;    /**< UI-specific settings.         */
 
-	GaimProxyInfo *proxy_info;  /**< Proxy information.          */
+	char *ip;                   /**< The IP address for transfers. */
+	GaimProxyInfo *proxy_info;  /**< Proxy information.            */
 
-	GSList *permit;             /**< Permit list.                */
-	GSList *deny;               /**< Deny list.                  */
-	int perm_deny;              /**< The permit/deny setting.    */
+	GSList *permit;             /**< Permit list.                  */
+	GSList *deny;               /**< Deny list.                    */
+	int perm_deny;              /**< The permit/deny setting.      */
 };
 
 #ifdef __cplusplus
@@ -197,6 +198,15 @@
 								 gboolean value);
 
 /**
+ * Sets the public IP address the account will use for such things
+ * as file transfer.
+ *
+ * @param account The account.
+ * @param ip      The IP address.
+ */
+void gaim_account_set_public_ip(GaimAccount *account, const char *ip);
+
+/**
  * Sets the account's proxy information.
  * 
  * @param account The account.
@@ -385,6 +395,15 @@
 									 const char *ui);
 
 /**
+ * Returns the account's public IP address.
+ *
+ * @param account The account.
+ *
+ * @return The IP address.
+ */
+const char *gaim_account_get_public_ip(const GaimAccount *account);
+
+/**
  * Returns the account's proxy information.
  *
  * @param account The account.