Starts the server; make slight changes in server code
so that it understands qt's resource system (qrc)
we can use that to manage the html related files
(would be stored in app bundle for mac osx, and in
perhaps /usr/local/share for Linux by qt)
Change-Id: I8cc9e7bd99000d287bac5e6c8bd86008924351c6
diff --git a/gui/chronosharegui.cpp b/gui/chronosharegui.cpp
index 04bff02..038f05a 100644
--- a/gui/chronosharegui.cpp
+++ b/gui/chronosharegui.cpp
@@ -34,12 +34,18 @@
using namespace boost;
using namespace Ccnx;
+static const string HTTP_SERVER_ADDRESS = "localhost";
+static const string HTTP_SERVER_PORT = "9001";
+static const string DOC_ROOT = ":/html";
+static const QString ICON_PICTURE_QSTRING(":/images/friends-group-icon.png");
+
INIT_LOGGER ("Gui");
ChronoShareGui::ChronoShareGui(QWidget *parent)
: QDialog(parent)
, m_watcher(0)
, m_dispatcher(0)
+ , m_httpServer(0)
#ifdef ADHOC_SUPPORTED
, m_executor (1)
#endif
@@ -132,6 +138,17 @@
m_watcher = new FsWatcher (m_dirPath,
bind (&Dispatcher::Did_LocalFile_AddOrModify, m_dispatcher, _1),
bind (&Dispatcher::Did_LocalFile_Delete, m_dispatcher, _1));
+ QFileInfo indexHtmlInfo(":/html/index.html");
+ if (indexHtmlInfo.exists())
+ {
+ m_httpServer = new http::server::server(HTTP_SERVER_ADDRESS, HTTP_SERVER_PORT, DOC_ROOT);
+ m_httpServerThread = boost::thread(&http::server::server::run, m_httpServer);
+ }
+ else
+ {
+ _LOG_ERROR ("Http server doc root dir does not exist!");
+ // shall we bail here?
+ }
}
ChronoShareGui::~ChronoShareGui()
@@ -142,6 +159,7 @@
delete m_watcher; // stop filewatching ASAP
delete m_dispatcher; // stop dispatcher ASAP, but after watcher (to prevent triggering callbacks on deleted object)
+ delete m_httpServer;
// cleanup
delete m_trayIcon;
@@ -169,7 +187,7 @@
messageBox.setWindowTitle(title);
messageBox.setText(text);
- messageBox.setIconPixmap(QPixmap(":/images/friends-group-icon.png"));
+ messageBox.setIconPixmap(QPixmap(ICON_PICTURE_QSTRING));
messageBox.exec();
}
@@ -181,7 +199,7 @@
messageBox.setText(text);
messageBox.setInformativeText(infotext);
- messageBox.setIconPixmap(QPixmap(":/images/friends-group-icon.png"));
+ messageBox.setIconPixmap(QPixmap(ICON_PICTURE_QSTRING));
messageBox.exec();
}
@@ -284,7 +302,7 @@
void ChronoShareGui::setIcon()
{
// set the icon image
- m_trayIcon->setIcon(QIcon(":/images/friends-group-icon.png"));
+ m_trayIcon->setIcon(QIcon(ICON_PICTURE_QSTRING));
}
void ChronoShareGui::openSharedFolder()