diff --git a/client.pro b/client.pro
index d507501..3abe77a 100644
--- a/client.pro
+++ b/client.pro
@@ -32,7 +32,8 @@ SOURCES += src/main.cpp \
src/historywindow.cpp \
src/avatars.cpp \
src/messages.cpp \
- src/messagelabel.cpp
+ src/messagelabel.cpp \
+ src/devicehelper.cpp
HEADERS += src/mainwindow.h \
src/dialogitemmodel.h \
@@ -42,7 +43,8 @@ HEADERS += src/mainwindow.h \
src/main.h \
src/avatars.h \
src/messages.h \
- src/messagelabel.h
+ src/messagelabel.h \
+ src/devicehelper.h
FORMS += src/mainwindow.ui \
src/historywindow.ui
diff --git a/rc/platforms/symbian.pri b/rc/platforms/symbian.pri
index 3e82405..5a731b7 100644
--- a/rc/platforms/symbian.pri
+++ b/rc/platforms/symbian.pri
@@ -10,7 +10,7 @@ TARGET.EPOCSTACKSIZE = 0x08000
#TARGET.EPOCALLOWDLLDATA = 1
contains(SYMBIAN_VERSION, Symbian3) {
- DEFINES += SYMBIAN3_READY
+ DEFINES += SYMBIAN3_READY=1
}
#QMAKE_CXXFLAGS.CW += -O2
@@ -39,7 +39,6 @@ ICON = rc/icons/hicolor/scalable/apps/kutegram.svg
LIBS += -lavkon \
# -laknnotify \
-# -lhwrmlightclient \
-lapgrfx \
-lcone \
# -lws32 \
@@ -58,3 +57,7 @@ LIBS += -lavkon \
# -lcntmodel \
# -lbafl \
# -lmgfetch
+
+contains(SYMBIAN_VERSION, Symbian3) {
+ LIBS += -lhwrmlightclient
+}
diff --git a/rc/translations/kutegram_en.ts b/rc/translations/kutegram_en.ts
index de59995..71d4e14 100644
--- a/rc/translations/kutegram_en.ts
+++ b/rc/translations/kutegram_en.ts
@@ -9,22 +9,22 @@
-
+
-
+
-
+
-
+
@@ -34,7 +34,7 @@
-
+
@@ -53,18 +53,18 @@ p, li { white-space: pre-wrap; }
-
+
-
+
-
+
@@ -89,22 +89,22 @@ p, li { white-space: pre-wrap; }
-
+
-
+
-
+
-
+
@@ -129,7 +129,12 @@ p, li { white-space: pre-wrap; }
-
+
+
+
+
+
+
-
-
-
-
+
+
+
+
-
+
-
+
-
+
-
+
diff --git a/rc/translations/kutegram_es.ts b/rc/translations/kutegram_es.ts
index 4fab519..f26ca1f 100644
--- a/rc/translations/kutegram_es.ts
+++ b/rc/translations/kutegram_es.ts
@@ -9,22 +9,22 @@
-
+
-
+
Escribir mensaje:
-
+
Opciones
-
+
Atrás
@@ -34,7 +34,7 @@
-
+
@@ -57,18 +57,18 @@ p, li { white-space: pre-wrap; }
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="kutegram://change-phone"><span style=" text-decoration: underline; color:#0000ff;">Cambiar núm. de teléfono...</span></a></p></body></html>
-
+
Mi cuenta
-
+
Ayuda
-
+
Iniciar sesión
@@ -93,22 +93,22 @@ p, li { white-space: pre-wrap; }
Aceptar
-
+
Cerrar
-
+
Finalizar sesión
-
+
Acerca de Kutegram
-
+
Acerca de Qt
@@ -133,7 +133,12 @@ p, li { white-space: pre-wrap; }
Salir
-
+
+
+
+
+
+
-
-
-
-
+
+
+
+
Error
-
+
Error de conexión: %1
-
+
Error de MT: %1
-
+
Error DH: %1
-
+
Error de RPC: %1, %2, %3
diff --git a/rc/translations/kutegram_pt.ts b/rc/translations/kutegram_pt.ts
index 406eb76..c4a3321 100644
--- a/rc/translations/kutegram_pt.ts
+++ b/rc/translations/kutegram_pt.ts
@@ -9,7 +9,7 @@
-
+
@@ -18,17 +18,17 @@
Carregando...
-
+
Digite a Mensagem...
-
+
-
+
Voltar
@@ -53,23 +53,23 @@
-
+
-
+
Ações
-
+
Ajuda
-
+
Entrar
@@ -108,22 +108,22 @@ p, li { white-space: pre-wrap; }
-
+
Sair
-
+
Log out
-
+
Sobre Kutegram
-
+
Sobre Qt
@@ -148,7 +148,12 @@ p, li { white-space: pre-wrap; }
-
+
+
+
+
+
+
-
-
-
-
+
+
+
+
Error
-
+
Got socket error %1
-
+
Got MT error: %1
-
+
Got DH error: %1
-
+
Got RPC error: %1, %2, %3
diff --git a/rc/translations/kutegram_ru.ts b/rc/translations/kutegram_ru.ts
index 2f1cd33..83e7db3 100644
--- a/rc/translations/kutegram_ru.ts
+++ b/rc/translations/kutegram_ru.ts
@@ -9,7 +9,7 @@
-
+
@@ -18,17 +18,17 @@
Загрузка...
-
+
Написать сообщение...
-
+
Функции
-
+
Назад
@@ -53,7 +53,7 @@
-
+
@@ -72,18 +72,18 @@ p, li { white-space: pre-wrap; }
-
+
Действия
-
+
Помощь
-
+
Авторизоваться
@@ -108,22 +108,22 @@ p, li { white-space: pre-wrap; }
-
+
Выйти
-
+
Выйти из аккаунта
-
+
О Kutegram
-
+
О Qt
@@ -148,7 +148,12 @@ p, li { white-space: pre-wrap; }
Выход
-
+
+
+
+
+
+
Чат Telegram: https://t.me/kutegramchat
-
-
-
-
+
+
+
+
Ошибка
-
+
Ошибка сокета: %1
-
+
Ошибка MT: %1
-
+
Ошибка DH: %1
-
+
Ошибка RPC: %1, %2, %3
diff --git a/rc/translations/kutegram_uk.ts b/rc/translations/kutegram_uk.ts
index 68ad055..02bbad6 100644
--- a/rc/translations/kutegram_uk.ts
+++ b/rc/translations/kutegram_uk.ts
@@ -9,7 +9,7 @@
-
+
@@ -18,17 +18,17 @@
Завантаження...
-
+
Написати повідомлення...
-
+
Опції
-
+
Назад
@@ -53,7 +53,7 @@
-
+
@@ -78,18 +78,18 @@
-
+
Дії
-
+
Допомога
-
+
Авторизуватись
@@ -113,22 +113,22 @@ p, li { white-space: pre-wrap; }
-
+
Вийти
-
+
Вийти з акауту
-
+
Про Kutegram
-
+
Про Qt
@@ -148,7 +148,12 @@ p, li { white-space: pre-wrap; }
Опції
-
+
+
+
+
+
+
Чат Telegram: https://t.me/kutegramchat
-
-
-
-
+
+
+
+
Помилка
-
+
Помилка сокету: %1
-
+
Помилка МТ: %1
-
+
Помилка DH: %1
-
+
Помилка RPC: %1, %2, %3
diff --git a/src/devicehelper.cpp b/src/devicehelper.cpp
new file mode 100644
index 0000000..dc1f045
--- /dev/null
+++ b/src/devicehelper.cpp
@@ -0,0 +1,192 @@
+#include "devicehelper.h"
+
+#include
+#include
+
+#ifdef MOBILITY_READY
+#include
+
+QTM_USE_NAMESPACE
+#endif
+
+#if defined(Q_OS_SYMBIAN)
+#include // KAknDiscreetPopupDurationLong
+#include // CEikonEnv
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include // RApaLsSession
+#include // TApaTaskList, TApaTask
+#include //http://katastrophos.net/symbian-dev/GUID-C6E5F800-0637-419E-8FE5-1EBB40E725AA/GUID-C4776034-D190-3FC4-AF45-C7F195093AC3.html
+#include
+#include
+#include
+#endif
+
+#ifdef SYMBIAN3_READY
+#include //keys for RProperty
+#include
+#include
+#endif
+
+#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN)
+#include
+#include
+#include
+#endif
+
+bool isInSilentMode()
+{
+#ifdef MOBILITY_READY
+ return (QSystemDeviceInfo::Profile) QSystemDeviceInfo().currentProfile() == QSystemDeviceInfo::SilentProfile;
+#else
+ return false;
+#endif
+}
+
+void showChatIcon()
+{
+#if defined(Q_OS_SYMBIAN) && defined(SYMBIAN3_READY)
+ static bool chatIconStatus = false;
+ if (!chatIconStatus) {
+ RProperty iProperty;
+ iProperty.Set(KPSUidCoreApplicationUIs, KCoreAppUIsUipInd, ECoreAppUIsShow);
+ chatIconStatus = true;
+ }
+#endif
+}
+
+void hideChatIcon()
+{
+#if defined(Q_OS_SYMBIAN) && defined(SYMBIAN3_READY)
+ RProperty iProperty;
+ iProperty.Set(KPSUidCoreApplicationUIs, KCoreAppUIsUipInd, ECoreAppUIsDoNotShow);
+#endif
+}
+
+void playNotification(QString path)
+{
+ //TODO
+}
+
+void setAppHiddenState(bool state)
+{
+#if defined(Q_OS_SYMBIAN)
+ static CAknAppUi* appUi = dynamic_cast(CEikonEnv::Static()->AppUi());
+ appUi->HideApplicationFromFSW(state);
+#endif
+}
+
+void notificationBlink(int device) {
+#if defined(Q_OS_SYMBIAN) && defined(SYMBIAN3_READY) //TODO: why only S^3? it should works on S^1, but it can't find a binary
+ if (isInSilentMode()) return;
+ static CHWRMLight* notifyLight = CHWRMLight::NewL();
+ switch (device) {
+ case 1: TRAP_IGNORE(notifyLight->LightBlinkL(CHWRMLight::ECustomTarget1, 30, 1, 1, KHWRMDefaultIntensity)); break;
+ case 2: TRAP_IGNORE(notifyLight->LightBlinkL(CHWRMLight::ECustomTarget2, 30, 1, 1, KHWRMDefaultIntensity)); break;
+ default: TRAP_IGNORE(notifyLight->LightBlinkL(CHWRMLight::ECustomTarget2, 30, 1, 1, KHWRMDefaultIntensity)); break;
+ }
+#endif
+}
+
+void showSystemNotificationPopup(QString title, QString message)
+{
+#if defined(Q_OS_SYMBIAN) && defined(SYMBIAN3_READY)
+ static TUid symbianUid = {SYMBIAN_UID};
+ TPtrC16 sTitle(reinterpret_cast(title.utf16()));
+ TPtrC16 sMessage(reinterpret_cast(message.utf16()));
+ //TODO: icon?
+ TRAP_IGNORE(CAknDiscreetPopup::ShowGlobalPopupL(sTitle, sMessage, KAknsIIDNone, KNullDesC, 0, 0, KAknDiscreetPopupDurationLong, 0, NULL, symbianUid));
+#elif !defined(Q_OS_SYMBIAN)
+ QSystemTrayIcon icon;
+ icon.show();
+ icon.setToolTip("Kutegram");
+ icon.showMessage(title, message);
+ icon.hide();
+#endif
+}
+
+void showNotification(QString title, QString message)
+{
+ showChatIcon();
+ showSystemNotificationPopup(title, message);
+ //TODO: vibrate
+ //TODO: sound
+ //TODO: blink
+}
+
+void openUrl(const QUrl &url)
+{
+#ifdef Q_OS_SYMBIAN
+ static TUid KUidBrowser = {0x10008D39};
+ _LIT(KBrowserPrefix, "4 " );
+
+ // convert url to encoded version of QString
+ QString encUrl(QString::fromUtf8(url.toEncoded()));
+ // using qt_QString2TPtrC() based on
+ //
+ TPtrC tUrl(TPtrC16(static_cast(encUrl.utf16()), encUrl.length()));
+
+ // Following code based on
+ //
+
+ // create a session with apparc server
+ RApaLsSession appArcSession;
+ User::LeaveIfError(appArcSession.Connect());
+ CleanupClosePushL(appArcSession);
+
+ // get the default application uid for application/x-web-browse
+ TDataType mimeDatatype(_L8("application/x-web-browse"));
+ TUid handlerUID;
+ appArcSession.AppForDataType(mimeDatatype, handlerUID);
+
+ // if UiD not found, use the native browser
+ if (handlerUID.iUid == 0 || handlerUID.iUid == -1)
+ handlerUID = KUidBrowser;
+
+ // Following code based on
+ //
+
+ HBufC* buf16 = HBufC::NewLC(tUrl.Length() + KBrowserPrefix.iTypeLength);
+ buf16->Des().Copy(KBrowserPrefix); // Prefix used to launch correct browser view
+ buf16->Des().Append(tUrl);
+
+ TApaTaskList taskList(CCoeEnv::Static()->WsSession());
+ TApaTask task = taskList.FindApp(handlerUID);
+ if (task.Exists()) {
+ // Switch to existing browser instance
+ task.BringToForeground();
+ HBufC8* param8 = HBufC8::NewLC(buf16->Length());
+ param8->Des().Append(buf16->Des());
+ task.SendMessage(TUid::Uid( 0 ), *param8); // Uid is not used
+ CleanupStack::PopAndDestroy(param8);
+ } else {
+ // Start a new browser instance
+ TThreadId id;
+ appArcSession.StartDocument(*buf16, handlerUID, id);
+ }
+
+ CleanupStack::PopAndDestroy(buf16);
+ CleanupStack::PopAndDestroy(&appArcSession);
+#else
+ QDesktopServices::openUrl(url);
+#endif
+}
+
+void writeX11OrientationAngleProperty(QWidget* widget, ScreenOrientationX11 orientation)
+{
+#ifdef Q_WS_X11
+ if (widget) {
+ WId id = widget->winId();
+ Display *display = QX11Info::display();
+ if (!display) return;
+ Atom orientationAngleAtom = XInternAtom(display, "_MEEGOTOUCH_ORIENTATION_ANGLE", False);
+ XChangeProperty(display, id, orientationAngleAtom, XA_CARDINAL, 32, PropModeReplace, (unsigned char*)&orientation, 1);
+ }
+#endif
+}
diff --git a/src/devicehelper.h b/src/devicehelper.h
new file mode 100644
index 0000000..c46036c
--- /dev/null
+++ b/src/devicehelper.h
@@ -0,0 +1,31 @@
+#ifndef DEVICEHELPER_H
+#define DEVICEHELPER_H
+
+#include
+#include
+
+//TODO: Symbian Vibration Example
+//TODO: Maemo Vibration Example
+//TODO: desktop notification
+//TODO: notifications
+
+enum ScreenOrientationX11
+{
+ Landscape = 0,
+ Portrait = 270,
+ LandscapeInverted = 180,
+ PortraitInverted = 90
+};
+
+bool isInSilentMode();
+void showChatIcon();
+void hideChatIcon();
+void playNotification(QString path);
+void setAppHiddenState(bool state);
+void writeX11OrientationAngleProperty(QWidget* widget, ScreenOrientationX11 orientation = Portrait);
+void notificationBlink(int device);
+void showSystemNotificationPopup(QString title, QString message);
+void showNotification(QString title, QString message);
+void openUrl(const QUrl &url);
+
+#endif // DEVICEHELPER_H
diff --git a/src/historywindow.cpp b/src/historywindow.cpp
index 7f800a7..2ca221e 100644
--- a/src/historywindow.cpp
+++ b/src/historywindow.cpp
@@ -12,7 +12,7 @@
#include "messagelabel.h"
#include "tlschema.h"
#include "tl.h"
-#include "main.h"
+#include "devicehelper.h"
using namespace TLType;
diff --git a/src/library b/src/library
index 2501716..9b64465 160000
--- a/src/library
+++ b/src/library
@@ -1 +1 @@
-Subproject commit 25017164cde2425da36ea5f4ba894fc024114db9
+Subproject commit 9b6446563a31ea6244a39085f9ff2dd48b098bdf
diff --git a/src/main.cpp b/src/main.cpp
index e42be4a..151efe1 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -8,25 +8,7 @@
#include
#include
#include
-#include
-#include
-
-#if defined(Q_OS_SYMBIAN)
-#include // KAknDiscreetPopupDurationLong
-#include // CEikonEnv
-#include // RApaLsSession
-#include // TApaTaskList, TApaTask
-#endif
-
-#ifdef SYMBIAN3_READY
-#include
-#endif
-
-#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN)
-#include
-#include
-#include
-#endif
+#include "devicehelper.h"
Q_DECL_EXPORT int main(int argc, char *argv[])
{
@@ -113,19 +95,6 @@ void setOrientation(QMainWindow* window, ScreenOrientation orientation)
window->setAttribute(attribute, true);
}
-void writeX11OrientationAngleProperty(QWidget* widget, ScreenOrientationX11 orientation)
-{
-#ifdef Q_WS_X11
- if (widget) {
- WId id = widget->winId();
- Display *display = QX11Info::display();
- if (!display) return;
- Atom orientationAngleAtom = XInternAtom(display, "_MEEGOTOUCH_ORIENTATION_ANGLE", False);
- XChangeProperty(display, id, orientationAngleAtom, XA_CARDINAL, 32, PropModeReplace, (unsigned char*)&orientation, 1);
- }
-#endif
-}
-
void showExpanded(QMainWindow* window)
{
writeX11OrientationAngleProperty(window);
@@ -135,71 +104,3 @@ void showExpanded(QMainWindow* window)
window->show();
#endif
}
-
-void showAvkonPopup(QString title, QString message)
-{
-#if defined(Q_OS_SYMBIAN) && defined(SYMBIAN3_READY)
- TUid symbianUid = {SYMBIAN_UID};
- TPtrC16 sTitle(reinterpret_cast(title.utf16()));
- TPtrC16 sMessage(reinterpret_cast(message.utf16()));
- TRAP_IGNORE(CAknDiscreetPopup::ShowGlobalPopupL(sTitle, sMessage, KAknsIIDNone, KNullDesC, 0, 0, KAknDiscreetPopupDurationLong, 0, NULL, symbianUid));
-#endif
-}
-
-void openUrl(const QUrl &url)
-{
-#ifdef Q_OS_SYMBIAN
- TUid KUidBrowser = {0x10008D39};
- _LIT(KBrowserPrefix, "4 " );
-
- // convert url to encoded version of QString
- QString encUrl(QString::fromUtf8(url.toEncoded()));
- // using qt_QString2TPtrC() based on
- //
- TPtrC tUrl(TPtrC16(static_cast(encUrl.utf16()), encUrl.length()));
-
- // Following code based on
- //
-
- // create a session with apparc server
- RApaLsSession appArcSession;
- User::LeaveIfError(appArcSession.Connect());
- CleanupClosePushL(appArcSession);
-
- // get the default application uid for application/x-web-browse
- TDataType mimeDatatype(_L8("application/x-web-browse"));
- TUid handlerUID;
- appArcSession.AppForDataType(mimeDatatype, handlerUID);
-
- // if UiD not found, use the native browser
- if (handlerUID.iUid == 0 || handlerUID.iUid == -1)
- handlerUID = KUidBrowser;
-
- // Following code based on
- //
-
- HBufC* buf16 = HBufC::NewLC(tUrl.Length() + KBrowserPrefix.iTypeLength);
- buf16->Des().Copy(KBrowserPrefix); // Prefix used to launch correct browser view
- buf16->Des().Append(tUrl);
-
- TApaTaskList taskList(CCoeEnv::Static()->WsSession());
- TApaTask task = taskList.FindApp(handlerUID);
- if (task.Exists()) {
- // Switch to existing browser instance
- task.BringToForeground();
- HBufC8* param8 = HBufC8::NewLC(buf16->Length());
- param8->Des().Append(buf16->Des());
- task.SendMessage(TUid::Uid( 0 ), *param8); // Uid is not used
- CleanupStack::PopAndDestroy(param8);
- } else {
- // Start a new browser instance
- TThreadId id;
- appArcSession.StartDocument(*buf16, handlerUID, id);
- }
-
- CleanupStack::PopAndDestroy(buf16);
- CleanupStack::PopAndDestroy(&appArcSession);
-#else
- QDesktopServices::openUrl(url);
-#endif
-}
diff --git a/src/main.h b/src/main.h
index d856a9d..c3eb185 100644
--- a/src/main.h
+++ b/src/main.h
@@ -1,9 +1,6 @@
#ifndef MAIN_H
#define MAIN_H
-#include
-#include
-
class QWidget;
class QMainWindow;
@@ -13,20 +10,7 @@ enum ScreenOrientation {
ScreenOrientationAuto
};
-enum ScreenOrientationX11
-{
- Landscape = 0,
- Portrait = 270,
- LandscapeInverted = 180,
- PortraitInverted = 90
-};
-
void setOrientation(QMainWindow* window, ScreenOrientation orientation);
void showExpanded(QMainWindow* window);
-void writeX11OrientationAngleProperty(QWidget* widget, ScreenOrientationX11 orientation = Portrait);
-
-void showAvkonPopup(QString title, QString message);
-void openUrl(const QUrl &url);
-
#endif // MAIN_H
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index fde48be..5e79f53 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -10,6 +10,7 @@
#include
#include
#include
+#include "devicehelper.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
@@ -83,6 +84,8 @@ MainWindow::MainWindow(QWidget *parent) :
connect(client, SIGNAL(gotMessageError(qint64,qint32)), this, SLOT(client_gotMessageError(qint64,qint32)));
connect(client, SIGNAL(gotRPCError(qint64,qint32,QString,bool)), this, SLOT(client_gotRPCError(qint64,qint32,QString,bool)));
+ connect(client, SIGNAL(updateNewMessage(TObject,qint32,qint32)), this, SLOT(client_updateNewMessage(TObject,qint32,qint32)));
+
if (client->isLoggedIn()) client->start();
}
@@ -225,3 +228,10 @@ void MainWindow::dialogView_activated(QModelIndex index)
setOrientation(window, ScreenOrientationAuto);
showExpanded(window);
}
+
+void MainWindow::client_updateNewMessage(TObject msg, qint32 pts, qint32 pts_count)
+{
+ //TODO: improve it.
+ showNotification(QApplication::translate("MainWindow", "New message", 0, QApplication::UnicodeUTF8),
+ msg["message"].toString().mid(0, 40));
+}
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 273fcbf..e66cad9 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -41,6 +41,8 @@ public slots:
void client_gotMessageError(qint64 mtm, qint32 error_code);
void client_gotRPCError(qint64 mtm, qint32 error_code, QString error_message, bool handled);
+ void client_updateNewMessage(TObject msg, qint32 pts, qint32 pts_count);
+
private:
FlickCharm flickcharm;
TelegramClient *client;