utilities/downloadmanager/inc/omaddparser.h
author hgs
Fri, 15 Oct 2010 17:30:59 -0400
changeset 16 3c88a81ff781
permissions -rw-r--r--
201041
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
16
hgs
parents:
diff changeset
     1
/**
hgs
parents:
diff changeset
     2
   This file is part of CWRT package **
hgs
parents:
diff changeset
     3
hgs
parents:
diff changeset
     4
   Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). **
hgs
parents:
diff changeset
     5
hgs
parents:
diff changeset
     6
   This program is free software: you can redistribute it and/or modify
hgs
parents:
diff changeset
     7
   it under the terms of the GNU (Lesser) General Public License as 
hgs
parents:
diff changeset
     8
   published by the Free Software Foundation, version 2.1 of the License. 
hgs
parents:
diff changeset
     9
   This program is distributed in the hope that it will be useful, but
hgs
parents:
diff changeset
    10
   WITHOUT ANY WARRANTY; without even the implied warranty of 
hgs
parents:
diff changeset
    11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
hgs
parents:
diff changeset
    12
   (Lesser) General Public License for more details. You should have 
hgs
parents:
diff changeset
    13
   received a copy of the GNU (Lesser) General Public License along 
hgs
parents:
diff changeset
    14
   with this program. If not, see <http://www.gnu.org/licenses/>.
hgs
parents:
diff changeset
    15
*/
hgs
parents:
diff changeset
    16
hgs
parents:
diff changeset
    17
#ifndef OMADDPARSER_H_
hgs
parents:
diff changeset
    18
#define OMADDPARSER_H_
hgs
parents:
diff changeset
    19
hgs
parents:
diff changeset
    20
#include "dmcommon.h"
hgs
parents:
diff changeset
    21
#include "dmcommoninternal.h"
hgs
parents:
diff changeset
    22
#include "dmpimpl.h"
hgs
parents:
diff changeset
    23
#include <QtXml>
hgs
parents:
diff changeset
    24
#include <QVariant>
hgs
parents:
diff changeset
    25
#include <QStack>
hgs
parents:
diff changeset
    26
hgs
parents:
diff changeset
    27
// forward declarations
hgs
parents:
diff changeset
    28
class QString;
hgs
parents:
diff changeset
    29
class OMADownloadDescriptor;
hgs
parents:
diff changeset
    30
class OMADownloadDescParserPrivate;
hgs
parents:
diff changeset
    31
class OMADownloadDescriptorPrivate;
hgs
parents:
diff changeset
    32
class OMA2DownloadProduct;
hgs
parents:
diff changeset
    33
class OMA2DownloadProductPrivate;
hgs
parents:
diff changeset
    34
class OMA2DownloadMediaObj;
hgs
parents:
diff changeset
    35
class OMA2DownloadMediaObjPrivate;
hgs
parents:
diff changeset
    36
hgs
parents:
diff changeset
    37
typedef QList<OMA2DownloadProduct*> ProductList;
hgs
parents:
diff changeset
    38
typedef QList<OMA2DownloadMediaObj*> MediaObjectList;
hgs
parents:
diff changeset
    39
hgs
parents:
diff changeset
    40
enum OMADownloadAttribute
hgs
parents:
diff changeset
    41
{
hgs
parents:
diff changeset
    42
    /* OMA Download Attributes */
hgs
parents:
diff changeset
    43
    OMADownloadDescName = 0,                  // "name" in OMA dd
hgs
parents:
diff changeset
    44
    OMADownloadDescVersion,                   // "version" in OMA dd
hgs
parents:
diff changeset
    45
    OMADownloadDescObjectURI,                 // "objectURI" in OMA dd
hgs
parents:
diff changeset
    46
    OMADownloadDescType,                      // "type" in OMA dd
hgs
parents:
diff changeset
    47
    OMADownloadDescSize,                      // "size" in OMA dd
hgs
parents:
diff changeset
    48
    OMADownloadDescVendor,                    // "vendor" in OMA dd
hgs
parents:
diff changeset
    49
    OMADownloadDescDescription,               // "description" in OMA dd
hgs
parents:
diff changeset
    50
    OMADownloadDescInstallNotifyURI,          // "installNotifyURI" in OMA dd
hgs
parents:
diff changeset
    51
    OMADownloadDescNextURL,                   // "nextURL" in OMA dd
hgs
parents:
diff changeset
    52
    OMADownloadDescInfoURL,                   // "infoURL" in OMA dd
hgs
parents:
diff changeset
    53
    OMADownloadDescIconURL,                   // "iconURL" in OMA dd
hgs
parents:
diff changeset
    54
    OMADownloadDescInstallParam,              // "instalParam" in OMA dd
hgs
parents:
diff changeset
    55
hgs
parents:
diff changeset
    56
    /* OMA2 Download Attributes */
hgs
parents:
diff changeset
    57
    OMA2DownloadDescUpdatedDDURI,             // "updatedDDURI" in OMA dd2
hgs
parents:
diff changeset
    58
    OMA2DownloadDescProductName,              // "product" in OMA dd2
hgs
parents:
diff changeset
    59
    OMA2DownloadDescProductInstallNotifyURI,  // "installNotifyURI" of product in OMA dd2
hgs
parents:
diff changeset
    60
    OMA2DownloadDescProductSuppressConfirmation,  // "suppressuserconfirmation" of product in OMA dd2
hgs
parents:
diff changeset
    61
    OMA2DownloadDescMediaObjName,             // "mediaObject" in OMA dd2
hgs
parents:
diff changeset
    62
    OMA2DownloadDescMediaObjType,             // "type" in OMA dd2
hgs
parents:
diff changeset
    63
    OMA2DownloadDescMediaObjSize,             // "size" in OMA dd2
hgs
parents:
diff changeset
    64
    OMA2DownloadDescMediaObjProgressiveDl,    // "progressivedl" in OMA dd2
hgs
parents:
diff changeset
    65
    OMA2DownloadDescMediaObjServer,           // "server" in OMA dd2
hgs
parents:
diff changeset
    66
    OMA2DownloadDescMediaObjInstallNotifyURI, // "installNotifyURI" of mediaObj in OMA dd2
hgs
parents:
diff changeset
    67
    OMA2DownloadDescMediaObjSuppressConfirmation, // "suppressuserconfirmation" of mediaobj in OMA dd2
hgs
parents:
diff changeset
    68
    OMA2DownloadDescLicense,                  // "license" in OMA dd2
hgs
parents:
diff changeset
    69
    OMA2DownloadDescOrder,                    // "order" in OMA dd2
hgs
parents:
diff changeset
    70
    OMA2DownloadDescText                      // "text" in OMA dd2 
hgs
parents:
diff changeset
    71
};
hgs
parents:
diff changeset
    72
// class declaration
hgs
parents:
diff changeset
    73
hgs
parents:
diff changeset
    74
// for parsing the OMA download descriptor
hgs
parents:
diff changeset
    75
class  OMADownloadDescParser : public QXmlDefaultHandler
hgs
parents:
diff changeset
    76
{
hgs
parents:
diff changeset
    77
    DM_DECLARE_PRIVATE(OMADownloadDescParser);
hgs
parents:
diff changeset
    78
hgs
parents:
diff changeset
    79
public:
hgs
parents:
diff changeset
    80
    OMADownloadDescParser();
hgs
parents:
diff changeset
    81
    ~OMADownloadDescParser();
hgs
parents:
diff changeset
    82
    bool startDocument();
hgs
parents:
diff changeset
    83
    bool startElement(const QString&, const QString&, const QString& ,
hgs
parents:
diff changeset
    84
                       const QXmlAttributes&);
hgs
parents:
diff changeset
    85
    bool endElement(const QString&, const QString&, const QString&);
hgs
parents:
diff changeset
    86
    bool characters(const QString& ch);
hgs
parents:
diff changeset
    87
    QString errorString();
hgs
parents:
diff changeset
    88
    bool fatalError(const QXmlParseException &exception);
hgs
parents:
diff changeset
    89
    OMADownloadDescriptor* downloadDescriptor();
hgs
parents:
diff changeset
    90
};
hgs
parents:
diff changeset
    91
hgs
parents:
diff changeset
    92
// represents OMA download descriptor
hgs
parents:
diff changeset
    93
class OMADownloadDescriptor
hgs
parents:
diff changeset
    94
{
hgs
parents:
diff changeset
    95
    DM_DECLARE_PRIVATE(OMADownloadDescriptor);
hgs
parents:
diff changeset
    96
public:
hgs
parents:
diff changeset
    97
    OMADownloadDescriptor();
hgs
parents:
diff changeset
    98
    ~OMADownloadDescriptor();
hgs
parents:
diff changeset
    99
    // fetches the OMA DD related attributes
hgs
parents:
diff changeset
   100
    QVariant getAttribute(OMADownloadAttribute attr);
hgs
parents:
diff changeset
   101
    // sets the attributes if any
hgs
parents:
diff changeset
   102
    void setAttribute(const QString&, const QVariant&);
hgs
parents:
diff changeset
   103
    // fetches the product List
hgs
parents:
diff changeset
   104
    QList<OMA2DownloadProduct*> productList();
hgs
parents:
diff changeset
   105
    // fetches the product count in a dd
hgs
parents:
diff changeset
   106
    int productCount();
hgs
parents:
diff changeset
   107
    // adding product to the list
hgs
parents:
diff changeset
   108
    void addProduct(OMA2DownloadProduct*);
hgs
parents:
diff changeset
   109
};
hgs
parents:
diff changeset
   110
hgs
parents:
diff changeset
   111
class OMA2DownloadProduct
hgs
parents:
diff changeset
   112
{
hgs
parents:
diff changeset
   113
    DM_DECLARE_PRIVATE(OMA2DownloadProduct);
hgs
parents:
diff changeset
   114
public:
hgs
parents:
diff changeset
   115
    OMA2DownloadProduct();
hgs
parents:
diff changeset
   116
    ~OMA2DownloadProduct();
hgs
parents:
diff changeset
   117
    // fetches Product related attributes
hgs
parents:
diff changeset
   118
    QVariant getAttribute(OMADownloadAttribute attr);
hgs
parents:
diff changeset
   119
    // sets the Product attributes if any
hgs
parents:
diff changeset
   120
    void setAttribute(const QString&, const QVariant&);
hgs
parents:
diff changeset
   121
    // fetches the Media Object list
hgs
parents:
diff changeset
   122
    QList<OMA2DownloadMediaObj*> mediaObjList();
hgs
parents:
diff changeset
   123
    // fetches the number of media downloads in a product
hgs
parents:
diff changeset
   124
    int mediaCount();
hgs
parents:
diff changeset
   125
    // fetches the size of all the media objects present in dd
hgs
parents:
diff changeset
   126
    qint64 albumSize();
hgs
parents:
diff changeset
   127
    // adding media object to the media object list.
hgs
parents:
diff changeset
   128
    void addMediaObject(OMA2DownloadMediaObj*);
hgs
parents:
diff changeset
   129
};
hgs
parents:
diff changeset
   130
hgs
parents:
diff changeset
   131
class OMA2DownloadMediaObj
hgs
parents:
diff changeset
   132
{
hgs
parents:
diff changeset
   133
    DM_DECLARE_PRIVATE(OMA2DownloadMediaObj);
hgs
parents:
diff changeset
   134
public:
hgs
parents:
diff changeset
   135
    OMA2DownloadMediaObj();
hgs
parents:
diff changeset
   136
    ~OMA2DownloadMediaObj();
hgs
parents:
diff changeset
   137
    // fetches the Media Object attributes
hgs
parents:
diff changeset
   138
    QVariant getAttribute(OMADownloadAttribute attr);
hgs
parents:
diff changeset
   139
    // sets the Media Object attributes if any
hgs
parents:
diff changeset
   140
    void setAttribute(const QString&, const QVariant&);
hgs
parents:
diff changeset
   141
};
hgs
parents:
diff changeset
   142
#endif