[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [bodega-client] /: syncronize error codes with server side
From:       Aaron Seigo <aseigo () kde ! org>
Date:       2013-09-30 16:44:52
Message-ID: E1VQgaa-0000es-1l () scm ! kde ! org
[Download RAW message or body]

Git commit ccf5caeaa4396e8c6e99f0cfe1fc63ebf533ee2f by Aaron Seigo.
Committed on 30/09/2013 at 16:41.
Pushed by aseigo into branch 'master'.

syncronize error codes with server side

this includes removing the duplication in active-addons (bodega.h)
by splittng out the error codes into their own QObject (yay QML)

as a side bonus, the by-hand population of the status code has
now becomes a simple iteration through the a QMetaEnum

M  +3    -3    activeclient/src/bodegastore.cpp
M  +0    -53   activeclient/src/bodegastore.h
M  +61   -103  lib/bodega/error.cpp
M  +99   -46   lib/bodega/error.h
M  +1    -1    lib/bodega/networkjob.cpp

http://commits.kde.org/bodega-client/ccf5caeaa4396e8c6e99f0cfe1fc63ebf533ee2f

diff --git a/activeclient/src/bodegastore.cpp b/activeclient/src/bodegastore.cpp
index 4fabcea..a16abd4 100644
--- a/activeclient/src/bodegastore.cpp
+++ b/activeclient/src/bodegastore.cpp
@@ -96,8 +96,8 @@ void errorFromQScriptValue(const QScriptValue &scriptValue, Bodega::Error &error
         it.next();
         //kDebug() << it.name() << "is" << it.value().toString();
         if (it.name() == "serverCode") {
-            const Error::ServerCode code = (Error::ServerCode)it.value().toInteger();
-            if (code != Error::NoCode) {
+            const ErrorCodes::ServerCode code = (ErrorCodes::ServerCode)it.value().toInteger();
+            if (code != ErrorCodes::NoCode) {
                 error = Error(code);
                 return;
             }
@@ -315,7 +315,7 @@ BodegaStore::BodegaStore()
     qRegisterMetaType<Bodega::InstallJobScheduler::InstallStatus>("Bodega::InstallJobScheduler::InstallStatus");
  qScriptRegisterMetaType<Bodega::InstallJobScheduler::InstallStatus>(declarativeView()->scriptEngine(), \
qScriptValueFromStatus, statusFromQScriptValue, QScriptValue());  \
qmlRegisterUncreatableType<Bodega::InstallJobScheduler>("com.makeplaylive.addonsapp", 1, 0, \
                "InstallJobScheduler", QLatin1String("Do not create objects of this type."));
-    qmlRegisterUncreatableType<ErrorCode>("com.makeplaylive.addonsapp", 1, 0, "ErrorCode", \
QLatin1String("Do not create objects of this type.")); +    \
qmlRegisterUncreatableType<Bodega::ErrorCodes>("com.makeplaylive.addonsapp", 1, 0, "ErrorCode", \
                QLatin1String("Do not create objects of this type."));
     qScriptRegisterMetaType<Bodega::Error>(declarativeView()->scriptEngine(), qScriptValueFromError, \
                errorFromQScriptValue, QScriptValue());
     qScriptRegisterMetaType<Bodega::ChannelInfo>(declarativeView()->scriptEngine(), \
                qScriptValueFromChannelInfo, channelInfoFromQScriptValue, QScriptValue());
     qScriptRegisterMetaType<Bodega::AssetInfo>(declarativeView()->scriptEngine(), \
                qScriptValueFromAssetInfo, assetInfoFromQScriptValue, QScriptValue());
diff --git a/activeclient/src/bodegastore.h b/activeclient/src/bodegastore.h
index 2d71bb0..f2a4846 100644
--- a/activeclient/src/bodegastore.h
+++ b/activeclient/src/bodegastore.h
@@ -36,59 +36,6 @@ namespace Bodega {
     class InstallJobScheduler;
 }
 
-class ErrorCode : public QObject
-{
-    Q_OBJECT
-public:
-    // These should remain in sync with the library and the server implementation
-    enum ServerCode {
-        NoCode                = 0,
-        Connection            = 1, //reserved for client side connection errors
-        Unknown               = 2, //unexpected problem
-        Database              = 3, //db communication problem
-        Unauthorized          = 4, //unauthorized access
-        MissingParameters     = 5, //username/password/device id missing
-        NoMatch               = 6, //no or incorrect result
-        AccountInactive       = 7, //account is inactive
-        AccountExists         = 8, //collection/asset already exists
-        PurchaseFailed        = 9, //failed to purchase item
-        MailerFailure         = 10, //failed to generate an email
-        AccountUpdateFailed   = 11, //account update failed
-        EncryptionFailure     = 12, //couldn't encrypt text
-        PasswordTooShort      = 13, //password has to be at least 8 characters
-        Download              = 14, //problem with the download
-        AccessDenied          = 15, //access denied to the requested asset
-        RedeemCodeFailure     = 16, //could not redeem points code.
-
-        PaymentMethodCreation = 17, //could not link credit card to customer
-        PaymentMethodDeletion = 18, //delete card details
-        PaymentMethodDetails  = 19, //problem updating customer card details
-        PaymentMethodMissing  = 20, //customer card details missing
-        CustomerRetrieval     = 21, //problems retrieving card details
-        CustomerDatabase      = 22, //db error while querying for customer id
-        CustomerCharge        = 23, //unable to charge the customers card
-        CustomerRefund        = 24, //unable to charge the customers card
-        ChargeNotRecorded     = 25, //charged the customer but couldn't record it
-        NotEnoughPoints       = 26, //not enough points for a purchase
-        TooManyPoints         = 27,  //tried to buy too many points at once
-        CollectionExists      = 28, //collection already exists
-        AssetExists           = 29,  //asset already exists
-        CardDeclined           = 30,//credit card was declined
-        CardIncorrectNumber    = 31,//incorrect credit card number
-        CardInvalidNumber      = 32,//invalid credit card number
-        CardInvalidExpiryMonth = 33,//invalid credit card expiry month
-        CardInvalidExpiryYear  = 34,//invalid credit card expiry year
-        CardInvalidCVC         = 35,//invalid credit card cvs
-        CardExpired            = 36,//card expired
-        CardInvalidAmount      = 37,//invalid payment amount
-        CardDuplicateTransaction = 38,//same transaction was just submitted
-        CardProcessingError    = 39,//error occurred while processing the card
-        PurchaseNotEnoughPoints       = 40, //not enough points for a purchase
-        PurchaseTooManyPoints         = 41,  //tried to buy too many points at once
-    };
-    Q_ENUMS(ServerCode)
-};
-
 class BodegaStore : public KDeclarativeMainWindow
 {
     Q_OBJECT
diff --git a/lib/bodega/error.cpp b/lib/bodega/error.cpp
index 78c6418..a6a7eb9 100644
--- a/lib/bodega/error.cpp
+++ b/lib/bodega/error.cpp
@@ -19,6 +19,7 @@
 
 #include "error.h"
 
+#include <QMetaEnum>
 #include <QObject>
 
 using namespace Bodega;
@@ -30,7 +31,7 @@ public:
             const QString &errorId,
             const QString &title,
             const QString &descr)
-      : code(NoCode),
+      : code(ErrorCodes::NoCode),
         type(t),
         id(errorId),
         title(title),
@@ -39,84 +40,46 @@ public:
     }
 
 
-    Private(ServerCode c)
-        : code(NoCode)
+    Private(ErrorCodes::ServerCode c)
+        : code(ErrorCodes::NoCode)
     {
         setServerCode(c);
     }
 
     Private(Type t)
-        : code(NoCode),
+        : code(ErrorCodes::NoCode),
           type(t)
     {
     }
 
-    void setServerCode(ServerCode c);
+    void setServerCode(ErrorCodes::ServerCode c);
     static void initServerCodeDict();
 
-    ServerCode code;
+    ErrorCodes::ServerCode code;
     Type type;
     QString id;
     QString title;
     QString description;
 
-    static QMap<QString, ServerCode> serverCodes;
+    static QMap<QString, ErrorCodes::ServerCode> serverCodes;
 };
 
-QMap<QString, Error::ServerCode> Error::Private::serverCodes;
+QMap<QString, ErrorCodes::ServerCode> Error::Private::serverCodes;
 
 void Error::Private::initServerCodeDict()
 {
     if (!serverCodes.isEmpty()) {
         return;
     }
-    #define ADD_SERVER_CODE(CODE) serverCodes.insert(QLatin1String("" #CODE), CODE);
-    ADD_SERVER_CODE(NoCode)
-    ADD_SERVER_CODE(Connection)
-    ADD_SERVER_CODE(Unknown)
-    ADD_SERVER_CODE(Database)
-    ADD_SERVER_CODE(Unauthorized)
-    ADD_SERVER_CODE(MissingParameters)
-    ADD_SERVER_CODE(NoMatch)
-    ADD_SERVER_CODE(AccountInactive)
-    ADD_SERVER_CODE(AccountExists)
-    ADD_SERVER_CODE(PurchaseFailed)
-    ADD_SERVER_CODE(MailerFailure)
-    ADD_SERVER_CODE(AccountUpdateFailed)
-    ADD_SERVER_CODE(EncryptionFailure)
-    ADD_SERVER_CODE(PasswordTooShort)
-    ADD_SERVER_CODE(Download)
-    ADD_SERVER_CODE(AccessDenied)
-    ADD_SERVER_CODE(RedeemCodeFailure)
-
-    ADD_SERVER_CODE(PaymentMethodCreation)
-    ADD_SERVER_CODE(PaymentMethodDeletion)
-    ADD_SERVER_CODE(PaymentMethodDetails)
-    ADD_SERVER_CODE(PaymentMethodMissing)
-    ADD_SERVER_CODE(CustomerRetrieval)
-    ADD_SERVER_CODE(CustomerDatabase)
-    ADD_SERVER_CODE(CustomerCharge)
-    ADD_SERVER_CODE(CustomerRefund)
-    ADD_SERVER_CODE(ChargeNotRecorded)
-    ADD_SERVER_CODE(NotEnoughPoints)
-    ADD_SERVER_CODE(TooManyPoints)
-    ADD_SERVER_CODE(CollectionExists)
-    ADD_SERVER_CODE(AssetExists)
-    ADD_SERVER_CODE(CardDeclined)
-    ADD_SERVER_CODE(CardIncorrectNumber)
-    ADD_SERVER_CODE(CardInvalidNumber)
-    ADD_SERVER_CODE(CardInvalidExpiryMonth)
-    ADD_SERVER_CODE(CardInvalidExpiryYear)
-    ADD_SERVER_CODE(CardInvalidCVC)
-    ADD_SERVER_CODE(CardExpired)
-    ADD_SERVER_CODE(CardInvalidAmount)
-    ADD_SERVER_CODE(CardDuplicateTransaction)
-    ADD_SERVER_CODE(CardProcessingError)
-    ADD_SERVER_CODE(PurchaseNotEnoughPoints)
-    ADD_SERVER_CODE(PurchaseTooManyPoints)
+
+    ErrorCodes codes;
+    QMetaEnum e = codes.metaObject()->enumerator(codes.metaObject()->indexOfEnumerator("ServerCode"));
+    for (int i = 0; i < e.keyCount(); ++i) {
+        serverCodes.insert(QLatin1String(e.key(i)), static_cast<ErrorCodes::ServerCode>(e.value(i)));
+    }
 }
 
-void Error::Private::setServerCode(ServerCode c)
+void Error::Private::setServerCode(ErrorCodes::ServerCode c)
 {
     code = c;
     type = Session;
@@ -124,154 +87,147 @@ void Error::Private::setServerCode(ServerCode c)
     title = QObject::tr("Session Error");
 
     switch (code) {
-        case Connection:
+        case ErrorCodes::Connection:
             description = QObject::tr("Connection failed.");
         break;
-        case Database:
+        case ErrorCodes::Database:
             description = QObject::tr("The add-ons database could not be reached.");
         break;
-        case Unauthorized:
+        case ErrorCodes::Unauthorized:
             description = QObject::tr("This account may not perform the requested action.");
         break;
-        case MissingParameters:
+        case ErrorCodes::MissingParameters:
             description = QObject::tr("Required information was missing from the request.");
         break;
-        case NoMatch:
+        case ErrorCodes::NoMatch:
             description = QObject::tr("Wrong user name or password.");
         break;
-        case AccountInactive:
+        case ErrorCodes::AccountInactive:
             description = QObject::tr("This account is not active.");
         break;
-        case AccountExists:
+        case ErrorCodes::AccountExists:
             description = QObject::tr("An account for that email already exists.");
         break;
-        case PurchaseFailed:
+        case ErrorCodes::PurchaseFailed:
             description = QObject::tr("Could not purchase the requested item.");
         break;
-        case MailerFailure:
+        case ErrorCodes::MailerFailure:
             description = QObject::tr("Failed to send email.");
         break;
-        case AccountUpdateFailed:
+        case ErrorCodes::AccountUpdateFailed:
             description = QObject::tr("Failed to change account information.");
         break;
-        case EncryptionFailure:
+        case ErrorCodes::EncryptionFailure:
             description = QObject::tr("Encryption failed, please try again.");
         break;
-        case PasswordTooShort:
+        case ErrorCodes::PasswordTooShort:
             description = QObject::tr("The password is too short, please try again.");
         break;
-        case Download:
+        case ErrorCodes::Download:
             description = QObject::tr("Could not complete the download of the requested item.");
         break;
-        case AccessDenied:
+        case ErrorCodes::AccessDenied:
             description = QObject::tr("Could not complete the download of the requested item.");
         break;
-        case RedeemCodeFailure:
+        case ErrorCodes::RedeemCodeFailure:
             description = QObject::tr("The supplied points code was not valid.");
         break;
 
-        case PaymentMethodCreation:
+        case ErrorCodes::PurchaseMethodCreation:
             title = QObject::tr("Payment Method Error");
             description = QObject::tr("Failed to update purchase method details.");
         break;
-        case PaymentMethodDeletion:
+        case ErrorCodes::PurchaseMethodDeletion:
             title = QObject::tr("Payment Method Error");
             description = QObject::tr("Failed to update purchase method details.");
         break;
-        case PaymentMethodDetails:
+        case ErrorCodes::PurchaseMethodDetails:
             title = QObject::tr("Payment Method Error");
             description = QObject::tr("Failed to update purchase method details.");
         break;
-        case PaymentMethodMissing:
+        case ErrorCodes::PurchaseMethodMissing:
             title = QObject::tr("Payment Method Error");
             description = QObject::tr("A valid payment method could not be found. Please add a payment \
method to your account.");  break;
-        case CustomerRetrieval:
+        case ErrorCodes::CustomerRetrieval:
             title = QObject::tr("Purchase Method Error");
             description = QObject::tr("No purchase method (e.g. credit card) information found.");
         break;
-        case CustomerDatabase:
+        case ErrorCodes::CustomerDatabase:
             description = QObject::tr("Could not locate the requested customer account.");
         break;
-        case CustomerCharge:
-        case CustomerRefund:
+        case ErrorCodes::CustomerCharge:
+        case ErrorCodes::CustomerRefund:
             title = QObject::tr("Transaction Error");
             description = QObject::tr("Unable to complete the purchase process. No charge was made to \
your card.");  break;
-        case ChargeNotRecorded:
+        case ErrorCodes::ChargeNotRecorded:
             title = QObject::tr("Transaction Error");
             description = QObject::tr("Transaction was successful, but could not record the result on \
the account");  break;
-        case NotEnoughPoints:
+        case ErrorCodes::AccountNotEnoughPoints:
             title = QObject::tr("Purchase Error");
             description = QObject::tr("Your account lacks enough points to make this purchase.");
         break;
-        case TooManyPoints:
-            title = QObject::tr("Purchase Error");
-            description = QObject::tr("The requested amount of points exceeds the maximum purchase \
                limit.");
-        break;
-
-        case CollectionExists:
+        case ErrorCodes::CollectionExists:
             title = QObject::tr("Creation Error");
             description = QObject::tr("The collection already exists.");
         break;
-        case AssetExists:
+        case ErrorCodes::AssetExists:
             title = QObject::tr("Creation Error");
             description = QObject::tr("The asset already exists.");
         break;
 
-        case CardDeclined:
+        case ErrorCodes::CardDeclined:
             title = QObject::tr("Transaction Error");
             description = QObject::tr("Your card has been declined. Please try another payment method");
         break;
 
-        case CardIncorrectNumber:
-        case CardInvalidNumber:
+        case ErrorCodes::CardIncorrectNumber:
+        case ErrorCodes::CardInvalidNumber:
             title = QObject::tr("Transaction Error");
             description = QObject::tr("The card number supplied is incorrect. Please check it and try \
again.");  break;
 
-        case CardInvalidExpiryMonth:
+        case ErrorCodes::CardInvalidExpiryMonth:
             title = QObject::tr("Transaction Error");
             description = QObject::tr("The card expiry month supplied is incorrect.");
         break;
 
-        case CardInvalidExpiryYear:
+        case ErrorCodes::CardInvalidExpiryYear:
             title = QObject::tr("Transaction Error");
             description = QObject::tr("The card expiry year supplied is incorrect.");
         break;
 
-        case CardInvalidCVC:
+        case ErrorCodes::CardInvalidCVC:
             title = QObject::tr("Transaction Error");
             description = QObject::tr("The card CVC supplied is incorrect.");
         break;
 
-        case CardExpired:
+        case ErrorCodes::CardExpired:
             title = QObject::tr("Transaction Error");
             description = QObject::tr("Your card has expired. Please try another payment method.");
         break;
 
-        case CardInvalidAmount:
+        case ErrorCodes::CardInvalidAmount:
             title = QObject::tr("Transaction Error");
             description = QObject::tr("The purchase amount was invalid. Please try again.");
         break;
 
-        case CardDuplicateTransaction:
+        case ErrorCodes::CardDuplicateTransaction:
             title = QObject::tr("Transaction Error");
             description = QObject::tr("This transaction was already processed.");
         break;
 
-        case CardProcessingError:
+        case ErrorCodes::CardProcessingError:
             title = QObject::tr("Transaction Error");
             description = QObject::tr("A processing error occured when making the purchase. Please try \
again.");  break;
-
-        case PurchaseNotEnoughPoints:
+        case ErrorCodes::PurchaseNotEnoughPoints:
             title = QObject::tr("Transaction Error");
             description = QObject::tr("Too few points were requested. A minimum of 500 points per \
purchase is required.");  break;
-
-        case PurchaseTooManyPoints:
+        case ErrorCodes::PurchaseTooManyPoints:
             title = QObject::tr("Transaction Error");
             description = QObject::tr("Too many points were requested. Please purchase fewer points.");
         break;
@@ -294,7 +250,7 @@ Error::Error(const Error &other)
 
 }
 
-Error::Error(ServerCode code)
+Error::Error(ErrorCodes::ServerCode code)
     : d(new Private(code))
 {
 }
@@ -327,7 +283,7 @@ Error &Error::operator=(const Error &rhs)
     return *this;
 }
 
-Error::ServerCode Error::serverCode() const
+ErrorCodes::ServerCode Error::serverCode() const
 {
     return d->code;
 }
@@ -352,13 +308,15 @@ QString Error::description() const
     return d->description;
 }
 
-Error::ServerCode Error::serverCodeId(const QString &string)
+ErrorCodes::ServerCode Error::serverCodeId(const QString &string)
 {
     Private::initServerCodeDict();
     if (Private::serverCodes.contains(string)) {
         return Private::serverCodes.value(string);
     }
 
-    return Unknown;
+    return ErrorCodes::Unknown;
 }
 
+#include "error.moc"
+
diff --git a/lib/bodega/error.h b/lib/bodega/error.h
index a402810..3ff4dcd 100644
--- a/lib/bodega/error.h
+++ b/lib/bodega/error.h
@@ -25,56 +25,109 @@
 
 namespace Bodega {
 
-    class BODEGA_EXPORT Error
+    class BODEGA_EXPORT ErrorCodes : public QObject
     {
+        Q_OBJECT
+
     public:
-        // These should remain in sync with the server implementation
+        // These must remain in sync with the server implementation
         enum ServerCode {
             NoCode                = 0,
-            Connection            = 1, //reserved for client side connection errors
-            Unknown               = 2, //unexpected problem
-            Database              = 3, //db communication problem
-            Unauthorized          = 4, //unauthorized access
-            MissingParameters     = 5, //username/password/device id missing
-            NoMatch               = 6, //no or incorrect result
-            AccountInactive       = 7, //account is inactive
-            AccountExists         = 8, //collection/asset already exists
-            PurchaseFailed        = 9, //failed to purchase item
-            MailerFailure         = 10, //failed to generate an email
-            AccountUpdateFailed   = 11, //account update failed
-            EncryptionFailure     = 12, //couldn't encrypt text
-            PasswordTooShort      = 13, //password has to be at least 8 characters
-            Download              = 14, //problem with the download
-            AccessDenied          = 15, //access denied to the requested asset
-            RedeemCodeFailure     = 16, //could not redeem points code.
-
-            PaymentMethodCreation = 17, //could not link credit card to customer
-            PaymentMethodDeletion = 18, //delete card details
-            PaymentMethodDetails  = 19, //problem updating customer card details
-            PaymentMethodMissing  = 20, //customer card details missing
-            CustomerRetrieval     = 21, //problems retrieving card details
-            CustomerDatabase      = 22, //db error while querying for customer id
-            CustomerCharge        = 23, //unable to charge the customers card
-            CustomerRefund        = 24, //unable to charge the customers card
-            ChargeNotRecorded     = 25, //charged the customer but couldn't record it
-            NotEnoughPoints       = 26, //not enough points for a purchase
-            TooManyPoints         = 27,  //tried to buy too many points at once
-            CollectionExists      = 28, //collection already exists
-            AssetExists           = 29,  //asset already exists
-            CardDeclined           = 30,//credit card was declined
-            CardIncorrectNumber    = 31,//incorrect credit card number
-            CardInvalidNumber      = 32,//invalid credit card number
-            CardInvalidExpiryMonth = 33,//invalid credit card expiry month
-            CardInvalidExpiryYear  = 34,//invalid credit card expiry year
-            CardInvalidCVC         = 35,//invalid credit card cvs
-            CardExpired            = 36,//card expired
-            CardInvalidAmount      = 37,//invalid payment amount
+            Connection            = 1,//reserved for client side connection errors
+            Unknown               = 2,//unexpected problem
+            Database              = 3,//db communication problem
+            Unauthorized          = 4,//unauthorized access
+            MissingParameters     = 5,//username/password/store id missing
+            NoMatch               = 6,//no or incorrect result
+            AccountInactive       = 7,//account is inactive
+            AccountExists         = 8,//collection/asset already exists
+            PurchaseFailed        = 9,//failed to purchase item
+            MailerFailure         = 10,//failed to generate an email
+            AccountUpdateFailed   = 11,//account update failed
+            EncryptionFailure     = 12,//couldn't encrypt text
+            PasswordTooShort      = 13,//password has to be at least 8 characters
+            Download              = 14,//problem with the download
+            AccessDenied          = 15,//access denied to the requested asset
+            RedeemCodeFailure     = 16,//could not redeem points code.
+            InvalidEmailAddress   = 1000,//email address not valid
+            InvalidAsset          = 1001,//The asset doesn't exist in this store
+            InvalidRole           = 1002,//The account lacks the necessary person role
+            InvalidAccount        = 1003,//The account does not exist
+            TooManyParameters     = 1004,//Too many parameters were passed in to a call
+            AccountNotEnoughPoints = 1005,//Not enough points to complete an asset purchase
+
+            PurchaseMethodCreation  = 17,//could not link credit card to customer
+            PurchaseMethodDeletion  = 18,//delete card details
+            PurchaseMethodDetails   = 19,//problem updating customer card details
+            PurchaseMethodMissing   = 20,//customer card details missing
+            CustomerRetrieval       = 21,//problems retrieving card details
+            CustomerDatabase        = 22,//db error while querying for customer id
+            CustomerCharge          = 23,//unable to charge the customers card
+            CustomerRefund          = 24,//unable to charge the customers card
+            ChargeNotRecorded       = 25,//charged the customer but couldn't record it
+            PurchaseNotEnoughPoints = 26,//not enough points for a purchase
+            PurchaseTooManyPoints   = 27,//tried to buy too many points at once
+            CollectionExists        = 28,//collection/asset already exists
+            AssetExists             = 29,//collection/asset already exists
+
+            CardDeclined             = 30,//credit card was declined
+            CardIncorrectNumber      = 31,//incorrect credit card number
+            CardInvalidNumber        = 32,//invalid credit card number
+            CardInvalidExpiryMonth   = 33,//invalid credit card expiry month
+            CardInvalidExpiryYear    = 34,//invalid credit card expiry year
+            CardInvalidCVC           = 35,//invalid credit card cvs
+            CardExpired              = 36,//card expired
+            CardInvalidAmount        = 37,//invalid payment amount
             CardDuplicateTransaction = 38,//same transaction was just submitted
-            CardProcessingError    = 39,//error occurred while processing the card
-            PurchaseNotEnoughPoints       = 40, //not enough points for a purchase
-            PurchaseTooManyPoints         = 41,  //tried to buy too many points at once
+            CardProcessingError      = 39,//error occurred while processing the card
+
+            PartnerInvalid      = 40, //the partner ID provided is invalid for the request
+            UploadFailed        = 41, //the uploading of the file did not succeed
+            UploadInvalidJson   = 42, //asset info data was malformed
+            UploadTagError      = 43, //one of the required tags is missing
+            UploadPreviewError  = 44, //the asset is missing a preview
+            UploadIconError     = 45, //the asset is missing an icon
+            AssetMissing        = 46, //the given asset doesn't exist'
+            InvalidUrl          = 47, //the requested url is invalid
+
+            PreviewFileMissing      = 48, //one of the preview files is missing
+            IconWrongSize           = 49, //one of the icons is of the wrong size
+            CoverWrongSize          = 50, //one of the covers is of the wrong size
+            ScreenshotWrongSize     = 51, //one of the screenshots is of the wrong size
+            AssetMissingIcons       = 52, //asset is missing the required icons
+            AssetMissingScreenshot  = 53, //asset is missing required screenshot
+            AssetMissingCover       = 54, //asset is missing required screenshot
+            AssetInfoMissing        = 55, //asset info is missing
+            AssetFileMissing        = 56, //the specified asset file doesn't exist
+            AssetPosted             = 57, //can't edit a posted asset!
+            InvalidAssetListing     = 58, //the specified asset listing is invalid
+            PartnerRoleMissng       = 59, //person is not a validator
+
+            StoreIdExists             = 60,//on creating a store, the store id already exists
+            StoreNameInvalid          = 62,//an invalid (e.g. missing) store name
+            StoreNotDeleted           = 63,//deleting a store failed
+            StoreIdInvalid            = 64,//the provided store id is not valid for this user
+            StoreChannelIdInvalid     = 65,//the requested channel id for editting is invalid
+            StoreCreateChannelFailed  = 66,//could not create the requested channel
+            PublishingFailed          = 67,//wasn't able to publish an asset
+
+            PartnerNameExists  = 80,//the partner already exists in the database
+            InvalidLinkService = 81,//the service requested for use as a link does not exist
+
+            TagIdInvalid      = 90,//The tag that has been requested doesn't exist
+            TagNotDeleted     = 91,//The tag that has been requested to be deleted is still there
+            TagExists         = 92,//The tag that has been requested to be created already exists
+            TagTypeInvalid    = 93,//The tag that has been requested doesn't exist
+            RatingExists      = 94,//rating already exists
+            UploadMissingTag  = 95, //The asset doesn't have a required tag
+            AssetIconMissing  = 96 //The asset Doesn't have any icon
         };
+        Q_ENUMS(ServerCode)
+    };
 
+    class BODEGA_EXPORT Error
+    {
+    public:
         enum Type {
             Network,
             Authentication,
@@ -84,7 +137,7 @@ namespace Bodega {
 
         Error();
         Error(const Error &other);
-        Error(ServerCode serverCode);
+        Error(ErrorCodes::ServerCode serverCode);
         Error(Type type, const QString &msg);
         Error(Type type,
               const QString &errorId,
@@ -92,13 +145,13 @@ namespace Bodega {
               const QString &descr);
         ~Error();
         Error &operator=(const Error &rhs);
-        ServerCode serverCode() const;
+        ErrorCodes::ServerCode serverCode() const;
         Type type() const;
         QString errorId() const;
         QString title() const;
         QString description() const;
 
-        static ServerCode serverCodeId(const QString &string);
+        static ErrorCodes::ServerCode serverCodeId(const QString &string);
 
     private:
         class Private;
diff --git a/lib/bodega/networkjob.cpp b/lib/bodega/networkjob.cpp
index 9b16836..0896c65 100644
--- a/lib/bodega/networkjob.cpp
+++ b/lib/bodega/networkjob.cpp
@@ -205,7 +205,7 @@ void NetworkJob::parseErrors(const QVariantMap &jsonMap)
                          tr("Authentication Error"),
                          tr("Invalid username or password"));
     } else {
-        const Error::ServerCode code = \
Error::serverCodeId(error.value(QLatin1String("type")).toString()); +        const ErrorCodes::ServerCode \
code = Error::serverCodeId(error.value(QLatin1String("type")).toString());  d->error = Error(code);
     }
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic