From 7f2aa8d6f145f46c57fdaab00c4e6af0961d245d Mon Sep 17 00:00:00 2001
From: yanmorin <yanmorin>
Date: Wed, 12 Jul 2006 21:39:42 +0000
Subject: [PATCH] Add first getaccount event handling in daemon and qt Need to
 send the message in qt

---
 src/account.h                       | 11 +++++++
 src/eventthread.cpp                 |  4 +--
 src/gui/guiframework.cpp            |  5 +++
 src/gui/guiframework.h              |  1 +
 src/gui/qt/CallStatus.cpp           |  2 +-
 src/gui/qt/CallStatus.hpp           |  2 +-
 src/gui/qt/Event.hpp                |  3 ++
 src/gui/qt/EventAccount.cpp         | 50 +++++++++++++++++++++++++++++
 src/gui/qt/EventAccount.hpp         | 40 +++++++++++++++++++++++
 src/gui/qt/Makefile.am              |  2 ++
 src/gui/qt/PhoneLine.cpp            | 19 +++++------
 src/gui/qt/PhoneLine.hpp            |  3 --
 src/gui/qt/PhoneLineManagerImpl.cpp | 10 +++---
 src/gui/qt/PhoneLineManagerImpl.hpp |  1 -
 src/gui/qt/SFLPhoneApp.cpp          |  1 +
 src/gui/qt/SFLRequest.cpp           | 33 ++++++++++++++++++-
 src/gui/qt/SFLRequest.hpp           | 34 ++++++++++++++++++++
 src/gui/qt/Session.cpp              | 35 ++++++++++++++++++--
 src/gui/qt/Session.hpp              | 23 +++++++++++++
 src/gui/server/requestconfig.cpp    | 15 +++++++++
 src/gui/server/requestconfig.h      |  5 +++
 src/gui/server/requestfactory.cpp   |  1 +
 src/managerimpl.cpp                 | 24 ++++++++++++++
 src/managerimpl.h                   |  7 ++++
 24 files changed, 306 insertions(+), 25 deletions(-)
 create mode 100644 src/gui/qt/EventAccount.cpp
 create mode 100644 src/gui/qt/EventAccount.hpp

diff --git a/src/account.h b/src/account.h
index 40586b5093..0301649e2d 100644
--- a/src/account.h
+++ b/src/account.h
@@ -49,6 +49,12 @@ public:
   virtual void initConfig(Conf::ConfigTree& config) = 0;
   virtual void loadConfig() = 0;
 
+  /**
+   * Get the account ID
+   * @return constant account id
+   */
+  inline const AccountID& getAccountID() { return _accountID; }
+
   /**
    * Get the voiplink pointer
    * @return the pointer or 0
@@ -91,6 +97,11 @@ public:
    */
   bool shouldRegisterOnStart() {return _shouldRegisterOnStart; }
 
+  /**
+   * Tell if the account is enable or not
+   */
+  bool isEnabled() { return _enabled; }
+
 private:
   /**
    * Create a unique voIPLink() depending on the protocol
diff --git a/src/eventthread.cpp b/src/eventthread.cpp
index 7edc957062..dd113bad97 100644
--- a/src/eventthread.cpp
+++ b/src/eventthread.cpp
@@ -1,5 +1,5 @@
-/**
- *  Copyright (C) 2004-2005 Savoir-Faire Linux inc.
+/*
+ *  Copyright (C) 2004, 2005, 2006 Savoir-Faire Linux inc.
  *  Author: Yan Morin <yan.morin@savoirfairelinux.com>
  *  Author : Laurielle Lea <laurielle.lea@savoirfairelinux.com>
  *                                                                              
diff --git a/src/gui/guiframework.cpp b/src/gui/guiframework.cpp
index 56ff4e6074..b902b95d47 100644
--- a/src/gui/guiframework.cpp
+++ b/src/gui/guiframework.cpp
@@ -175,6 +175,11 @@ GuiFramework::getCallStatus(const std::string& sequenceId)
   return Manager::instance().getCallStatus(sequenceId);
 }
 
+bool 
+GuiFramework::getAccountList(const std::string& sequenceId)
+{
+  return Manager::instance().getAccountList(sequenceId);
+}
 const CallID&
 GuiFramework::getCurrentId() 
 {
diff --git a/src/gui/guiframework.h b/src/gui/guiframework.h
index 347a93757a..2f8daa75ea 100644
--- a/src/gui/guiframework.h
+++ b/src/gui/guiframework.h
@@ -84,6 +84,7 @@ public:
   bool attachZeroconfEvents(const std::string& sequenceId, Pattern::Observer& observer);
   bool detachZeroconfEvents(Pattern::Observer& observer);
   bool getCallStatus(const std::string& sequenceId);
+  bool getAccountList(const std::string& sequenceId);
   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);
diff --git a/src/gui/qt/CallStatus.cpp b/src/gui/qt/CallStatus.cpp
index 2ed447d80e..63c155fadc 100644
--- a/src/gui/qt/CallStatus.cpp
+++ b/src/gui/qt/CallStatus.cpp
@@ -1,4 +1,4 @@
-/**
+/*
  *  Copyright (C) 2004-2005 Savoir-Faire Linux inc.
  *  Author: Jean-Philippe Barrette-LaPierre
  *             <jean-philippe.barrette-lapierre@savoirfairelinux.com>
diff --git a/src/gui/qt/CallStatus.hpp b/src/gui/qt/CallStatus.hpp
index 3b648d0ead..de5973362d 100644
--- a/src/gui/qt/CallStatus.hpp
+++ b/src/gui/qt/CallStatus.hpp
@@ -1,4 +1,4 @@
-/**
+/*
  *  Copyright (C) 2004-2005 Savoir-Faire Linux inc.
  *  Author: Jean-Philippe Barrette-LaPierre
  *             <jean-philippe.barrette-lapierre@savoirfairelinux.com>
diff --git a/src/gui/qt/Event.hpp b/src/gui/qt/Event.hpp
index 1fea8a1762..52b3aa1a79 100644
--- a/src/gui/qt/Event.hpp
+++ b/src/gui/qt/Event.hpp
@@ -41,6 +41,9 @@ public:
   void setUnusedArgs(const std::list< QString > &args)
   {mUnusedArgs = args;}
 
+protected:
+  QString& getCode() { return mCode; }
+
 private:
   QString mCode;
   std::list< QString > mUnusedArgs;
diff --git a/src/gui/qt/EventAccount.cpp b/src/gui/qt/EventAccount.cpp
new file mode 100644
index 0000000000..73ae1b140f
--- /dev/null
+++ b/src/gui/qt/EventAccount.cpp
@@ -0,0 +1,50 @@
+/*
+ *  Copyright (C) 2004-2005 Savoir-Faire Linux inc.
+ *  Author: Jean-Philippe Barrette-LaPierre
+ *             <jean-philippe.barrette-lapierre@savoirfairelinux.com>
+ *                                                                              
+ *  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.
+ */
+
+#include "globals.h"
+
+#include "EventAccount.hpp"
+#include "PhoneLineManager.hpp"
+
+AccountItemEvent::AccountItemEvent(const QString &code,
+		       const std::list< QString > &args)
+  : Event(code, args)
+{
+  std::list< QString > l = getUnusedArgs();
+  if(l.size() >= 3) {
+    mAccountId = *l.begin();
+    l.pop_front();
+    mStatus = *l.begin();
+    l.pop_front();
+    setUnusedArgs(l);
+  }
+}
+
+void
+AccountItemEvent::execute()
+{
+  bool isEnabled = false;
+  if (getCode() == "130") {
+    isEnabled = true;
+  }
+  // PhoneLineManager::instance().addAccount(mAccountId, isEnabled);
+  
+}
+
diff --git a/src/gui/qt/EventAccount.hpp b/src/gui/qt/EventAccount.hpp
new file mode 100644
index 0000000000..4392ec209a
--- /dev/null
+++ b/src/gui/qt/EventAccount.hpp
@@ -0,0 +1,40 @@
+/*
+ *  Copyright (C) 2004-2005 Savoir-Faire Linux inc.
+ *  Author: Jean-Philippe Barrette-LaPierre
+ *             <jean-philippe.barrette-lapierre@savoirfairelinux.com>
+ *                                                                              
+ *  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 __REQUESTACCOUNT_HPP__
+#define __REQUESTACCOUNT_HPP__
+
+#include "Event.hpp"
+
+class AccountItemEvent : public Event
+{
+public:
+  AccountItemEvent(const QString &code,
+	     const std::list< QString > &args);
+  
+  void execute();
+
+protected:
+  QString mAccountId;
+  QString mStatus;
+};
+
+#endif
+
diff --git a/src/gui/qt/Makefile.am b/src/gui/qt/Makefile.am
index abb1d28fd3..fed6a4e339 100644
--- a/src/gui/qt/Makefile.am
+++ b/src/gui/qt/Makefile.am
@@ -36,6 +36,8 @@ sflphone_qt_SOURCES = \
     ./CallManagerImpl.hpp \
     ./CallStatus.cpp \
     ./CallStatus.hpp \
+    ./EventAccount.cpp \
+    ./EventAccount.hpp \
     ./CallStatusFactory.hpp \
     ./ConfigurationManager.hpp \
     ./ConfigurationManagerImpl.cpp \
diff --git a/src/gui/qt/PhoneLine.cpp b/src/gui/qt/PhoneLine.cpp
index 4fd05f29a2..17d0f116d1 100644
--- a/src/gui/qt/PhoneLine.cpp
+++ b/src/gui/qt/PhoneLine.cpp
@@ -27,10 +27,8 @@
 #include "Request.hpp"
 
 PhoneLine::PhoneLine(const Session &session,
-		     const Account &account,
 		     unsigned int line)
   : mSession(session)
-  , mAccount(account)
   , mCall(NULL)
   , mLine(line)
   , mSelected(false)
@@ -298,19 +296,22 @@ PhoneLine::call(const QString &to)
   if(!mCall) {
     setLineStatus(tr("Calling %1...").arg(to));
     Call *call;
-    Request *r = mAccount.createCall(call, to);
-    // entry
-    connect(r, SIGNAL(entry(QString, QString)),
+    const Account* account = mSession.getSelectedAccount();
+    if (account) {
+      Request *r = account->createCall(call, to);
+      // entry
+      connect(r, SIGNAL(entry(QString, QString)),
 	    this, SLOT(setLineStatus(QString)));
 
-    connect(r, SIGNAL(error(QString, QString)),
+      connect(r, SIGNAL(error(QString, QString)),
 	    this, SLOT(error(QString)));
 
-    connect(r, SIGNAL(success(QString, QString)),
+      connect(r, SIGNAL(success(QString, QString)),
 	    this, SLOT(setTalkingState()));
 
-    setCall(call);
-    clear();
+      setCall(call);
+      clear();
+    }
   }
 }
 
diff --git a/src/gui/qt/PhoneLine.hpp b/src/gui/qt/PhoneLine.hpp
index 97acd883ac..7496dedf28 100644
--- a/src/gui/qt/PhoneLine.hpp
+++ b/src/gui/qt/PhoneLine.hpp
@@ -35,7 +35,6 @@ class PhoneLine : public QObject
   
 public:
   PhoneLine(const Session &session, 
-	    const Account &account, 
 	    unsigned int line);
   ~PhoneLine();
 
@@ -163,10 +162,8 @@ private:
   void setCall(Call *call);
   void setCall(const Call &call);
   void clearCall();
-  
 
   Session mSession;
-  Account mAccount;
   Call *mCall;
   unsigned int mLine;
 
diff --git a/src/gui/qt/PhoneLineManagerImpl.cpp b/src/gui/qt/PhoneLineManagerImpl.cpp
index 9ede36811a..a831aa9a71 100644
--- a/src/gui/qt/PhoneLineManagerImpl.cpp
+++ b/src/gui/qt/PhoneLineManagerImpl.cpp
@@ -28,6 +28,7 @@
 #include "ConfigurationManager.hpp"
 #include "SFLEvents.hpp"
 #include "SFLCallStatus.hpp"
+#include "EventAccount.hpp"
 #include "PhoneLine.hpp"
 #include "PhoneLineLocker.hpp"
 #include "PhoneLineManager.hpp"
@@ -37,7 +38,6 @@
 
 PhoneLineManagerImpl::PhoneLineManagerImpl()
   : mSession(NULL)
-  , mAccount(NULL)
   , mCurrentLine(NULL)
   , mIsInitialized(false)
   , mVolume(-1)
@@ -68,6 +68,10 @@ PhoneLineManagerImpl::PhoneLineManagerImpl()
   EventFactory::instance().registerEvent< BusyStatus >("114");
   EventFactory::instance().registerEvent< CongestionStatus >("115");
   EventFactory::instance().registerEvent< WrongNumberStatus >("116");
+
+  EventFactory::instance().registerEvent< AccountItemEvent >("130");
+  EventFactory::instance().registerEvent< AccountItemEvent >("131");
+
   QObject::connect(this, SIGNAL(disconnected()),        this, SLOT(closeSession()));
   QObject::connect(this, SIGNAL(readyToHandleEvents()), this, SLOT(handleEvents()));
   QObject::connect(this, SIGNAL(connected()),           this, SIGNAL(readyToSendStatus()));
@@ -78,7 +82,6 @@ PhoneLineManagerImpl::PhoneLineManagerImpl()
 PhoneLineManagerImpl::~PhoneLineManagerImpl()
 {
   delete mSession;
-  delete mAccount;
   for(std::vector< PhoneLine * >::iterator pos = mPhoneLines.begin();
       pos != mPhoneLines.end();
       pos++) {
@@ -104,7 +107,6 @@ PhoneLineManagerImpl::initialize(const Session &session)
   if(!mIsInitialized) {
     mIsInitialized = true;
     mSession = new Session(session);
-    mAccount = new Account(mSession->getDefaultAccount());
   }
 }
 
@@ -286,7 +288,7 @@ PhoneLineManagerImpl::setNbLines(unsigned int nb)
 
   mPhoneLines.clear();
   for(unsigned int i = 0; i < nb; i++) {
-    PhoneLine *p = new PhoneLine(*mSession, *mAccount, i + 1);
+    PhoneLine *p = new PhoneLine(*mSession, i + 1);
     QObject::connect(p, SIGNAL(lineStatusChanged(QString)),
 		     this, SIGNAL(unselectedLineStatusSet(QString)));
     mPhoneLines.push_back(p);
diff --git a/src/gui/qt/PhoneLineManagerImpl.hpp b/src/gui/qt/PhoneLineManagerImpl.hpp
index 6e9255a0c0..a15c30c36e 100644
--- a/src/gui/qt/PhoneLineManagerImpl.hpp
+++ b/src/gui/qt/PhoneLineManagerImpl.hpp
@@ -336,7 +336,6 @@ private:
 
 private:
   Session *mSession;
-  Account *mAccount;
 
   std::vector< PhoneLine * > mPhoneLines;
   PhoneLine *mCurrentLine;
diff --git a/src/gui/qt/SFLPhoneApp.cpp b/src/gui/qt/SFLPhoneApp.cpp
index 06d1cc57bf..844f268007 100644
--- a/src/gui/qt/SFLPhoneApp.cpp
+++ b/src/gui/qt/SFLPhoneApp.cpp
@@ -66,6 +66,7 @@ SFLPhoneApp::SFLPhoneApp(int argc, char **argv)
 
   Requester::instance().registerObject< EventRequest >(QString("getevents"));
   Requester::instance().registerObject< CallStatusRequest >(QString("getcallstatus"));
+  Requester::instance().registerObject< AccountStatusRequest >(QString("getaccount"));
   Requester::instance().registerObject< PermanentRequest >(QString("answer"));
   Requester::instance().registerObject< PermanentRequest >(QString("notavailable"));
   Requester::instance().registerObject< PermanentRequest >(QString("refuse"));
diff --git a/src/gui/qt/SFLRequest.cpp b/src/gui/qt/SFLRequest.cpp
index e7a7ff2e87..c113c9309f 100644
--- a/src/gui/qt/SFLRequest.cpp
+++ b/src/gui/qt/SFLRequest.cpp
@@ -28,11 +28,13 @@
 #include "CallManager.hpp"
 #include "CallStatus.hpp"
 #include "CallStatusFactory.hpp"
+#include "RequestAccount.hpp"
 #include "ConfigurationManager.hpp"
 #include "PhoneLine.hpp"
 #include "PhoneLineLocker.hpp"
 #include "PhoneLineManager.hpp"
 #include "SFLRequest.hpp"
+#include "EventAccount.hpp"
 
 EventRequest::EventRequest(const QString &sequenceId,
 			   const QString &command,
@@ -73,7 +75,6 @@ CallStatusRequest::CallStatusRequest(const QString &sequenceId,
   : Request(sequenceId, command, args)
 {}
 
-
 void
 CallStatusRequest::onError(const QString &code, const QString &message)
 {
@@ -109,6 +110,36 @@ CallStatusRequest::onSuccess(const QString &code, const QString &message)
   PhoneLineManager::instance().handleEvents();
 }
 
+AccountStatusRequest::AccountStatusRequest(const QString &sequenceId,
+				     const QString &command,
+				     const std::list< QString > &args)
+  : Request(sequenceId, command, args)
+{}
+
+void
+AccountStatusRequest::onError(const QString &code, const QString &message)
+{
+  DebugOutput::instance() << QObject::tr("CallStatusRequest error: (%1) %1\n")
+    .arg(code)
+    .arg(message);
+  //PhoneLineManager::instance().errorOnCallStatus(message);
+}
+
+void
+AccountStatusRequest::onEntry(const QString &code, const QString &message)
+{
+  std::auto_ptr< Event > 
+    e(EventFactory::instance().create(code, Request::parseArgs(message)));
+  e->execute();
+}
+
+void
+AccountStatusRequest::onSuccess(const QString &code, const QString &message)
+{
+  DebugOutput::instance() << QObject::tr("AccountStatusRequest success: (%1) %1\n").arg(code).arg(message);
+  //PhoneLineManager::instance().handleEvents();
+}
+
 
 PermanentRequest::PermanentRequest(const QString &sequenceId,
 			 const QString &command,
diff --git a/src/gui/qt/SFLRequest.hpp b/src/gui/qt/SFLRequest.hpp
index 305cbec132..56b367c998 100644
--- a/src/gui/qt/SFLRequest.hpp
+++ b/src/gui/qt/SFLRequest.hpp
@@ -62,6 +62,40 @@ public:
 
 };
 
+class AccountStatusRequest : public Request
+{
+public:
+  AccountStatusRequest(const QString &sequenceId,
+		    const QString &command,
+		    const std::list< QString > &args);
+
+
+  virtual ~AccountStatusRequest(){}
+
+  /**
+   * This function will be called when the request 
+   * receive its answer, if the request didn't successfully
+   * ended. When we have an error on an EventRequest, we should
+   * quit the program.
+   */
+  virtual void onError(const QString &code, const QString &message);
+
+  /**
+   * This function will be called when the request 
+   * receive an answer, but there's other answers to come.
+   * This will be dispatched to the valid event.
+   */
+  virtual void onEntry(const QString &code, const QString &message);
+
+  /**
+   * This function will be called when the request 
+   * receive its answer, if the request successfully
+   * ended. The event handling is gone, so we should 
+   * quit.
+   */
+  virtual void onSuccess(const QString &code, const QString &message);
+};
+
 class CallStatusRequest : public Request
 {
 public:
diff --git a/src/gui/qt/Session.cpp b/src/gui/qt/Session.cpp
index eada91927b..ad632eb7db 100644
--- a/src/gui/qt/Session.cpp
+++ b/src/gui/qt/Session.cpp
@@ -26,11 +26,14 @@
 #include "Session.hpp"
 #include "Requester.hpp"
 #include "SessionIOFactory.hpp"
+#include "globals.h"
 
 
 Session::Session(const QString &id)
-  : mId(id)
-{}
+  : mId(id), mSelectedAccountId(ACCOUNT_DEFAULT_NAME)
+{
+  mAccountMap[mSelectedAccountId] = new Account(mId, mSelectedAccountId);
+}
 
 Session::Session()
 {
@@ -39,6 +42,17 @@ Session::Session()
   Requester::instance().registerSession(mId, s);
 }
 
+Session::~Session()
+{
+  // remove account
+  std::map<QString, Account*>::iterator iter = mAccountMap.begin();
+  while ( iter != mAccountMap.end() ) {
+    delete iter->second; iter->second = 0;
+    iter++;
+  }
+  mAccountMap.clear();
+}
+
 QString
 Session::id() const
 {
@@ -141,6 +155,12 @@ Session::getCallStatus() const
   return Requester::instance().send(mId, "getcallstatus", std::list< QString >());
 }
 
+Request* 
+Session::getAccountList() const
+{
+  return Requester::instance().send(mId, "getaccount", std::list< QString >());
+}
+
 Request *
 Session::playDtmf(char c) const
 {
@@ -184,6 +204,15 @@ Session::getAccount(const QString &name) const
 Account
 Session::getDefaultAccount() const
 {
-  return Account(mId, QString("SIP0"));
+  return Account(mId, QString(ACCOUNT_DEFAULT_NAME));
 }
 
+Account*
+Session::getSelectedAccount()
+{
+  std::map< QString, Account* >::iterator iter = mAccountMap.find(mSelectedAccountId);
+  if (iter!=mAccountMap.end()) {
+    return iter->second;
+  }
+  return 0;
+}
diff --git a/src/gui/qt/Session.hpp b/src/gui/qt/Session.hpp
index 973a042e0d..00893ea504 100644
--- a/src/gui/qt/Session.hpp
+++ b/src/gui/qt/Session.hpp
@@ -23,6 +23,7 @@
 #define SFLPHONEGUI_SESSION_H
 
 #include <qstring.h>
+#include <map>
 
 #include "Account.hpp"
 
@@ -31,6 +32,7 @@ class Session
  public:
   Session();
   Session(const QString &id);
+  ~Session();
   
   /**
    * retreive the account identified by name.
@@ -39,6 +41,25 @@ class Session
 
   Account getDefaultAccount() const;
 
+  /**
+   * Return the first or selected account object
+   * or 0 if not found
+   */
+  Account* getSelectedAccount();
+
+  /**
+   * Set Selected Account ID
+   * @param accountID account id
+   */
+  void setSelectedAccountID(const QString &accountID) {
+    mSelectedAccountId = accountID;
+  }
+
+  /**
+   * retreive account 
+   */
+  Request* getAccountList() const;
+
   /**
    * This function will play a tone. This is
    * just a ear candy.
@@ -121,6 +142,8 @@ class Session
 
  private:
   QString mId;
+  QString mSelectedAccountId;
+  std::map<QString, Account*> mAccountMap;
 };
 
 #endif
diff --git a/src/gui/server/requestconfig.cpp b/src/gui/server/requestconfig.cpp
index e06c2602de..45cce8ecf7 100644
--- a/src/gui/server/requestconfig.cpp
+++ b/src/gui/server/requestconfig.cpp
@@ -78,6 +78,21 @@ RequestCallStatus::execute()
   return message(code, tk);
 }
 
+ResponseMessage
+RequestAccountList::execute()
+{
+  std::string code;
+  std::string response;
+  if ( GUIServer::instance().getAccountList(_sequenceId) ) {
+    code = "200";
+    response = "OK";
+  } else {
+    code = "400";
+    response = "No active account";
+  }
+  return message(code, _(response));
+}
+
 ResponseMessage
 RequestConfigGetAll::execute()
 {
diff --git a/src/gui/server/requestconfig.h b/src/gui/server/requestconfig.h
index 2edd772625..6de941daf7 100644
--- a/src/gui/server/requestconfig.h
+++ b/src/gui/server/requestconfig.h
@@ -51,6 +51,11 @@ public:
   ResponseMessage execute();
 };
 
+class RequestAccountList : public RequestGlobal {
+public:
+  RequestAccountList(const std::string &sequenceId, const TokenList& argList) : RequestGlobal(sequenceId,argList) {}
+  ResponseMessage execute();
+};
 
 class RequestConfigGetAll : public RequestGlobal {
 public:
diff --git a/src/gui/server/requestfactory.cpp b/src/gui/server/requestfactory.cpp
index 9a45c39d8d..896e5e1b07 100644
--- a/src/gui/server/requestfactory.cpp
+++ b/src/gui/server/requestfactory.cpp
@@ -123,6 +123,7 @@ RequestFactory::registerAll() {
   registerRequest<RequestZeroconf>    ("getzeroconf");
   registerRequest<RequestZeroconfEvent>("getzeroconfevents");
   registerRequest<RequestCallStatus>  ("getcallstatus");
+  registerRequest<RequestAccountList> ("getaccount");
   registerRequest<RequestConfigGetAll>("configgetall");
   registerRequest<RequestConfigGet>   ("configget");
   registerRequest<RequestConfigSet>   ("configset");
diff --git a/src/managerimpl.cpp b/src/managerimpl.cpp
index 5ea446088d..8352fb93d4 100644
--- a/src/managerimpl.cpp
+++ b/src/managerimpl.cpp
@@ -1485,6 +1485,30 @@ ManagerImpl::getDirListing(const std::string& sequenceId, const std::string& pat
   }
 }
 
+bool 
+ManagerImpl::getAccountList(const std::string& sequenceId) 
+{
+  bool oneActive = false;
+  TokenList tk;
+
+  AccountMap::iterator iter = _accountMap.begin();
+  while ( iter != _accountMap.end() ) {
+    tk.push_back(iter->first);
+    if ( iter->second->isEnabled() ) {
+      tk.push_back("Active");
+      _gui->sendMessage("130", sequenceId, tk);
+      oneActive = true;
+    } else {
+      tk.push_back("Inactive");
+      _gui->sendMessage("131", sequenceId, tk);
+    }
+    tk.clear();
+    iter++;
+  }
+
+  return oneActive;
+}
+
 //THREAD=Main
 /*
  * Experimental...
diff --git a/src/managerimpl.h b/src/managerimpl.h
index 31c655a78e..a9d23e7a4b 100644
--- a/src/managerimpl.h
+++ b/src/managerimpl.h
@@ -196,6 +196,11 @@ public:
   bool attachZeroconfEvents(const std::string& sequenceId, Pattern::Observer& observer);
   bool detachZeroconfEvents(Pattern::Observer& observer);
   bool getCallStatus(const std::string& sequenceId);
+  /** 
+   * Get account list and status
+   * @param return true if there is atleast one active
+   */
+  bool getAccountList(const std::string& sequenceId);
   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);
@@ -363,6 +368,8 @@ private:
   Conf::ConfigTree _config;
   bool getCountryTones(const std::string& sequenceId);
   void sendCountryTone(const std::string& sequenceId, int index, const std::string& name);
+  
+
 
   /**
    * Tell if there is a current call processed
-- 
GitLab