| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- #include "formad.h"
- #include "ui_formad.h"
- #include "sncdatabase.h"
- #include "respencrypt.h"
- #include "respgetservertime.h"
- FormAd::FormAd(QWidget *parent) :
- QWidget(parent),
- ui(new Ui::FormAd)
- {
- ui->setupUi(this);
- page_ads = SNCDataBase::getLocalPageAds();
- m_webview = new CacheWebView(this);
- m_webview->setMinimumWidth(280);
- m_webview->setMaximumWidth(280);
- QString url = "";
- if(page_ads.count()>0)
- {
- url = page_ads.value("ad_app2_zxsh");
- }
- m_webview->setPageUrl(url,QCoreApplication::applicationDirPath()+"/../cache");
- connect(m_webview,SIGNAL(titleChanged(QString)),this,SLOT(onTitleChanged(QString)));
- ui->verticalLayout->addWidget(m_webview);
- m_ssows = new WSSSO();
- }
- void FormAd::setAccountInfo(QMap<QString, QString> info)
- {
- m_account = info;
- QString ssoHash = info.value("ssohash");
- if(ssoHash.isEmpty())
- {
- m_webview->setPageUrl(SNCDataBase::getZxshUrl(),QCoreApplication::applicationDirPath()+"/../cache");
- }
- else
- {
- QString url = getUserCenterUrl();
- //QString url = SNCDataBase::getZxshUrl();
- m_webview->setPageUrl(url,QCoreApplication::applicationDirPath()+"/../cache");
- }
- }
- FormAd::~FormAd()
- {
- if(m_ssows)
- {
- m_ssows->abort();
- delete m_ssows;
- }
- delete m_webview;
- delete ui;
- qDebug()<<QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")\
- <<"FormRiddle.FormAd Destroyed.";
- }
- QString FormAd::getUserCenterUrl()
- {
- QString ssoHash = m_account.value("ssohash");
- QString json = m_ssows->encrypt(ssoHash);
- RespEncrypt resp1(json);
- QString data = resp1.getEncryptData();
- json = m_ssows->getServerTime();
- RespGetServerTime resp2(json);
- QString authCode;
- QByteArray ba;
- QString str = SNCDataBase::getAuthCodeUrl().arg(resp2.getServerTime().mid(0,16));
- ba = QCryptographicHash::hash ( str.toAscii(), QCryptographicHash::Md5 );
- authCode.append(ba.toHex());
- QString url = SNCDataBase::getSSOAccountUrl() + "?s=mf&r="+authCode+"&u="+data+"&p=ad_zxsh";
- return url;
- }
- void FormAd::onTitleChanged(QString title)
- {
- if(title=="ÉêÇë³É¹¦")
- emit userStateChanged();
- }
|