--- a/ipsservices/ipssosplugin/src/ipsplgeventhandler.cpp Thu Aug 19 09:38:05 2010 +0300
+++ b/ipsservices/ipssosplugin/src/ipsplgeventhandler.cpp Tue Aug 31 15:04:17 2010 +0300
@@ -105,8 +105,7 @@
iIPSSettingsObservers.ResetAndDestroy();
iIPSSettingsObservers.Close();
iPropertyObservers.Close();
- iConnOpCallbacks.Close();
- delete iSettingsApi;
+// <qmail> iConnOpCallbacks, iSettingsApi members removed
iImapFolderIds.Close();
}
@@ -119,8 +118,7 @@
iIPSAccounts( KEventGranularity ),
iIPSSettingsObservers( KEventGranularity ),
iIsConnected( EFalse ),
- iPropertyObservers( KEventGranularity ),
- iConnOpCallbacks( KEventGranularity )
+ iPropertyObservers( KEventGranularity )
{
FUNC_LOG;
}
@@ -130,7 +128,11 @@
void CIpsPlgEventHandler::ConstructL( )
{
FUNC_LOG;
- iCenRep = CRepository::NewL( KCRUidExtendedSettingsUid );
+// <qmail>
+ // commented out from qmail when extented settings
+ // cen rep not exist in environment
+ //iCenRep = CRepository::NewL( KCRUidExtendedSettingsUid );
+// </qmail>
iPluginId = iBasePlugin.PluginId();
RegisterPropertyObserverL( this );
}
@@ -141,7 +143,7 @@
{
FUNC_LOG;
iSession = aSession;
- iSettingsApi = CIpsSetDataApi::NewL( *iSession );
+// <qmail> iSettingsApi member removed
// this collects all folderids to array from mailboxes that
// have registered observers, this is need to do here because
@@ -152,7 +154,7 @@
TMsvId mboxId = iMBoxObservers[i]->iMBoxId.Id();
if ( mboxes.Find(mboxId) == KErrNotFound )
{
- mboxes.Append( mboxId );
+ mboxes.AppendL( mboxId );
}
}
@@ -204,7 +206,7 @@
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
-TInt CIpsPlgEventHandler::RegisterPropertyObserverL(
+void CIpsPlgEventHandler::RegisterPropertyObserverL(
MIpsPlgPropertyObserver* aObserver )
{
FUNC_LOG;
@@ -219,7 +221,7 @@
CActive::EPriorityIdle, *this );
}
- return iPropertyObservers.Append( aObserver );
+ iPropertyObservers.AppendL( aObserver );
}
// ----------------------------------------------------------------------------
@@ -249,7 +251,8 @@
TIpsPlgPropertyEvent aEvent )
{
FUNC_LOG;
- TBool doNotify = ETrue;
+ INFO_1("pluginid == 0x%x", iPluginId);
+ //<qmail> not used: TBool doNotify = ETrue;
switch ( aEvent.iEvent )
{
case KIpsSosEmailSyncStarted:
@@ -265,8 +268,8 @@
default:
break;
}
-
- for ( TInt i = 0; doNotify && i < iPropertyObservers.Count(); i++ )
+ // <qmail> removed doNotify bool below
+ for ( TInt i = 0; i < iPropertyObservers.Count(); i++ )
{
TRAP_IGNORE( iPropertyObservers[i]->HandlePropertyEventL(
aEvent.iEvent, aEvent.iMailbox,
@@ -489,7 +492,7 @@
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
-inline void CIpsPlgEventHandler::FillFSMessageArray(
+inline void CIpsPlgEventHandler::FillFSMessageArrayL(
RArray<TFSMailMsgId>& aFSArray,
const CMsvEntrySelection* aSelection,
TUint aMtmUid )
@@ -501,7 +504,7 @@
for ( TInt i = 0; i < aSelection->Count(); i++ )
{
- aFSArray.Append( SymId2FsId(aSelection->At(i), aMtmUid) );
+ aFSArray.AppendL( SymId2FsId(aSelection->At(i), aMtmUid) );
}
}
@@ -658,6 +661,7 @@
if ( type == KUidMsvMessageEntry && !isMarkedAsDeleted )
{
TMsvId* parent = static_cast<TMsvId*>(aArg2);
+ // NOTE: assumed that event contains only one new message
event = TFSEventNewMail;
TFSMailMsgId mbox;
@@ -690,7 +694,7 @@
RArray<TFSMailMsgId> array(KEventGranularity);
CleanupClosePushL( array );
- FillFSMessageArray(
+ FillFSMessageArrayL(
array,
static_cast<const CMsvEntrySelection*>(aArg1),
tNew.iMtm.iUid );
@@ -713,7 +717,7 @@
// set entries array pointer
RArray<TFSMailMsgId> array(1);
CleanupClosePushL( array );
- array.Append( SymId2FsId( tNew ) );
+ array.AppendL( SymId2FsId( tNew ) );
arg1 = &array;
// set parent pointer
@@ -762,7 +766,7 @@
RArray<TFSMailMsgId> array(KEventGranularity);
CleanupClosePushL( array );
- FillFSMessageArray(
+ FillFSMessageArrayL(
array,
static_cast<const CMsvEntrySelection*>(aArg1),
tMoved.iMtm.iUid );
@@ -931,7 +935,7 @@
}
else
{
- array.Append( SymId2FsId(deletedId, tEntry.iMtm.iUid) );
+ array.AppendL( SymId2FsId(deletedId, tEntry.iMtm.iUid) );
arg1 = &array;
arg2 = &parentId;
@@ -988,7 +992,7 @@
RArray<TFSMailMsgId> array(1);
CleanupClosePushL( array );
- array.Append( msg );
+ array.AppendL( msg );
arg1 = &array;
arg2 = &parent;
event = TFSEventMailDeleted;
@@ -1021,19 +1025,17 @@
TAny* arg2=NULL;
TAny* arg3=NULL;
+ TInt errorCode( KErrNone ); // <qmail>
+
TUid uId;
TMsvEntry tChanged;
if ( !IsEventFromIpsSourceL( aArg1, uId, tChanged ) )
{
return;
}
- else if ( tChanged.iMtm.iUid == KSenduiMtmSmtpUidValue )
- {
- // do not send entry changed events from draft messages
- // mess up draft email
- return;
- }
-
+//<Qmail>
+
+//</Qmail>
TFSMailEvent event = static_cast<TFSMailEvent>( KErrNotFound );
RArray<TFSMailMsgId> array(1);
@@ -1052,7 +1054,7 @@
}
// message entry
- array.Append( SymId2FsId( tChanged ) );
+ array.AppendL( SymId2FsId( tChanged ) );
arg1 = &array;
// parent entry
@@ -1064,7 +1066,7 @@
{
event = TFSEventFolderChanged;
- array.Append( SymId2FsId( tChanged ) );
+ array.AppendL( SymId2FsId( tChanged ) );
arg1 = &array;
TFSMailMsgId id = SymId2FsId( *(static_cast<TMsvId*>(aArg2)), tChanged.iMtm.iUid );
@@ -1076,7 +1078,7 @@
TInt index = iImapFolderIds.Find(tChanged.Id());
if ( eml.LocalSubscription() && index == KErrNotFound )
{
- iImapFolderIds.Append( tChanged.Id() );
+ iImapFolderIds.AppendL( tChanged.Id() );
}
else if ( !eml.LocalSubscription() && index != KErrNotFound )
{
@@ -1093,7 +1095,18 @@
}
else
{
+ // <qmail> add error code
event = TFSEventMailboxOffline;
+ const CMsvEntrySelection* selection = static_cast<CMsvEntrySelection*>( aArg1 );
+ TFSMailMsgId mailboxId( iPluginId, selection->At(0) );
+
+ if ( !(iBasePlugin.HasOperations( mailboxId )) && iBasePlugin.ActivityTimerL( mailboxId ).IsActive() )
+ {
+ // considering this disconnection event as unexpected
+ errorCode = KErrDisconnected;
+ arg1 = &errorCode;
+ }
+ // </qmail>
}
}
else if( IsAccountNameChangeL( aArg1, aArg2 ) )
@@ -1196,7 +1209,12 @@
// ---------------------------------------------------------------------------
TUid CIpsPlgEventHandler::MtmId() const
{
- return iBasePlugin.MtmId();
+ TUid ret = KSenduiMtmImap4Uid;
+ if ( iBasePlugin.MtmId().iUid == KIpsPlgPop3PluginUidValue )
+ {
+ ret = KSenduiMtmPop3Uid;
+ }
+ return ret;
}
//</cmail>
// ----------------------------------------------------------------------------
@@ -1324,7 +1342,6 @@
}
RPointerArray<MFSMailEventObserver> observers;
- CleanupClosePushL( observers ); // not owning classes
MailboxObserversL( aAccount, observers );
if ( find != KErrNotFound )
@@ -1333,12 +1350,16 @@
}
else
{
- CIpsPlgSettingsObserver* obs =
+// <qmail>
+ // commented out from qmail when extented settings
+ // cen rep not exist in environment
+ /*CIpsPlgSettingsObserver* obs =
CIpsPlgSettingsObserver::NewL( aAccount, *iCenRep, *this );
obs->SetKeyAndActivateL( aSettingKey, observers );
- iIPSSettingsObservers.AppendL( obs );
+ iIPSSettingsObservers.AppendL( obs );*/
+// </qmail>
}
- CleanupStack::PopAndDestroy( &observers );
+ observers.Close();
}
// ----------------------------------------------------------------------------
@@ -1461,7 +1482,7 @@
aFSParent.SetId( aParent.Id() );
for ( TInt i = 0; i < aDeletedIds.Count(); i++ )
{
- aFSDeletedArray.Append(
+ aFSDeletedArray.AppendL(
TFSMailMsgId( iPluginId, aDeletedIds.At(i) ) );
}
}
@@ -1488,62 +1509,86 @@
void CIpsPlgEventHandler::SignalStartSyncL( const TFSMailMsgId& aAccount )
{
FUNC_LOG;
- TFSMailEvent event = TFSEventMailboxSyncStateChanged;
- TSSMailSyncState state = StartingSync;
+ // <qmail> no need to create event variable here
+ // TFSMailEvent event = TFSEventMailboxSyncStateChanged;
+ // <qmail> renamed variable
+ TSSMailSyncState syncState( StartingSync );
- SaveSyncStatusL( aAccount.Id(), TInt( state ) );
+ // <qmail> remove SaveSyncStatusL as it does nothing
+ // SaveSyncStatusL( aAccount.Id(), TInt( syncState ) );
SendDelayedEventL(
- event,
+ TFSEventMailboxSyncStateChanged,
aAccount,
- &state,
+ &syncState,
NULL,
NULL );
}
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
-void CIpsPlgEventHandler::SignalSyncCompletedL(
- const TFSMailMsgId& aAccount,
- TInt aError )
+void CIpsPlgEventHandler::SignalSyncCompletedL( const TFSMailMsgId& aAccount, TInt aError )
{
FUNC_LOG;
- TFSMailEvent event = TFSEventMailboxSyncStateChanged;
-
- TSSMailSyncState state = FinishedSuccessfully;
+ // <qmail> no need to create event variable here
+ // TFSMailEvent event = TFSEventMailboxSyncStateChanged;
+ // <qmail> renamed variable, and setting value in new func
+ TSSMailSyncState syncState = ConvertCompletionCode( aError );
- if ( aError == KErrCancel )
- {
- state = SyncCancelled;
- }
- else if ( aError != KErrNone && aError != KErrCancel )
- {
- state = SyncError;
- }
-
- SaveSyncStatusL( aAccount.Id(), TInt( state ) );
+ // <qmail> remove SaveSyncStatusL as it does nothing
+ // SaveSyncStatusL( aAccount.Id(), TInt( syncState ) );
SendDelayedEventL(
- event,
+ TFSEventMailboxSyncStateChanged,
aAccount,
- &state,
+ &syncState,
NULL,
NULL );
}
+// <qmail> new function
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
-void CIpsPlgEventHandler::SignalMailboxOfflineStateL(
- const TFSMailMsgId& aAccount )
+TSSMailSyncState CIpsPlgEventHandler::ConvertCompletionCode( TInt aCompletionCode )
{
FUNC_LOG;
- SendDelayedEventL(
- TFSEventMailboxOffline,
- aAccount,
- NULL,
- NULL,
- NULL );
+ INFO_1("completioncode == %d", aCompletionCode);
+ switch ( aCompletionCode )
+ {
+ case KErrNone:
+ return FinishedSuccessfully;
+ case KErrCancel:
+ return SyncCancelled;
+ case KErrImapBadLogon:
+ case KPop3InvalidUser:
+ case KPop3InvalidLogin:
+ case KPop3InvalidApopLogin:
+ return PasswordNotVerified;
+ case -5120: // (DndTimedOut) wrong server name in settings
+ case KErrHostUnreach: // wrong port number
+ return ServerConnectionError;
+ case KErrTimedOut:
+ default:
+ return SyncError;
+ }
}
+// </qmail>
+
+//<qmail> not used at all
+// ----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
+//void CIpsPlgEventHandler::SignalMailboxOfflineStateL(
+// const TFSMailMsgId& aAccount )
+// {
+// FUNC_LOG;
+// SendDelayedEventL(
+// TFSEventMailboxOffline,
+// aAccount,
+// NULL,
+// NULL,
+// NULL );
+// }
+// </qmail>
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
@@ -1552,139 +1597,102 @@
FUNC_LOG;
}
+//<qmail> not used at all
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
-void CIpsPlgEventHandler::SaveSyncStatusL( TMsvId aMailboxId, TInt aState )
- {
- FUNC_LOG;
- TMsvEntry tEntry;
- TMsvId service;
- if( !iSession )
- {
- User::Leave( KErrNotReady );
- }
- TInt err = iSession->GetEntry( aMailboxId, service, tEntry );
-
- if( err == KErrNone )
- {
- iSettingsApi->SaveSyncStatusL( tEntry, aState );
- }
- }
+//void CIpsPlgEventHandler::SaveSyncStatusL( TMsvId aMailboxId, TInt /*aState*/ )
+// {
+// FUNC_LOG;
+// TMsvEntry tEntry;
+// TMsvId service;
+// if( !iSession )
+// {
+// User::Leave( KErrNotReady );
+// }
+// TInt err = iSession->GetEntry( aMailboxId, service, tEntry );
+//
+// if( err == KErrNone )
+// {
+// }
+// }
+// </qmail>
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
void CIpsPlgEventHandler::HandlePropertyEventL(
- TInt aEvent,
- TInt aMailbox,
- TInt aPluginId,
- TInt /*aError*/ )
+ TInt aEvent,
+ TInt aMailbox,
+ TInt /*aPluginId*/,
+ TInt /*aError*/ )
{
FUNC_LOG;
- RProcess process;
-
- // only email server should handle login notifications
- if (( aEvent == EIPSSosPswErr || aEvent == EIPSSosSmtpPswErr ) &&
- process.SecureId() == FREESTYLE_FSSERVER_SID &&
- iQueryPassState == EReady &&
- iBasePlugin.PluginId() == aPluginId )
- {
- TFSMailMsgId mbox = SymId2FsId( aMailbox, iBasePlugin.MtmId().iUid );
-
- // keep information about type of mail we`re setting the password
- iIncomingPass = ( aEvent == EIPSSosPswErr ? ETrue : EFalse );
- iQueryPassState = ENotificationRequest;
-
- TFSMailEvent event = TFSEventException;
- TFsEmailNotifierSystemMessageType msg = EFsEmailNotifErrLoginUnsuccesfull;
- SendDelayedEventL( event, mbox, &msg, NULL, (MFSMailExceptionEventCallback*)this );
- }
- else if ( aEvent == EIPSSosCredientialsSet || aEvent == EIPSSosCredientialsCancelled )
- {
- // if this handler invoked query user pass
- if ( iQueryPassState == EBusy )
- {
- iQueryPassState = ERequestResponding;
- // run callbacks
- for ( TInt i = 0; i < iConnOpCallbacks.Count(); i++ )
- iConnOpCallbacks[i]->CredientialsSetL( aEvent );
-
- iConnOpCallbacks.Reset();
- // now handler is ready for another query user pass
- iQueryPassState = EReady;
- }
-
- //if password was changed, we need to send settings changed event also.
- if( aEvent == EIPSSosCredientialsSet )
- {
- TFSMailMsgId mbox = SymId2FsId( aMailbox,
- iBasePlugin.MtmId().iUid );
- TFSMailEvent event = TFSEventMailboxSettingsChanged;
- SendDelayedEventL( event, mbox, NULL, NULL , NULL );
- }
- }
- else if ( aEvent == EIPSSosSettingsChanged )
+// <qmail> remove these events
+// RProcess process;
+// if ( aEvent == EIPSSosPswErr && process.SecureId() == FREESTYLE_FSSERVER_SID )
+// {
+// TFSMailMsgId mbox = SymId2FsId( aMailbox,
+// iBasePlugin.MtmId().iUid );
+// TFSMailEvent event = TFSEventException;
+// TFsEmailNotifierSystemMessageType msg = EFsEmailNotifErrLoginUnsuccesfull;
+// SendDelayedEventL( event, mbox, &msg, NULL , (MFSMailExceptionEventCallback*)this );
+// }
+// else if ( aEvent == EIPSSosCredientialsSet || aEvent == EIPSSosCredientialsCancelled )
+// {
+// if ( iConnOpCallback )
+// {
+// iConnOpCallback->CredientialsSetL( aEvent );
+//
+// //Set to null after we have used this.
+// //don't delete, we don't own this.
+// iConnOpCallback=NULL;
+// }
+// //if password was changed, we need to send settings changed event also.
+// if( aEvent == EIPSSosCredientialsSet )
+// {
+// TFSMailMsgId mbox = SymId2FsId( aMailbox,
+// iBasePlugin.MtmId().iUid );
+// TFSMailEvent event = TFSEventMailboxSettingsChanged;
+// SendDelayedEventL( event, mbox, NULL, NULL , NULL );
+// }
+// }
+// else
+// </qmail>
+ if ( aEvent == EIPSSosSettingsChanged )
{
TFSMailMsgId mbox = SymId2FsId( aMailbox,
iBasePlugin.MtmId().iUid );
TFSMailEvent event = TFSEventMailboxSettingsChanged;
SendDelayedEventL( event, mbox, NULL, NULL , NULL );
}
+
+// <qmail> no need for KIpsSosEmailSyncCompleted event handling here,
+// because it has just been sent in NotifyPropertyEventL()
}
+// <qmail> removing unused functions
+// ----------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
+//void CIpsPlgEventHandler::QueryUsrPassL( TMsvId aMbox, MIpsPlgConnectOpCallback* aCallback )
+// {
+// FUNC_LOG;
+// iConnOpCallback = aCallback;//can be null, doesn't matter.
+// SetNewPropertyEvent( aMbox, EIPSSosPswErr, 0 );
+// }
+
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
-TBool CIpsPlgEventHandler::QueryUsrPassL(
- TMsvId aMbox,
- MIpsPlgConnectOpCallback* aCallback/*=NULL*/,
- TBool aIncoming/*=ETrue*/ )
- {
- FUNC_LOG;
-
- ASSERT( iConnOpCallbacks.Find( aCallback ) == KErrNotFound );
- if ( aCallback )
- iConnOpCallbacks.Append( aCallback );
-
- // set or re-set property event
- SetNewPropertyEvent( aMbox, (aIncoming ? EIPSSosPswErr : EIPSSosSmtpPswErr), 0 );
-
- // only one query at a time allowed
- if ( iQueryPassState != EReady )
- {
- return EFalse;
- }
-
- // update state
- iQueryPassState = EBusy;
-
- return ETrue;
- }
-
-// ----------------------------------------------------------------------------
-// ----------------------------------------------------------------------------
-TBool CIpsPlgEventHandler::IncomingPass() const
- {
- return iIncomingPass;
- }
-
-// ----------------------------------------------------------------------------
-// ----------------------------------------------------------------------------
-void CIpsPlgEventHandler::SignalCredientialsSetL( TInt aMailboxId, TBool aCancelled )
- {
- FUNC_LOG;
- if ( iQueryPassState == EPasswordRequest )
- {
- iQueryPassState = EReady;
- iIncomingPass = ETrue;
- }
-
- TInt event = EIPSSosCredientialsSet;
- if ( aCancelled )
- {
- event = EIPSSosCredientialsCancelled;
- }
-
- SetNewPropertyEvent( aMailboxId, event, 0 );
- }
+//void CIpsPlgEventHandler::SignalCredientialsSetL( TInt aMailboxId, TBool aCancelled )
+// {
+// FUNC_LOG;
+// TInt event = EIPSSosCredientialsSet;
+// if ( aCancelled )
+// {
+// event = EIPSSosCredientialsCancelled;
+// }
+//
+// SetNewPropertyEvent( aMailboxId, event, 0 );
+// }
+// </qmail>
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
@@ -1725,34 +1733,27 @@
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
-void CIpsPlgEventHandler::CollectSubscribedFoldersL( TMsvId aMailboxId )
+void CIpsPlgEventHandler::CollectSubscribedFoldersL( TMsvId /*aMailboxId*/ )
{
FUNC_LOG;
- if ( iSession )
- {
- iSettingsApi->GetSubscribedImapFoldersL( aMailboxId, iImapFolderIds );
- }
+// <qmail> code removed as it does nothing; keeping the func as it probably will be needed
}
+// <qmail> not needed
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
-void CIpsPlgEventHandler::ExceptionEventCallbackL(
- TFSMailMsgId aMailboxId,
- TInt aEventType,
- TBool /*aResponse*/ )
- {
- FUNC_LOG;
-
- if ( aEventType == EFsEmailNotifErrLoginUnsuccesfull &&
- iQueryPassState == ENotificationRequest )
- {
- iQueryPassState = EPasswordRequest;
- TFSMailEvent event = TFSEventMailboxSyncStateChanged;
- TSSMailSyncState state = PasswordNotVerified;
-
- SendDelayedEventL( event, aMailboxId, &state, NULL, NULL );
- }
- }
+//void CIpsPlgEventHandler::ExceptionEventCallbackL(
+// TFSMailMsgId aMailboxId,
+// TInt /*aEventType*/,
+// TBool /*aResponse*/ )
+// {
+// FUNC_LOG;
+// TFSMailEvent event = TFSEventMailboxSyncStateChanged;
+// TSSMailSyncState state = PasswordNotVerified;
+//
+// SendDelayedEventL( event, aMailboxId, &state, NULL , NULL );
+// }
+// </qmail>
// End of File