phonebookui/phonebookservices/src/cntserviceproviderviewing.cpp
changeset 61 d30183af6ca6
parent 54 47627ab5d7a4
child 72 6abfb1094884
equal deleted inserted replaced
56:d508aa856878 61:d30183af6ca6
    26 #include <QUrl>
    26 #include <QUrl>
    27 
    27 
    28 CntServiceProviderViewing::CntServiceProviderViewing(CntServices& aServices, QObject *parent):
    28 CntServiceProviderViewing::CntServiceProviderViewing(CntServices& aServices, QObject *parent):
    29     XQServiceProvider(QLatin1String(KCntServiceInterfaceView), parent),
    29     XQServiceProvider(QLatin1String(KCntServiceInterfaceView), parent),
    30     mServices(aServices),
    30     mServices(aServices),
    31     mCurrentRequestIndex(0)
    31     mCurrentRequestIndex(0),
       
    32     mAllowExit(true)
    32 {
    33 {
    33     CNT_ENTRY
    34     CNT_ENTRY
    34     publishAll();
    35     publishAll();
    35     connect(this, SIGNAL(clientDisconnected()), &mServices, SLOT(quitApp()));
    36     connect(this, SIGNAL(clientDisconnected()), &mServices, SLOT(quitApp()));
    36     CNT_EXIT
    37     CNT_EXIT
    41     CNT_ENTRY
    42     CNT_ENTRY
    42     CNT_EXIT
    43     CNT_EXIT
    43 }
    44 }
    44 
    45 
    45 void CntServiceProviderViewing::openContactCard( int aContactId )
    46 void CntServiceProviderViewing::openContactCard( int aContactId )
    46     {
    47 {
    47     CNT_ENTRY
    48     CNT_ENTRY
    48     mCurrentRequestIndex = setCurrentRequestAsync();
    49     mCurrentRequestIndex = setCurrentRequestAsync();
    49     mServices.setQuittable(requestInfo().isEmbedded());
    50     mServices.setQuittable(requestInfo().isEmbedded());
    50     mServices.launchContactCard( aContactId, *this );
    51     mServices.launchContactCard( aContactId, *this );
    51     CNT_EXIT
    52     CNT_EXIT
    52     }
    53 }
    53 
    54 
    54 void CntServiceProviderViewing::openTemporaryContactCard( QString aFieldName, QString aFieldValue )
    55 void CntServiceProviderViewing::openTemporaryContactCard( QString aFieldName, QString aFieldValue )
    55     {
    56 {
    56     CNT_ENTRY
    57     CNT_ENTRY
    57     mCurrentRequestIndex = setCurrentRequestAsync();
    58     mCurrentRequestIndex = setCurrentRequestAsync();
    58     mServices.setQuittable(requestInfo().isEmbedded());
    59     mServices.setQuittable(requestInfo().isEmbedded());
    59     mServices.launchTemporaryContactCard( aFieldName, aFieldValue, *this );
    60     mServices.launchTemporaryContactCard( aFieldName, aFieldValue, *this );
    60     CNT_EXIT
    61     CNT_EXIT
    61     }
    62 }
    62 
    63 
    63 void CntServiceProviderViewing::openGroup( int aContactId )
    64 void CntServiceProviderViewing::openGroup( int aContactId )
    64     {
    65 {
    65     CNT_ENTRY
    66     CNT_ENTRY
    66     mCurrentRequestIndex = setCurrentRequestAsync();
    67     mCurrentRequestIndex = setCurrentRequestAsync();
       
    68     mAllowExit = false;
    67     mServices.setQuittable(requestInfo().isEmbedded());
    69     mServices.setQuittable(requestInfo().isEmbedded());
    68     mServices.launchGroupMemberView( aContactId, *this );
    70     mServices.launchGroupMemberView( aContactId, *this );
    69     CNT_EXIT
    71     CNT_EXIT
    70     }
    72 }
    71 
    73 
    72 void CntServiceProviderViewing::CompleteServiceAndCloseApp(const QVariant& retValue)
    74 void CntServiceProviderViewing::CompleteServiceAndCloseApp(const QVariant& retValue)
    73     {
    75 {
    74     CNT_ENTRY
    76     CNT_ENTRY
    75     connect(this, SIGNAL(returnValueDelivered()), qApp, SLOT(quit()));
    77     connect(this, SIGNAL(returnValueDelivered()), qApp, SLOT(quit()));
    76     if ( mCurrentRequestIndex != 0 )
    78     if ( mCurrentRequestIndex != 0 )
    77     {
    79     {
    78         const bool success = completeRequest(mCurrentRequestIndex, retValue);
    80         bool success = false;
       
    81         
       
    82         if (!mOverriddenReturnValue.isNull() && retValue.value<int>() != KCntServicesReturnValueContactDeleted)
       
    83         {
       
    84             CNT_LOG_ARGS(mOverriddenReturnValue.value<int>());
       
    85             success = completeRequest(mCurrentRequestIndex, mOverriddenReturnValue);
       
    86         }
       
    87         else
       
    88         {
       
    89             CNT_LOG_ARGS(retValue.value<int>());
       
    90             success = completeRequest(mCurrentRequestIndex, retValue);
       
    91         }
       
    92         
    79         if ( !success )
    93         if ( !success )
    80         {
    94         {
    81             CNT_LOG_ARGS("Failed to complete highway request.");
    95             CNT_LOG_ARGS("Failed to complete highway request.");
    82         }
    96         }
    83         mCurrentRequestIndex = 0;
    97         mCurrentRequestIndex = 0;
    84     }
    98     }
    85     CNT_EXIT
    99     CNT_EXIT
       
   100 }
       
   101 
       
   102 void CntServiceProviderViewing::overrideReturnValue(const QVariant& retValue)
       
   103 {
       
   104     CNT_ENTRY
       
   105     
       
   106     if (mOverriddenReturnValue.isNull() || mOverriddenReturnValue.value<int>() != KCntServicesReturnValueContactSaved)
       
   107     {
       
   108         mOverriddenReturnValue = retValue;
    86     }
   109     }
       
   110     
       
   111     CNT_EXIT
       
   112 }
       
   113 
       
   114 bool CntServiceProviderViewing::allowSubViewsExit()
       
   115 {
       
   116     return mAllowExit;
       
   117 }