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
c7b30f5a
Commit
c7b30f5a
authored
Oct 02, 2007
by
Alexandre Bourget
Browse files
Correct support for add/remove Accounts.
parent
1093d618
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/dbus/configurationmanager.cpp
View file @
c7b30f5a
...
...
@@ -50,9 +50,7 @@ void
ConfigurationManager
::
addAccount
(
const
std
::
map
<
::
DBus
::
String
,
::
DBus
::
String
>&
details
)
{
_debug
(
"ConfigurationManager::addAccount received
\n
"
);
std
::
stringstream
accountID
;
accountID
<<
"Account:"
<<
time
(
NULL
);
Manager
::
instance
().
setAccountDetails
(
accountID
.
str
(),
details
);
Manager
::
instance
().
addAccount
(
details
);
}
...
...
src/managerimpl.cpp
View file @
c7b30f5a
...
...
@@ -1684,7 +1684,7 @@ ManagerImpl::setAccountDetails( const ::DBus::String& accountID,
const
std
::
map
<
::
DBus
::
String
,
::
DBus
::
String
>&
details
)
{
std
::
string
accountType
=
(
*
details
.
find
(
CONFIG_ACCOUNT_TYPE
)).
second
;
setConfig
(
accountID
,
CONFIG_ACCOUNT_ALIAS
,
(
*
details
.
find
(
CONFIG_ACCOUNT_ALIAS
)).
second
);
//setConfig(accountID, CONFIG_ACCOUNT_AUTO_REGISTER,
// (*details.find(CONFIG_ACCOUNT_AUTO_REGISTER)).second == "TRUE" ? "1": "0" );
...
...
@@ -1717,10 +1717,57 @@ ManagerImpl::setAccountDetails( const ::DBus::String& accountID,
if
(
_dbus
)
_dbus
->
getConfigurationManager
()
->
accountsChanged
();
}
void
ManagerImpl
::
addAccount
(
const
std
::
map
<
::
DBus
::
String
,
::
DBus
::
String
>&
details
)
{
/** @todo Deal with both the _accountMap and the Configuration */
std
::
string
accountType
=
(
*
details
.
find
(
CONFIG_ACCOUNT_TYPE
)).
second
;
Account
*
newAccount
;
std
::
stringstream
accountID
;
accountID
<<
"Account:"
<<
time
(
NULL
);
AccountID
newAccountID
=
accountID
.
str
();
/** @todo Verify the uniqueness, in case a program adds accounts, two in a row. */
setAccountDetails
(
accountID
.
str
(),
details
);
saveConfig
();
if
(
accountType
==
"SIP"
)
{
newAccount
=
AccountCreator
::
createAccount
(
AccountCreator
::
SIP_ACCOUNT
,
newAccountID
);
}
else
if
(
accountType
==
"IAX"
)
{
newAccount
=
AccountCreator
::
createAccount
(
AccountCreator
::
IAX_ACCOUNT
,
newAccountID
);
}
else
{
_debug
(
"Unknown %s param when calling addAccount(): %s
\n
"
,
CONFIG_ACCOUNT_TYPE
,
accountType
.
c_str
());
return
;
}
_accountMap
[
newAccountID
]
=
newAccount
;
// Get it up and running...
newAccount
->
loadConfig
();
if
(
newAccount
->
isEnabled
())
{
if
(
newAccount
->
init
())
{
newAccount
->
registerVoIPLink
();
}
}
}
void
ManagerImpl
::
removeAccount
(
const
AccountID
&
accountID
)
{
// Get it down and dying
Account
*
remAccount
=
getAccount
(
accountID
);
if
(
remAccount
)
{
remAccount
->
unregisterVoIPLink
();
_accountMap
.
erase
(
accountID
);
delete
remAccount
;
}
_config
.
removeSection
(
accountID
);
saveConfig
();
}
...
...
src/managerimpl.h
View file @
c7b30f5a
...
...
@@ -220,15 +220,35 @@ public:
bool
attachZeroconfEvents
(
const
std
::
string
&
sequenceId
,
Pattern
::
Observer
&
observer
);
bool
detachZeroconfEvents
(
Pattern
::
Observer
&
observer
);
bool
getCallStatus
(
const
std
::
string
&
sequenceId
);
/**
* Get account list
* @return A list of accoundIDs
*/
std
::
vector
<
std
::
string
>
getAccountList
();
/**
* Retrieve details about a given account
*/
std
::
map
<
std
::
string
,
std
::
string
>
getAccountDetails
(
const
AccountID
&
accountID
);
/**
* Save the details of an existing account, given the account ID
*/
void
setAccountDetails
(
const
::
DBus
::
String
&
accountID
,
const
std
::
map
<
::
DBus
::
String
,
::
DBus
::
String
>&
details
);
/**
* Add a new account, and give it a new account ID automatically
*/
void
addAccount
(
const
std
::
map
<
::
DBus
::
String
,
::
DBus
::
String
>&
details
);
/**
* Delete an existing account, unregister VoIPLink associated, and
* purge from configuration.
*/
void
removeAccount
(
const
AccountID
&
accountID
);
bool
getConfigAll
(
const
std
::
string
&
sequenceId
);
bool
getConfig
(
const
std
::
string
&
section
,
const
std
::
string
&
name
,
TokenList
&
arg
);
bool
setConfig
(
const
std
::
string
&
section
,
const
std
::
string
&
name
,
const
std
::
string
&
value
);
...
...
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