*/
vector<EmailAccountInfo> Messaging::getEmailAccounts() const
{
- email_account_t* accounts = NULL;
- int count = 0;
- Try {
- if (!email_get_account_list(&accounts, &count)) {
- ThrowMsg(WrtDeviceApis::Commons::PlatformException,
- "Couldn't get e-mail accounts.");
- }
+ LogError("enter");
+ email_account_t* accounts = NULL;
+ int count = 0;
+ Try {
+ if (!email_get_account_list(&accounts, &count)) {
+ ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Couldn't get e-mail accounts.");
+ }
- if (0 == count) {
- ThrowMsg(WrtDeviceApis::Commons::PlatformException, "No e-mail account found.");
- }
+ LogError( "count : " << count);
- vector<Api::Messaging::EmailAccountInfo> result;
- for (int i = 0; i < count; ++i) {
- Api::Messaging::EmailAccountInfo account(accounts[i].account_id,
- accounts[i].incoming_server_user_name,
- accounts[i].user_email_address);
- result.push_back(account);
- }
+ if (0 == count) {
+ ThrowMsg(WrtDeviceApis::Commons::PlatformException, "No e-mail account found.");
+ }
- if (accounts != NULL) {
- email_free_account(&accounts, count);
- }
+ vector<Api::Messaging::EmailAccountInfo> result;
+ for (int i = 0; i < count; ++i)
+ {
+ if(accounts[i].incoming_server_user_name != NULL)
+ {
+ LogError("server user name is NULL");
+ Api::Messaging::EmailAccountInfo account(accounts[i].account_id,
+ accounts[i].incoming_server_user_name,
+ accounts[i].user_email_address);
+ result.push_back(account);
+ }
+ else
+ {
+ LogError("normal case");
+ std::string Unknown = "UNKNOWN";
+ Api::Messaging::EmailAccountInfo account(accounts[i].account_id,
+ Unknown,
+ accounts[i].user_email_address);
+ result.push_back(account);
+ }
+ }
- return result;
- }
- Catch(WrtDeviceApis::Commons::PlatformException) {
- if (accounts != NULL) {
- email_free_account(&accounts, count);
- }
- throw;
- }
+ if (accounts != NULL) {
+ email_free_account(&accounts, count);
+ }
+ LogError("end");
+ return result;
+ }
+ Catch(WrtDeviceApis::Commons::PlatformException) {
+ if (accounts != NULL) {
+ email_free_account(&accounts, count);
+ }
+ LogError("PlatformException");
+ ThrowMsg(WrtDeviceApis::Commons::PlatformException, "No e-mail account found.");
+ }
+ Catch(WrtDeviceApis::Commons::UnknownException) {
+ if (accounts != NULL) {
+ email_free_account(&accounts, count);
+ }
+ LogError("UnknownException");
+ ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Couldn't convert e-mail account id");
+ }
}
int Messaging::getEmailAccountId(const std::string& account)