calendarengines/caleninterimutils/src/CalenInterimUtils2Impl.cpp
changeset 18 c198609911f9
parent 0 f979ecb2b13e
child 89 b57382753122
equal deleted inserted replaced
0:f979ecb2b13e 18:c198609911f9
    30 #include <caluser.h>
    30 #include <caluser.h>
    31 #include <calentryview.h>
    31 #include <calentryview.h>
    32 #include <etelmm.h>
    32 #include <etelmm.h>
    33 #include <e32math.h>
    33 #include <e32math.h>
    34 #include <calrrule.h>
    34 #include <calrrule.h>
    35 #include <cmrmailboxutils.h>
       
    36 #include <featmgr.h>
    35 #include <featmgr.h>
    37 #include <MeetingRequestUids.hrh>
       
    38 #include <ecom/ecom.h>
    36 #include <ecom/ecom.h>
    39 #include <utf.h>
    37 #include <utf.h>
    40 #include <openssl/md5.h>
    38 #include <openssl/md5.h>
    41 #include <string.h>
    39 #include <string.h>
    42 
    40 
    88 // -----------------------------------------------------------------------------
    86 // -----------------------------------------------------------------------------
    89 CCalenInterimUtils2Impl::CCalenInterimUtils2Impl()
    87 CCalenInterimUtils2Impl::CCalenInterimUtils2Impl()
    90     {
    88     {
    91     TRACE_ENTRY_POINT;
    89     TRACE_ENTRY_POINT;
    92 
    90 
    93     iMrEnabledCheck = ETrue;
       
    94     iMrEnabled = EFalse;
       
    95     
       
    96     TRACE_EXIT_POINT;
    91     TRACE_EXIT_POINT;
    97     }
    92     }
    98 
    93 
    99 // -----------------------------------------------------------------------------
    94 // -----------------------------------------------------------------------------
   100 // CCalenInterimUtils2Impl::ConstructL()
    95 // CCalenInterimUtils2Impl::ConstructL()
   564 // Checks to see if Meeting Request Viewer functionality
   559 // Checks to see if Meeting Request Viewer functionality
   565 // is enabled and an implementation is available to use
   560 // is enabled and an implementation is available to use
   566 // (other items were commented in a header).
   561 // (other items were commented in a header).
   567 // -----------------------------------------------------------------------------
   562 // -----------------------------------------------------------------------------
   568 //
   563 //
   569 TBool CCalenInterimUtils2Impl::MRViewersEnabledL(TBool aForceCheck)
   564 TBool CCalenInterimUtils2Impl::MRViewersEnabledL(TBool /*aForceCheck*/)
   570     {
   565     {
   571     TRACE_ENTRY_POINT;
   566     TRACE_ENTRY_POINT;
   572     if( aForceCheck || iMrEnabledCheck )
   567     // Need to implement it once we have meeting request viewer in 10.1
   573         {
   568     TRACE_EXIT_POINT;
   574 		iMrEnabled = EFalse;
   569     return false;    
   575 		iMrEnabledCheck = EFalse;
       
   576 
       
   577         PIM_TRAPD_HANDLE( DoMRViewersEnabledL() );
       
   578         }
       
   579         
       
   580     TRACE_EXIT_POINT;
       
   581     return iMrEnabled;    
       
   582     }
   570     }
   583 // -----------------------------------------------------------------------------
   571 // -----------------------------------------------------------------------------
   584 // CCalenInterimUtils2Impl::DoMRViewersEnabledL()
   572 // CCalenInterimUtils2Impl::DoMRViewersEnabledL()
   585 // Checks to see if Meeting Request Viewer functionality
   573 // Checks to see if Meeting Request Viewer functionality
   586 // is enabled and an implementation is available to use
   574 // is enabled and an implementation is available to use
   588 // -----------------------------------------------------------------------------
   576 // -----------------------------------------------------------------------------
   589 //
   577 //
   590 void CCalenInterimUtils2Impl::DoMRViewersEnabledL()
   578 void CCalenInterimUtils2Impl::DoMRViewersEnabledL()
   591     {
   579     {
   592     TRACE_ENTRY_POINT;
   580     TRACE_ENTRY_POINT;
   593 
   581 		// Need to implement it once we have meeting request viewer in 10.1
   594     // We ignore any leaves because iMrEnabled and iMrEnabledCheck are already set to
   582     TRACE_EXIT_POINT;
   595     // EFalse, so if the function leaves it will return EFalse this time and any future
       
   596     // calls will not force a check (unless aForceCheck is ETrue).
       
   597     if (FeatureManager::FeatureSupported(KFeatureIdMeetingRequestSupport))
       
   598         {
       
   599         // Full meeting request solution
       
   600         // As long as we have at least one mailbox we can return true
       
   601         CMRMailboxUtils *mbUtils = CMRMailboxUtils::NewL();
       
   602         CleanupStack::PushL( mbUtils );
       
   603 
       
   604                 RArray<CMRMailboxUtils::TMailboxInfo> mailboxes;
       
   605                 CleanupClosePushL(mailboxes);
       
   606                 mbUtils->ListMailBoxesL(mailboxes);
       
   607                 if(mailboxes.Count() > 0)
       
   608                     {
       
   609                     iMrEnabled = ETrue; // && 1 mailbox
       
   610                     }
       
   611 
       
   612         CleanupStack::PopAndDestroy(); // mailboxes
       
   613         CleanupStack::PopAndDestroy(); // mbUtils
       
   614         }
       
   615      else
       
   616         {
       
   617         if (FeatureManager::FeatureSupported(KFeatureIdMeetingRequestEnabler))
       
   618             {
       
   619     		// Meeting request enablers solution
       
   620     		//Check for:
       
   621     		//	At least one mailbox exists on the terminal
       
   622     		//	At least one MRViewer implementation, with an id matching a mailbox,
       
   623     		    //	exists on the terminal
       
   624     		    //	At least one MRUtils implementation exists on the terminal
       
   625     		    CMRMailboxUtils *mbUtils = CMRMailboxUtils::NewL();
       
   626     		    CleanupStack::PushL( mbUtils );
       
   627 
       
   628                 RArray<CMRMailboxUtils::TMailboxInfo> mailboxes;
       
   629                 CleanupClosePushL(mailboxes);
       
   630 
       
   631                 mbUtils->ListMailBoxesL(mailboxes);
       
   632                 if(mailboxes.Count() > 0)
       
   633                     {
       
   634                     RImplInfoPtrArrayOwn implArray;
       
   635                      CleanupClosePushL( implArray );
       
   636 
       
   637                      //Check for a MRViewers Implementation
       
   638                      const TUid mrViewersIface = {KMRViewersInterfaceUID};
       
   639                      REComSession::ListImplementationsL(mrViewersIface, implArray );
       
   640                      if ( implArray.Count() > 0 )
       
   641                          {
       
   642                          // MRViewers implementations exist.  We need to see if any are
       
   643                          // associated with an existing mailbox
       
   644                          TBool mrImplMatchesMailbox = EFalse;
       
   645                          for (TInt i=0; i<implArray.Count(); ++i)
       
   646                              {
       
   647                              for(TInt j=0; j<mailboxes.Count(); ++j)
       
   648                                  {
       
   649                                  TBuf16<KMaxUidName> mbName;
       
   650                                  CnvUtfConverter::ConvertToUnicodeFromUtf8( mbName, implArray[i]->DataType() );
       
   651                                  if(mailboxes[j].iMtmUid.Name().CompareF(mbName) == 0)
       
   652                                      {
       
   653                                     mrImplMatchesMailbox = ETrue;
       
   654                                     //One match is enough for this decision to be true
       
   655                                     break;
       
   656                                     }
       
   657                                  }
       
   658                              if (mrImplMatchesMailbox)
       
   659                                  {
       
   660                                  break;
       
   661                                  }
       
   662                              }
       
   663 
       
   664                          // Reset the viewer implementation array.  This will be reused
       
   665                          // if we need to check for mr utils implementations
       
   666                          implArray.ResetAndDestroy();
       
   667 
       
   668                          if (mrImplMatchesMailbox)
       
   669                              {
       
   670                              // We have at least one MRViewer implementation with an associated
       
   671                              // mailbox.  Check for a matching MR utils implementation
       
   672                              const TUid mrUtilsIface = {KMRUtilsInterfaceUID};
       
   673                              REComSession::ListImplementationsL(mrUtilsIface, implArray );
       
   674                              if (implArray.Count() > 0)
       
   675                                  {
       
   676                                  // Meeting request functionality is available on this device
       
   677                                  iMrEnabled = ETrue;
       
   678                                  }
       
   679                              }
       
   680 
       
   681                          }
       
   682                       CleanupStack::PopAndDestroy(); // implArray
       
   683                       }
       
   684 
       
   685                 CleanupStack::PopAndDestroy(); // mailboxes
       
   686                 CleanupStack::PopAndDestroy(); // mbUtils
       
   687                 }            
       
   688             }
       
   689     }
   583     }
   690 
   584 
   691 // -----------------------------------------------------------------------------
   585 // -----------------------------------------------------------------------------
   692 // CCalenInterimUtils2Impl::HasTimeOrDateChangedL()
   586 // CCalenInterimUtils2Impl::HasTimeOrDateChangedL()
   693 // Checks to see if the date or time has changed from the given entry to the
   587 // Checks to see if the date or time has changed from the given entry to the
   730     if (FeatureManager::FeatureSupported(KFeatureIdMeetingRequestEnabler) ||
   624     if (FeatureManager::FeatureSupported(KFeatureIdMeetingRequestEnabler) ||
   731         FeatureManager::FeatureSupported(KFeatureIdMeetingRequestSupport))
   625         FeatureManager::FeatureSupported(KFeatureIdMeetingRequestSupport))
   732         {
   626         {
   733         if( IsMeetingRequestL(aEntry) && aEntry.PhoneOwnerL() == NULL )
   627         if( IsMeetingRequestL(aEntry) && aEntry.PhoneOwnerL() == NULL )
   734             {
   628             {
   735             CMRMailboxUtils *mbUtils = CMRMailboxUtils::NewL();
   629             // Need to implement it once we have meeting request viewer in 10.1
   736             CleanupStack::PushL( mbUtils );
       
   737             mbUtils->SetPhoneOwnerL( aEntry );
       
   738             CleanupStack::PopAndDestroy(); // mbUtils
       
   739             }
   630             }
   740         }
   631         }
   741     FeatureManager::UnInitializeLib();
   632     FeatureManager::UnInitializeLib();
   742     
   633     
   743     TRACE_EXIT_POINT;
   634     TRACE_EXIT_POINT;