formnotice.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #include "formnotice.h"
  2. #include "ui_formnotice.h"
  3. #include "sncdatabase.h"
  4. #include "respencrypt.h"
  5. #include "respgetservertime.h"
  6. #include <QtCore>
  7. FormNotice::FormNotice(QWidget *parent) :
  8. QWidget(parent),
  9. ui(new Ui::FormNotice)
  10. {
  11. ui->setupUi(this);
  12. m_webview = new CacheWebView(this);
  13. m_webview->setMinimumWidth(280);
  14. m_webview->setMaximumWidth(280);
  15. ui->verticalLayout->addWidget(m_webview);
  16. m_ssows = new WSSSO();
  17. }
  18. void FormNotice::setNoticeUrl(QString pageUrl)
  19. {
  20. m_pageUrl = pageUrl;
  21. m_webview->setPageUrl(m_pageUrl,QCoreApplication::applicationDirPath()+"/cache");
  22. }
  23. void FormNotice::setAccountInfo(QMap<QString, QString> info)
  24. {
  25. m_userHash = info.value("userhash");
  26. m_ssoHash = info.value("ssohash");
  27. if(m_userHash.isEmpty())
  28. {
  29. m_webview->setPageUrl(m_pageUrl,QCoreApplication::applicationDirPath()+"/../cache");
  30. }
  31. else
  32. {
  33. QString url = getUserCenterUrl();
  34. m_webview->setPageUrl(url,QCoreApplication::applicationDirPath()+"/../cache");
  35. }
  36. }
  37. void FormNotice::setClientID(QString clientID)
  38. {
  39. m_clientID = clientID;
  40. }
  41. FormNotice::~FormNotice()
  42. {
  43. if(m_ssows)
  44. {
  45. m_ssows->abort();
  46. delete m_ssows;
  47. }
  48. delete ui;
  49. delete m_webview;
  50. qDebug()<<QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")\
  51. <<"FormNotice Destroyed.";
  52. }
  53. QString FormNotice::getUserCenterUrl()
  54. {
  55. QString json = m_ssows->encrypt(m_ssoHash);
  56. RespEncrypt resp1(json);
  57. QString data = resp1.getEncryptData();
  58. json = m_ssows->getServerTime();
  59. RespGetServerTime resp2(json);
  60. QString authCode;
  61. QByteArray ba;
  62. QString str = SNCDataBase::getAuthCodeUrl().arg(resp2.getServerTime().mid(0,16));
  63. ba = QCryptographicHash::hash ( str.toAscii(), QCryptographicHash::Md5 );
  64. authCode.append(ba.toHex());
  65. QString url = SNCDataBase::getSSOAccountUrl() + "?s=mf&r="+authCode+"&u="+data+"&p=ad_"+m_clientID;
  66. return url;
  67. }