Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
savoirfairelinux
jami-daemon
Commits
9775d1c9
Commit
9775d1c9
authored
Aug 29, 2007
by
Alexandre Bourget
Browse files
Centralize account information to account.cpp/h, config file info gathering.
parent
b1718213
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/account.cpp
View file @
9775d1c9
...
...
@@ -18,10 +18,11 @@
*/
#include "account.h"
#include "voIPLink.h"
#include "manager.h"
Account
::
Account
(
const
AccountID
&
accountID
)
:
_accountID
(
accountID
)
{
_link
=
0
;
_link
=
NULL
;
_shouldInitOnStart
=
false
;
_shouldRegisterOnStart
=
false
;
...
...
@@ -33,5 +34,27 @@ Account::Account(const AccountID& accountID) : _accountID(accountID)
Account
::~
Account
()
{
delete
_link
;
_link
=
0
;
delete
_link
;
_link
=
NULL
;
}
void
Account
::
initConfig
(
Conf
::
ConfigTree
&
config
)
{
std
::
string
section
(
_accountID
);
std
::
string
type_str
(
"string"
);
std
::
string
type_int
(
"int"
);
config
.
addConfigTreeItem
(
section
,
Conf
::
ConfigTreeItem
(
CONFIG_ACCOUNT_ENABLE
,
"1"
,
type_int
));
config
.
addConfigTreeItem
(
section
,
Conf
::
ConfigTreeItem
(
CONFIG_ACCOUNT_AUTO_REGISTER
,
"1"
,
type_int
));
config
.
addConfigTreeItem
(
section
,
Conf
::
ConfigTreeItem
(
CONFIG_ACCOUNT_ALIAS
,
_
(
"My account"
),
type_str
));
}
void
Account
::
loadConfig
()
{
_shouldInitOnStart
=
Manager
::
instance
().
getConfigInt
(
_accountID
,
CONFIG_ACCOUNT_ENABLE
)
?
true
:
false
;
_shouldRegisterOnStart
=
Manager
::
instance
().
getConfigInt
(
_accountID
,
CONFIG_ACCOUNT_AUTO_REGISTER
)
?
true
:
false
;
}
src/account.h
View file @
9775d1c9
/*
* Copyright (C) 2006 Savoir-Faire Linux inc.
* Copyright (C) 2006
-2007
Savoir-Faire Linux inc.
* Author: Yan Morin <yan.morin@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -32,13 +32,13 @@ typedef std::string AccountID;
#define CONFIG_ACCOUNT_ALIAS "Account.alias"
/**
* Class account is an interface to protocol account (
sipa
ccount,
aixa
ccount)
* Class account is an interface to protocol account (
SIPA
ccount,
IAXA
ccount)
* It can be enable on loading or activate after.
* It contains account, configuration, VoIP Link and Calls (inside the VoIPLink)
* @author Yan Morin
*/
class
Account
{
public:
public:
Account
(
const
AccountID
&
accountID
);
virtual
~
Account
();
...
...
@@ -46,8 +46,12 @@ public:
/**
* Load the default properties for the account
*/
virtual
void
initConfig
(
Conf
::
ConfigTree
&
config
)
=
0
;
virtual
void
loadConfig
()
=
0
;
virtual
void
initConfig
(
Conf
::
ConfigTree
&
config
);
/**
* Load the settings for this account.
*/
virtual
void
loadConfig
();
/**
* Get the account ID
...
...
@@ -128,13 +132,13 @@ protected:
/**
* Tells if the link should be start on loading or not
* Modified by the configuration
* Modified by the configuration
(key: ENABLED)
*/
bool
_shouldInitOnStart
;
/**
* Tells if we should register automatically on startup
* Modified by the configuration
* Modified by the configuration
(key: AUTO-REGISTER)
*/
bool
_shouldRegisterOnStart
;
...
...
src/iaxaccount.cpp
View file @
9775d1c9
...
...
@@ -17,6 +17,7 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "iaxaccount.h"
#include "account.h"
#include "iaxvoiplink.h"
#include "manager.h"
...
...
@@ -99,12 +100,12 @@ IAXAccount::initConfig(Conf::ConfigTree& config)
std
::
string
section
(
_accountID
);
std
::
string
type_str
(
"string"
);
std
::
string
type_int
(
"int"
);
// Account generic
Account
::
initConfig
(
config
);
// IAX specific
config
.
addConfigTreeItem
(
section
,
Conf
::
ConfigTreeItem
(
CONFIG_ACCOUNT_TYPE
,
"IAX"
,
type_str
));
config
.
addConfigTreeItem
(
section
,
Conf
::
ConfigTreeItem
(
CONFIG_ACCOUNT_ENABLE
,
"1"
,
type_int
));
config
.
addConfigTreeItem
(
section
,
Conf
::
ConfigTreeItem
(
CONFIG_ACCOUNT_AUTO_REGISTER
,
"1"
,
type_int
));
config
.
addConfigTreeItem
(
section
,
Conf
::
ConfigTreeItem
(
CONFIG_ACCOUNT_ALIAS
,
_
(
"My account"
),
type_str
));
config
.
addConfigTreeItem
(
section
,
Conf
::
ConfigTreeItem
(
IAX_HOST
,
""
,
type_str
));
config
.
addConfigTreeItem
(
section
,
Conf
::
ConfigTreeItem
(
IAX_USER
,
""
,
type_str
));
config
.
addConfigTreeItem
(
section
,
Conf
::
ConfigTreeItem
(
IAX_PASS
,
""
,
type_str
));
...
...
@@ -113,6 +114,9 @@ IAXAccount::initConfig(Conf::ConfigTree& config)
void
IAXAccount
::
loadConfig
()
{
_shouldInitOnStart
=
Manager
::
instance
().
getConfigInt
(
_accountID
,
CONFIG_ACCOUNT_ENABLE
)
?
true
:
false
;
_shouldRegisterOnStart
=
Manager
::
instance
().
getConfigInt
(
_accountID
,
CONFIG_ACCOUNT_AUTO_REGISTER
)
?
true
:
false
;
// Account generic
Account
::
loadConfig
();
// IAX specific
//none
}
src/sipaccount.cpp
View file @
9775d1c9
...
...
@@ -115,11 +115,12 @@ SIPAccount::initConfig(Conf::ConfigTree& config)
std
::
string
section
(
_accountID
);
std
::
string
type_str
(
"string"
);
std
::
string
type_int
(
"int"
);
// Account generic
Account
::
initConfig
(
config
);
// SIP specific
config
.
addConfigTreeItem
(
section
,
Conf
::
ConfigTreeItem
(
CONFIG_ACCOUNT_TYPE
,
"SIP"
,
type_str
));
config
.
addConfigTreeItem
(
section
,
Conf
::
ConfigTreeItem
(
CONFIG_ACCOUNT_ENABLE
,
"1"
,
type_int
));
config
.
addConfigTreeItem
(
section
,
Conf
::
ConfigTreeItem
(
CONFIG_ACCOUNT_AUTO_REGISTER
,
"1"
,
type_int
));
config
.
addConfigTreeItem
(
section
,
Conf
::
ConfigTreeItem
(
CONFIG_ACCOUNT_ALIAS
,
_
(
"My account"
),
type_str
));
config
.
addConfigTreeItem
(
section
,
Conf
::
ConfigTreeItem
(
SIP_FULL_NAME
,
""
,
type_str
));
config
.
addConfigTreeItem
(
section
,
Conf
::
ConfigTreeItem
(
SIP_USER_PART
,
""
,
type_str
));
config
.
addConfigTreeItem
(
section
,
Conf
::
ConfigTreeItem
(
SIP_HOST_PART
,
""
,
type_str
));
...
...
@@ -133,6 +134,9 @@ SIPAccount::initConfig(Conf::ConfigTree& config)
void
SIPAccount
::
loadConfig
()
{
_shouldInitOnStart
=
Manager
::
instance
().
getConfigInt
(
_accountID
,
CONFIG_ACCOUNT_ENABLE
)
?
true
:
false
;
_shouldRegisterOnStart
=
Manager
::
instance
().
getConfigInt
(
_accountID
,
CONFIG_ACCOUNT_AUTO_REGISTER
)
?
true
:
false
;
// Account generic
Account
::
loadConfig
();
// SIP specific
//none
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment