Changing build system to waf
diff --git a/.gitignore b/.gitignore
index fd68882..5853b18 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,3 +7,6 @@
*.pb.*
qrc*
gdb-target
+.waf*
+.lock*
+build/
diff --git a/README b/README
deleted file mode 100644
index 3841068..0000000
--- a/README
+++ /dev/null
@@ -1,36 +0,0 @@
-Chronos is a multiparty chat application that demostrates our work on sync (high level idea is similar to ccnx sync, but the design is slightly different).
-
-Chronos will have binary package for Mac OS X 10.7 and 10.8 hopefully by the time of the next retreat. However, it's too much work to do binary packaging for different flavors of Linux, so Linux users will have to compile by their own.
-
-If you are following Alex A's suggestion and installed his package of ccnx, you don't have to input the name prefix for your data manually. However, if you haven't installed his ccnx package, or your hub does not support prefix auto configuration, you'll have to manually input a routable prefix for your data.
-
-Note that after you click to close Chronos, it will be running on your system tray. To restore it to normal size window, you have to click on the system tray icon (normally on the upper right corner of your screen). Clicking on the dock won't work for now and is still on the to-do list (because I'm using qt for gui, not the native Cocoa framework).
-
-== Known Issues ==
-1. When you switch to a new room, you'll temporarily see yourself in two nodes for a minute or so. It won't affect others, just yourself. Hopefully it's not so disturbing.
-2. Sometimes you may not get the most up-to-date chat history.
-
-== For those who wants (or is forced to) compile from source code ==
-
-You need pkg-config, protobuf, boost, and qt to compile this app. All of them can be installed through macports.
-The following command should do it:
-$ sudo port install pkg-config protobuf-cpp boost qt4-mac
-
-To compile this app:
-1. in the top directory, check out the "sync" submodule
-$ git submodule update --init
-
-2. go to sync directory, do:
-$ ./waf configure
-$ ./waf
-$ sudo ./waf install
-
-3. back to the top directory, set up environment for pkg-config, make sure libsync.pc is searchable, this is mine:
-$ export PKG_CONFIG_PATH=/opt/local/lib/pkgconfig:/usr/local/lib/pkgconfig:/usr/lib/pkgconfig
-
-4. compile Chronos:
-$ qmake
-$ make
-
-Congratulations! Chronos.app is ready to use (on a Mac).
-
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..82b2dc8
--- /dev/null
+++ b/README.md
@@ -0,0 +1,43 @@
+ChronoChat
+==========
+
+ChronoChat is a multiparty chat application that demostrates our synchronization primitive that we call ChronoSync.
+
+Note that after you click to close ChronoChat, it will keep running on your system tray. To restore it to normal size window, you have to click on the system tray icon (normally on the upper right corner of your screen). Clicking on the dock won't work for now and is still on the to-do list (because I'm using qt for gui, not the native Cocoa framework).
+
+## Known Issues
+---------------
+
+1. When you switch to a new room, you'll temporarily see yourself in two nodes for a minute or so. It won't affect others, just yourself. Hopefully it's not so disturbing.
+2. Sometimes you may not get the most up-to-date chat history.
+
+## For those who wants (or is forced to) compile from source code
+-----------------------------------------------------------------
+
+You need pkg-config, protobuf, boost, and qt to compile this app. All of them can be installed through macports.
+The following command should do it:
+$ sudo port install pkg-config protobuf-cpp boost qt4-mac
+
+To compile this app:
+
+1. in the top directory, check out the "sync" submodule
+
+ $ git submodule update --init
+
+2. go to sync directory, do:
+
+ $ ./waf configure
+ $ ./waf
+ $ sudo ./waf install
+
+3. back to the top directory, set up environment for pkg-config, make sure libsync.pc is searchable, this is mine:
+
+ $ export PKG_CONFIG_PATH=/opt/local/lib/pkgconfig:/usr/local/lib/pkgconfig:/usr/lib/pkgconfig
+
+4. compile Chronos:
+
+ $ ./waf configure
+ $ ./waf
+
+Congratulations! build/ChronoChat.app is ready to use (on a Mac).
+
diff --git a/chatdialog.cpp b/chatdialog.cpp
index a3137a0..71d4652 100644
--- a/chatdialog.cpp
+++ b/chatdialog.cpp
@@ -1,3 +1,15 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2013, Regents of the University of California
+ * Alexander Afanasyev
+ * Zhenkai Zhu
+ *
+ * GNU v3.0 license, See the LICENSE file for more information
+ *
+ * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
+ * Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
#include "chatdialog.h"
#include "settingdialog.h"
@@ -19,21 +31,27 @@
#include <stdio.h>
#endif
-#define BROADCAST_PREFIX_FOR_SYNC_DEMO "/ndn/broadcast/chronos"
+#define BROADCAST_PREFIX_FOR_SYNC_DEMO "/ndn/broadcast/ChronoChat-0.3"
#define LOCAL_PREFIX_QUERY "/local/ndn/prefix"
#define DEFAULT_LOCAL_PREFIX "/private/local"
-#define CCN_EXEC "/usr/local/bin/ccnpeek"
+// #define CCN_EXEC "/usr/local/bin/ccnpeek"
static const int HELLO_INTERVAL = FRESHNESS * 3 / 4; // seconds
ChatDialog::ChatDialog(QWidget *parent)
- : QDialog(parent), m_sock(NULL), m_lastMsgTime(0), m_historyInitialized(false), m_joined(false)
+ : QDialog(parent)
+ , m_sock(NULL)
+ , m_lastMsgTime(0)
+ , m_historyInitialized(false)
+ , m_joined(false)
{
// have to register this, otherwise
// the signal-slot system won't recognize this type
qRegisterMetaType<std::vector<Sync::MissingDataInfo> >("std::vector<Sync::MissingDataInfo>");
qRegisterMetaType<size_t>("size_t");
- setupUi(this);
+
+ setupUi (this);
+
m_session = time(NULL);
m_scene = new DigestTreeScene(this);
@@ -44,28 +62,31 @@
lineEdit->setFocusPolicy(Qt::StrongFocus);
treeViewer->setScene(m_scene);
+ treeViewer->hide ();
m_scene->plot("Empty");
QRectF rect = m_scene->itemsBoundingRect();
m_scene->setSceneRect(rect);
- listView->setStyleSheet("QListView { alternate-background-color: white; background: #F0F0F0; color: darkGreen; font: bold large; }");
- listView->setEditTriggers(QAbstractItemView::NoEditTriggers);
- listView->setDragDropMode(QAbstractItemView::NoDragDrop);
- listView->setSelectionMode(QAbstractItemView::NoSelection);
+ // listView->setStyleSheet("QListView { alternate-background-color: white; background: #F0F0F0; color: darkGreen; font: bold large; }");
+ // listView->setEditTriggers(QAbstractItemView::NoEditTriggers);
+ // listView->setDragDropMode(QAbstractItemView::NoDragDrop);
+ // listView->setSelectionMode(QAbstractItemView::NoSelection);
+
m_rosterModel = new QStringListModel(this);
listView->setModel(m_rosterModel);
- refreshButton->setIcon(QIcon(QPixmap(":images/refresh.png")));
- reapButton->hide();
+ // refreshButton->setIcon(QIcon(QPixmap(":images/refresh.png")));
+ // reapButton->hide();
createActions();
createTrayIcon();
m_timer = new QTimer(this);
connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(returnPressed()));
- connect(setButton, SIGNAL(pressed()), this, SLOT(buttonPressed()));
+ // connect(setButton, SIGNAL(pressed()), this, SLOT(buttonPressed()));
connect(treeButton, SIGNAL(pressed()), this, SLOT(treeButtonPressed()));
- connect(reapButton, SIGNAL(pressed()), this, SLOT(summonReaper()));
- connect(refreshButton, SIGNAL(pressed()), this, SLOT(updateLocalPrefix()));
+ // connect(reapButton, SIGNAL(pressed()), this, SLOT(summonReaper()));
+ // connect(refreshButton, SIGNAL(pressed()), this, SLOT(updateLocalPrefix()));
+
connect(this, SIGNAL(dataReceived(QString, const char *, size_t, bool, bool)), this, SLOT(processData(QString, const char *, size_t, bool, bool)));
connect(this, SIGNAL(treeUpdated(const std::vector<Sync::MissingDataInfo>)), this, SLOT(processTreeUpdate(const std::vector<Sync::MissingDataInfo>)));
connect(m_timer, SIGNAL(timeout()), this, SLOT(replot()));
@@ -75,7 +96,6 @@
connect(m_scene, SIGNAL(rosterChanged(QStringList)), this, SLOT(updateRosterList(QStringList)));
initializeSync();
-
}
void
@@ -235,6 +255,10 @@
minimizeAction->setEnabled(visible);
maximizeAction->setEnabled(!isMaximized());
restoreAction->setEnabled(isMaximized() || !visible);
+
+ raise(); // for MacOS
+ activateWindow(); // for Windows
+
QDialog::setVisible(visible);
}
@@ -693,10 +717,11 @@
bool
ChatDialog::readSettings()
{
- QSettings s(ORGANIZATION, APPLICATION);
- QString nick = s.value("nick", "").toString();
- QString chatroom = s.value("chatroom", "").toString();
- // QString originPrefix = s.value("originPrefix", "").toString();
+ QSettings settings (QSettings::NativeFormat, QSettings::UserScope, ORGANIZATION, APPLICATION);
+
+ QString nick = settings.value("nick", "").toString();
+ QString chatroom = settings.value("chatroom", "").toString();
+ // QString originPrefix = settings.value("originPrefix", "").toString();
// Sync::CcnxWrapperPtr wrapper = Sync::CcnxWrapper::Create ();
// QString originPrefix = QString::fromStdString (wrapper->getLocalPrefix());
@@ -704,7 +729,7 @@
QString originPrefix = DEFAULT_LOCAL_PREFIX;
- m_minimaniho = s.value("minimaniho", false).toBool();
+ m_minimaniho = settings.value("minimaniho", false).toBool();
if (nick == "" || chatroom == "" || originPrefix == "") {
m_user.setOriginPrefix(DEFAULT_LOCAL_PREFIX);
m_user.setChatroom("retreat2012");
@@ -727,11 +752,12 @@
void
ChatDialog::writeSettings()
{
- QSettings s(ORGANIZATION, APPLICATION);
- s.setValue("nick", m_user.getNick());
- s.setValue("chatroom", m_user.getChatroom());
- //s.setValue("originPrefix", m_user.getOriginPrefix());
- s.setValue("minimaniho", m_minimaniho);
+ QSettings settings (QSettings::NativeFormat, QSettings::UserScope, ORGANIZATION, APPLICATION);
+
+ settings.setValue("nick", m_user.getNick());
+ settings.setValue("chatroom", m_user.getChatroom());
+ //settings.setValue("originPrefix", m_user.getOriginPrefix());
+ settings.setValue("minimaniho", m_minimaniho);
}
void
@@ -765,14 +791,15 @@
if (text.startsWith("boruoboluomi"))
{
- reapButton->show();
+ summonReaper ();
+ // reapButton->show();
fitView();
return;
}
if (text.startsWith("minimanihong"))
{
- reapButton->hide();
+ // reapButton->hide();
fitView();
return;
}
@@ -870,12 +897,12 @@
if (treeViewer->isVisible())
{
treeViewer->hide();
- treeButton->setText("Show Sync Tree");
+ treeButton->setText("Show ChronoSync Tree");
}
else
{
treeViewer->show();
- treeButton->setText("Hide Sync Tree");
+ treeButton->setText("Hide ChronoSync Tree");
}
fitView();
@@ -884,8 +911,8 @@
void ChatDialog::enableTreeDisplay()
{
treeButton->setEnabled(true);
- treeViewer->show();
- fitView();
+ // treeViewer->show();
+ // fitView();
}
void ChatDialog::disableTreeDisplay()
@@ -1052,6 +1079,14 @@
restoreAction = new QAction(tr("&Restore"), this);
connect(restoreAction, SIGNAL(triggered()), this, SLOT(showNormal()));
+ settingsAction = new QAction(tr("Settings"), this);
+ connect (settingsAction, SIGNAL(triggered()), this, SLOT(buttonPressed()));
+
+ settingsAction->setMenuRole (QAction::PreferencesRole);
+
+ updateLocalPrefixAction = new QAction(tr("Update local prefix"), this);
+ connect (updateLocalPrefixAction, SIGNAL(triggered()), this, SLOT(updateLocalPrefix()));
+
quitAction = new QAction(tr("Quit"), this);
connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
}
@@ -1064,6 +1099,10 @@
trayIconMenu->addAction(maximizeAction);
trayIconMenu->addAction(restoreAction);
trayIconMenu->addSeparator();
+ trayIconMenu->addAction(settingsAction);
+ trayIconMenu->addSeparator();
+ trayIconMenu->addAction(updateLocalPrefixAction);
+ trayIconMenu->addSeparator();
trayIconMenu->addAction(quitAction);
trayIcon = new QSystemTrayIcon(this);
@@ -1074,6 +1113,11 @@
setWindowIcon(icon);
trayIcon->setToolTip("Chronos System Tray Icon");
trayIcon->setVisible(true);
+
+ // // QApplication::getMenu ()->addMenu (trayIconMenu);
+ // QMenuBar *bar = new QMenuBar ();
+ // bar->setMenu (trayIconMenu);
+ // setMenuBar (bar);
}
void
@@ -1096,3 +1140,8 @@
m_scene->setSceneRect(rect);
treeViewer->fitInView(m_scene->itemsBoundingRect(), Qt::KeepAspectRatio);
}
+
+#if WAF
+#include "chatdialog.moc"
+#include "chatdialog.cpp.moc"
+#endif
diff --git a/chatdialog.h b/chatdialog.h
index 71f36d8..d10c60e 100644
--- a/chatdialog.h
+++ b/chatdialog.h
@@ -1,3 +1,15 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2013, Regents of the University of California
+ * Alexander Afanasyev
+ * Zhenkai Zhu
+ *
+ * GNU v3.0 license, See the LICENSE file for more information
+ *
+ * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
+ * Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
#ifndef CHATDIALOG_H
#define CHATDIALOG_H
@@ -15,10 +27,11 @@
#endif
#include <QSystemTrayIcon>
+#include <QMainWindow>
#include <QQueue>
-#define ORGANIZATION "IRL@UCLA"
-#define APPLICATION "CHRONOS"
+#define ORGANIZATION "irl.cs.ucla.edu"
+#define APPLICATION "ChronoChat"
#define MAX_HISTORY_ENTRY 20
class QAction;
@@ -26,7 +39,7 @@
class QStringListModel;
class QTextTable;
-class ChatDialog : public QDialog, private Ui::ChatDialog
+class ChatDialog : public QDialog, private Ui::ChatDialog
{
Q_OBJECT
@@ -122,8 +135,11 @@
QAction *minimizeAction;
QAction *maximizeAction;
QAction *restoreAction;
+ QAction *settingsAction;
+ QAction *updateLocalPrefixAction;
QAction *quitAction;
QSystemTrayIcon *trayIcon;
+ // QMenu *menuBar;
QMenu *trayIconMenu;
};
#endif
diff --git a/chatdialog.ui b/chatdialog.ui
index dcee37e..2380f3d 100644
--- a/chatdialog.ui
+++ b/chatdialog.ui
@@ -1,219 +1,176 @@
+<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
- <class>ChatDialog</class>
- <widget class="QDialog" name="ChatDialog">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>800</width>
- <height>600</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Retreat Chat -- Powered By Chronos</string>
- </property>
- <!-- start of root layout -->
- <layout class="QVBoxLayout">
- <property name="spacing">
- <number>6</number>
- </property>
- <!-- start of head bar item -->
- <item >
+ <class>ChatDialog</class>
+ <widget class="QDialog" name="ChatDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>838</width>
+ <height>600</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>ChronoChat -- Powered By ChronoSync</string>
+ </property>
+ <layout class="QVBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <item>
+ <layout class="QHBoxLayout">
+ <property name="spacing">
+ <number>-1</number>
+ </property>
+ <item>
+ <layout class="QVBoxLayout">
+ <item>
+ <widget class="QLabel" name="infoLabel">
+ <property name="focusPolicy">
+ <enum>Qt::NoFocus</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
<layout class="QHBoxLayout">
- <property name="margin">
- <number>0</number>
- </property>
- <property name="spacing">
- <number>6</number>
- </property>
- <item>
- <layout class = "QVBoxLayout" >
- <property name="margin">
- <number>0</number>
- </property>
- <property name="spacing">
- <number>6</number>
- </property>
- <item>
- <widget class="QLabel" name="infoLabel">
- <property name="focusPolicy">
- <enum>Qt::NoFocus</enum>
- </property>
- </widget>
- </item>
- <item>
- <layout class = "QHBoxLayout" >
- <property name="margin">
- <number>0</number>
- </property>
- <property name="spacing">
- <number>6</number>
- </property>
- <item>
- <widget class="QLabel" name="prefixLabel">
- <property name="focusPolicy">
- <enum>Qt::NoFocus</enum>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="refreshButton">
- <property name="focusPolicy">
- <enum>Qt::NoFocus</enum>
- </property>
- <property name="minimumWidth">
- <number>150</number>
- </property>
- <property name="maximumWidth">
- <number>150</number>
- </property>
- <property name="text">
- <string>Update Prefix</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </item>
- <item>
- <layout class = "QVBoxLayout" >
- <property name="margin">
- <number>0</number>
- </property>
- <property name="spacing">
- <number>6</number>
- </property>
- <item>
- <widget class="QPushButton" name="setButton">
- <property name="focusPolicy">
- <enum>Qt::NoFocus</enum>
- </property>
- <property name="text">
- <string>Settings</string>
- </property>
- <property name="minimumWidth">
- <number>150</number>
- </property>
- <property name="maximumWidth">
- <number>150</number>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="treeButton">
- <property name="focusPolicy">
- <enum>Qt::NoFocus</enum>
- </property>
- <property name="text">
- <string>Hide Sync Tree</string>
- </property>
- <property name="minimumWidth">
- <number>150</number>
- </property>
- <property name="maximumWidth">
- <number>150</number>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="reapButton">
- <property name="focusPolicy">
- <enum>Qt::NoFocus</enum>
- </property>
- <property name="text">
- <string>Summon Reaper!</string>
- </property>
- <property name="minimumWidth">
- <number>150</number>
- </property>
- <property name="maximumWidth">
- <number>150</number>
- </property>
- </widget>
- </item>
- </layout>
- </item>
+ <item>
+ <widget class="QLabel" name="prefixLabel">
+ <property name="focusPolicy">
+ <enum>Qt::NoFocus</enum>
+ </property>
+ </widget>
+ </item>
</layout>
- </item>
- <!-- end of head bar item -->
- <!-- start of display area -->
- <item>
- <layout class = "QHBoxLayout">
- <property name="margin">
- <number>0</number>
- </property>
- <property name="spacing">
- <number>6</number>
- </property>
- <item>
- <widget class = "QListView" name="listView">
- <property name="focusPolicy">
- <enum>Qt::NoFocus</enum>
- </property>
- <property name="maximumWidth">
- <number>200</number>
- </property>
- </widget>
- </item>
- <item>
- <layout class="QVBoxLayout">
- <property name="margin">
- <number>0</number>
- </property>
- <property name="spacing">
- <number>6</number>
- </property>
- <item>
- <widget class="QGraphicsView" name="treeViewer">
- <property name="focusPolicy">
- <enum>Qt::NoFocus</enum>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QTextEdit" name="textEdit">
- <property name="focusPolicy">
- <enum>Qt::NoFocus</enum>
- </property>
- <property name="minimumWidth">
- <number>600</number>
- </property>
- <property name="readOnly">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <!-- start of input line widget -->
- <item>
- <layout class="QHBoxLayout">
- <property name="margin">
- <number>0</number>
- </property>
- <property name="spacing">
- <number>6</number>
- </property>
- <item>
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Message:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="lineEdit" />
- </item>
- </layout>
- </item>
- <!-- end of input line widget -->
- </layout>
- </item>
- </layout>
- </item>
- <!-- end of display area -->
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <layout class="QVBoxLayout">
+ <property name="sizeConstraint">
+ <enum>QLayout::SetFixedSize</enum>
+ </property>
+ <item>
+ <widget class="QPushButton" name="treeButton">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>200</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>200</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="focusPolicy">
+ <enum>Qt::NoFocus</enum>
+ </property>
+ <property name="text">
+ <string>Show ChronoSync Tree</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
</layout>
- </widget>
- <resources/>
- <connections/>
+ </item>
+ <item>
+ <layout class="QHBoxLayout">
+ <item>
+ <widget class="QListView" name="listView">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>14</pointsize>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
+ <property name="focusPolicy">
+ <enum>Qt::NoFocus</enum>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">color: darkGreen;
+background: #F0F0F0;</string>
+ </property>
+ <property name="editTriggers">
+ <set>QAbstractItemView::NoEditTriggers</set>
+ </property>
+ <property name="showDropIndicator" stdset="0">
+ <bool>false</bool>
+ </property>
+ <property name="selectionMode">
+ <enum>QAbstractItemView::NoSelection</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QVBoxLayout">
+ <item>
+ <widget class="QGraphicsView" name="treeViewer">
+ <property name="focusPolicy">
+ <enum>Qt::NoFocus</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QTextEdit" name="textEdit">
+ <property name="focusPolicy">
+ <enum>Qt::NoFocus</enum>
+ </property>
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout">
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Message:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="lineEdit"/>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
</ui>
-
diff --git a/digesttreescene.cpp b/digesttreescene.cpp
index 5e474bf..ba45af8 100644
--- a/digesttreescene.cpp
+++ b/digesttreescene.cpp
@@ -313,3 +313,7 @@
seqTextItem->setPos(innerBR.x() + (innerBR.width() - textBR.width())/2, innerBR.y() + (innerBR.height() - textBR.height())/2);
}
+#if WAF
+#include "digesttreescene.moc"
+#include "digesttreescene.cpp.moc"
+#endif
diff --git a/main.cpp b/main.cpp
index c12375a..6c2ff22 100644
--- a/main.cpp
+++ b/main.cpp
@@ -2,10 +2,9 @@
#include "chatdialog.h"
#include <QMessageBox>
-int main(int argc, char *argv[])
+int main(int argc, char *argv[])
{
-
- Q_INIT_RESOURCE(demo);
+ // Q_INIT_RESOURCE(demo);
QApplication app(argc, argv);
if (!QSystemTrayIcon::isSystemTrayAvailable()) {
@@ -14,8 +13,8 @@
"on this system."));
return 1;
}
- QApplication::setQuitOnLastWindowClosed(false);
-
+ QApplication::setQuitOnLastWindowClosed (false);
+
#ifdef __APPLE__
app.setWindowIcon(QIcon(":/demo.icns"));
#else
@@ -23,7 +22,10 @@
#endif
ChatDialog dialog;
- dialog.show();
- dialog.activateWindow();
+
+ dialog.show ();
+ dialog.activateWindow ();
+ dialog.raise ();
+
return app.exec();
}
diff --git a/osxdist.py b/osxdist.py
old mode 100644
new mode 100755
index ef704aa..9e7ac14
--- a/osxdist.py
+++ b/osxdist.py
@@ -240,7 +240,7 @@
print ' * Changing version in Info.plist'
p = self.infoplist
p['CFBundleVersion'] = self.version
- p['CFBundleExecutable'] = "Chronos"
+ p['CFBundleExecutable'] = "ChronoChat"
p['CFBundleIconFile'] = 'demo.icns'
p['CFBundleGetInfoString'] = '''
'''
@@ -344,11 +344,11 @@
if __name__ == '__main__':
parser = OptionParser()
- parser.add_option('', '--release', dest='release', help='Build a release. This determines the version number of the release.')
- parser.add_option('', '--snapshot', dest='snapshot', help='Build a snapshot release. This determines the \'snapshot version\'.')
- parser.add_option('', '--git', dest='git', help='Build a snapshot release. Use the git revision number as the \'snapshot version\'.', action='store_true', default=False)
- parser.add_option('', '--codesign', dest='codesign', help='Identity to use for code signing. (If not set, no code signing will occur)')
- parser.add_option('', '--codesign-keychain', dest='codesign_keychain', help='The keychain to use when invoking the codesign utility.')
+ parser.add_option('-r', '--release', dest='release', help='Build a release. This determines the version number of the release.')
+ parser.add_option('-s', '--snapshot', dest='snapshot', help='Build a snapshot release. This determines the \'snapshot version\'.')
+ parser.add_option('-g', '--git', dest='git', help='Build a snapshot release. Use the git revision number as the \'snapshot version\'.', action='store_true', default=False)
+ parser.add_option('--codesign', dest='codesign', help='Identity to use for code signing. (If not set, no code signing will occur)')
+ parser.add_option('--codesign-keychain', dest='codesign_keychain', help='The keychain to use when invoking the codesign utility.')
options, args = parser.parse_args()
@@ -363,16 +363,17 @@
ver = gitrev()
#ver = "0.0.1"
else:
- print 'Neither snapshot or release selected. Bailing.'
+ print 'ERROR: Neither snapshot or release selected. Bailing.'
+ parser.print_help ()
sys.exit(1)
# Do the finishing touches to our Application bundle before release
- a = AppBundle('ChronoChat.app', ver)
+ a = AppBundle('build/ChronoChat.app', ver)
a.copy_qt_plugins()
a.handle_libs()
- a.copy_resources(['demo.icns', 'qt.conf'])
- a.update_plist()
+ a.copy_resources(['qt.conf'])
+ # a.update_plist()
a.set_min_macosx_version('10.8.0')
a.done()
@@ -380,18 +381,18 @@
if options.codesign:
print ' * Signing binaries with identity `%s\'' % options.codesign
binaries = (
- 'ChronoChat.app',
+ 'build/ChronoChat.app',
)
codesign(binaries)
print ''
# Create diskimage
- title = "ChronosChat %s" % ver
- fn = "%s.dmg" % title
+ title = "ChronosChat-%s" % ver
+ fn = "build/%s.dmg" % title
d = DiskImage(fn, title)
d.symlink('/Applications', '/Applications')
- d.copy('ChronoChat.app', '/ChronoChat.app')
- d.copy('README', '/README.txt')
+ d.copy('build/ChronoChat.app', '/ChronoChat.app')
+ d.copy('README.md', '/README.txt')
d.create()
diff --git a/settingdialog.cpp b/settingdialog.cpp
index 23ddc3c..ff617a2 100644
--- a/settingdialog.cpp
+++ b/settingdialog.cpp
@@ -50,3 +50,8 @@
QDialog::keyPressEvent(e);
}
}
+
+#if WAF
+#include "settingdialog.moc"
+#include "settingdialog.cpp.moc"
+#endif
diff --git a/sync-demo.pri b/sync-demo.pri
deleted file mode 100644
index 3ff4309..0000000
--- a/sync-demo.pri
+++ /dev/null
@@ -1,18 +0,0 @@
-PROTOPATH += .
-PROTOPATHS =
-for(p, PROTOPATH):PROTOPATHS += --proto_path=$${p}
-
-protobuf_decl.name = protobuf header
-protobuf_decl.input = PROTOS
-protobuf_decl.output = ${QMAKE_FILE_BASE}.pb.h
-protobuf_decl.commands = protoc --cpp_out="." $${PROTOPATHS} ${QMAKE_FILE_NAME}
-protobuf_decl.variable_out = GENERATED_FILES
-QMAKE_EXTRA_COMPILERS += protobuf_decl
-
-protobuf_impl.name = protobuf implementation
-protobuf_impl.input = PROTOS
-protobuf_impl.output = ${QMAKE_FILE_BASE}.pb.cc
-protobuf_impl.depends = ${QMAKE_FILE_BASE}.pb.h
-protobuf_impl.commands = $$escape_expand(\\n)
-protobuf_impl.variable_out = GENERATED_SOURCES
-QMAKE_EXTRA_COMPILERS += protobuf_impl
diff --git a/sync-demo.pro b/sync-demo.pro
deleted file mode 100644
index e86a54d..0000000
--- a/sync-demo.pro
+++ /dev/null
@@ -1,32 +0,0 @@
-TEMPLATE = app
-TARGET = ChronoChat
-DEFINES += __DEBUG
-HEADERS = chatdialog.h \
- digesttreescene.h \
- settingdialog.h \
- treelayout.h
-
-SOURCES = main.cpp \
- chatdialog.cpp \
- digesttreescene.cpp \
- settingdialog.cpp \
- treelayout.cpp
-
-RESOURCES = demo.qrc
-ICON = demo.icns
-QT += xml svg
-FORMS = chatdialog.ui \
- settingdialog.ui
-
-QMAKE_CXXFLAGS *= -g
-QMAKE_CFLAGS *= -g
-LIBS += -lboost_system-mt -lboost_random-mt
-
-CONFIG += console
-
-PROTOS = chatbuf.proto
-include (sync-demo.pri)
-
-CONFIG += link_pkgconfig
-PKGCONFIG += libsync
-PKGCONFIG += protobuf
diff --git a/waf b/waf
new file mode 100755
index 0000000..1bbe08e
--- /dev/null
+++ b/waf
Binary files differ
diff --git a/wscript b/wscript
new file mode 100644
index 0000000..863d2ac
--- /dev/null
+++ b/wscript
@@ -0,0 +1,191 @@
+# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
+VERSION='0.3'
+APPNAME='ChronoChat'
+
+from waflib import Build, Logs, Utils, Task, TaskGen, Configure
+
+def options(opt):
+ opt.add_option('--debug',action='store_true',default=False,dest='debug',help='''debugging mode''')
+ # opt.add_option('--test', action='store_true',default=False,dest='_test',help='''build unit tests''')
+ # opt.add_option('--log4cxx', action='store_true',default=False,dest='log4cxx',help='''Compile with log4cxx logging support''')
+
+ # if Utils.unversioned_sys_platform () == "darwin":
+ # opt.add_option('--auto-update', action='store_true',default=False,dest='autoupdate',help='''(OSX) Download sparkle framework and enable autoupdate feature''')
+
+ opt.load('compiler_c compiler_cxx boost protoc qt4')
+
+def configure(conf):
+ conf.load("compiler_c compiler_cxx")
+
+ if conf.options.debug:
+ conf.define ('_DEBUG', 1)
+ conf.add_supported_cxxflags (cxxflags = ['-O0',
+ '-Wall',
+ '-Wno-unused-variable',
+ '-g3',
+ '-Wno-unused-private-field', # only clang supports
+ '-fcolor-diagnostics', # only clang supports
+ '-Qunused-arguments' # only clang supports
+ ])
+ else:
+ conf.add_supported_cxxflags (cxxflags = ['-O3', '-g'])
+
+ conf.check_cfg (package='libsync', args=['--cflags', '--libs'], uselib_store='SYNC', mandatory=True)
+
+ conf.define ("CHRONOCHAT_VERSION", VERSION)
+
+ # if Utils.unversioned_sys_platform () == "darwin":
+ # conf.check_cxx(framework_name='Foundation', uselib_store='OSX_FOUNDATION', mandatory=False, compile_filename='test.mm')
+ # conf.check_cxx(framework_name='AppKit', uselib_store='OSX_APPKIT', mandatory=False, compile_filename='test.mm')
+ # conf.check_cxx(framework_name='CoreWLAN', uselib_store='OSX_COREWLAN', define_name='HAVE_COREWLAN',
+ # use="OSX_FOUNDATION", mandatory=False, compile_filename='test.mm')
+
+ # if conf.options.autoupdate:
+ # def check_sparkle(**kwargs):
+ # conf.check_cxx (framework_name="Sparkle", header_name=["Foundation/Foundation.h", "AppKit/AppKit.h"],
+ # uselib_store='OSX_SPARKLE', define_name='HAVE_SPARKLE', mandatory=True,
+ # compile_filename='test.mm', use="OSX_FOUNDATION OSX_APPKIT",
+ # **kwargs
+ # )
+ # try:
+ # # Try standard paths first
+ # check_sparkle()
+ # except:
+ # try:
+ # # Try local path
+ # Logs.info ("Check local version of Sparkle framework")
+ # check_sparkle(cxxflags="-F%s/osx/Frameworks/" % conf.path.abspath(),
+ # linkflags="-F%s/osx/Frameworks/" % conf.path.abspath())
+ # conf.env.HAVE_LOCAL_SPARKLE = 1
+ # except:
+ # import urllib, subprocess, os, shutil
+ # if not os.path.exists('osx/Frameworks/Sparkle.framework'):
+ # # Download to local path and retry
+ # Logs.info ("Sparkle framework not found, trying to download it to 'build/'")
+
+ # urllib.urlretrieve ("http://sparkle.andymatuschak.org/files/Sparkle%201.5b6.zip", "build/Sparkle.zip")
+ # if os.path.exists('build/Sparkle.zip'):
+ # try:
+ # subprocess.check_call (['unzip', '-qq', 'build/Sparkle.zip', '-d', 'build/Sparkle'])
+ # os.remove ("build/Sparkle.zip")
+ # if not os.path.exists("osx/Frameworks"):
+ # os.mkdir ("osx/Frameworks")
+ # os.rename ("build/Sparkle/Sparkle.framework", "osx/Frameworks/Sparkle.framework")
+ # shutil.rmtree("build/Sparkle", ignore_errors=True)
+
+ # check_sparkle(cxxflags="-F%s/osx/Frameworks/" % conf.path.abspath(),
+ # linkflags="-F%s/osx/Frameworks/" % conf.path.abspath())
+ # conf.env.HAVE_LOCAL_SPARKLE = 1
+ # except subprocess.CalledProcessError as e:
+ # conf.fatal("Cannot find Sparkle framework. Auto download failed: '%s' returned %s" % (' '.join(e.cmd), e.returncode))
+ # except:
+ # conf.fatal("Unknown Error happened when auto downloading Sparkle framework")
+
+ # if conf.is_defined('HAVE_SPARKLE'):
+ # conf.env.HAVE_SPARKLE = 1 # small cheat for wscript
+
+ # if conf.options.log4cxx:
+ # conf.check_cfg(package='liblog4cxx', args=['--cflags', '--libs'], uselib_store='LOG4CXX', mandatory=True)
+ # conf.define ("HAVE_LOG4CXX", 1)
+
+ conf.load('protoc')
+
+ conf.load('qt4')
+
+ conf.load('boost')
+
+ conf.check_boost(lib='system test iostreams filesystem regex thread date_time random')
+
+ boost_version = conf.env.BOOST_VERSION.split('_')
+ if int(boost_version[0]) < 1 or int(boost_version[1]) < 46:
+ Logs.error ("Minumum required boost version is 1.46")
+ return
+
+ # if conf.options._test:
+ # conf.define ('_TESTS', 1)
+ # conf.env.TEST = 1
+
+ conf.write_config_header('config.h')
+
+def build (bld):
+ # # Unit tests
+ # if bld.env['TEST']:
+ # unittests = bld.program (
+ # target="unit-tests",
+ # features = "qt4 cxx cxxprogram",
+ # defines = "WAF",
+ # source = bld.path.ant_glob(['test/*.cc']),
+ # use = 'BOOST_TEST BOOST_FILESYSTEM BOOST_DATE_TIME LOG4CXX SQLITE3 QTCORE QTGUI ccnx database fs_watcher chronoshare',
+ # includes = "ccnx scheduler src executor gui fs-watcher",
+ # install_prefix = None,
+ # )
+
+ qt = bld (
+ target = "ChronoChat",
+ features = "qt4 cxx cxxprogram",
+ defines = "WAF",
+ source = bld.path.ant_glob(['*.cpp', '*.ui', 'demo.qrc', '*.proto']),
+ includes = " . ",
+ use = "BOOST BOOST_FILESYSTEM BOOST_RANDOM BOOST_DATE_TIME SQLITE3 QTCORE QTGUI LOG4CXX SYNC",
+ )
+
+ if Utils.unversioned_sys_platform () == "darwin":
+ app_plist = '''<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
+<plist version="0.9">
+<dict>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleIconFile</key>
+ <string>demo.icns</string>
+ <key>CFBundleGetInfoString</key>
+ <string>Created by Waf</string>
+ <key>CFBundleIdentifier</key>
+ <string>edu.ucla.cs.irl.ChronoChat</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>NOTE</key>
+ <string>THIS IS A GENERATED FILE, DO NOT MODIFY</string>
+ <key>CFBundleExecutable</key>
+ <string>%s</string>
+ <key>SUPublicDSAKeyFile</key>
+ <string>dsa_pub.pem</string>
+ <key>CFBundleIconFile</key>
+ <string>demo.icns</string>
+</dict>
+</plist>'''
+
+ # <key>LSUIElement</key>
+ # <string>1</string>
+ qt.mac_app = "ChronoChat.app"
+ qt.mac_plist = app_plist % "ChronoChat"
+ qt.mac_resources = 'demo.icns'
+ # qt.use += " OSX_FOUNDATION OSX_COREWLAN adhoc"
+
+ # if bld.env['HAVE_SPARKLE']:
+ # qt.use += " OSX_SPARKLE"
+ # qt.source += ["osx/auto-update/sparkle-auto-update.mm"]
+ # qt.includes += " osx/auto-update"
+ # if bld.env['HAVE_LOCAL_SPARKLE']:
+ # qt.mac_frameworks = "osx/Frameworks/Sparkle.framework"
+
+from waflib import TaskGen
+@TaskGen.extension('.mm')
+def m_hook(self, node):
+ """Alias .mm files to be compiled the same as .cc files, gcc/clang will do the right thing."""
+ return self.create_compiled_task('cxx', node)
+
+@Configure.conf
+def add_supported_cxxflags(self, cxxflags):
+ """
+ Check which cxxflags are supported by compiler and add them to env.CXXFLAGS variable
+ """
+ self.start_msg('Checking allowed flags for c++ compiler')
+
+ supportedFlags = []
+ for flag in cxxflags:
+ if self.check_cxx (cxxflags=[flag], mandatory=False):
+ supportedFlags += [flag]
+
+ self.end_msg (' '.join (supportedFlags))
+ self.env.CXXFLAGS += supportedFlags