mmserv/sts/stsserver/src/stsserver.cpp
changeset 16 43d09473c595
parent 14 80975da52420
child 20 b67dd1fc57c5
equal deleted inserted replaced
14:80975da52420 16:43d09473c595
    18  * functionality is handled in the STS class.
    18  * functionality is handled in the STS class.
    19  */
    19  */
    20 
    20 
    21 #include "stsserver.h"
    21 #include "stsserver.h"
    22 
    22 
    23 #include <ecom/ecom.h>
       
    24 #include "stsserversession.h"
    23 #include "stsserversession.h"
    25 #include "sts.h"
    24 #include "sts.h"
    26 
    25 
    27 // TODO: IMPLEMENT PLATFORM SECURITY CHECKS ON THIS API.
    26 // TODO: IMPLEMENT PLATFORM SECURITY CHECKS ON THIS API.
    28 
    27 
    78 
    77 
    79 CStsServer::~CStsServer()
    78 CStsServer::~CStsServer()
    80     {
    79     {
    81     iSessions.ResetAndDestroy();
    80     iSessions.ResetAndDestroy();
    82     CSts::Delete(iSts);
    81     CSts::Delete(iSts);
    83     REComSession::FinalClose();
       
    84     }
    82     }
    85 
    83 
    86 CSession2* CStsServer::NewSessionL(const TVersion& aVersion, const RMessage2& /*aMessage*/) const
    84 CSession2* CStsServer::NewSessionL(const TVersion& aVersion, const RMessage2& /*aMessage*/) const
    87     {
    85     {
    88     if (aVersion.iMajor != KStsServerMajorVersion || aVersion.iMinor
    86     if (aVersion.iMajor != KStsServerMajorVersion || aVersion.iMinor
    89             != KStsServerMinorVersion || aVersion.iBuild != KStsServerBuild)
    87             != KStsServerMinorVersion || aVersion.iBuild != KStsServerBuild)
    90         {
    88         {
    91         User::Leave(KErrNotSupported);
    89         User::Leave(KErrNotSupported);
    92         } // end if
    90         }
       
    91     else
       
    92         {
       
    93         //TODO: Add trace here
       
    94         }// end if
    93 
    95 
    94     CStsServer& nonConstThis = *const_cast<CStsServer*> (this);
    96     CStsServer& nonConstThis = *const_cast<CStsServer*> (this);
    95 
    97 
    96     // Construct a new session, passing it a pointer to the server object.  This function
    98     // Construct a new session, passing it a pointer to the server object.  This function
    97     // is const, so the const-ness must be cast away from the this pointer.
    99     // is const, so the const-ness must be cast away from the this pointer.
    98     CSession2* returnValue = new (ELeave) CStsServerSession(nonConstThis, *iSts);
   100     CSession2* returnValue = new (ELeave) CStsServerSession(nonConstThis,
       
   101             *iSts);
    99 
   102 
   100     return returnValue;
   103     return returnValue;
   101     }
   104     }
   102 
   105 
   103 void CStsServer::AddSession(CStsServerSession* aSession)
   106 void CStsServer::AddSession(CStsServerSession* aSession)
   112 
   115 
   113     if (index != KErrNotFound)
   116     if (index != KErrNotFound)
   114         {
   117         {
   115         // Remove the session from the list of sessions.
   118         // Remove the session from the list of sessions.
   116         iSessions.Remove(index);
   119         iSessions.Remove(index);
       
   120         }
       
   121     else
       
   122         {
       
   123         //TODO: Add trace here
   117         } // end if
   124         } // end if
   118 
   125 
   119     if (iSessions.Count() == 0)
   126     if (iSessions.Count() == 0)
   120         {
   127         {
   121         // No more clients. Shutdown the server.
   128         // No more clients. Shutdown the server.
   123         }
   130         }
   124     }
   131     }
   125 
   132 
   126 // SERVER LAUNCHING FUNCTIONALITY
   133 // SERVER LAUNCHING FUNCTIONALITY
   127 
   134 
   128 EXPORT_C void CStsServer::RunServerL(bool aPerformProcessRendezvous,
   135 EXPORT_C void CStsServer::RunServerL()
   129         bool aPerformThreadRendezvous)
       
   130     {
   136     {
   131     // naming the server thread after the server helps to debug panics
   137     // naming the server thread after the server helps to debug panics
   132     User::LeaveIfError(User::RenameThread(KStsServerName));
   138     User::LeaveIfError(User::RenameThread(KStsServerName));
   133 
   139 
   134     // create and install the active scheduler
   140     // create and install the active scheduler
   137     CActiveScheduler::Install(scheduler);
   143     CActiveScheduler::Install(scheduler);
   138 
   144 
   139     // create the server (leave it on the cleanup stack)
   145     // create the server (leave it on the cleanup stack)
   140     CStsServer* server = CStsServer::NewLC();
   146     CStsServer* server = CStsServer::NewLC();
   141 
   147 
   142     // Initialisation complete, now signal the client, if requested.
   148     // Initialisation complete, now signal the client.
   143 
   149     RProcess::Rendezvous(KErrNone);
   144     if (aPerformProcessRendezvous)
       
   145         {
       
   146         RProcess::Rendezvous(KErrNone);
       
   147         }
       
   148 
       
   149     if (aPerformThreadRendezvous)
       
   150         {
       
   151         RThread::Rendezvous(KErrNone);
       
   152         }
       
   153 
   150 
   154     // Ready to run
   151     // Ready to run
   155     // Start wait loop, will return when server is shutdown
   152     // Start wait loop, will return when server is shutdown
   156     CActiveScheduler::Start();
   153     CActiveScheduler::Start();
   157 
   154