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
ee09fc14
Commit
ee09fc14
authored
Mar 29, 2006
by
yanmorin
Browse files
First Account-based save/load implementation
parent
2c74a005
Changes
9
Hide whitespace changes
Inline
Side-by-side
src/account.cpp
View file @
ee09fc14
...
...
@@ -32,5 +32,3 @@ Account::~Account()
{
delete
_link
;
_link
=
0
;
}
src/account.h
View file @
ee09fc14
...
...
@@ -20,10 +20,14 @@
#define ACCOUNT_H
#include
<string>
#include
"config/config.h"
class
VoIPLink
;
typedef
std
::
string
AccountID
;
#define AccountNULL ""
#define CONFIG_ACCOUNT_TYPE "Account.type"
#define CONFIG_ACCOUNT_ENABLE "Account.enable"
/**
@author Yan Morin
...
...
@@ -37,6 +41,11 @@ public:
~
Account
();
/**
* Load the default properties for the account
*/
virtual
void
initConfig
(
Conf
::
ConfigTree
&
config
)
=
0
;
/**
* Register the account
* @return false is an error occurs
...
...
@@ -69,10 +78,6 @@ private:
*/
virtual
bool
createVoIPLink
()
=
0
;
/**
* Account ID are assign in constructor and shall not changed
*/
AccountID
_accountID
;
/**
* Voice over IP Link contains a listener thread and calls
*/
...
...
@@ -95,6 +100,13 @@ private:
* Modified by unregister/register
*/
bool
_registered
;
protected:
/**
* Account ID are assign in constructor and shall not changed
*/
AccountID
_accountID
;
};
#endif
src/aixaccount.cpp
View file @
ee09fc14
...
...
@@ -59,4 +59,16 @@ AIXAccount::terminate()
return
false
;
}
void
AIXAccount
::
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_TYPE
,
"AIX"
,
type_str
));
config
.
addConfigTreeItem
(
section
,
Conf
::
ConfigTreeItem
(
CONFIG_ACCOUNT_ENABLE
,
"1"
,
type_int
));
config
.
addConfigTreeItem
(
section
,
Conf
::
ConfigTreeItem
(
"AIX.Proxy"
,
""
,
type_str
));
}
src/aixaccount.h
View file @
ee09fc14
...
...
@@ -33,6 +33,7 @@ public:
~
AIXAccount
();
/* virtual Account function implementation */
void
initConfig
(
Conf
::
ConfigTree
&
config
);
bool
registerAccount
();
bool
unregisterAccount
();
bool
init
();
...
...
src/managerimpl.cpp
View file @
ee09fc14
...
...
@@ -89,6 +89,16 @@ ManagerImpl::ManagerImpl (void)
_hasTriedToRegister
=
false
;
// initialize random generator for call id
srand
(
time
(
NULL
));
#ifdef TEST
testAccountMap
();
loadAccountMap
();
testCallAccountMap
();
unloadAccountMap
();
#endif
// should be call before initConfigFile
loadAccountMap
();
}
// never call if we use only the singleton...
...
...
@@ -106,12 +116,6 @@ ManagerImpl::~ManagerImpl (void)
void
ManagerImpl
::
init
()
{
#ifdef TEST
testAccountMap
();
loadAccountMap
();
testCallAccountMap
();
unloadAccountMap
();
#endif
initVolume
();
if
(
_exist
==
0
)
{
...
...
@@ -157,7 +161,6 @@ ManagerImpl::init()
// Set a sip voip link by default
_voIPLinkVector
.
push_back
(
new
SipVoIPLink
());
loadAccountMap
();
// initRegisterVoIP was here, but we doing it after the gui loaded...
// the stun detection is long, so it's a better idea to do it after getEvents
initZeroconf
();
...
...
@@ -1270,6 +1273,8 @@ ManagerImpl::initConfigFile (void)
fill_config_str
(
VOICEMAIL_NUM
,
DFT_VOICEMAIL
);
fill_config_int
(
CONFIG_ZEROCONF
,
CONFIG_ZEROCONF_DEFAULT_STR
);
initConfigAccount
();
_exist
=
createSettingsPath
();
_setupLoaded
=
(
_exist
==
2
)
?
false
:
true
;
}
...
...
@@ -1839,22 +1844,15 @@ ManagerImpl::getNewCallID()
return
random_id
;
}
AccountMap
_accountMap
;
short
ManagerImpl
::
loadAccountMap
()
{
short
nbAccount
=
0
;
AccountID
accID
=
"acc0"
;
_accountMap
[
accID
]
=
AccountCreator
::
createAccount
(
AccountCreator
::
SIP_ACCOUNT
,
accID
);
_accountMap
[
ACCOUNT_SIP0
]
=
AccountCreator
::
createAccount
(
AccountCreator
::
SIP_ACCOUNT
,
ACCOUNT_SIP0
);
nbAccount
++
;
accID
=
"acc1"
;
_accountMap
[
accID
]
=
AccountCreator
::
createAccount
(
AccountCreator
::
AIX_ACCOUNT
,
accID
);
_accountMap
[
ACCOUNT_AIX0
]
=
AccountCreator
::
createAccount
(
AccountCreator
::
AIX_ACCOUNT
,
ACCOUNT_AIX0
);
nbAccount
++
;
return
nbAccount
;
...
...
@@ -1891,6 +1889,17 @@ ManagerImpl::getAccount(AccountID accountID)
return
iter
->
second
;
}
void
ManagerImpl
::
initConfigAccount
()
{
AccountMap
::
iterator
iter
=
_accountMap
.
begin
();
while
(
iter
!=
_accountMap
.
end
()
)
{
if
(
iter
!=
0
&&
iter
->
second
!=
0
)
{
iter
->
second
->
initConfig
(
_config
);
}
iter
++
;
}
}
#ifdef TEST
/**
* Test accountMap
...
...
src/managerimpl.h
View file @
ee09fc14
...
...
@@ -486,6 +486,12 @@ private:
*/
Account
*
getAccount
(
AccountID
accountID
);
/**
* load default account variable for each protocol
*/
void
initConfigAccount
();
#ifdef TEST
bool
testCallAccountMap
();
bool
testAccountMap
();
...
...
src/sipaccount.cpp
View file @
ee09fc14
...
...
@@ -17,6 +17,16 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include
"sipaccount.h"
#define SIP_FULL_NAME "SIP.fullName"
#define SIP_USER_PART "SIP.userPart"
#define SIP_AUTH_USER_NAME "SIP.username"
#define SIP_PASSWORD "SIP.password"
#define SIP_HOST_PART "SIP.hostPart"
#define SIP_PROXY "SIP.proxy"
#define SIP_AUTO_REGISTER "SIP.autoregister"
#define SIP_STUN_SERVER "STUN.STUNserver"
#define SIP_USE_STUN "STUN.useStun"
SIPAccount
::
SIPAccount
(
const
AccountID
&
accountID
)
:
Account
(
accountID
)
...
...
@@ -59,3 +69,21 @@ SIPAccount::terminate()
return
false
;
}
void
SIPAccount
::
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_TYPE
,
"SIP"
,
type_str
));
config
.
addConfigTreeItem
(
section
,
Conf
::
ConfigTreeItem
(
CONFIG_ACCOUNT_ENABLE
,
"1"
,
type_int
));
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_AUTH_USER_NAME
,
""
,
type_str
));
config
.
addConfigTreeItem
(
section
,
Conf
::
ConfigTreeItem
(
SIP_PROXY
,
""
,
type_str
));
config
.
addConfigTreeItem
(
section
,
Conf
::
ConfigTreeItem
(
SIP_AUTO_REGISTER
,
"1"
,
type_int
));
config
.
addConfigTreeItem
(
section
,
Conf
::
ConfigTreeItem
(
SIP_STUN_SERVER
,
"stun.fwdnet.net:3478"
,
type_str
));
config
.
addConfigTreeItem
(
section
,
Conf
::
ConfigTreeItem
(
SIP_USE_STUN
,
"0"
,
type_int
));
}
src/sipaccount.h
View file @
ee09fc14
...
...
@@ -33,6 +33,7 @@ public:
~
SIPAccount
();
/* virtual Account function implementation */
void
initConfig
(
Conf
::
ConfigTree
&
config
);
bool
registerAccount
();
bool
unregisterAccount
();
bool
init
();
...
...
src/user_cfg.h
View file @
ee09fc14
...
...
@@ -37,6 +37,10 @@
#define NETWORK "Network"
#define PREFERENCES "Preferences"
#define ACCOUNT_SIP0 "SIP0"
#define ACCOUNT_AIX0 "AIX0"
// Fields to fill
#define VOIP_LINK_ID "VoIPLink.index"
#define SYMMETRIC "VoIPLink.symmetric"
...
...
Write
Preview
Supports
Markdown
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