formad.cpp 2.0 KB

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