fotaapplication/fotaserver/src/fotaSrvSession.cpp
author hgs
Fri, 15 Oct 2010 11:46:45 +0530
changeset 73 ae69c2e8bc34
parent 51 2e64dc50f295
permissions -rw-r--r--
201041
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
51
2e64dc50f295 201025_02
hgs
parents:
diff changeset
     1
/*
2e64dc50f295 201025_02
hgs
parents:
diff changeset
     2
 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). 
2e64dc50f295 201025_02
hgs
parents:
diff changeset
     3
 * All rights reserved.
2e64dc50f295 201025_02
hgs
parents:
diff changeset
     4
 * This component and the accompanying materials are made available
2e64dc50f295 201025_02
hgs
parents:
diff changeset
     5
 * under the terms of "Eclipse Public License v1.0"
2e64dc50f295 201025_02
hgs
parents:
diff changeset
     6
 * which accompanies this distribution, and is available
2e64dc50f295 201025_02
hgs
parents:
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
2e64dc50f295 201025_02
hgs
parents:
diff changeset
     8
 *
2e64dc50f295 201025_02
hgs
parents:
diff changeset
     9
 * Initial Contributors:
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    10
 * Nokia Corporation - initial contribution.
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    11
 *
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    12
 * Contributors:
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    13
 *
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    14
 * Description:   fotaengines server side session
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    15
 *
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    16
 */
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    17
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    18
// INCLUDE FILES
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    19
#include "FotasrvSession.h"
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    20
#include "FotaSrvDebug.h"
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    21
#include <eikenv.h>
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    22
#include <eikappui.h>
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    23
#include <s32mem.h>
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    24
#include <e32base.h>
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    25
#include <centralrepository.h>
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    26
#include "FotaServer.h"
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    27
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    28
// ============================= MEMBER FUNCTIONS ============================
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    29
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    30
class CFotaServer;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    31
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    32
// ---------------------------------------------------------------------------
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    33
// CFotaSrvSession::CheckClientSecureIdL 
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    34
// Returns True if caller is syncml framework. False for fotasrv.
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    35
// Leaves if client is unknown
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    36
// ---------------------------------------------------------------------------
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    37
//
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    38
TFotaClient CFotaSrvSession::CheckClientSecureIdL(const RMessage2& aMessage)
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    39
    {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    40
    TFotaClient client(EUnknown);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    41
    TUid dmhostserver1 = TUid::Uid(KDMHostServer1Uid);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    42
    TUid fota = TUid::Uid(KFotaServerUid);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    43
    TUid omadmappui = TUid::Uid(KOmaDMAppUid);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    44
    TUid starter = TUid::Uid(KStarterUid);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    45
    TUid fscheduler = TUid::Uid(KFotaScheduler);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    46
    TUid fms = TUid::Uid(KFMSServerUid);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    47
    TUid softwarechecker = TUid::Uid(0x2000BB96);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    48
    TUid softwarecheckerbackground = TUid::Uid(0x2000BB97);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    49
    TUid testapp = TUid::Uid(0x102073E4);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    50
    TUid testapp2 = TUid::Uid(0x10009CF4);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    51
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    52
    TUid iadclient = TUid::Uid(0x2000F85A);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    53
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    54
    // Syncml
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    55
    if (aMessage.SecureId() == dmhostserver1.iUid)
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    56
        {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    57
        FLOG(
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    58
                _L("[CFotaSrvSession] CheckClientSecureIdL client is DmHostserver!"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    59
        client = EDMHostServer;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    60
        }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    61
    else if (aMessage.SecureId() == omadmappui.iUid)
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    62
        {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    63
        FLOG(
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    64
                _L("[CFotaSrvSession] CheckClientSecureIdL client is omadmappui!"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    65
        client = EOMADMAppUi;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    66
        }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    67
    else if (aMessage.SecureId() == starter.iUid)
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    68
        {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    69
        FLOG(_L("[CFotaSrvSession] CheckClientSecureIdL client is starter!"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    70
        client = EStarter;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    71
        }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    72
    else if (aMessage.SecureId() == softwarechecker.iUid
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    73
            || aMessage.SecureId() == iadclient.iUid)
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    74
        {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    75
        FLOG(_L("[CFotaSrvSession] CheckClientSecureIdL client is IAD!"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    76
        client = ESoftwareChecker;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    77
        }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    78
    else if (aMessage.SecureId() == softwarecheckerbackground.iUid)
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    79
        {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    80
        FLOG(
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    81
                _L("[CFotaSrvSession] CheckClientSecureIdL client is IAD - background!"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    82
        client = ESoftwareCheckerBackground;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    83
        }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    84
    else if (aMessage.SecureId() == fms.iUid)
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    85
        {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    86
        FLOG(_L("[CFotaSrvSession] CheckClientSecureIdL client is FMS!"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    87
        client = EFMSServer;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    88
        }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    89
    else if (aMessage.SecureId() == fscheduler.iUid)
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    90
        {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    91
        FLOG(
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    92
                _L("[CFotaSrvSession] CheckClientSecureIdL client is fota scheduler!"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    93
        client = EFotaScheduler;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    94
        }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    95
    else if (aMessage.SecureId() == 0x0323231 || aMessage.SecureId()
73
hgs
parents: 51
diff changeset
    96
            == testapp.iUid || aMessage.SecureId() == testapp2.iUid || aMessage.SecureId() == 0x2001133B)
51
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    97
        {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    98
        client = EFotaTestApp;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
    99
        }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   100
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   101
    return client;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   102
    }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   103
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   104
// ---------------------------------------------------------------------------
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   105
// CFotaSrvSession::CFotaSrvSession
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   106
// ---------------------------------------------------------------------------
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   107
//
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   108
CFotaSrvSession::CFotaSrvSession()
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   109
    {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   110
    FLOG(_L( "CFotaSrvSession::CFotaSrvSession( )" ));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   111
    iError = KErrNone;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   112
    //iDoc = CEikonEnv::Static()->EikAppUi()->Document();
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   113
    }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   114
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   115
// ---------------------------------------------------------------------------
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   116
// CFotaSrvSession::~CFotaSrvSession
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   117
// ---------------------------------------------------------------------------
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   118
//
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   119
CFotaSrvSession::~CFotaSrvSession()
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   120
    {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   121
    FotaServer()->DropSession();
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   122
    }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   123
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   124
// ---------------------------------------------------------------------------
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   125
// CFotaSrvSession::ServiceL
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   126
// Handle client request
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   127
// ---------------------------------------------------------------------------
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   128
//
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   129
void CFotaSrvSession::ServiceL(const RMessage2& aMessage)
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   130
    {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   131
    TInt err(KErrNone);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   132
    TInt pkgid = 0;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   133
    TPackageState state;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   134
    RThread clt;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   135
    aMessage.ClientL(clt);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   136
    TFullName cltnm = clt.FullName();
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   137
    FLOG(_L( "CFotaSrvSession::ServiceL      %d   serving for %S?" ),
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   138
            aMessage.Function(), &cltnm);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   139
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   140
    TFotaClient client = CheckClientSecureIdL(aMessage);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   141
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   142
    if (client == EUnknown)
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   143
        {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   144
        FLOG(_L("Permission denied to use fota services!"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   145
        User::Leave(KErrPermissionDenied);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   146
        }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   147
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   148
    TInt cmd = aMessage.Function();
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   149
    if ((cmd != EGetState) && (cmd != EGetResult) && (cmd != EGetCurrFwDetails) && (cmd != EGetUpdateTimestamp))
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   150
        {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   151
    
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   152
        TInt fotaValue(1);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   153
        CRepository* centrep(NULL);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   154
        TUid uidValue =
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   155
            {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   156
            0x101F9A08
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   157
            }; // KCRFotaAdapterEnabled
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   158
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   159
        centrep = CRepository::NewL(uidValue);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   160
        if (centrep)
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   161
            {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   162
            FLOG(_L("centralrepository found "));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   163
            centrep->Get(1, fotaValue); // KCRFotaAdapterEnabled     
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   164
            delete centrep;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   165
            }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   166
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   167
        if (!fotaValue)
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   168
            {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   169
            FLOG(_L("Fota is disabled or not supported!"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   170
            User::Leave(KErrNotSupported);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   171
            }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   172
            
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   173
        }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   174
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   175
    switch (aMessage.Function())
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   176
        {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   177
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   178
        case EFotaDownload:
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   179
            {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   180
            FLOG(_L( "CFotaSrvSession::ServiceL DOWNLOAD"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   181
            TDownloadIPCParams ipc;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   182
            TPckg<TDownloadIPCParams> pkg(ipc);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   183
            aMessage.Read(0, pkg);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   184
            TInt deslen = aMessage.GetDesLengthL(1);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   185
            HBufC8* urlbuf = HBufC8::NewLC(deslen);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   186
            TPtr8 urlptr = urlbuf->Des();
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   187
            aMessage.Read(1, urlptr);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   188
            TInt silent = aMessage.Int2();
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   189
            FotaServer()->DownloadL(ipc, urlptr, client, silent, EFalse);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   190
            CleanupStack::PopAndDestroy(urlbuf); // urlbuf
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   191
            aMessage.Complete(KErrNone);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   192
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   193
            break;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   194
            }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   195
        case EFotaUpdate:
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   196
            {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   197
            FLOG(_L( "CFotaSrvSession::ServiceL UPDATE" ));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   198
            TDownloadIPCParams ipc;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   199
            TPckg<TDownloadIPCParams> pkg(ipc);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   200
            aMessage.Read(0, pkg);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   201
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   202
            // If update started from omadmappui, no alert should be sent if 
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   203
            // update is cancelled
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   204
            if (client == EOMADMAppUi)
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   205
                {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   206
                ipc.iSendAlert = EFalse;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   207
                }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   208
            FotaServer()->TryUpdateL(client);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   209
            aMessage.Complete(KErrNone);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   210
            break;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   211
            }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   212
        case EFotaDownloadAndUpdate:
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   213
            {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   214
            FLOG(_L( "CFotaSrvSession::ServiceL DOWNLOADANDUPDATE" ));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   215
            TDownloadIPCParams ipc;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   216
            TPckg<TDownloadIPCParams> pkg(ipc);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   217
            aMessage.Read(0, pkg);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   218
            TInt deslen = aMessage.GetDesLengthL(1);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   219
            HBufC8* urlbuf = HBufC8::NewLC(deslen);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   220
            TPtr8 urlptr = urlbuf->Des();
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   221
            aMessage.Read(1, urlptr);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   222
            TFotaClient requester = CheckClientSecureIdL(aMessage);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   223
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   224
            TInt silent = aMessage.Int2();
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   225
            FotaServer()->DownloadL(ipc, urlptr, requester, silent, ETrue);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   226
            CleanupStack::PopAndDestroy(urlbuf);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   227
            aMessage.Complete(KErrNone);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   228
            }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   229
            break;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   230
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   231
        case EFotaTryResumeDownload:
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   232
            {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   233
            FLOG(_L( "CFotaSrvSession::ServiceL TRYRESUMEDOWNLOAD" ));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   234
            if (client == EOMADMAppUi || client == EFMSServer || client
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   235
                    == EFotaTestApp)
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   236
                {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   237
                TInt silent = aMessage.Int0();
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   238
                
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   239
                FotaServer()->TryResumeDownloadL(client, silent); // silent
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   240
                aMessage.Complete(KErrNone);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   241
                }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   242
            else
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   243
                {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   244
                aMessage.Complete(KErrAccessDenied);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   245
                }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   246
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   247
            }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   248
            break;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   249
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   250
        case EDeletePackage:
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   251
            {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   252
            FLOG(_L( "CFotaSrvSession::ServiceL DELETEPACKAGE"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   253
            pkgid = aMessage.Int0();
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   254
            FotaServer()->DeletePackageL(pkgid);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   255
            aMessage.Complete(KErrNone);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   256
            }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   257
            break;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   258
        case EGetState:
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   259
            {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   260
            FLOG(_L( "CFotaSrvSession::ServiceL GETSTATE" ));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   261
            pkgid = aMessage.Int0();
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   262
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   263
            state = FotaServer()->GetStateL(pkgid);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   264
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   265
            FLOG(_L( "CFotaSrvSession::ServiceL GETSTATE << %d" ),  state.iState);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   266
            TPckg<RFotaEngineSession::TState> pkg2(state.iState);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   267
            aMessage.Write(1, pkg2);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   268
            aMessage.Complete(KErrNone);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   269
            }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   270
            break;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   271
        case EGetResult:
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   272
            {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   273
            FLOG(_L( "CFotaSrvSession::ServiceL GETRESULT >>" ));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   274
            pkgid = aMessage.Int0();
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   275
            state = FotaServer()->GetStateL(pkgid);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   276
            TPckg<TInt> pkg2(state.iResult);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   277
            FLOG(_L( "CFotaSrvSession::ServiceL GETRESULT << %d" ),
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   278
                    state.iResult);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   279
            aMessage.Write(1, pkg2);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   280
            aMessage.Complete(err);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   281
            break;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   282
            }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   283
        case EGetUpdatePackageIds:
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   284
            {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   285
            FLOG(_L( "CFotaSrvSession::ServiceL EGETUPDATEPACKAGEIDS" ));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   286
            TPkgIdList pkgids;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   287
            FotaServer()->GetUpdatePackageIdsL(pkgids);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   288
            TPckg<TPkgIdList> pkgids_pkg(pkgids);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   289
            aMessage.Write(0, pkgids_pkg);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   290
            aMessage.Complete(KErrNone);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   291
            }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   292
            break;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   293
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   294
        case EGetUpdateTimestamp:
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   295
            {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   296
            FLOG(_L( "CFotaSrvSession::ServiceL EGETUPDATETIMESTAMP" ));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   297
            TBuf16<15> timestamp;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   298
            FotaServer()->GetUpdateTimeStampL(timestamp);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   299
            aMessage.Write(0, timestamp);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   300
            aMessage.Complete(KErrNone);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   301
            }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   302
            break;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   303
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   304
        case EGenericAlertSentForPackage:
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   305
            {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   306
            FLOG(_L( "CFotaSrvSession::ServiceL EGENERICALERTSENT FOR PKGID" ));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   307
            TInt pkgid = aMessage.Int0();
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   308
            FotaServer()->ResetFotaStateL(pkgid);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   309
            aMessage.Complete(err);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   310
            }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   311
            break;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   312
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   313
        case EScheduledUpdate:
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   314
            {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   315
            FLOG(_L( "CFotaSrvSession::ServiceL ESCHEDULEDUPDATE" ));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   316
            TFotaScheduledUpdate sched(-1, -1);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   317
            TPckg<TFotaScheduledUpdate> p(sched);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   318
            aMessage.Read(0, p);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   319
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   320
            FLOG(_L(" pkgid: %d   scheduleid:%d"), sched.iPkgId,
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   321
                    sched.iScheduleId);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   322
            FotaServer()->ScheduledUpdateL(sched, client);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   323
            aMessage.Complete(KErrNone);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   324
            
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   325
            }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   326
            break;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   327
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   328
        case EPauseDownload:
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   329
            {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   330
            FLOG(_L( "CFotaSrvSession::ServiceL EPAUSEDOWNLOAD" ));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   331
            FotaServer()->PauseDownloadL();
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   332
            aMessage.Complete(KErrNone);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   333
            }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   334
            break;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   335
        case EGetCurrFwDetails:
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   336
            {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   337
            FLOG(_L( "CFotaSrvSession::ServiceL EGETCURRFWDETAILS" ));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   338
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   339
            TBuf8<KFotaMaxPkgNameLength> name;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   340
            TBuf8<KFotaMaxPkgVersionLength> version;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   341
            TInt size(0);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   342
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   343
            FotaServer()->GetCurrentFwDetailsL(name, version, size);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   344
            
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   345
            aMessage.Write(0, name);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   346
            aMessage.Write(1, version);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   347
            TPckg<TInt> psize(size);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   348
            aMessage.Write(2, psize);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   349
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   350
            aMessage.Complete(KErrNone);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   351
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   352
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   353
            }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   354
            break;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   355
        default:
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   356
            {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   357
            FLOG(_L( "CFotaSrvSession::ServiceL In default case" ));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   358
            }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   359
            break;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   360
        }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   361
    }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   362
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   363
// ----------------------------------------------------------------------------------------
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   364
// CFotaSrvSession::ServiceError
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   365
// ----------------------------------------------------------------------------------------
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   366
void CFotaSrvSession::ServiceError(const RMessage2& aMessage, TInt aError)
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   367
    {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   368
    FLOG(_L("CFotaSrvSession::ServiceError, err = %d >>"), aError);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   369
    CSession2::ServiceError(aMessage, aError);
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   370
    FLOG(_L("CFotaSrvSession::ServiceError <<"));
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   371
    }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   372
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   373
// ---------------------------------------------------------------------------
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   374
// CFotaSrvSession::FotaServer
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   375
// Helper function
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   376
// ---------------------------------------------------------------------------
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   377
//
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   378
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   379
CFotaServer* CFotaSrvSession::FotaServer() const
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   380
    {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   381
    return (CFotaServer*) Server();
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   382
    }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   383
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   384
void DispatchMessageL(const RMessage2& aMessage)
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   385
    {
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   386
    return;
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   387
    }
2e64dc50f295 201025_02
hgs
parents:
diff changeset
   388