Accounts interfaceRequest

From TrillWiki

Jump to: navigation, search

The accounts_interfaceRequest notification is sent to an account's callback when Trillian needs to know what information to display for an account.

Compatibility: 3.0 and higher

Contents

Syntax

callback(int window_id, char *icontrol, "accounts_interfaceRequest", account_interface_request_t *data, void *userData);

Note that all Trillian functions and notifications begin with a lower-case letter, despite the Wiki requirement that all pages start with a capital letter.

Parameters

Accounts interfaceRequest utilitizes the account_interface_request_t structure.

struct account_interface_request_t 
{ 
    unsigned int                struct_size; 
 
    struct account_entry_t      *account; 
 
    ttkCallback                 callback; 
    void                        *data; 
};



account
The name of the account whose preferences should be displayed. If this is a new account, this will be NULL.
callback
The callback to send interface data to.
data
Data that uniquely identifies this request to Trillian.


Return Value

Return 1. Always.

Remarks

You will want to build a list of account_interface_entry_t structures, and pass it to the callback provided, using the notification 'accounts_interfaceSet' -- Trillian will use the list of interface elements to render a representation of the account. You MUST pass the contents of the 'data' field as well, as the userData portion of the callback. For instance:

 airt->callback(0,0,"accounts_interfaceSet",my_interface_data,airt->data);


Related Structures

account_interface_entry_t

struct account_interface_entry_t
{
    unsigned int                struct_size;

    struct account_entry_t      *account;

    char                        *name;

    char                        *type;
    char                        *description;
    char                        *value;

    struct account_interface_entry_t    *next_entry;
};


name
The name of this interface element. (i.e. variable name), do not leave as null.
type
The type of interface element. These are 'text-static' (for informational text), 'newline' (add a new line, should be used after 'text-static'), 'text-single' (for text input), 'special-controls' (the connect/disconnect/preferences buttons), 'text-single-readonly' (like text-single except contents not editable), 'text-private' (for passwords), 'button' (for a button to be pressed), and 'boolean' (for an on/off checkbox).
value
The default value for this variable.

Example Code

 if (!stricmp(event,"accounts_interfaceRequest")) 
 {
   account_interface_request_t* air = (account_interface_request_t *)data;
   account_interface_entry_t aie0, aie1, aie2, aie3, aie4, aie5, aie6, aie7;
   trillianInitialize(aie0);
   trillianInitialize(aie1);
   trillianInitialize(aie2);
   trillianInitialize(aie4);
   trillianInitialize(aie3);
   trillianInitialize(aie5);
   trillianInitialize(aie6);
   trillianInitialize(aie7);
   
   aie7.name="onstartup";
   aie7.type="boolean";
   aie7.description="Automatically connect to this account on startup";
   
   aie6.name="password";
   aie6.type="text-private";
   aie6.description="password";
   aie6.next_entry=&aie7;
   
   if (air->account->account) {
     aie5.account=air->account;
     aie5.name="username";
     aie5.type="text-single-readonly";
     aie5.description="username@TBBShost[:port]";
     aie5.next_entry=&aie6;
     
     // set the default values for when updating an account
     // aie5.value = "blah";
     // aei6.value = "blah";
     // aie7.value = "blah";
     
     (air->callback)(0,0,"accounts_interfaceSet",&aie5,air->data);
   }
   else
   {
     aie0.name="static1";
     aie0.type="text-static";
     aie0.description="1. If you do not have a TBBS account click this button for a list of systems.";
     aie0.next_entry=&aie1;
     
     aie1.name="blank";
     aie1.type="newline";
     aie1.next_entry=&aie2;
     
     aie2.name="TBBSsystems";
     aie2.type="button";
     aie2.description="Press for a list of TBBS Systems";
     aie2.next_entry=&aie3;
     
     aie3.name="static2";
     aie3.type="text-static";
     aie3.value = "";
     aie3.description="2. Login <username>@<TBBS server address>[:<port>] include port if not port 23.";
     aie3.next_entry=&aie4;
     
     aie4.name="username";
     aie4.type="text-single";
     aie4.value="";
     aie4.description="username@TBBShost[:<port>]";
     aie4.next_entry=&aie5;
     
     aie5.name="special";
     aie5.type="special-controls";
     aie5.next_entry=&aie6;
     
     (air->callback)(window_id,icontrol,"accounts_interfaceSet",&aie0,air->data);
   }
   return 1;
 }
Personal tools