--- a/libpurple/account.c Wed Nov 16 22:37:33 2022 -0600
+++ b/libpurple/account.c Wed Nov 16 23:43:30 2022 -0600
@@ -93,6 +93,8 @@
PurpleConnectionErrorInfo *current_error; /* Errors */
PurpleNotification *error_notification;
+ PurpleContact *contact; @@ -118,6 +120,7 @@
@@ -761,6 +764,21 @@
g_checksum_free(checksum);
+ /* Create the contact for the account and bind our properties to it. */ + account->contact = purple_contact_new(account, NULL); + /* Skip id for now as it's construct only and exposing it is more work than + * it's worth right now. + g_object_bind_property(account, "id", account->contact, "id", + G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); + g_object_bind_property(account, "username", account->contact, "username", + G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); + g_object_bind_property(account, "private-alias", + account->contact, "display-name", + G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); "protocol-id", &protocol_id,
@@ -805,6 +823,7 @@
g_clear_object(&account->gc);
g_clear_object(&account->presence);
+ g_clear_object(&account->contact); G_OBJECT_CLASS(purple_account_parent_class)->dispose(object);
@@ -857,11 +876,9 @@
GObjectClass *obj_class = G_OBJECT_CLASS(klass);
+ obj_class->constructed = purple_account_constructed; obj_class->dispose = purple_account_dispose;
obj_class->finalize = purple_account_finalize;
- obj_class->constructed = purple_account_constructed;
obj_class->get_property = purple_account_get_property;
obj_class->set_property = purple_account_set_property;
@@ -952,6 +969,19 @@
PURPLE_TYPE_CONNECTION_ERROR_INFO,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+ * PurpleAccount:contact: + * The [class@Purple.Contact] that represents this account. + properties[PROP_CONTACT] = g_param_spec_object( + "The contact for this account", + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); g_object_class_install_properties(obj_class, PROP_LAST, properties);
@@ -2299,3 +2329,10 @@
return account->require_password;
+purple_account_get_contact(PurpleAccount *account) { + g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL); + return account->contact; --- a/libpurple/account.h Wed Nov 16 22:37:33 2022 -0600
+++ b/libpurple/account.h Wed Nov 16 23:43:30 2022 -0600
@@ -39,6 +39,7 @@
#include "purpleconnectionerrorinfo.h"
+#include "purplecontact.h" #include "purpleprotocol.h"
#include "purpleproxyinfo.h"
@@ -947,6 +948,22 @@
gboolean purple_account_get_require_password(PurpleAccount *account);
+ * purple_account_get_contact: + * @account: The instance. + * Gets the [class@Purple.Contact] for @account that represents the user of + * This can be used by protocol plugins to store additional information about + * Returns: (transfer none): The contact that represents @account. +PurpleContact *purple_account_get_contact(PurpleAccount *account); #endif /* PURPLE_ACCOUNT_H */
--- a/libpurple/purplecontact.c Wed Nov 16 22:37:33 2022 -0600
+++ b/libpurple/purplecontact.c Wed Nov 16 23:43:30 2022 -0600
@@ -72,21 +72,6 @@
-purple_contact_set_id(PurpleContact *contact, const gchar *id) {
- g_return_if_fail(PURPLE_IS_CONTACT(contact));
- contact->id = g_strdup(id);
- contact->id = g_uuid_string_random();
- g_object_notify_by_pspec(G_OBJECT(contact), properties[PROP_ID]);
/******************************************************************************
*****************************************************************************/
@@ -234,7 +219,7 @@
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); @@ -389,6 +374,16 @@
+purple_contact_set_id(PurpleContact *contact, const gchar *id) { + g_return_if_fail(PURPLE_IS_CONTACT(contact)); + contact->id = g_strdup(id); + g_object_notify_by_pspec(G_OBJECT(contact), properties[PROP_ID]); purple_contact_get_username(PurpleContact *contact) {
g_return_val_if_fail(PURPLE_IS_CONTACT(contact), NULL);
--- a/libpurple/purplecontact.h Wed Nov 16 22:37:33 2022 -0600
+++ b/libpurple/purplecontact.h Wed Nov 16 23:43:30 2022 -0600
@@ -28,7 +28,6 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
-#include <libpurple/account.h>
#include <libpurple/purplepresence.h>
#include <libpurple/purpletags.h>
@@ -56,6 +55,7 @@
PURPLE_CONTACT_PERMISSION_DENY,
} PurpleContactPermission;
+#include <libpurple/account.h> #include <libpurple/purpleperson.h>
@@ -109,6 +109,20 @@
const gchar *purple_contact_get_id(PurpleContact *contact);
+ * purple_contact_set_id: + * @contact: The instance. + * @id: The new identifier. + * Sets the identifier of @contact to @id. Note, this should be used rarely if + * at all. The main intent of this, is for protocols to update the id of + * [property@Purple.Account:contact] when an account is connected if it is +void purple_contact_set_id(PurpleContact *contact, const char *id); * purple_contact_get_username:
* @contact: The instance.