]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/client.c
Implement account login support
[ngircd-alex.git] / src / ngircd / client.c
index cf0720b9942e81631a84fc0900fb259903b8ac99..32690288529499097c0b6d88c1127774202f51bd 100644 (file)
@@ -124,6 +124,8 @@ Client_Exit( void )
        {
                cnt++;
                next = (CLIENT *)c->next;
+               if (c->account_name)
+                       free(c->account_name);
                free( c );
                c = next;
        }
@@ -318,6 +320,8 @@ Client_Destroy( CLIENT *Client, const char *LogMsg, const char *FwdMsg, bool Sen
                                }
                        }
 
+                       if (c->account_name)
+                               free(c->account_name);
                        if (c->cloaked)
                                free(c->cloaked);
                        free( c );
@@ -454,6 +458,21 @@ Client_SetFlags( CLIENT *Client, const char *Flags )
 } /* Client_SetFlags */
 
 
+GLOBAL void
+Client_SetAccountName(CLIENT *Client, const char *AccountName)
+{
+       assert(Client != NULL);
+
+       if (Client->account_name)
+               free(Client->account_name);
+
+       if (*AccountName)
+               Client->account_name = strdup(AccountName);
+       else
+               Client->account_name = NULL;
+}
+
+
 GLOBAL void
 Client_SetAway( CLIENT *Client, const char *Txt )
 {
@@ -973,6 +992,14 @@ Client_Away( CLIENT *Client )
 } /* Client_Away */
 
 
+GLOBAL char *
+Client_AccountName(CLIENT *Client)
+{
+       assert(Client != NULL);
+       return Client->account_name;
+}
+
+
 /**
  * Make sure that a given nickname is valid.
  *
@@ -1611,6 +1638,14 @@ Client_Announce(CLIENT * Client, CLIENT * Prefix, CLIENT * User)
                                return DISCONNECTED;
                }
 
+               if (Client_AccountName(User)) {
+                       if (!IRC_WriteStrClientPrefix(Client, Prefix,
+                                       "METADATA %s accountname :%s",
+                                       Client_ID(User),
+                                       Client_AccountName(User)))
+                               return DISCONNECTED;
+               }
+
                if (Conn_GetCertFp(Client_Conn(User))) {
                        if (!IRC_WriteStrClientPrefix(Client, Prefix,
                                        "METADATA %s certfp :%s",