Added error handling to listing of users and showing of user information.
authorJanne Änäkkälä <janne_anakkala@hotmail.com>
Thu, 27 May 2010 08:05:07 +0000 (11:05 +0300)
committerJanne Änäkkälä <janne_anakkala@hotmail.com>
Thu, 27 May 2010 08:05:07 +0000 (11:05 +0300)
Client/httpclient.cpp
Client/usersdialog.cpp
Client/usersdialog.h
Client/usersdialog.ui

index d5049fd..e43f761 100644 (file)
@@ -636,12 +636,27 @@ void HttpClient::ackOfUserInfo()
     file.close();*/
 
     QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
     file.close();*/
 
     QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
-    myXmlreader->xmlReadUserInfo(reply);
+    //myXmlreader->xmlReadUserInfo(reply);
 
     //for(int i = 0; i < myXmlreader->usersList->count(); i++)
     //{
     //    myMainw->settingsDialog->sendUsernameToUsersDialog(myXmlreader->usersList->at(i));
     //}
 
     //for(int i = 0; i < myXmlreader->usersList->count(); i++)
     //{
     //    myMainw->settingsDialog->sendUsernameToUsersDialog(myXmlreader->usersList->at(i));
     //}
+    QNetworkReply::NetworkError errorcode;
+    errorcode = reply->error();
+    if(errorcode != 0) {
+        qDebug() <<  "errorcode:" << errorcode << reply->errorString();
+        //QMessageBox::about(myMainw->topResultDialog, "Server reply to requesting categories",reply->errorString());
+        if(myMainw->usersDialog)
+            myMainw->usersDialog->setLabelInfoToUser("You're not logged! Please register or log in.");
+    }
+    else {
+        myXmlreader->xmlReadUserInfo(reply);
+        qDebug() <<  "errorcode:" << errorcode << reply->errorString();
+        //QMessageBox::about(myMainw->topResultDialog, "Server reply to requesting categories ", "OK");
+        if(myMainw->usersDialog)
+            myMainw->usersDialog->setLabelInfoToUser("");
+    }
 }
 
 /**
 }
 
 /**
@@ -668,8 +683,8 @@ void HttpClient::requestUsers()
     //connect(currentDownload,SIGNAL(error(QNetworkReply::NetworkError)),myMainw,SLOT(errorFromServer(QNetworkReply::NetworkError)));
 
     //Indicating user
     //connect(currentDownload,SIGNAL(error(QNetworkReply::NetworkError)),myMainw,SLOT(errorFromServer(QNetworkReply::NetworkError)));
 
     //Indicating user
-    //if(myMainw->topResultDialog)
-        //myMainw->topResultDialog->setLabelInfoToUser("Reguesting categories from server");
+    if(myMainw->usersDialog)
+        myMainw->usersDialog->setLabelInfoToUser("Reguesting users from server");
 
     //ackOfUsers();
 }
 
     //ackOfUsers();
 }
@@ -703,26 +718,27 @@ void HttpClient::ackOfUsers()
     //    myMainw->topResultDialog->setLabelInfoToUser("");
 
     QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
     //    myMainw->topResultDialog->setLabelInfoToUser("");
 
     QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
-    myXmlreader->xmlReadUsers(reply);
+    //myXmlreader->xmlReadUsers(reply);
 
 
-    for(int i = 0; i < myXmlreader->usersList->count(); i++)
-    {
-        myMainw->usersDialog->appendUserToList(myXmlreader->usersList->at(i));
-    }
-   /* QNetworkReply::NetworkError errorcode;
+    QNetworkReply::NetworkError errorcode;
     errorcode = reply->error();
     if(errorcode != 0) {
         qDebug() <<  "errorcode:" << errorcode << reply->errorString();
         //QMessageBox::about(myMainw->topResultDialog, "Server reply to requesting categories",reply->errorString());
     errorcode = reply->error();
     if(errorcode != 0) {
         qDebug() <<  "errorcode:" << errorcode << reply->errorString();
         //QMessageBox::about(myMainw->topResultDialog, "Server reply to requesting categories",reply->errorString());
-        if(myMainw->topResultDialog)
-            myMainw->topResultDialog->setLabelInfoToUser("You're not logged! Please register or log in.");
+        if(myMainw->usersDialog)
+            myMainw->usersDialog->setLabelInfoToUser("You're not logged! Please register or log in.");
     }
     else {
     }
     else {
+        myXmlreader->xmlReadUsers(reply);
         qDebug() <<  "errorcode:" << errorcode << reply->errorString();
         //QMessageBox::about(myMainw->topResultDialog, "Server reply to requesting categories ", "OK");
         qDebug() <<  "errorcode:" << errorcode << reply->errorString();
         //QMessageBox::about(myMainw->topResultDialog, "Server reply to requesting categories ", "OK");
-        if(myMainw->topResultDialog)
-            myMainw->topResultDialog->setLabelInfoToUser("");
-    }*/
+        if(myMainw->usersDialog)
+            myMainw->usersDialog->setLabelInfoToUser("");
+        for(int i = 0; i < myXmlreader->usersList->count(); i++)
+        {
+            myMainw->usersDialog->appendUserToList(myXmlreader->usersList->at(i));
+        }
+    }
 }
 
 /**
 }
 
 /**
index 2d7186c..c61c5d1 100644 (file)
@@ -86,3 +86,8 @@ void UsersDialog::setUserInfo(QStringList *usersInfo)
    }
    //ui->labelDescriptionHeader->setText("Description: " + usersInfo->at(4));
 }
    }
    //ui->labelDescriptionHeader->setText("Description: " + usersInfo->at(4));
 }
+
+void UsersDialog::setLabelInfoToUser(QString infoText)
+{
+    this->ui->labelInfoToUser->setText(infoText);
+}
index 91e3a82..db291f9 100644 (file)
@@ -15,6 +15,7 @@ public:
     ~UsersDialog();
     void appendUserToList(QString usrname);
     void setUserInfo(QStringList *usersInfo);
     ~UsersDialog();
     void appendUserToList(QString usrname);
     void setUserInfo(QStringList *usersInfo);
+    void setLabelInfoToUser(QString infoText);
 
 protected:
     void changeEvent(QEvent *e);
 
 protected:
     void changeEvent(QEvent *e);
index 64b7bf8..f716fe4 100644 (file)
     <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
    </property>
   </widget>
     <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
    </property>
   </widget>
+  <widget class="QLabel" name="labelInfoToUser">
+   <property name="geometry">
+    <rect>
+     <x>10</x>
+     <y>320</y>
+     <width>671</width>
+     <height>51</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>Info label</string>
+   </property>
+  </widget>
  </widget>
  <resources/>
  <connections/>
  </widget>
  <resources/>
  <connections/>