accountlist.h 3.79 KB
Newer Older
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
1
2
/*
 *  Copyright (C) 2007 Savoir-Faire Linux inc.
3
 *  Author: Pierre-Luc Beaudoin <pierre-luc@squidy.info>
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 *                                                                              
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *                                                                                
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *                                                                              
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
#ifndef __ACCOUNTLIST_H__
#define __ACCOUNTLIST_H__

#include <gtk/gtk.h>
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
24
25
26
/** @file accountlist.h
  * @brief A list to hold accounts.
  */
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
27
28
29
30

#define ACCOUNT_TYPE               "Account.type"
#define ACCOUNT_ALIAS              "Account.alias"
#define ACCOUNT_ENABLED            "Account.enable"
31
//#define ACCOUNT_REGISTER           "Account.autoregister"
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
32
33

#define ACCOUNT_SIP_FULL_NAME      "SIP.fullName"
34
#define ACCOUNT_SIP_HOST_PART      "SIP.hostPart"
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
35
36
37
38
39
#define ACCOUNT_SIP_USER_PART      "SIP.userPart"
#define ACCOUNT_SIP_AUTH_NAME      "SIP.username"
#define ACCOUNT_SIP_PASSWORD       "SIP.password"
#define ACCOUNT_SIP_PROXY          "SIP.proxy"

40
41
42
43
#define ACCOUNT_IAX_FULL_NAME      "IAX.fullName"
#define ACCOUNT_IAX_HOST           "IAX.host"
#define ACCOUNT_IAX_USER           "IAX.user"
#define ACCOUNT_IAX_PASS           "IAX.pass"
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
44

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
45
46
47
/** @enum account_state_t 
  * This enum have all the states an account can take.
  */
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
48
49
50
51
typedef enum
{
   ACCOUNT_STATE_INVALID = 0,
   ACCOUNT_STATE_REGISTERED,   
52
   ACCOUNT_STATE_UNREGISTERED,   
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
53
54
   ACCOUNT_STATE_TRYING, 
   ACCOUNT_STATE_ERROR
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
55
56
} account_state_t;

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
57
58
59
60
61
62
63
64
/** @struct account_t
  * @brief Account information.
  * This struct holds information about an account.  All values are stored in the 
  * properties GHashTable except the accountID and state.  This match how the 
  * server internally works and the dbus API to save and retrieve the accounts details.
  * 
  * To retrieve the Alias for example, use g_hash_table_lookup(a->properties, ACCOUNT_ALIAS).  
  */
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
65
66
typedef struct  {
  gchar * accountID;
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
67
68
  account_state_t state;  
  GHashTable * properties;
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
69
70
} account_t;

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
71
/** This function initialize the account list. */
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
72
73
void account_list_init ();

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
74
/** This function empty and free the account list. */
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
75
76
void account_list_clean ();

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
77
78
/** This function append an account to list. 
  * @param a The account you want to add */
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
79
80
void account_list_add (account_t * a);

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
81
82
83
/** This function remove an account from list. 
  * @param accountID The accountID of the account you want to remove
  */
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
84
85
void account_list_remove (const gchar * accountID);

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
86
87
88
/** Return the first account that corresponds to the state 
  * @param s The state
  * @return An account or NULL */
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
89
90
account_t * account_list_get_by_state ( account_state_t state);

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
91
92
/** Return the number of accounts in the list
  * @return The number of accounts in the list */
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
93
94
guint account_list_get_size ( );

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
95
96
97
/** Return the account at the nth position in the list
  * @param n The position of the account you want
  * @return An account or NULL */
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
98
99
account_t * account_list_get_nth ( guint n );

Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
100
101
102
/** This function maps account_state_t enums to a description.
  * @param s The state
  * @return The full text description of the state */
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
103
const gchar * account_state_name(account_state_t s);
104
105

void account_list_clear ( );
Pierre-Luc Beaudoin's avatar
Pierre-Luc Beaudoin committed
106
#endif