summaryrefslogtreecommitdiff
path: root/qt4/examples/file-transfer/file-receiver.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qt4/examples/file-transfer/file-receiver.cpp')
-rw-r--r--qt4/examples/file-transfer/file-receiver.cpp78
1 files changed, 78 insertions, 0 deletions
diff --git a/qt4/examples/file-transfer/file-receiver.cpp b/qt4/examples/file-transfer/file-receiver.cpp
new file mode 100644
index 000000000..97c9d412f
--- /dev/null
+++ b/qt4/examples/file-transfer/file-receiver.cpp
@@ -0,0 +1,78 @@
+/*
+ * This file is part of TelepathyQt4
+ *
+ * Copyright (C) 2011 Collabora Ltd. <http://www.collabora.co.uk/>
+ * Copyright (C) 2011 Nokia Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "file-receiver.h"
+
+#include <TelepathyQt4/AccountFactory>
+#include <TelepathyQt4/ChannelFactory>
+#include <TelepathyQt4/ClientRegistrar>
+#include <TelepathyQt4/Connection>
+#include <TelepathyQt4/ConnectionFactory>
+#include <TelepathyQt4/ContactFactory>
+#include <TelepathyQt4/Debug>
+#include <TelepathyQt4/IncomingFileTransferChannel>
+
+#include <QDebug>
+
+FileReceiver::FileReceiver(QObject *parent)
+ : QObject(parent)
+{
+ QDBusConnection bus(QDBusConnection::sessionBus());
+
+ AccountFactoryPtr accountFactory = AccountFactory::create(bus);
+ ConnectionFactoryPtr connectionFactory = ConnectionFactory::create(bus);
+ ChannelFactoryPtr channelFactory = ChannelFactory::create(bus);
+ channelFactory->addCommonFeatures(Channel::FeatureCore);
+ channelFactory->addFeaturesForIncomingFileTransfers(IncomingFileTransferChannel::FeatureCore);
+
+ mCR = ClientRegistrar::create(accountFactory, connectionFactory,
+ channelFactory);
+
+ qDebug() << "Registering incoming file transfer handler";
+ mHandler = FileReceiverHandler::create();
+ QString handlerName(QLatin1String("TpQt4ExampleFileReceiverHandler"));
+ if (!mCR->registerClient(AbstractClientPtr::dynamicCast(mHandler), handlerName)) {
+ qWarning() << "Unable to register incoming file transfer handler, aborting";
+ QCoreApplication::exit(1);
+ return;
+ }
+
+ qDebug() << "Awaiting file transfers";
+}
+
+FileReceiver::~FileReceiver()
+{
+}
+
+int main(int argc, char **argv)
+{
+ QCoreApplication app(argc, argv);
+
+ Tp::registerTypes();
+ Tp::enableDebug(false);
+ Tp::enableWarnings(true);
+
+ new FileReceiver(&app);
+
+ return app.exec();
+}
+
+#include "_gen/file-receiver.moc.hpp"