emailservices/nmclientapi/src/nmapimailboxsettings_p.cpp
author hgs
Thu, 24 Jun 2010 14:32:18 +0300
changeset 47 f83bd4ae1fe3
child 48 10eaf342f539
permissions -rw-r--r--
201025
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
47
hgs
parents:
diff changeset
     1
/*
hgs
parents:
diff changeset
     2
 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
hgs
parents:
diff changeset
     3
 * All rights reserved.
hgs
parents:
diff changeset
     4
 * This component and the accompanying materials are made available
hgs
parents:
diff changeset
     5
 * under the terms of "Eclipse Public License v1.0"
hgs
parents:
diff changeset
     6
 * which accompanies this distribution, and is available
hgs
parents:
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents:
diff changeset
     8
 *
hgs
parents:
diff changeset
     9
 * Initial Contributors:
hgs
parents:
diff changeset
    10
 * Nokia Corporation - initial contribution.
hgs
parents:
diff changeset
    11
 *
hgs
parents:
diff changeset
    12
 * Contributors:
hgs
parents:
diff changeset
    13
 *
hgs
parents:
diff changeset
    14
 * Description:
hgs
parents:
diff changeset
    15
 *
hgs
parents:
diff changeset
    16
 */
hgs
parents:
diff changeset
    17
hgs
parents:
diff changeset
    18
#include "nmapimailboxsettings_p.h"
hgs
parents:
diff changeset
    19
hgs
parents:
diff changeset
    20
#include "nmdataplugininterface.h"
hgs
parents:
diff changeset
    21
#include "nmapidatapluginfactory.h"
hgs
parents:
diff changeset
    22
//#include "nmapipopimapsettingsmanager.h"
hgs
parents:
diff changeset
    23
#include "emailtrace.h"
hgs
parents:
diff changeset
    24
hgs
parents:
diff changeset
    25
#include <nmapimailboxsettings.h>
hgs
parents:
diff changeset
    26
#include <nmapimailboxsettingsdata.h>
hgs
parents:
diff changeset
    27
hgs
parents:
diff changeset
    28
#include <QVariant>
hgs
parents:
diff changeset
    29
#include <QString>
hgs
parents:
diff changeset
    30
#include <QHash>
hgs
parents:
diff changeset
    31
#include <QList>
hgs
parents:
diff changeset
    32
hgs
parents:
diff changeset
    33
namespace EmailClientApi
hgs
parents:
diff changeset
    34
{
hgs
parents:
diff changeset
    35
NmApiMailboxSettingsPrivate::NmApiMailboxSettingsPrivate(QObject *parent) : 
hgs
parents:
diff changeset
    36
    QObject(parent), 
hgs
parents:
diff changeset
    37
    mFactory(NULL),
hgs
parents:
diff changeset
    38
    mDeleteMailboxOperation(NULL)
hgs
parents:
diff changeset
    39
{
hgs
parents:
diff changeset
    40
    NM_FUNCTION;
hgs
parents:
diff changeset
    41
    mFactory = NmApiDataPluginFactory::instance();
hgs
parents:
diff changeset
    42
    Q_CHECK_PTR(mFactory);
hgs
parents:
diff changeset
    43
}
hgs
parents:
diff changeset
    44
hgs
parents:
diff changeset
    45
NmApiMailboxSettingsPrivate::~NmApiMailboxSettingsPrivate()
hgs
parents:
diff changeset
    46
{
hgs
parents:
diff changeset
    47
    NM_FUNCTION;
hgs
parents:
diff changeset
    48
    NmApiDataPluginFactory::releaseInstance(mFactory);
hgs
parents:
diff changeset
    49
    if(mDeleteMailboxOperation && mDeleteMailboxOperation->isRunning()) {
hgs
parents:
diff changeset
    50
        mDeleteMailboxOperation->cancelOperation();        
hgs
parents:
diff changeset
    51
    }
hgs
parents:
diff changeset
    52
}
hgs
parents:
diff changeset
    53
hgs
parents:
diff changeset
    54
bool NmApiMailboxSettingsPrivate::listMailboxIds(QList<quint64> &idList)
hgs
parents:
diff changeset
    55
{
hgs
parents:
diff changeset
    56
    NM_FUNCTION; 
hgs
parents:
diff changeset
    57
    QList<NmId> mailboxIds;
hgs
parents:
diff changeset
    58
    bool ret = false;
hgs
parents:
diff changeset
    59
    idList.clear();
hgs
parents:
diff changeset
    60
    
hgs
parents:
diff changeset
    61
    NmDataPluginInterface *instance = mFactory->interfaceInstance();
hgs
parents:
diff changeset
    62
    if (instance) {
hgs
parents:
diff changeset
    63
        if (instance->listMailboxIds(mailboxIds) == KErrNone) {
hgs
parents:
diff changeset
    64
            
hgs
parents:
diff changeset
    65
            foreach (NmId boxId, mailboxIds) {
hgs
parents:
diff changeset
    66
                        idList.append(boxId.id());
hgs
parents:
diff changeset
    67
                    }
hgs
parents:
diff changeset
    68
            
hgs
parents:
diff changeset
    69
            ret = true;   
hgs
parents:
diff changeset
    70
            }
hgs
parents:
diff changeset
    71
        } 
hgs
parents:
diff changeset
    72
     
hgs
parents:
diff changeset
    73
    return ret;
hgs
parents:
diff changeset
    74
}
hgs
parents:
diff changeset
    75
hgs
parents:
diff changeset
    76
bool NmApiMailboxSettingsPrivate::loadSettings(quint64 mailboxId, NmApiMailboxSettingsData &data)
hgs
parents:
diff changeset
    77
{
hgs
parents:
diff changeset
    78
    NM_FUNCTION;
hgs
parents:
diff changeset
    79
    Q_UNUSED(mailboxId);
hgs
parents:
diff changeset
    80
    Q_UNUSED(data);
hgs
parents:
diff changeset
    81
    return false;
hgs
parents:
diff changeset
    82
}
hgs
parents:
diff changeset
    83
hgs
parents:
diff changeset
    84
bool NmApiMailboxSettingsPrivate::saveSettings(const NmApiMailboxSettingsData &data)
hgs
parents:
diff changeset
    85
{
hgs
parents:
diff changeset
    86
    NM_FUNCTION;
hgs
parents:
diff changeset
    87
    Q_UNUSED(data);
hgs
parents:
diff changeset
    88
    return false;
hgs
parents:
diff changeset
    89
}
hgs
parents:
diff changeset
    90
hgs
parents:
diff changeset
    91
bool NmApiMailboxSettingsPrivate::createMailbox(
hgs
parents:
diff changeset
    92
    const QString &mailboxType,
hgs
parents:
diff changeset
    93
    NmApiMailboxSettingsData &data)
hgs
parents:
diff changeset
    94
{
hgs
parents:
diff changeset
    95
    NM_FUNCTION;
hgs
parents:
diff changeset
    96
    
hgs
parents:
diff changeset
    97
    bool ret = false;
hgs
parents:
diff changeset
    98
    
hgs
parents:
diff changeset
    99
    /*QT_TRY {
hgs
parents:
diff changeset
   100
        if (mailboxType==NmApiMailboxTypePop || mailboxType==NmApiMailboxTypeImap) {
hgs
parents:
diff changeset
   101
            QScopedPointer<NmApiPopImapSettingsManager> popImapManager(new NmApiPopImapSettingsManager());  
hgs
parents:
diff changeset
   102
            popImapManager->createMailbox(mailboxType, data);
hgs
parents:
diff changeset
   103
            ret = true;
hgs
parents:
diff changeset
   104
        }
hgs
parents:
diff changeset
   105
        else {
hgs
parents:
diff changeset
   106
            ret = false;
hgs
parents:
diff changeset
   107
        }
hgs
parents:
diff changeset
   108
        //TODO store cenrep stuff here
hgs
parents:
diff changeset
   109
    }
hgs
parents:
diff changeset
   110
    QT_CATCH(...){
hgs
parents:
diff changeset
   111
        ret = false;
hgs
parents:
diff changeset
   112
    }*/
hgs
parents:
diff changeset
   113
    
hgs
parents:
diff changeset
   114
    return ret;
hgs
parents:
diff changeset
   115
}
hgs
parents:
diff changeset
   116
hgs
parents:
diff changeset
   117
bool NmApiMailboxSettingsPrivate::deleteMailbox(quint64 mailboxId)
hgs
parents:
diff changeset
   118
{
hgs
parents:
diff changeset
   119
    NM_FUNCTION;
hgs
parents:
diff changeset
   120
    bool ret = false;
hgs
parents:
diff changeset
   121
    NmDataPluginInterface *instance = mFactory->interfaceInstance();
hgs
parents:
diff changeset
   122
    if (instance) {
hgs
parents:
diff changeset
   123
        if (mDeleteMailboxOperation && mDeleteMailboxOperation->isRunning()) {
hgs
parents:
diff changeset
   124
            mDeleteMailboxOperation->cancelOperation();
hgs
parents:
diff changeset
   125
        }
hgs
parents:
diff changeset
   126
        mDeleteMailboxOperation = instance->deleteMailboxById(NmId(mailboxId));
hgs
parents:
diff changeset
   127
        
hgs
parents:
diff changeset
   128
        if (mDeleteMailboxOperation) {
hgs
parents:
diff changeset
   129
            ret = true;
hgs
parents:
diff changeset
   130
            connect(mDeleteMailboxOperation, 
hgs
parents:
diff changeset
   131
                    SIGNAL(operationCompleted(int)), 
hgs
parents:
diff changeset
   132
                    this, 
hgs
parents:
diff changeset
   133
                    SIGNAL(mailboxDeleted(int)));
hgs
parents:
diff changeset
   134
        }
hgs
parents:
diff changeset
   135
    }
hgs
parents:
diff changeset
   136
    return ret;
hgs
parents:
diff changeset
   137
}
hgs
parents:
diff changeset
   138
hgs
parents:
diff changeset
   139
bool NmApiMailboxSettingsPrivate::populateDefaultSettings(
hgs
parents:
diff changeset
   140
    const QString &mailboxType, NmApiMailboxSettingsData &data) 
hgs
parents:
diff changeset
   141
{
hgs
parents:
diff changeset
   142
    NM_FUNCTION;
hgs
parents:
diff changeset
   143
    /*QScopedPointer<NmApiPopImapSettingsManager> popImapManager(new NmApiPopImapSettingsManager());  
hgs
parents:
diff changeset
   144
    return popImapManager->populateDefaults(mailboxType, data);*/
hgs
parents:
diff changeset
   145
    return true;
hgs
parents:
diff changeset
   146
}
hgs
parents:
diff changeset
   147
hgs
parents:
diff changeset
   148
}// namespace