29 const TUint KTMSServerConnectRetries = 2; |
29 const TUint KTMSServerConnectRetries = 2; |
30 const TUint KSessionMessageSlots = 10; |
30 const TUint KSessionMessageSlots = 10; |
31 |
31 |
32 // ----------------------------------------------------------------------------- |
32 // ----------------------------------------------------------------------------- |
33 // StartServer |
33 // StartServer |
34 // Static function to start the server process thread. |
34 // |
35 // Start the server process/thread which lives in an EPOCEXE object. |
35 // Function that will launch TMS server executable in it its own process. |
36 // Returns: gint: TMS_RESULT_SUCCESS (0) if no error |
36 // Start the server process/thread, which lives in an EPOCEXE object. |
37 // ----------------------------------------------------------------------------- |
37 // Returns: gint: TMS_RESULT_SUCCESS (0) if no error. |
38 // |
38 // ----------------------------------------------------------------------------- |
39 static gint StartServer() |
39 // |
|
40 gint TMSProxy::StartServer() |
40 { |
41 { |
41 const TUidType serverUid(KNullUid, KNullUid, KTMSServerUid3); |
42 const TUidType serverUid(KNullUid, KNullUid, KTMSServerUid3); |
42 |
43 |
43 // Only one instance of the server is allowed. Attempt of launching |
44 // Only one instance of the server is allowed. Attempt of launching |
44 // second instance of the server will fail with KErrAlreadyExists. |
45 // second instance of the server will fail with KErrAlreadyExists. |
45 RProcess server; |
46 RProcess server; |
46 gint r = server.Create(KTMSServerName, KNullDesC, serverUid); |
47 gint ret = server.Create(KTMSServerFile, KNullDesC, serverUid); |
47 |
48 |
48 if (r != TMS_RESULT_SUCCESS) |
49 if (ret == TMS_RESULT_SUCCESS) |
49 { |
50 { |
50 return r; |
51 TRequestStatus stat; |
51 } |
52 server.Rendezvous(stat); |
52 |
53 |
53 TRequestStatus stat; |
54 if (stat != KRequestPending) |
54 server.Rendezvous(stat); |
55 { |
55 |
56 server.Kill(0); // abort startup |
56 if (stat != KRequestPending) |
57 } |
57 { |
58 else |
58 server.Kill(0); // abort startup |
59 { |
59 } |
60 server.Resume(); // logon OK - start the server |
60 else |
61 } |
61 { |
62 |
62 server.Resume(); // logon OK - start the server |
63 User::WaitForRequest(stat); // wait for start or death |
63 } |
64 |
64 |
65 // We can't use the 'exit reason' if the server panicked, as '0' is a |
65 User::WaitForRequest(stat); // wait for start or death |
66 // valid panic 'reason', which cannot be distinguished from |
66 |
67 // TMS_RESULT_SUCCESS. |
67 // Panic reason cannot be '0' as it would conflict with TMS_RESULT_SUCCESS |
68 ret = (server.ExitType() == EExitPanic) ? KErrGeneral : stat.Int(); |
68 r = (server.ExitType() == EExitPanic) ? KErrGeneral : stat.Int(); |
69 server.Close(); |
69 server.Close(); |
70 } |
70 return r; |
71 |
|
72 return ret; |
71 } |
73 } |
72 |
74 |
73 // ----------------------------------------------------------------------------- |
75 // ----------------------------------------------------------------------------- |
74 // TMSProxy::TMSProxy |
76 // TMSProxy::TMSProxy |
75 // ----------------------------------------------------------------------------- |
77 // ----------------------------------------------------------------------------- |
619 // |
621 // |
620 void TMSProxy::QueueEvent(gint aEventType, gint aError, void* event_data) |
622 void TMSProxy::QueueEvent(gint aEventType, gint aError, void* event_data) |
621 { |
623 { |
622 TMSSignalEvent event = {}; //all elements initialized to zeros |
624 TMSSignalEvent event = {}; //all elements initialized to zeros |
623 event.type = aEventType; |
625 event.type = aEventType; |
624 event.reason = aError; |
626 event.reason = TMSRESULT(aError); |
625 event.user_data = NULL; //use only to return data passed in by the user |
627 event.user_data = NULL; //use only to return data passed in by the user |
626 |
628 |
627 switch (aEventType) |
629 switch (aEventType) |
628 { |
630 { |
629 case TMS_EVENT_EFFECT_VOL_CHANGED: |
631 case TMS_EVENT_EFFECT_VOL_CHANGED: |