tpsession initial import
[tpsession] / tpsession-0.1 / tests / smstest / testprog.cpp
diff --git a/tpsession-0.1/tests/smstest/testprog.cpp b/tpsession-0.1/tests/smstest/testprog.cpp
new file mode 100644 (file)
index 0000000..69f2385
--- /dev/null
@@ -0,0 +1,24 @@
+#include "testprog.h"
+#include <TelepathyQt4/Message>
+
+TestProg::TestProg(QString addr,QString msg)
+{
+    qDebug() << __PRETTY_FUNCTION__ ;
+  message=msg;
+  address=addr;
+  tps =new TpSession("ring");
+  connect(tps,SIGNAL(accountReady(TpSessionAccount *)),SLOT(onAccountReady(TpSessionAccount *)));
+  connect(tps,SIGNAL(messageReceived(const Tp::ReceivedMessage &,TpSessionAccount *)),
+                SLOT(onMessageReceived(const Tp::ReceivedMessage &,TpSessionAccount *)));
+}
+
+void TestProg::onAccountReady(TpSessionAccount *tpsa)
+{
+    qDebug() << __PRETTY_FUNCTION__ ;
+    tpsa->sendMessageToAddress(address,message);
+};
+
+void TestProg::onMessageReceived(const Tp::ReceivedMessage &msg,TpSessionAccount *acc)
+{
+    qDebug() << "TestProg::onMessageReceived " << msg.text() << "from " << msg.sender()->id();
+}