19 * |
19 * |
20 */ |
20 */ |
21 |
21 |
22 #include <assert.h> |
22 #include <assert.h> |
23 |
23 |
24 #include "BookmarksManager.h" |
24 #include "HistoryManager.h" |
25 #include "actionjsobject.h" |
25 #include "actionjsobject.h" |
26 #include "webpagedata.h" |
26 #include "webpagedata.h" |
27 #include "wrtbrowsercontainer.h" |
27 #include "wrtbrowsercontainer.h" |
28 #include "wrtbrowsercontainer_p.h" |
28 #include "wrtbrowsercontainer_p.h" |
29 #include "webpagecontroller_p.h" |
29 #include "webpagecontroller_p.h" |
45 #include <QWebDatabase> |
45 #include <QWebDatabase> |
46 #include <QWebSettings> |
46 #include <QWebSettings> |
47 #include <QtCore/QSettings> |
47 #include <QtCore/QSettings> |
48 using namespace WRT; |
48 using namespace WRT; |
49 |
49 |
|
50 #ifdef ORBIT_UI |
|
51 #include <shareui.h> |
|
52 #include <qcontactemailaddress.h> |
|
53 #include <xqaiwdeclplat.h> |
|
54 #include <xqaiwrequest.h> |
|
55 #include <xqappmgr.h> |
|
56 #endif // ORBIT_UI |
|
57 |
|
58 |
50 #if defined(Q_OS_SYMBIAN) // for shareToMail |
59 #if defined(Q_OS_SYMBIAN) // for shareToMail |
51 #include <miutset.h> |
60 #include <miutset.h> |
52 #include <sendui.h> |
61 #include <sendui.h> |
53 #include <cmessagedata.h> |
62 #include <cmessagedata.h> |
54 #include <txtrich.h> |
63 #include <txtrich.h> |
55 #include <SendUiConsts.h> |
64 #include <SendUiConsts.h> |
56 const TUid KShareOnline = { 0x200009D5 }; |
65 const TUid KShareOnline = { 0x200009D5 }; |
57 const TUid KShareOnOvi = { 0x2001AA43 }; |
66 const TUid KShareOnOvi = { 0x2001AA43 }; |
58 #endif |
67 #endif |
|
68 #ifdef ORBIT_UI |
|
69 static const QString EMAIL_SEND_TO_KEY = "to"; |
|
70 #endif // ORBIT_UI |
59 |
71 |
60 #define MAX_NUM_WINDOWS_TO_RESTORE 5 |
72 #define MAX_NUM_WINDOWS_TO_RESTORE 5 |
61 #define MAX_NUM_WINDOWS 5 |
73 #define MAX_NUM_WINDOWS 5 |
62 |
74 |
63 static const char KHISTORYEXTENSION[] = ".history"; |
75 static const char KHISTORYEXTENSION[] = ".history"; |
|
76 static const char KCOOKIESEXTENSION[] = ".ini"; |
|
77 |
64 |
78 |
65 WebPageControllerPrivate::WebPageControllerPrivate(WebPageController* qq) : |
79 WebPageControllerPrivate::WebPageControllerPrivate(WebPageController* qq) : |
66 q(qq), |
80 q(qq), |
67 m_widgetParent(0), |
81 m_widgetParent(0), |
68 m_currentPage(-1), |
82 m_currentPage(-1), |
109 } |
123 } |
110 else |
124 else |
111 { |
125 { |
112 q->deleteDataFiles(); |
126 q->deleteDataFiles(); |
113 } |
127 } |
114 /* #if defined(Q_OS_SYMBIAN) |
128 |
115 // clean up all pages |
129 // clean up all pages |
116 while ( !m_allPages.isEmpty() ) |
130 while ( !m_allPages.isEmpty() ) |
117 q->closePage(m_allPages.at(0)); |
131 q->closePage(m_allPages.at(0)); |
118 |
132 |
119 Q_ASSERT ( m_allPages.isEmpty() ); |
133 Q_ASSERT ( m_allPages.isEmpty() ); |
120 #endif*/ |
134 |
121 // delete(m_widgetParent); |
135 // delete(m_widgetParent); |
122 } |
136 } |
123 |
137 |
124 |
138 |
125 |
139 |
281 * @param page WRT::WrtBrowserContainer instance to be closed |
295 * @param page WRT::WrtBrowserContainer instance to be closed |
282 * @see WRT::WrtBrowserContainer |
296 * @see WRT::WrtBrowserContainer |
283 */ |
297 */ |
284 void WebPageController::closePage ( WRT::WrtBrowserContainer *page ) |
298 void WebPageController::closePage ( WRT::WrtBrowserContainer *page ) |
285 { |
299 { |
286 if(pageCount() > 1) { |
|
287 WRT::WrtBrowserContainer * theCurrentPage = currentPage(); |
300 WRT::WrtBrowserContainer * theCurrentPage = currentPage(); |
288 bool updateCurrentPageIndex = false; |
301 bool updateCurrentPageIndex = false; |
289 |
302 |
290 // get index of page we want to remove |
303 // get index of page we want to remove |
291 int closeIndex = d->m_allPages.indexOf(page); |
304 int closeIndex = d->m_allPages.indexOf(page); |
295 // was this page the "current page?" |
308 // was this page the "current page?" |
296 // if so, we need to select the page to become the new one |
309 // if so, we need to select the page to become the new one |
297 // select the previous page unless at the beginning, then select next |
310 // select the previous page unless at the beginning, then select next |
298 if(page == theCurrentPage) { |
311 if(page == theCurrentPage) { |
299 int newCurrIndex = closeIndex - 1; |
312 int newCurrIndex = closeIndex - 1; |
300 if(closeIndex == 0 ) { |
313 if(closeIndex == 0 && pageCount() > 1) { |
301 newCurrIndex = closeIndex + 1; |
314 newCurrIndex = closeIndex + 1; |
302 } |
315 } |
303 |
316 |
304 // change the current page |
317 // change the current page |
305 if(newCurrIndex >= 0) { |
318 if(newCurrIndex >= 0) { |
379 connect( page, SIGNAL( loadProgress(int) ), SIGNAL( loadProgress(int) ) ); |
390 connect( page, SIGNAL( loadProgress(int) ), SIGNAL( loadProgress(int) ) ); |
380 connect( page, SIGNAL( loadFinished(bool) ), SLOT( onLoadFinished(bool) ) ); |
391 connect( page, SIGNAL( loadFinished(bool) ), SLOT( onLoadFinished(bool) ) ); |
381 |
392 |
382 connect( page, SIGNAL( databaseQuotaExceeded (QWebFrame *,QString) ), SLOT( onDatabaseQuotaExceeded (QWebFrame *,QString)) ); |
393 connect( page, SIGNAL( databaseQuotaExceeded (QWebFrame *,QString) ), SLOT( onDatabaseQuotaExceeded (QWebFrame *,QString)) ); |
383 |
394 |
384 connect( page->mainFrame(), SIGNAL( iconChanged() ), SIGNAL( pageIconChanged() ) ); |
395 connect( page->mainFrame(), SIGNAL( iconChanged() ), this, SIGNAL( pageIconChanged() ) ); |
385 connect( page->loadController(), SIGNAL( pageLoadStarted() ), SIGNAL( pageLoadStarted() ) ); |
396 connect( page->loadController(), SIGNAL( pageLoadStarted() ), SIGNAL( pageLoadStarted() ) ); |
386 connect( page->loadController(), SIGNAL( pageLoadFailed() ), SIGNAL( pageLoadFailed() ) ); |
397 connect( page->loadController(), SIGNAL( pageLoadFailed() ), SIGNAL( pageLoadFailed() ) ); |
387 connect( page->loadController(), SIGNAL( pageLoadProgress(int) ), SIGNAL( pageLoadProgress(int) ) ); |
398 connect( page->loadController(), SIGNAL( pageLoadProgress(int) ), SIGNAL( pageLoadProgress(int) ) ); |
388 connect( page->loadController(), SIGNAL( pageLoadFinished(bool) ), SIGNAL( pageLoadFinished(bool) ) ); |
399 connect( page->loadController(), SIGNAL( pageLoadFinished(bool) ), SIGNAL( pageLoadFinished(bool) ) ); |
389 connect( page->loadController(), SIGNAL( pageUrlChanged(QString) ), SIGNAL( pageUrlChanged(QString) ) ); |
400 connect( page->loadController(), SIGNAL( pageUrlChanged(QString) ), SIGNAL( pageUrlChanged(QString) ) ); |
444 { |
455 { |
445 QWebSecurityOrigin qwso = frame->securityOrigin(); |
456 QWebSecurityOrigin qwso = frame->securityOrigin(); |
446 qint64 quota = qwso.databaseQuota() ; |
457 qint64 quota = qwso.databaseQuota() ; |
447 qint64 usage = qwso.databaseUsage() ; |
458 qint64 usage = qwso.databaseUsage() ; |
448 } |
459 } |
449 m_promptMsg = "Database Quota Error"; |
460 //m_promptMsg = "Database Quota Error"; |
|
461 m_promptMsg = qtTrId("txt_browser_error_database_quota"); |
450 emit databaseQuotaExceeded (frame, database); |
462 emit databaseQuotaExceeded (frame, database); |
451 |
463 |
452 return; |
464 return; |
453 } |
465 } |
454 |
466 |
459 WRT::WrtBrowserContainer* page = qobject_cast<WRT::WrtBrowserContainer*> (sender()); |
471 WRT::WrtBrowserContainer* page = qobject_cast<WRT::WrtBrowserContainer*> (sender()); |
460 if (page){ |
472 if (page){ |
461 page->setUpdateThumbnail(true); |
473 page->setUpdateThumbnail(true); |
462 // Current page is handled in onLoadFinished() so skip this case here |
474 // Current page is handled in onLoadFinished() so skip this case here |
463 if(page != currentPage()){ |
475 if(page != currentPage()){ |
464 BookmarksManager::getSingleton()->addHistory(page->mainFrame()->url().toString(), page->pageTitle()); |
476 HistoryManager::getSingleton()->addHistory(page->mainFrame()->url().toString(), page->pageTitle()); |
465 emit (loadFinishedForBackgroundWindow(true,page)); |
477 emit (loadFinishedForBackgroundWindow(true,page)); |
466 } |
478 } |
467 } |
479 } |
468 } |
480 } |
469 |
481 |
470 void WebPageController::updateHistory() |
482 void WebPageController::updateHistory() |
471 { |
483 { |
472 BookmarksManager::getSingleton()->addHistory(currentDocUrl(), currentDocTitle()); |
484 HistoryManager::getSingleton()->addHistory(currentDocUrl(), currentDocTitle()); |
473 emit(loadFinished(true)); |
485 emit(loadFinished(true)); |
474 } |
486 } |
475 |
487 |
476 /*! |
488 /*! |
477 * Handling of network error happens signal |
489 * Handling of network error happens signal |
708 Share the url through mail client |
720 Share the url through mail client |
709 */ |
721 */ |
710 #if defined(Q_OS_SYMBIAN) |
722 #if defined(Q_OS_SYMBIAN) |
711 void WebPageController::share(const QString &url) |
723 void WebPageController::share(const QString &url) |
712 { |
724 { |
|
725 #ifdef ORBIT_UI |
|
726 ShareUi *shareUi = new ShareUi(); |
|
727 QStringList stringList; |
|
728 stringList << QString(url); |
|
729 shareUi->send(stringList,true); |
|
730 if(shareUi) |
|
731 delete shareUi; |
|
732 #else |
713 QString body = url; |
733 QString body = url; |
714 CSendUi* sendUi = CSendUi::NewLC(); |
734 CSendUi* sendUi = CSendUi::NewLC(); |
715 CMessageData* messageData = CMessageData::NewLC(); |
735 CMessageData* messageData = CMessageData::NewLC(); |
716 |
736 |
717 TSendingCapabilities sendingCapabilities; |
737 TSendingCapabilities sendingCapabilities; |
747 bodyRichText->InsertL( 0, KNullDesC ); |
767 bodyRichText->InsertL( 0, KNullDesC ); |
748 |
768 |
749 messageData->SetBodyTextL( bodyRichText ); |
769 messageData->SetBodyTextL( bodyRichText ); |
750 sendUi->ShowQueryAndSendL(messageData, sendingCapabilities, array); |
770 sendUi->ShowQueryAndSendL(messageData, sendingCapabilities, array); |
751 CleanupStack::PopAndDestroy( 6 ); // bodyRichText, charFormat, paraFormat, messageData, sendUi |
771 CleanupStack::PopAndDestroy( 6 ); // bodyRichText, charFormat, paraFormat, messageData, sendUi |
|
772 #endif // ORBIT_UI |
752 } |
773 } |
753 #else |
774 #else |
754 void WebPageController::share(const QString &url) |
775 void WebPageController::share(const QString &url) |
755 { |
776 { |
756 return; // Not supported |
777 return; // Not supported |
761 Feedback from user |
782 Feedback from user |
762 */ |
783 */ |
763 #if defined(Q_OS_SYMBIAN) |
784 #if defined(Q_OS_SYMBIAN) |
764 void WebPageController::feedbackMail(const QString &mailAddress, const QString &mailBody) |
785 void WebPageController::feedbackMail(const QString &mailAddress, const QString &mailBody) |
765 { |
786 { |
|
787 #ifdef ORBIT_UI |
|
788 |
|
789 XQAiwRequest *sendRequest; |
|
790 XQApplicationManager appManager; |
|
791 QVariant retValue; |
|
792 |
|
793 sendRequest = appManager.create(XQI_EMAIL_MESSAGE_SEND, "send(QVariant)",true); |
|
794 |
|
795 if(sendRequest) { |
|
796 QMap<QString, QVariant> map; |
|
797 QStringList recipients; |
|
798 QList<QVariant> data; |
|
799 recipients.append(mailAddress); |
|
800 map.insert(EMAIL_SEND_TO_KEY, recipients); |
|
801 data.append(map); |
|
802 data << mailBody; |
|
803 sendRequest->setArguments(data); |
|
804 sendRequest->send(retValue); |
|
805 } |
|
806 |
|
807 if(sendRequest) { |
|
808 delete sendRequest; |
|
809 } |
|
810 #else |
766 QString to = mailAddress; |
811 QString to = mailAddress; |
767 QString body = mailBody; |
812 QString body = mailBody; |
768 CSendUi* sendUi = CSendUi::NewLC(); |
813 CSendUi* sendUi = CSendUi::NewLC(); |
769 CMessageData* messageData = CMessageData::NewLC(); |
814 CMessageData* messageData = CMessageData::NewLC(); |
770 |
815 |
786 messageData->SetBodyTextL( bodyRichText ); |
831 messageData->SetBodyTextL( bodyRichText ); |
787 |
832 |
788 TRAP_IGNORE(sendUi->CreateAndSendMessageL( KUidMsgTypeSMTP, messageData )); |
833 TRAP_IGNORE(sendUi->CreateAndSendMessageL( KUidMsgTypeSMTP, messageData )); |
789 // TRAP_IGNORE(sendUi->CreateAndSendMessageL( KSenduiMtmSmsUid, messageData )); |
834 // TRAP_IGNORE(sendUi->CreateAndSendMessageL( KSenduiMtmSmsUid, messageData )); |
790 CleanupStack::PopAndDestroy( 5 ); |
835 CleanupStack::PopAndDestroy( 5 ); |
|
836 #endif //// ORBIT_UI |
791 } |
837 } |
792 #else |
838 #else |
793 void WebPageController::feedbackMail(const QString &mailAddress, const QString &mailBody) |
839 void WebPageController::feedbackMail(const QString &mailAddress, const QString &mailBody) |
794 { |
840 { |
795 return; // Not supported |
841 return; // Not supported |
929 WRT::WrtBrowserContainer* BrowserPageFactory::openBrowserPage() |
975 WRT::WrtBrowserContainer* BrowserPageFactory::openBrowserPage() |
930 { |
976 { |
931 return WebPageController::getSingleton()->openPage(); |
977 return WebPageController::getSingleton()->openPage(); |
932 } |
978 } |
933 |
979 |
|
980 |
|
981 QString WebPageController::removeScheme(const QString & s) { |
|
982 |
|
983 return (WRT::UiUtil::removeScheme(s)); |
|
984 } |
|
985 |
934 QString WebPageController::guessUrlFromString(const QString &s){ |
986 QString WebPageController::guessUrlFromString(const QString &s){ |
935 QUrl u = WRT::UiUtil::guessUrlFromString(s); |
987 QUrl u = WRT::UiUtil::guessUrlFromString(s); |
936 return u.toString(); |
988 return u.toString(); |
937 } |
989 } |
938 |
990 |
939 QString WebPageController::searchUrl(const QString &s){ |
991 QString WebPageController::searchUrl(const QString &s){ |
940 QUrl u = WRT::UiUtil::searchUrl(s); |
992 QUrl u = WRT::UiUtil::searchUrl(s); |
1391 } |
1443 } |
1392 } |
1444 } |
1393 |
1445 |
1394 void WebPageController::deleteCookies() |
1446 void WebPageController::deleteCookies() |
1395 { |
1447 { |
1396 QDir dir(d->m_historyDir); |
1448 QDir dir(d->m_historyDir); |
1397 QFileInfoList fileList(dir.entryInfoList(QDir::Files)); |
1449 QFileInfoList fileList(dir.entryInfoList(QDir::Files)); |
1398 QString indexStr; |
1450 QString indexStr; |
1399 int index = 0; |
1451 int index = 0; |
1400 foreach (const QFileInfo fileInfo, fileList) { |
1452 foreach (const QFileInfo fileInfo, fileList) { |
1401 const QString filePath(fileInfo.absoluteFilePath()); |
1453 const QString filePath(fileInfo.absoluteFilePath()); |
1402 if (filePath.endsWith(QString(KHISTORYEXTENSION), Qt::CaseInsensitive)) { |
1454 //if (filePath.endsWith(QString(KHISTORYEXTENSION), Qt::CaseInsensitive)) { |
|
1455 if (filePath.endsWith(QString(KCOOKIESEXTENSION), Qt::CaseInsensitive)) { |
1403 indexStr.setNum(index); |
1456 indexStr.setNum(index); |
1404 QString cookiesFile = d->m_historyDir + QLatin1String("/cookies.ini"); |
1457 QString cookiesFile = d->m_historyDir + QLatin1String("/cookies.ini"); |
1405 QFile file(cookiesFile); |
1458 QFile file(cookiesFile); |
1406 if(file.open(QIODevice::ReadOnly)) { |
1459 if(file.open(QIODevice::ReadOnly)) { |
1407 file.remove(); |
1460 file.remove(); |
1445 |
1498 |
1446 if(diskCacheDir.isEmpty()) |
1499 if(diskCacheDir.isEmpty()) |
1447 return; |
1500 return; |
1448 |
1501 |
1449 //QDir dir1(d->m_historyDir +"/cwrtCache/http"); |
1502 //QDir dir1(d->m_historyDir +"/cwrtCache/http"); |
1450 QDir dir1(diskCacheDir + "/brCache/http"); |
1503 QDir dir1(diskCacheDir + "/http"); |
1451 |
1504 |
1452 QFileInfoList fileList1(dir1.entryInfoList(QDir::Files)); |
1505 QFileInfoList fileList1(dir1.entryInfoList(QDir::Files)); |
1453 |
1506 |
1454 foreach (const QFileInfo fileInfo, fileList1) { |
1507 foreach (const QFileInfo fileInfo, fileList1) { |
1455 const QString filePath(fileInfo.absoluteFilePath()); |
1508 const QString filePath(fileInfo.absoluteFilePath()); |
1459 file.close(); |
1512 file.close(); |
1460 } |
1513 } |
1461 } |
1514 } |
1462 |
1515 |
1463 //QDir dir2(d->m_historyDir +"/cwrtCache/https"); |
1516 //QDir dir2(d->m_historyDir +"/cwrtCache/https"); |
1464 QDir dir2(diskCacheDir +"/brCache/https"); |
1517 QDir dir2(diskCacheDir +"/https"); |
1465 |
1518 |
1466 QFileInfoList fileList2(dir2.entryInfoList(QDir::Files)); |
1519 QFileInfoList fileList2(dir2.entryInfoList(QDir::Files)); |
1467 |
1520 |
1468 foreach (const QFileInfo fileInfo, fileList2) { |
1521 foreach (const QFileInfo fileInfo, fileList2) { |
1469 const QString filePath(fileInfo.absoluteFilePath()); |
1522 const QString filePath(fileInfo.absoluteFilePath()); |
1564 |
1617 |
1565 void WebPageController::updatePageThumbnails() |
1618 void WebPageController::updatePageThumbnails() |
1566 { |
1619 { |
1567 // update current page's thumbnail forcely since the scrolling position may change |
1620 // update current page's thumbnail forcely since the scrolling position may change |
1568 WRT::WrtBrowserContainer *page = currentPage(); |
1621 WRT::WrtBrowserContainer *page = currentPage(); |
1569 QWebHistoryItem item = page->history()->currentItem(); |
1622 if(page) { |
1570 page->savePageDataToHistoryItem(page->mainFrame(), &item); |
1623 QWebHistoryItem item = page->history()->currentItem(); |
1571 page->setUpdateThumbnail(false); |
1624 page->savePageDataToHistoryItem(page->mainFrame(), &item); |
1572 checkAndUpdatePageThumbnails(); |
1625 page->setUpdateThumbnail(false); |
|
1626 checkAndUpdatePageThumbnails(); |
|
1627 } |
1573 } |
1628 } |
1574 |
1629 |
1575 void WebPageController::resizeAndUpdatePageThumbnails(QSize& s) |
1630 void WebPageController::resizeAndUpdatePageThumbnails(QSize& s) |
1576 { |
1631 { |
1577 webView()->resize(s); // resize the view |
1632 webView()->resize(s); // resize the view |
1589 //if (currentPage()) |
1644 //if (currentPage()) |
1590 |
1645 |
1591 return currentPage()->loadController()->mode(); |
1646 return currentPage()->loadController()->mode(); |
1592 } |
1647 } |
1593 |
1648 |
1594 void WebPageController::setLoadState(int mode) { |
1649 void WebPageController::setEditMode(bool editing) { |
1595 |
1650 |
1596 //qDebug() << __func__; |
1651 //qDebug() << __func__; |
1597 currentPage()->loadController()->setMode((WRT::LoadController::GotoBrowserMode)mode); |
1652 currentPage()->loadController()->setEditMode(editing); |
1598 //qDebug() << __func__ << currentPage()->loadController()->mode(); |
1653 //qDebug() << __func__ << currentPage()->loadController()->mode(); |
|
1654 } |
|
1655 |
|
1656 bool WebPageController::editMode() { |
|
1657 |
|
1658 return (currentPage()->loadController()->editMode()); |
1599 } |
1659 } |
1600 |
1660 |
1601 int WebPageController::loadProgressValue() { |
1661 int WebPageController::loadProgressValue() { |
1602 |
1662 |
1603 //qDebug() << __func__ << currentPage()->loadController()->progressValue(); |
1663 //qDebug() << __func__ << currentPage()->loadController()->progressValue(); |