emailservices/emailserver/cmailhandlerplugin/src/cmailcpsif.cpp
branchRCL_3
changeset 14 b13141f05c3d
parent 13 8592a65ad3fb
child 16 b5fbb9b25d57
equal deleted inserted replaced
13:8592a65ad3fb 14:b13141f05c3d
    93         {
    93         {
    94         iMsgInterface->Close();
    94         iMsgInterface->Close();
    95         iMsgInterface = NULL;
    95         iMsgInterface = NULL;
    96         }
    96         }
    97     delete iServiceHandler;
    97     delete iServiceHandler;
    98     iInstIdList.ResetAndDestroy();  
    98     for ( TInt i = 0; i < iInstIdList.Count(); i++ )
       
    99         {
       
   100         iInstIdList.Remove(i);
       
   101         }
    99     CCoeEnv::Static()->DeleteResourceFile( iResourceFileOffset );
   102     CCoeEnv::Static()->DeleteResourceFile( iResourceFileOffset );
   100     if ( iContentControlClient ) 
   103     if ( iContentControlClient ) 
   101         {
   104         {
   102         delete iContentControlClient;
   105         delete iContentControlClient;
   103         }
   106         }
   178 
   181 
   179 // ---------------------------------------------------------------------------
   182 // ---------------------------------------------------------------------------
   180 // CMailCpsIf::PublishSetupWizardL
   183 // CMailCpsIf::PublishSetupWizardL
   181 // ---------------------------------------------------------------------------
   184 // ---------------------------------------------------------------------------
   182 //
   185 //
   183 void CMailCpsIf::PublishSetupWizardL(TInt instance)
   186 void CMailCpsIf::PublishSetupWizardL(TInt aInstance)
   184     {
   187     {
   185     FUNC_LOG;
   188     FUNC_LOG;
   186     TFSMailMsgId mailBoxId;
   189     if (!iInstIdList[aInstance].iWizardPublished)
   187     TFSMailMsgId folderId;
   190         {
   188 
   191         TFSMailMsgId mailBoxId;
   189     HBufC* setupEmail = StringLoader::LoadLC(R_EMAILWIDGET_TEXT_SETUP_EMAIL);
   192         TFSMailMsgId folderId;
   190     
   193     
   191     iSetupUid = PublishDescriptorL(
   194        HBufC* setupEmail = StringLoader::LoadLC(R_EMAILWIDGET_TEXT_SETUP_EMAIL);
       
   195     
       
   196         iSetupUid = PublishDescriptorL(
   192             KPubId, KContTypeSetupText,
   197             KPubId, KContTypeSetupText,
   193             iInstIdList[instance]->Des(),
   198             iInstIdList[aInstance].iCid,
   194             *setupEmail, 
   199             *setupEmail, 
   195             KKeySetupText, KTriggerWizard8);	
   200             KKeySetupText, KTriggerWizard8);
   196 
   201 
   197     PublishImageL(
   202         PublishImageL(
   198             iInstIdList[instance]->Des(),
   203             iInstIdList[aInstance].iCid,
   199             KContTypeSetupIcon,
   204             KContTypeSetupIcon,
   200             KKeySetupIcon,
   205             KKeySetupIcon,
   201             EMbmCmailhandlerpluginQgn_prop_cmail_new_mailbox,
   206             EMbmCmailhandlerpluginQgn_prop_cmail_new_mailbox,
   202             EMbmCmailhandlerpluginQgn_prop_cmail_new_mailbox_mask,
   207             EMbmCmailhandlerpluginQgn_prop_cmail_new_mailbox_mask,
   203             mailBoxId,
   208             mailBoxId,
   204             KNullDes);
   209             KNullDes);
   205             
   210             
   206     PublishImageL(
   211         PublishImageL(
   207             iInstIdList[instance]->Des(),
   212             iInstIdList[aInstance].iCid,
   208             KContTypeSetupBrandIcon1,
   213             KContTypeSetupBrandIcon1,
   209             KKeySetupBrandIcon1,
   214             KKeySetupBrandIcon1,
   210             EMbmCmailhandlerpluginQgn_indi_cmail_drop_email_account,
   215             EMbmCmailhandlerpluginQgn_indi_cmail_drop_email_account,
   211             EMbmCmailhandlerpluginQgn_indi_cmail_drop_email_account_mask,
   216             EMbmCmailhandlerpluginQgn_indi_cmail_drop_email_account_mask,
   212             mailBoxId,
   217             mailBoxId,
   213             KSetupBrand1);
   218             KSetupBrand1);
   214 
   219 
   215     PublishImageL(
   220         PublishImageL(
   216             iInstIdList[instance]->Des(),
   221             iInstIdList[aInstance].iCid,
   217             KContTypeSetupBrandIcon2,
   222             KContTypeSetupBrandIcon2,
   218             KKeySetupBrandIcon2,
   223             KKeySetupBrandIcon2,
   219             EMbmCmailhandlerpluginQgn_indi_cmail_drop_email_account,
   224             EMbmCmailhandlerpluginQgn_indi_cmail_drop_email_account,
   220             EMbmCmailhandlerpluginQgn_indi_cmail_drop_email_account_mask,
   225             EMbmCmailhandlerpluginQgn_indi_cmail_drop_email_account_mask,
   221             mailBoxId,
   226             mailBoxId,
   222             KSetupBrand2);
   227             KSetupBrand2);
   223 
   228 
   224     PublishImageL(
   229         PublishImageL(
   225             iInstIdList[instance]->Des(),
   230             iInstIdList[aInstance].iCid,
   226             KContTypeSetupBrandIcon3,
   231             KContTypeSetupBrandIcon3,
   227             KKeySetupBrandIcon3,
   232             KKeySetupBrandIcon3,
   228             EMbmCmailhandlerpluginQgn_indi_cmail_drop_email_account,
   233             EMbmCmailhandlerpluginQgn_indi_cmail_drop_email_account,
   229             EMbmCmailhandlerpluginQgn_indi_cmail_drop_email_account_mask,
   234             EMbmCmailhandlerpluginQgn_indi_cmail_drop_email_account_mask,
   230             mailBoxId,
   235             mailBoxId,
   231             KSetupBrand3);
   236             KSetupBrand3);
   232 
   237 
   233     PublishImageL(
   238         PublishImageL(
   234             iInstIdList[instance]->Des(),
   239             iInstIdList[aInstance].iCid,
   235             KContTypeSetupBrandIcon4,
   240             KContTypeSetupBrandIcon4,
   236             KKeySetupBrandIcon4,
   241             KKeySetupBrandIcon4,
   237             EMbmCmailhandlerpluginQgn_indi_cmail_drop_email_account,
   242             EMbmCmailhandlerpluginQgn_indi_cmail_drop_email_account,
   238             EMbmCmailhandlerpluginQgn_indi_cmail_drop_email_account_mask,
   243             EMbmCmailhandlerpluginQgn_indi_cmail_drop_email_account_mask,
   239             mailBoxId,
   244             mailBoxId,
   240             KSetupBrand4);            
   245             KSetupBrand4);
   241 
   246         iInstIdList[aInstance].iWizardPublished = ETrue;
   242     CleanupStack::PopAndDestroy(setupEmail);    
   247         CleanupStack::PopAndDestroy(setupEmail);
       
   248         }        
   243     }
   249     }
   244 
   250 
   245 // ---------------------------------------------------------------------------
   251 // ---------------------------------------------------------------------------
   246 // CMailCpsIf::PublishActiveMailboxNameL
   252 // CMailCpsIf::PublishActiveMailboxNameL
   247 // ---------------------------------------------------------------------------
   253 // ---------------------------------------------------------------------------
   264     textKey.Copy(KKeyBodyText);
   270     textKey.Copy(KKeyBodyText);
   265     textKey.Append(row);
   271     textKey.Append(row);
   266 		
   272 		
   267     iMailboxNameUid = PublishDescriptorL(
   273     iMailboxNameUid = PublishDescriptorL(
   268         KPubId, contentType, 
   274         KPubId, contentType, 
   269         iInstIdList[aInstance]->Des(),
   275         iInstIdList[aInstance].iCid,        
   270         aMailboxName,
   276         aMailboxName,
   271         textKey, KTriggerEmailUi8);
   277         textKey, KTriggerEmailUi8);
   272     }
   278     }
   273 
   279 
   274 // ---------------------------------------------------------------------------
   280 // ---------------------------------------------------------------------------
   290     textKey.Copy(KKeyBodyText);
   296     textKey.Copy(KKeyBodyText);
   291     textKey.Append(_L("1"));
   297     textKey.Append(_L("1"));
   292 
   298 
   293     TFSMailMsgId dummy;
   299     TFSMailMsgId dummy;
   294     
   300     
   295     PublishDescriptorL( KPubId, contentType, iInstIdList[aInstance]->Des(),
   301     PublishDescriptorL( KPubId, contentType, iInstIdList[aInstance].iCid,
   296         aMailboxName, textKey, aAction);
   302         aMailboxName, textKey, aAction);        
   297     }
   303     }
   298 
   304 
   299 // ---------------------------------------------------------------------------
   305 // ---------------------------------------------------------------------------
   300 // CMailCpsIf::PublishIndicatorIconL
   306 // CMailCpsIf::PublishIndicatorIconL
   301 // ---------------------------------------------------------------------------
   307 // ---------------------------------------------------------------------------
   320     TBuf8<KMaxDescLen> key;
   326     TBuf8<KMaxDescLen> key;
   321     key.Copy(KKeyIndicatorIcon);     
   327     key.Copy(KKeyIndicatorIcon);     
   322     key.Append(row8);
   328     key.Append(row8);
   323 
   329 
   324     PublishImageL(
   330     PublishImageL(
   325               iInstIdList[aInstance]->Des(),
   331               iInstIdList[aInstance].iCid,
   326               contentType,
   332               contentType,
   327               key,
   333               key,
   328               aIcon,
   334               aIcon,
   329               aIcon + 1,
   335               aIcon + 1,
   330               mailBoxId,
   336               mailBoxId,
   355     TBuf8<KMaxDescLen> key;
   361     TBuf8<KMaxDescLen> key;
   356     key.Copy(KKeyMailboxIcons);     
   362     key.Copy(KKeyMailboxIcons);     
   357     key.Append(row8);
   363     key.Append(row8);
   358 
   364 
   359     PublishImageL(
   365     PublishImageL(
   360               iInstIdList[aInstance]->Des(),
   366               iInstIdList[aInstance].iCid,
   361               contentType,
   367               contentType,
   362               key,
   368               key,
   363               aIcon,
   369               aIcon,
   364               aIcon + 1,
   370               aIcon + 1,
   365               aMailBoxId,
   371               aMailBoxId,
   380 
   386 
   381     TBuf8<KMaxDescLen> key;
   387     TBuf8<KMaxDescLen> key;
   382     key.Copy(KKeyMailboxIcons);     
   388     key.Copy(KKeyMailboxIcons);     
   383     key.Append(_L8("1"));
   389     key.Append(_L8("1"));
   384 
   390 
   385     User::LeaveIfNull( iInstIdList[aInstance] );
   391     if ( GetWidgetInstanceCount() <= aInstance ) User::LeaveIfError( KErrNotFound );
       
   392 
   386     PublishIconReferenceL(
   393     PublishIconReferenceL(
   387         iInstIdList[aInstance]->Des(),
   394         iInstIdList[aInstance].iCid,
   388         contentType,
   395         contentType,
   389         key,
   396         key,
   390         aIconPath );
   397         aIconPath );
   391     }
   398     }
   392 
   399 
   478     TFSMailMsgId mailBoxId;
   485     TFSMailMsgId mailBoxId;
   479     TFSMailMsgId folderId;
   486     TFSMailMsgId folderId;
   480 
   487 
   481     iMailboxNameUid = PublishDescriptorL(
   488     iMailboxNameUid = PublishDescriptorL(
   482         KPubId, contentType, 
   489         KPubId, contentType, 
   483         iInstIdList[aInstance]->Des(),
   490         iInstIdList[aInstance].iCid,
   484         aText,
   491         aText,
   485         textKey, KNullDes8);  
   492         textKey, KNullDes8);  
   486     }
   493     }
   487 
   494 
   488 // ---------------------------------------------------------------------------
   495 // ---------------------------------------------------------------------------
   893                              }
   900                              }
   894                          if (trigger.Compare(KSuspend16) == 0)
   901                          if (trigger.Compare(KSuspend16) == 0)
   895                              {
   902                              {
   896                              // Publishing to homescreen suspended.
   903                              // Publishing to homescreen suspended.
   897                              HBufC* cid = contentid.AllocLC();
   904                              HBufC* cid = contentid.AllocLC();
   898 	                         TInt widgetInstance = FindWidgetInstanceId(cid->Des());
   905                              TInt widgetInstance = GetWidgetInstanceId(cid->Des());
   899 							 if(widgetInstance>=0)
   906 							 if(widgetInstance>=0)
   900                              	iAllowedToPublish[widgetInstance] = EFalse;
   907                              	iAllowedToPublish[widgetInstance] = EFalse;
   901                              CleanupStack::PopAndDestroy( cid );
   908                              CleanupStack::PopAndDestroy( cid );
   902                              }
   909                              }
   903                          else if (trigger.Compare(KResume16) == 0)
   910                          else if (trigger.Compare(KResume16) == 0)
   904                              {
   911                              {
   905                              HBufC* cid = contentid.AllocLC();
   912                              HBufC* cid = contentid.AllocLC();
   906                              if ( FindWidgetInstanceId(cid->Des()) < 0 )
   913                              if ( GetWidgetInstanceId(cid->Des()) < 0 )
   907                                  {
   914                                  {
   908                                  iInstIdList.AppendL( contentid.AllocL() );
   915                                  TInstIdInfo instIdInfo;
       
   916                                  instIdInfo.iCid.Copy(cid->Des());                           
       
   917                                  instIdInfo.iUpdateNeeded = ETrue;
       
   918                                  instIdInfo.iWizardPublished = EFalse;
       
   919                                  iInstIdList.AppendL(instIdInfo);
   909                                  }
   920                                  }
   910                              TInt widgetInstance = FindWidgetInstanceId(cid->Des()); 
   921                              TInt widgetInstance = GetWidgetInstanceId(cid->Des()); 
   911                              if(widgetInstance>=0)// coverity fix, index can be negativ, allowed 0, since it is valid index
   922                              if(widgetInstance>=0)// coverity fix, index can be negativ, allowed 0, since it is valid index
   912                                  {
   923                                  {
   913                                  PublishSetupWizardL(widgetInstance);
       
   914                                  iMailCpsHandler->UpdateMailboxesL(widgetInstance, cid->Des());
   924                                  iMailCpsHandler->UpdateMailboxesL(widgetInstance, cid->Des());
       
   925                                  PublishSetupWizardL(widgetInstance);                                 
   915                                  // Widget visible on the homescreen. Publishing allowed.
   926                                  // Widget visible on the homescreen. Publishing allowed.
   916                                  iAllowedToPublish[widgetInstance] = ETrue;
   927                                  iAllowedToPublish[widgetInstance] = ETrue;
   917                                  }
   928                                  }
   918                              CleanupStack::PopAndDestroy( cid );
   929                              CleanupStack::PopAndDestroy( cid );
   919                              }
   930                              }
   921                              {
   932                              {
   922                              // Widget added to homescreen
   933                              // Widget added to homescreen
   923                              HBufC* cid = contentid.AllocLC();
   934                              HBufC* cid = contentid.AllocLC();
   924                              if ( cid->Length() > 0 )
   935                              if ( cid->Length() > 0 )
   925                                  {
   936                                  {
   926                                  iInstIdList.AppendL( contentid.AllocL() );
   937                                  TInstIdInfo instIdInfo;
       
   938                                  instIdInfo.iCid.Copy(cid->Des());                           
       
   939                                  instIdInfo.iUpdateNeeded = ETrue;
       
   940                                  instIdInfo.iWizardPublished = EFalse;
       
   941                                  iInstIdList.AppendL(instIdInfo);
   927                                  TFSMailMsgId mailBox( iMailCpsHandler->WaitingForNewWidget() );
   942                                  TFSMailMsgId mailBox( iMailCpsHandler->WaitingForNewWidget() );
   928                                  if ( mailBox.Id() > 0 )
   943                                  if ( mailBox.Id() > 0 )
   929                                      {
   944                                      {
   930                                      // Associate new mailbox to widget setting
   945                                      // Associate new mailbox to widget setting
   931                                      iMailCpsHandler->AssociateWidgetToSetting( 
   946                                      iMailCpsHandler->AssociateWidgetToSetting( 
   948                              {                            
   963                              {                            
   949                              // Widget removed from homescreen.
   964                              // Widget removed from homescreen.
   950                              HBufC* cid = contentid.AllocLC();                             
   965                              HBufC* cid = contentid.AllocLC();                             
   951                              ResetPublishedDataL( cid->Des() );							 
   966                              ResetPublishedDataL( cid->Des() );							 
   952                              iMailCpsHandler->DissociateWidgetFromSettingL( cid->Des() );
   967                              iMailCpsHandler->DissociateWidgetFromSettingL( cid->Des() );
   953                              TInt widgetInstance = FindWidgetInstanceId( cid->Des() );
   968                              TInt widgetInstance = GetWidgetInstanceId( cid->Des() );
   954                              if (widgetInstance != KErrNotFound )
   969                              if (widgetInstance != KErrNotFound )
   955                                  {
   970                                  {
   956                                  iInstIdList.Remove(widgetInstance);
   971                                  iInstIdList.Remove(widgetInstance);
   957                                  }
   972                                  }
   958                              CleanupStack::PopAndDestroy( cid );
   973                              CleanupStack::PopAndDestroy( cid );
  1025     return iInstIdList.Count();
  1040     return iInstIdList.Count();
  1026     }
  1041     }
  1027 
  1042 
  1028 
  1043 
  1029 // ---------------------------------------------------------------------------
  1044 // ---------------------------------------------------------------------------
  1030 // CMailCpsIf::FindWidgetInstanceId
  1045 // CMailCpsIf::GetWidgetInstanceId
  1031 // ---------------------------------------------------------------------------
  1046 // ---------------------------------------------------------------------------
  1032 //
  1047 //
  1033 TInt CMailCpsIf::FindWidgetInstanceId( const TDesC& aContentId )
  1048 TInt CMailCpsIf::GetWidgetInstanceId( const TDesC& aContentId )
  1034     {
  1049     {
  1035     FUNC_LOG;
  1050     FUNC_LOG;
  1036     TInt instance(KErrNotFound);
  1051     TInt instance(KErrNotFound);
  1037     for (TInt i = 0; i < iInstIdList.Count(); i++)
  1052     for (TInt i = 0; i < iInstIdList.Count(); i++)    
  1038         {
  1053         {
  1039         TInt val = aContentId.Compare(iInstIdList[i]->Des());
  1054         TInt val = aContentId.Compare(iInstIdList[i].iCid);
  1040         if (!val)
  1055         if (!val)
  1041             {
  1056             {
  1042             instance = i;
  1057             instance = i;
  1043             break;
  1058             break;
  1044             }
  1059             }
  1090     {
  1105     {
  1091     FUNC_LOG;
  1106     FUNC_LOG;
  1092     
  1107     
  1093     for ( TInt i = 0; i < iInstIdList.Count(); i++ )
  1108     for ( TInt i = 0; i < iInstIdList.Count(); i++ )
  1094         {
  1109         {
  1095         if ( !iMailCpsHandler->Associated(iInstIdList[i]->Des()) )
  1110         if ( !iMailCpsHandler->Associated(iInstIdList[i].iCid) )
  1096             {
  1111             {
  1097             // Empty e-mail widget found. Associate new account to it.
  1112             // Empty e-mail widget found. Associate new account to it.
  1098             iMailCpsHandler->AssociateWidgetToSetting( 
  1113             iMailCpsHandler->AssociateWidgetToSetting( 
  1099                     iInstIdList[i]->Des(),
  1114                     iInstIdList[i].iCid,
  1100                     aMailbox );
  1115                     aMailbox );
  1101             return;
  1116             return;
  1102             }
  1117             }
  1103         }
  1118         }
  1104     
  1119     
  1155 void CMailCpsIf::NotifyAppListChanged()
  1170 void CMailCpsIf::NotifyAppListChanged()
  1156     {
  1171     {
  1157     FUNC_LOG;
  1172     FUNC_LOG;
  1158     }
  1173     }
  1159 
  1174 
       
  1175 // ---------------------------------------------------------------------------
       
  1176 // CMailCpsIf::SetUpdateNeeded
       
  1177 // ---------------------------------------------------------------------------
       
  1178 //
       
  1179 void CMailCpsIf::SetUpdateNeeded( const TInt aInstance, const TBool aValue )
       
  1180     {
       
  1181     FUNC_LOG;
       
  1182     iInstIdList[aInstance].iUpdateNeeded = aValue;
       
  1183     }
       
  1184 
       
  1185 // ---------------------------------------------------------------------------
       
  1186 // CMailCpsIf::UpdateNeeded
       
  1187 // ---------------------------------------------------------------------------
       
  1188 //
       
  1189 TBool CMailCpsIf::UpdateNeeded( const TInt aInstance )
       
  1190     {
       
  1191     FUNC_LOG;
       
  1192     return iInstIdList[aInstance].iUpdateNeeded;
       
  1193     }
       
  1194