Merge branch 'issue-510' into develop
authorVictor Kirhenshtein <victor@netxms.org>
Fri, 21 Feb 2014 22:39:35 +0000 (00:39 +0200)
committerVictor Kirhenshtein <victor@netxms.org>
Fri, 21 Feb 2014 22:39:35 +0000 (00:39 +0200)
148 files changed:
ChangeLog
android/src/agent/res/values/build_number.xml
android/src/console/res/values/build_number.xml
build/build_number
doc/nxsl.npp.styling.xml [new file with mode: 0644]
include/build.h
include/nms_agent.h
include/nms_cscp.h
include/nms_util.h
include/nxclapi.h
include/nxcpapi.h
src/agent/core/logmonitoring.cpp
src/agent/core/nxagentd.cpp
src/agent/core/nxagentd.h
src/agent/core/session.cpp
src/install/files
src/install/windows/common-webui.iss
src/install/windows/webui-x64.iss
src/install/windows/webui.iss
src/java/build/set_build_number.cmd
src/java/certificate-manager/pom.xml
src/java/mobile-agent/pom.xml
src/java/netxms-base/pom.xml
src/java/netxms-base/src/main/java/org/netxms/base/BuildNumber.java
src/java/netxms-base/src/main/java/org/netxms/base/NXCPCodes.java
src/java/netxms-base/src/main/java/org/netxms/base/NXCommon.java
src/java/netxms-client-api/pom.xml
src/java/netxms-client-api/src/main/java/org/netxms/api/client/Session.java
src/java/netxms-client/pom.xml
src/java/netxms-client/src/main/java/org/netxms/client/AgentFile.java [copied from src/java/netxms-base/src/main/java/org/netxms/base/NXCommon.java with 57% similarity]
src/java/netxms-client/src/main/java/org/netxms/client/NXCSession.java
src/java/netxms-client/src/test/java/org/netxms/client/ServerFilesTest.java
src/java/netxms-eclipse/AlarmViewer/OSGI-INF/l10n/bundle.properties
src/java/netxms-eclipse/AlarmViewer/OSGI-INF/l10n/bundle_cs.properties
src/java/netxms-eclipse/AlarmViewer/OSGI-INF/l10n/bundle_es.properties
src/java/netxms-eclipse/AlarmViewer/OSGI-INF/l10n/bundle_ru.properties
src/java/netxms-eclipse/AlarmViewer/OSGI-INF/l10n/bundle_zh_CN.properties
src/java/netxms-eclipse/AlarmViewer/build.properties
src/java/netxms-eclipse/AlarmViewer/plugin.xml
src/java/netxms-eclipse/AlarmViewer/src/org/netxms/ui/eclipse/alarmviewer/AlarmNotifier.java
src/java/netxms-eclipse/AlarmViewer/src/org/netxms/ui/eclipse/alarmviewer/Messages.java
src/java/netxms-eclipse/AlarmViewer/src/org/netxms/ui/eclipse/alarmviewer/messages.properties
src/java/netxms-eclipse/AlarmViewer/src/org/netxms/ui/eclipse/alarmviewer/messages_cs.properties
src/java/netxms-eclipse/AlarmViewer/src/org/netxms/ui/eclipse/alarmviewer/messages_es.properties
src/java/netxms-eclipse/AlarmViewer/src/org/netxms/ui/eclipse/alarmviewer/messages_ru.properties
src/java/netxms-eclipse/AlarmViewer/src/org/netxms/ui/eclipse/alarmviewer/messages_zh_CN.properties
src/java/netxms-eclipse/AlarmViewer/src/org/netxms/ui/eclipse/alarmviewer/preferencepages/AlarmMelody.java [new file with mode: 0755]
src/java/netxms-eclipse/Core/.classpath
src/java/netxms-eclipse/Core/META-INF/MANIFEST.MF
src/java/netxms-eclipse/Core/build.properties
src/java/netxms-eclipse/Core/src/org/netxms/ui/eclipse/actions/ExportToCsvAction.java
src/java/netxms-eclipse/Core/src/org/netxms/ui/eclipse/console/ApplicationWorkbenchWindowAdvisor.java
src/java/netxms-eclipse/Core/src/org/netxms/ui/eclipse/console/TweakletManager.java
src/java/netxms-eclipse/Core/src/org/netxms/ui/eclipse/jobs/LoginJob.java [moved from src/java/netxms-eclipse/Core/src/org/netxms/ui/eclipse/console/LoginJob.java with 90% similarity]
src/java/netxms-eclipse/Dashboard/META-INF/MANIFEST.MF
src/java/netxms-eclipse/DataCollection/META-INF/MANIFEST.MF
src/java/netxms-eclipse/ImageLibrary/META-INF/MANIFEST.MF
src/java/netxms-eclipse/ObjectTools/META-INF/MANIFEST.MF
src/java/netxms-eclipse/ObjectTools/src/org/netxms/ui/eclipse/objecttools/ObjectToolsCache.java
src/java/netxms-eclipse/ObjectTools/src/org/netxms/ui/eclipse/objecttools/ObjectToolsDynamicMenu.java
src/java/netxms-eclipse/ObjectTools/src/org/netxms/ui/eclipse/objecttools/views/FileViewer.java
src/java/netxms-eclipse/PerfView/META-INF/MANIFEST.MF
src/java/pom.xml
src/libnetxms/agent.cpp
src/libnetxms/nxcp.cpp
src/libnxcl/libnxcl.h
src/libnxcl/session.cpp
src/server/core/agent.cpp
src/server/core/download_job.cpp
src/server/core/interface.cpp
src/server/core/session.cpp
src/server/include/nms_core.h
src/server/libnxsrv/agent.cpp
src/server/libnxsrv/messages.mc
src/server/libnxsrv/snmp.cpp
webui/webapp/AlarmViewer/OSGI-INF/l10n/bundle.properties
webui/webapp/AlarmViewer/OSGI-INF/l10n/bundle_cs.properties
webui/webapp/AlarmViewer/OSGI-INF/l10n/bundle_es.properties
webui/webapp/AlarmViewer/OSGI-INF/l10n/bundle_ru.properties
webui/webapp/AlarmViewer/OSGI-INF/l10n/bundle_zh_CN.properties
webui/webapp/AlarmViewer/plugin.xml
webui/webapp/AlarmViewer/src/org/netxms/ui/eclipse/alarmviewer/AlarmNotifier.java [new file with mode: 0644]
webui/webapp/AlarmViewer/src/org/netxms/ui/eclipse/alarmviewer/LoginListener.java [copied from webui/webapp/DataCollection/src/org/netxms/ui/eclipse/datacollection/LoginListener.java with 88% similarity]
webui/webapp/AlarmViewer/src/org/netxms/ui/eclipse/alarmviewer/Messages.java
webui/webapp/AlarmViewer/src/org/netxms/ui/eclipse/alarmviewer/editors/AcknowledgeTimeEditor.java
webui/webapp/AlarmViewer/src/org/netxms/ui/eclipse/alarmviewer/messages.properties
webui/webapp/AlarmViewer/src/org/netxms/ui/eclipse/alarmviewer/messages_cs.properties
webui/webapp/AlarmViewer/src/org/netxms/ui/eclipse/alarmviewer/messages_es.properties
webui/webapp/AlarmViewer/src/org/netxms/ui/eclipse/alarmviewer/messages_ru.properties
webui/webapp/AlarmViewer/src/org/netxms/ui/eclipse/alarmviewer/messages_zh_CN.properties
webui/webapp/AlarmViewer/src/org/netxms/ui/eclipse/alarmviewer/preferencepages/AlarmMelody.java [new file with mode: 0755]
webui/webapp/Core/.classpath
webui/webapp/Core/META-INF/MANIFEST.MF
webui/webapp/Core/build.properties
webui/webapp/Core/src/org/netxms/ui/eclipse/actions/ExportToCsvAction.java
webui/webapp/Core/src/org/netxms/ui/eclipse/console/ApplicationWorkbenchAdvisor.java
webui/webapp/Core/src/org/netxms/ui/eclipse/console/Messages.java
webui/webapp/Core/src/org/netxms/ui/eclipse/jobs/ConsoleJob.java
webui/webapp/Core/src/org/netxms/ui/eclipse/jobs/LoginJob.java [moved from webui/webapp/Core/src/org/netxms/ui/eclipse/console/LoginJob.java with 91% similarity]
webui/webapp/Core/src/org/netxms/ui/eclipse/shared/ConsoleSharedData.java
webui/webapp/Dashboard/META-INF/MANIFEST.MF
webui/webapp/DataCollection/META-INF/MANIFEST.MF
webui/webapp/DataCollection/src/org/netxms/ui/eclipse/datacollection/LoginListener.java
webui/webapp/DataCollection/src/org/netxms/ui/eclipse/datacollection/SummaryTablesCache.java
webui/webapp/ImageLibrary/META-INF/MANIFEST.MF
webui/webapp/ImageLibrary/src/org/netxms/ui/eclipse/imagelibrary/LoginListener.java
webui/webapp/ImageLibrary/src/org/netxms/ui/eclipse/imagelibrary/Messages.java
webui/webapp/ImageLibrary/src/org/netxms/ui/eclipse/imagelibrary/shared/ImageProvider.java
webui/webapp/Mobile/.classpath [new file with mode: 0644]
webui/webapp/Mobile/.project [new file with mode: 0644]
webui/webapp/Mobile/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
webui/webapp/Mobile/META-INF/MANIFEST.MF [new file with mode: 0644]
webui/webapp/Mobile/OSGI-INF/configuration.xml [new file with mode: 0644]
webui/webapp/Mobile/build.properties [new file with mode: 0644]
webui/webapp/Mobile/icons/alarms.png [new file with mode: 0644]
webui/webapp/Mobile/icons/dashboard.png [new file with mode: 0644]
webui/webapp/Mobile/icons/entire_network.png [new file with mode: 0644]
webui/webapp/Mobile/icons/graphs.png [new file with mode: 0644]
webui/webapp/Mobile/icons/nodes.png [new file with mode: 0644]
webui/webapp/Mobile/icons/object_cluster.png [new file with mode: 0644]
webui/webapp/Mobile/icons/object_container.png [new file with mode: 0644]
webui/webapp/Mobile/icons/object_mobiledevice.png [new file with mode: 0644]
webui/webapp/Mobile/icons/object_node.png [new file with mode: 0644]
webui/webapp/Mobile/icons/object_subnet.png [new file with mode: 0644]
webui/webapp/Mobile/icons/object_unknown.png [new file with mode: 0644]
webui/webapp/Mobile/icons/object_zone.png [new file with mode: 0644]
webui/webapp/Mobile/jar/tabris-1.2.0.jar [new file with mode: 0644]
webui/webapp/Mobile/plugin.xml [new file with mode: 0644]
webui/webapp/Mobile/src/org/netxms/webui/mobile/Activator.java [new file with mode: 0644]
webui/webapp/Mobile/src/org/netxms/webui/mobile/Configuration.java [new file with mode: 0644]
webui/webapp/Mobile/src/org/netxms/webui/mobile/dialogs/ProgressDialog.java [new file with mode: 0644]
webui/webapp/Mobile/src/org/netxms/webui/mobile/pages/Alarms.java [new file with mode: 0644]
webui/webapp/Mobile/src/org/netxms/webui/mobile/pages/BasePage.java [new file with mode: 0644]
webui/webapp/Mobile/src/org/netxms/webui/mobile/pages/DashboardPage.java [new file with mode: 0644]
webui/webapp/Mobile/src/org/netxms/webui/mobile/pages/HomePage.java [new file with mode: 0644]
webui/webapp/Mobile/src/org/netxms/webui/mobile/pages/ObjectBrowser.java [new file with mode: 0644]
webui/webapp/Mobile/src/org/netxms/webui/mobile/pages/PredefinedGraphTree.java [new file with mode: 0644]
webui/webapp/Mobile/src/org/netxms/webui/mobile/pages/helpers/AlarmListLabelProvider.java [new file with mode: 0644]
webui/webapp/Mobile/src/org/netxms/webui/mobile/pages/helpers/ObjectListLabelProvider.java [new file with mode: 0644]
webui/webapp/Mobile/src/org/netxms/webui/mobile/widgets/NavigationBar.java [new file with mode: 0644]
webui/webapp/Mobile/src/org/netxms/webui/mobile/widgets/ProgressWidget.java [new file with mode: 0644]
webui/webapp/ObjectTools/META-INF/MANIFEST.MF
webui/webapp/ObjectTools/src/org/netxms/ui/eclipse/objecttools/LoginListener.java
webui/webapp/ObjectTools/src/org/netxms/ui/eclipse/objecttools/ObjectToolsCache.java
webui/webapp/ObjectTools/src/org/netxms/ui/eclipse/objecttools/ObjectToolsDynamicMenu.java
webui/webapp/ObjectTools/src/org/netxms/ui/eclipse/objecttools/views/FileViewer.java
webui/webapp/PerfView/META-INF/MANIFEST.MF
webui/webapp/SNMP/src/org/netxms/ui/eclipse/snmp/shared/MibCache.java

index 1b3186c..23a9bfb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+*
+* 1.2.13
+*
+
+- Management console:
+   - Implemented alarm sounds
+   - Fixed "broken pipe" errors
+- Fixed issues: #109   
+
+
 *
 * 1.2.12
 *
index af9f39b..6aa5c6a 100644 (file)
@@ -1,4 +1,4 @@
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
-       <string name="build_number">7861</string>
+       <string name="build_number">7862</string>
 </resources>
index af9f39b..6aa5c6a 100644 (file)
@@ -1,4 +1,4 @@
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
-       <string name="build_number">7861</string>
+       <string name="build_number">7862</string>
 </resources>
index 2f93e94..eb6d344 100644 (file)
@@ -1 +1 @@
-7861
+7862
diff --git a/doc/nxsl.npp.styling.xml b/doc/nxsl.npp.styling.xml
new file mode 100644 (file)
index 0000000..3e9fc06
--- /dev/null
@@ -0,0 +1,64 @@
+<NotepadPlus>
+    <UserLang name="NXSL" ext="nxsl" udlVersion="2.1">
+        <Settings>
+            <Global caseIgnored="no" allowFoldOfComments="no" foldCompact="no" forcePureLC="0" decimalSeparator="0" />
+            <Prefix Keywords1="no" Keywords2="no" Keywords3="no" Keywords4="no" Keywords5="no" Keywords6="no" Keywords7="no" Keywords8="no" />
+        </Settings>
+        <KeywordLists>
+            <Keywords name="Comments">00// 01 02 03/* 04*/</Keywords>
+            <Keywords name="Numbers, prefix1"></Keywords>
+            <Keywords name="Numbers, prefix2"></Keywords>
+            <Keywords name="Numbers, extras1"></Keywords>
+            <Keywords name="Numbers, extras2"></Keywords>
+            <Keywords name="Numbers, suffix1"></Keywords>
+            <Keywords name="Numbers, suffix2"></Keywords>
+            <Keywords name="Numbers, range"></Keywords>
+            <Keywords name="Operators1">( ) ; ! = ==  &gt; = &gt;= != | &amp; || &amp;&amp; ~ / -&gt; .</Keywords>
+            <Keywords name="Operators2"></Keywords>
+            <Keywords name="Folders in code1, open"></Keywords>
+            <Keywords name="Folders in code1, middle"></Keywords>
+            <Keywords name="Folders in code1, close"></Keywords>
+            <Keywords name="Folders in code2, open"></Keywords>
+            <Keywords name="Folders in code2, middle"></Keywords>
+            <Keywords name="Folders in code2, close"></Keywords>
+            <Keywords name="Folders in comment, open"></Keywords>
+            <Keywords name="Folders in comment, middle"></Keywords>
+            <Keywords name="Folders in comment, close"></Keywords>
+            <Keywords name="Keywords1">array break case const continue default do else exit for foreach global if ilike imatch like match print println return sub switch use while</Keywords>
+            <Keywords name="Keywords2">classof int32 int64 real string typeof uint32 uint64</Keywords>
+            <Keywords name="Keywords3">FALSE false TRUE true NULL null</Keywords>
+            <Keywords name="Keywords4"></Keywords>
+            <Keywords name="Keywords5"></Keywords>
+            <Keywords name="Keywords6"></Keywords>
+            <Keywords name="Keywords7"></Keywords>
+            <Keywords name="Keywords8"></Keywords>
+            <Keywords name="Delimiters">00&quot; 01\ 02&quot; 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23</Keywords>
+        </KeywordLists>
+        <Styles>
+            <WordsStyle name="DEFAULT" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
+            <WordsStyle name="COMMENTS" fgColor="8080C0" bgColor="FFFFFF" fontStyle="0" nesting="0" />
+            <WordsStyle name="LINE COMMENTS" fgColor="8080C0" bgColor="FFFFFF" fontStyle="0" nesting="0" />
+            <WordsStyle name="NUMBERS" fgColor="0000FF" bgColor="FFFFFF" fontStyle="0" nesting="0" />
+            <WordsStyle name="KEYWORDS1" fgColor="000080" bgColor="FFFFFF" fontStyle="1" nesting="0" />
+            <WordsStyle name="KEYWORDS2" fgColor="008000" bgColor="FFFFFF" fontStyle="1" nesting="0" />
+            <WordsStyle name="KEYWORDS3" fgColor="800000" bgColor="FFFFFF" fontStyle="1" nesting="0" />
+            <WordsStyle name="KEYWORDS4" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
+            <WordsStyle name="KEYWORDS5" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
+            <WordsStyle name="KEYWORDS6" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
+            <WordsStyle name="KEYWORDS7" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
+            <WordsStyle name="KEYWORDS8" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
+            <WordsStyle name="OPERATORS" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
+            <WordsStyle name="FOLDER IN CODE1" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
+            <WordsStyle name="FOLDER IN CODE2" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
+            <WordsStyle name="FOLDER IN COMMENT" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
+            <WordsStyle name="DELIMITERS1" fgColor="0000FF" bgColor="FFFFFF" fontStyle="0" nesting="0" />
+            <WordsStyle name="DELIMITERS2" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
+            <WordsStyle name="DELIMITERS3" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
+            <WordsStyle name="DELIMITERS4" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
+            <WordsStyle name="DELIMITERS5" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
+            <WordsStyle name="DELIMITERS6" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
+            <WordsStyle name="DELIMITERS7" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
+            <WordsStyle name="DELIMITERS8" fgColor="000000" bgColor="FFFFFF" fontStyle="0" nesting="0" />
+        </Styles>
+    </UserLang>
+</NotepadPlus>
index e8a046e..c7e39b9 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef __build_h
 #define __build_h
-#define NETXMS_VERSION_BUILD 7861
-#define NETXMS_VERSION_BUILD_STRING _T("7861")
+#define NETXMS_VERSION_BUILD 7862
+#define NETXMS_VERSION_BUILD_STRING _T("7862")
 #endif
index bc4bc7b..c9e17d8 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
 ** NetXMS - Network Management System
 ** Copyright (C) 2003-2013 Victor Kirhenshtein
 **
@@ -526,7 +526,7 @@ void LIBNETXMS_EXPORTABLE AgentWriteDebugLog(int level, const TCHAR *format, ...
 void LIBNETXMS_EXPORTABLE AgentWriteDebugLog2(int level, const TCHAR *format, va_list args);
 void LIBNETXMS_EXPORTABLE AgentSendTrap(UINT32 dwEvent, const TCHAR *eventName, const char *pszFormat, ...);
 void LIBNETXMS_EXPORTABLE AgentSendTrap2(UINT32 dwEvent, const TCHAR *eventName, int nCount, TCHAR **ppszArgList);
-BOOL LIBNETXMS_EXPORTABLE AgentSendFileToServer(void *session, UINT32 requestId, const TCHAR *file, long offset, long sizeLimit);
+BOOL LIBNETXMS_EXPORTABLE AgentSendFileToServer(void *session, UINT32 requestId, const TCHAR *file, long offset);
 BOOL LIBNETXMS_EXPORTABLE AgentPushParameterData(const TCHAR *parameter, const TCHAR *value);
 BOOL LIBNETXMS_EXPORTABLE AgentPushParameterDataInt32(const TCHAR *parameter, LONG value);
 BOOL LIBNETXMS_EXPORTABLE AgentPushParameterDataUInt32(const TCHAR *parameter, UINT32 value);
index 61c1937..79cd644 100644 (file)
@@ -962,6 +962,7 @@ typedef struct
 #define VID_ALARM_STATUS_FLOW_STATE ((UINT32)461)
 #define VID_GROUPS                  ((UINT32)462)
 #define VID_EFFECTIVE_RIGHTS        ((UINT32)463)
+#define VID_EXTENSION_COUNT         ((UINT32)464)
 
 // Base variabe for single threshold in message
 #define VID_THRESHOLD_BASE          ((UINT32)0x00800000)
@@ -1126,10 +1127,10 @@ typedef struct
 
 #define VID_RADIO_LIST_BASE         ((UINT32)0x30000000)
 
-#define VID_RADIO_LIST_BASE         ((UINT32)0x30000000)
-
 #define VID_RULE_LIST_BASE          ((UINT32)0x10000000)
 
+#define VID_EXTENSION_LIST_BASE     ((UINT32)0x10000000)
+
 //
 // Inline functions
 //
index 992a2ea..057ed97 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
 ** NetXMS - Network Management System
 ** Copyright (C) 2003-2013 Victor Kirhenshtein
 **
@@ -659,7 +659,7 @@ public:
        bool canRead(UINT32 timeout);
        virtual int read(char *pBuff, int nSize, UINT32 timeout = INFINITE);
        bool waitForText(const char *text, int timeout);
-       
+
        int write(const char *pBuff, int nSize);
        bool writeLine(const char *line);
 
@@ -727,7 +727,7 @@ typedef struct  __CODE_TO_TEXT
 inline void GetSystemTimeAsFileTime(LPFILETIME pFt)
 {
        SYSTEMTIME sysTime;
-       
+
        GetSystemTime(&sysTime);
        SystemTimeToFileTime(&sysTime, pFt);
 }
@@ -882,10 +882,10 @@ extern "C"
 #if !defined(_WIN32) && !defined(_NETWARE)
 #if defined(UNICODE_UCS2) || defined(UNICODE_UCS4)
    void LIBNETXMS_EXPORTABLE wcsupr(WCHAR *in);
-#endif   
+#endif
    void LIBNETXMS_EXPORTABLE strupr(char *in);
 #endif
-   
+
        void LIBNETXMS_EXPORTABLE QSortEx(void *base, size_t nmemb, size_t size, void *arg,
                                                                                                 int (*compare)(const void *, const void *, void *));
 
@@ -934,7 +934,7 @@ extern "C"
 #else
 #define StrToBin StrToBinA
 #endif
-   
+
    TCHAR LIBNETXMS_EXPORTABLE *MACToStr(const BYTE *pData, TCHAR *pStr);
 
    void LIBNETXMS_EXPORTABLE StrStripA(char *pszStr);
@@ -1057,11 +1057,11 @@ extern "C"
 
 #ifndef _WIN32
        BOOL LIBNETXMS_EXPORTABLE SetDefaultCodepage(const char *cp);
-   int LIBNETXMS_EXPORTABLE WideCharToMultiByte(int iCodePage, UINT32 dwFlags, const WCHAR *pWideCharStr, 
-                                                int cchWideChar, char *pByteStr, int cchByteChar, 
+   int LIBNETXMS_EXPORTABLE WideCharToMultiByte(int iCodePage, UINT32 dwFlags, const WCHAR *pWideCharStr,
+                                                int cchWideChar, char *pByteStr, int cchByteChar,
                                                 char *pDefaultChar, BOOL *pbUsedDefChar);
-   int LIBNETXMS_EXPORTABLE MultiByteToWideChar(int iCodePage, UINT32 dwFlags, const char *pByteStr, 
-                                                int cchByteChar, WCHAR *pWideCharStr, 
+   int LIBNETXMS_EXPORTABLE MultiByteToWideChar(int iCodePage, UINT32 dwFlags, const char *pByteStr,
+                                                int cchByteChar, WCHAR *pWideCharStr,
                                                 int cchWideChar);
 
 #if !defined(UNICODE_UCS2) || !HAVE_WCSLEN
@@ -1099,7 +1099,7 @@ extern "C"
        WCHAR LIBNETXMS_EXPORTABLE *WideStringFromUTF8String(const char *pszString);
    char LIBNETXMS_EXPORTABLE *MBStringFromWideString(const WCHAR *pwszString);
    char LIBNETXMS_EXPORTABLE *UTF8StringFromWideString(const WCHAR *pwszString);
-   
+
 #ifdef _WITH_ENCRYPTION
        WCHAR LIBNETXMS_EXPORTABLE *ERR_error_string_W(int nError, WCHAR *pwszBuffer);
 #endif
@@ -1300,7 +1300,7 @@ void LIBNETXMS_EXPORTABLE StartMainLoop(ThreadFunction pfSignalHandler, ThreadFu
 void LIBNETXMS_EXPORTABLE InitSubAgentAPI(void (* writeLog)(int, int, const TCHAR *),
                                           void (* sendTrap1)(UINT32, const TCHAR *, const char *, va_list),
                                           void (* sendTrap2)(UINT32, const TCHAR *, int, TCHAR **),
-                                          bool (* sendFile)(void *, UINT32, const TCHAR *, long, long),
+                                          bool (* sendFile)(void *, UINT32, const TCHAR *, long),
                                           bool (* pushData)(const TCHAR *, const TCHAR *, UINT32));
 
 #endif
index 91d967a..8944f26 100644 (file)
@@ -627,7 +627,7 @@ enum
 #define SYSTEM_ACCESS_XMPP_COMMANDS       0x04000000
 #define SYSTEM_ACCESS_MANAGE_IMAGE_LIB    0x08000000
 
-#define SYSTEM_ACCESS_FULL                0x07FFFFFF
+#define SYSTEM_ACCESS_FULL                0x0FFFFFFF
 
 #endif /* LIBNXCL_CUSTOM_USER_RIGHTS */
 
index 174863c..870c816 100644 (file)
@@ -151,7 +151,7 @@ private:
    void unlock() { MutexUnlock(m_mutexDataAccess); }
    void housekeeperThread();
    void *waitForMessageInternal(UINT16 wIsBinary, UINT16 wCode, UINT32 dwId, UINT32 dwTimeOut);
-   
+
    static THREAD_RESULT THREAD_CALL mwqThreadStarter(void *);
 
 public:
@@ -168,7 +168,7 @@ public:
    {
       return (CSCP_MESSAGE *)waitForMessageInternal(1, wCode, dwId, dwTimeOut);
    }
-   
+
    void clear();
    void setHoldTime(UINT32 dwHoldTime) { m_dwMsgHoldTime = dwHoldTime; }
 };
@@ -227,7 +227,7 @@ int LIBNETXMS_EXPORTABLE RecvNXCPMessage(SOCKET hSocket, CSCP_MESSAGE *pMsg,
                                          BYTE *pDecryptionBuffer, UINT32 dwTimeout);
 int LIBNETXMS_EXPORTABLE RecvNXCPMessageEx(SOCKET hSocket, CSCP_MESSAGE **msgBuffer,
                                            CSCP_BUFFER *nxcpBuffer, UINT32 *bufferSize,
-                                           NXCPEncryptionContext **ppCtx, 
+                                           NXCPEncryptionContext **ppCtx,
                                            BYTE **decryptionBuffer, UINT32 dwTimeout,
                                                                                                                 UINT32 maxMsgSize);
 CSCP_MESSAGE LIBNETXMS_EXPORTABLE *CreateRawNXCPMessage(WORD wCode, UINT32 dwId, WORD wFlags,
@@ -235,18 +235,18 @@ CSCP_MESSAGE LIBNETXMS_EXPORTABLE *CreateRawNXCPMessage(WORD wCode, UINT32 dwId,
                                                         CSCP_MESSAGE *pBuffer);
 TCHAR LIBNETXMS_EXPORTABLE *NXCPMessageCodeName(WORD wCode, TCHAR *pszBuffer);
 BOOL LIBNETXMS_EXPORTABLE SendFileOverNXCP(SOCKET hSocket, UINT32 dwId, const TCHAR *pszFile,
-                                           NXCPEncryptionContext *pCtx, long offset, long sizeLimit,
+                                           NXCPEncryptionContext *pCtx, long offset,
                                                                                                                 void (* progressCallback)(INT64, void *), void *cbArg,
                                                                                                                 MUTEX mutex);
 BOOL LIBNETXMS_EXPORTABLE NXCPGetPeerProtocolVersion(SOCKET hSocket, int *pnVersion, MUTEX mutex);
-   
+
 BOOL LIBNETXMS_EXPORTABLE InitCryptoLib(UINT32 dwEnabledCiphers, void (*debugCallback)(int, const TCHAR *, va_list args));
 UINT32 LIBNETXMS_EXPORTABLE CSCPGetSupportedCiphers();
 CSCP_ENCRYPTED_MESSAGE LIBNETXMS_EXPORTABLE *CSCPEncryptMessage(NXCPEncryptionContext *pCtx, CSCP_MESSAGE *pMsg);
 BOOL LIBNETXMS_EXPORTABLE CSCPDecryptMessage(NXCPEncryptionContext *pCtx,
                                              CSCP_ENCRYPTED_MESSAGE *pMsg,
                                              BYTE *pDecryptionBuffer);
-UINT32 LIBNETXMS_EXPORTABLE SetupEncryptionContext(CSCPMessage *pMsg, 
+UINT32 LIBNETXMS_EXPORTABLE SetupEncryptionContext(CSCPMessage *pMsg,
                                                   NXCPEncryptionContext **ppCtx,
                                                   CSCPMessage **ppResponse,
                                                   RSA *pPrivateKey, int nNXCPVersion);
index 67edb10..da416eb 100644 (file)
@@ -163,7 +163,7 @@ THREAD_RESULT THREAD_CALL SendFileUpdatesOverNXCP(void *args)
             pMsg = new CSCPMessage();
             pMsg->SetCode(CMD_FILE_MONITORING);
             pMsg->SetId(0);
-            pMsg->SetVariable(VID_FILE_NAME, flData->pszFile, MAX_PATH);
+            pMsg->SetVariable(VID_FILE_NAME, flData->fileId, MAX_PATH);
 
             lseek(hFile, flData->offset, SEEK_SET);
             readBytes = (BYTE*)malloc(readSize);
@@ -196,13 +196,14 @@ THREAD_RESULT THREAD_CALL SendFileUpdatesOverNXCP(void *args)
       }
 
       ThreadSleep(threadSleepTime);
-      if(!g_monitorFileList.checkFileMonitored(flData->pszFile))
+      if(!g_monitorFileList.checkFileMonitored(flData->fileId))
       {
          follow = false;
       }
    }
-   delete flData->pszFile;
-   delete flData;
+   delete_and_null(flData->pszFile);
+   delete_and_null(flData->fileId);
+   delete_and_null(flData);
    close(hFile);
    return THREAD_OK;
 };
index 4e538ff..8405cdd 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
 ** NetXMS multiplatform core agent
 ** Copyright (C) 2003-2014 Victor Kirhenshtein
 **
@@ -337,7 +337,7 @@ static HWND GetConsoleHWND()
           hWnd = FindWindowEx(NULL, NULL, _T("ConsoleWindowClass"), NULL);
       if (hWnd == NULL)
          break;
-          
+
       GetWindowThreadProcessId(hWnd, &wpid);
           if (cpid == wpid)
          break;
@@ -406,13 +406,13 @@ static LONG H_RestartAgent(const TCHAR *action, StringList *args, const TCHAR *d
    DWORD dwResult;
    STARTUPINFO si;
    PROCESS_INFORMATION pi;
-   
+
    // Fill in process startup info structure
    memset(&si, 0, sizeof(STARTUPINFO));
    si.cb = sizeof(STARTUPINFO);
 
    // Create new process
-   if (!CreateProcess(NULL, szCmdLine, NULL, NULL, FALSE, 
+   if (!CreateProcess(NULL, szCmdLine, NULL, NULL, FALSE,
                       (g_dwFlags & AF_DAEMON) ? (CREATE_NO_WINDOW | DETACHED_PROCESS) : (CREATE_NEW_CONSOLE),
                       NULL, NULL, &si, &pi))
    {
@@ -549,11 +549,11 @@ static void LoadPlatformSubagent()
 /**
  * Send file to server (subagent API)
  */
-static bool SendFileToServer(void *session, UINT32 requestId, const TCHAR *file, long offset, long sizeLimit)
+static bool SendFileToServer(void *session, UINT32 requestId, const TCHAR *file, long offset)
 {
        if (session == NULL)
                return false;
-       return ((CommSession *)session)->sendFile(requestId, file, offset, sizeLimit);
+       return ((CommSession *)session)->sendFile(requestId, file, offset);
 }
 
 /**
@@ -996,7 +996,7 @@ void Shutdown()
 #ifdef _WIN32
    ConditionSet(m_hCondShutdown);
 #endif
-   
+
    // Remove PID file
 #if !defined(_WIN32)
    _tremove(g_szPidFile);
@@ -1088,7 +1088,7 @@ static void DoRestartActions(UINT32 dwOldPID)
       if (kill(dwOldPID, SIGCONT) == -1)
          break;
    }
-   
+
    // Kill previous instance of agent if it's still running
    if (i == 30)
       kill(dwOldPID, SIGKILL);
@@ -1179,7 +1179,7 @@ int main(int argc, char *argv[])
 #ifdef NETXMS_MEMORY_DEBUG
        InitMemoryDebugger();
 #endif
-   
+
    // Set locale to C. It shouldn't be needed, according to
    // documentation, but I've seen the cases when agent formats
    // floating point numbers by sprintf inserting comma in place
@@ -1508,7 +1508,7 @@ int main(int argc, char *argv[])
                                                                                                  _T("nxagentd"), MSG_EXCEPTION, g_dwFlags & AF_WRITE_FULL_DUMP, !(g_dwFlags & AF_DAEMON));
                                        __try {
 #endif
-                                       if ((!_tcsicmp(g_szLogFile, _T("{syslog}"))) || 
+                                       if ((!_tcsicmp(g_szLogFile, _T("{syslog}"))) ||
                                                 (!_tcsicmp(g_szLogFile, _T("{eventlog}"))))
                                                g_dwFlags |= AF_USE_SYSLOG;
 
@@ -1552,7 +1552,7 @@ int main(int argc, char *argv[])
                                                        {
                                                                _ftprintf(fp, _T("%d"), m_pid);
                                                                fclose(fp);
-                                                       }   
+                                                       }
                                                        Main();
                                                        Shutdown();
                                                }
index 26f3c17..75f1453 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
 ** NetXMS multiplatform core agent
 ** Copyright (C) 2003-2012 Victor Kirhenshtein
 **
 //
 // Request types for H_FileTime
 //
+
 #define FILETIME_ATIME           1
 #define FILETIME_MTIME           2
 #define FILETIME_CTIME           3
@@ -210,7 +210,7 @@ typedef struct
    int iType;
    union
    {
-      TCHAR *pszCmdLine;      // to TCHAR 
+      TCHAR *pszCmdLine;      // to TCHAR
       struct __subagentAction
       {
          LONG (*fpHandler)(const TCHAR *, StringList *, const TCHAR *);
@@ -352,7 +352,7 @@ public:
 
    void sendMessage(CSCPMessage *pMsg) { m_pSendQueue->Put(pMsg->CreateMessage()); }
    void sendRawMessage(CSCP_MESSAGE *pMsg) { m_pSendQueue->Put(nx_memdup(pMsg, ntohl(pMsg->dwSize))); }
-       bool sendFile(UINT32 requestId, const TCHAR *file, long offset, long sizeLimit);
+       bool sendFile(UINT32 requestId, const TCHAR *file, long offset);
 
        UINT32 getServerAddress() { return m_dwHostAddr; }
 
@@ -410,7 +410,7 @@ BOOL InitSubAgent(HMODULE hModule, const TCHAR *pszModuleName,
                   BOOL (* SubAgentInit)(NETXMS_SUBAGENT_INFO **, Config *),
                   const TCHAR *pszEntryPoint);
 BOOL ProcessCmdBySubAgent(UINT32 dwCommand, CSCPMessage *pRequest, CSCPMessage *pResponse, void *session);
-BOOL AddAction(const TCHAR *pszName, int iType, const TCHAR *pArg, 
+BOOL AddAction(const TCHAR *pszName, int iType, const TCHAR *pArg,
                LONG (*fpHandler)(const TCHAR *, StringList *, const TCHAR *),
                const TCHAR *pszSubAgent, const TCHAR *pszDescription);
 BOOL AddActionFromConfig(TCHAR *pszLine, BOOL bShellExec);
@@ -475,6 +475,7 @@ struct MONITORED_FILE
 struct FollowData
 {
    const TCHAR *pszFile;
+   const TCHAR *fileId;
    long offset;
        void *cbArg;
 };
@@ -522,19 +523,19 @@ TCHAR *GetPdhErrorText(UINT32 dwError, TCHAR *pszBuffer, int iBufSize);
 
 extern UINT32 g_dwFlags;
 extern TCHAR g_szLogFile[];
-extern TCHAR g_szSharedSecret[]; 
-extern TCHAR g_szConfigFile[];  
-extern TCHAR g_szFileStore[];     
-extern TCHAR g_szConfigServer[]; 
-extern TCHAR g_szRegistrar[];  
-extern TCHAR g_szListenAddress[]; 
+extern TCHAR g_szSharedSecret[];
+extern TCHAR g_szConfigFile[];
+extern TCHAR g_szFileStore[];
+extern TCHAR g_szConfigServer[];
+extern TCHAR g_szRegistrar[];
+extern TCHAR g_szListenAddress[];
 extern TCHAR g_szConfigIncludeDir[];
 extern TCHAR g_masterAgent[];
 extern WORD g_wListenPort;
 extern SERVER_INFO g_pServerList[];
 extern UINT32 g_dwServerCount;
 extern time_t g_tmAgentStartTime;
-extern TCHAR g_szPlatformSuffix[]; 
+extern TCHAR g_szPlatformSuffix[];
 extern UINT32 g_dwStartupDelay;
 extern UINT32 g_dwIdleTimeout;
 extern UINT32 g_dwMaxSessions;
index c1cf957..59e35f1 100644 (file)
@@ -719,17 +719,21 @@ void CommSession::getLocalFile(CSCPMessage *pRequest, CSCPMessage *pMsg)
        if (m_bMasterServer)
        {
                TCHAR fileName[MAX_PATH];
+               TCHAR fileNameCode[MAX_PATH];
                pRequest->GetVariableStr(VID_FILE_NAME, fileName, MAX_PATH);
+               pRequest->GetVariableStr(VID_NAME, fileNameCode, MAX_PATH);
                DebugPrintf(m_dwIndex, 5, _T("CommSession::getLocalFile(): request for file \"%s\", follow = %s"),
                   fileName, pRequest->GetVariableShort(VID_FILE_FOLLOW) ? _T("true") : _T("false"));
-               bool result = sendFile(pRequest->GetId(), fileName, pRequest->GetVariableLong(VID_FILE_OFFSET), pRequest->GetVariableLong(VID_FILE_SIZE_LIMIT));
+               bool result = sendFile(pRequest->GetId(), fileName, (int)pRequest->GetVariableLong(VID_FILE_OFFSET));
                if(pRequest->GetVariableShort(VID_FILE_FOLLOW) && result)
       {
-         TCHAR* fName = _tcsdup(fileName);
-         g_monitorFileList.addMonitoringFile(fName);
+         TCHAR* fileID = _tcsdup(fileNameCode);
+         TCHAR* realName = _tcsdup(fileName);
+         g_monitorFileList.addMonitoringFile(fileID);
          FollowData *flData = new FollowData();
          flData->cbArg = this;
-         flData->pszFile = fName;
+         flData->pszFile = realName;
+         flData->fileId = fileID;
          flData->offset = 0;
          ThreadCreateEx(SendFileUpdatesOverNXCP, 0, (void*)flData);
       }
@@ -860,9 +864,9 @@ static void SendFileProgressCallback(INT64 bytesTransferred, void *cbArg)
        ((CommSession *)cbArg)->updateTimeStamp();
 }
 
-bool CommSession::sendFile(UINT32 requestId, const TCHAR *file, long offset, long sizeLimit)
+bool CommSession::sendFile(UINT32 requestId, const TCHAR *file, long offset)
 {
-       return SendFileOverNXCP(m_hSocket, requestId, file, m_pCtx, offset, sizeLimit, SendFileProgressCallback, this, m_socketWriteMutex) ? true : false;
+       return SendFileOverNXCP(m_hSocket, requestId, file, m_pCtx, offset, SendFileProgressCallback, this, m_socketWriteMutex) ? true : false;
 }
 
 
index 9b07ee9..7770f6e 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 9b07ee93095e604f8583fe419e17d90775f4d0b6
+Subproject commit 7770f6e18bbc08f4377f4722138008a2f2c38d46
index 92e2f5a..b201571 100644 (file)
@@ -23,7 +23,7 @@ begin
       'Web interface server settings',
       'Please check default settings and adjust them if required');
   DetailsPage.Add('Port:', False);
-  DetailsPage.Values[0] := GetPreviousData('JettyPort', '8787');
+  DetailsPage.Values[0] := GetPreviousData('JettyPort', '8080');
 end;
 
 Function GetJettyPort: String;
@@ -40,15 +40,15 @@ Function GenerateInstallParameters(Param: String): String;
 var
   strJvmArgument: String;
 begin
-  strJvmArgument := ExpandConstant('--DisplayName="NetXMS WebUI" --Description="NetXMS Web Interface (winstone)" --Install="{app}\WebUI\prunsrv.exe" --LogPath="{app}\WebUI\logs" --LogLevel=Debug --StdOutput=auto --StdError=auto --StartMode=jvm --StopMode=jvm --Jvm=auto --Classpath="{app}\WebUI\winstone-0.9.10.jar" --StartClass=winstone.Launcher ++StartParams=--controlPort=47777 ++StartParams=--ajp13Port=-1 ++StartParams=--warfile ++StartParams="{app}\WebUI\nxmc\nxmc.war" --StopClass=winstone.tools.WinstoneControl ++StopParams=shutdown ++StopParams=--port=47777')
+  strJvmArgument := ExpandConstant('--DisplayName="NetXMS WebUI" --Description="NetXMS Web Interface (jetty)" --Install="{app}\WebUI\prunsrv.exe" --Startup=auto --LogPath="{app}\WebUI\logs" --LogLevel=Debug --StdOutput=auto --StdError=auto --StartMode=jvm --StopMode=jvm --Jvm=auto --Classpath="{app}\WebUI\jetty-runner.jar;{app}\WebUI\start.jar" --StartClass=org.eclipse.jetty.runner.Runner ++StartParams=--stop-port ++StartParams=17003 ++StartParams=--stop-key ++StartParams=nxmc$jetty$key ++StartParams=--classes ++StartParams="{app}\WebUI\nxmc\lib"');
+  strJvmArgument := strJvmArgument + ' ++StartParams=--port ++StartParams=' + GetJettyPort();
+  strJvmArgument := strJvmArgument + ExpandConstant(' ++StartParams="{app}\WebUI\nxmc\nxmc.war" --StopClass=org.eclipse.jetty.start.Main ++StopParams=-DSTOP.PORT=17003 ++StopParams=-DSTOP.KEY=nxmc$jetty$key ++StopParams=--stop');
 
   if IsComponentSelected('jre') then
   begin
     strJvmArgument := strJvmArgument + ExpandConstant(' --Jvm="{app}\bin\jre\bin\server\jvm.dll"');
   end;
 
-  strJvmArgument := strJvmArgument + ' ++StartParams=--httpPort=' + GetJettyPort();
-
   Result := strJvmArgument;
 end;
 
index 86487e7..39fc5e2 100644 (file)
@@ -8,8 +8,10 @@ ArchitecturesAllowed=x64
 
 [Files]
 Source: ..\files\windows\x64\prunsrv.exe; DestDir: "{app}\WebUI"; BeforeInstall: StopAllServices; Flags: ignoreversion; Components: webui
-Source: ..\files\java\winstone\winstone-0.9.10.jar; DestDir: "{app}\WebUI"; Flags: ignoreversion; Components: webui
+Source: ..\files\java\jetty\jetty-runner.jar; DestDir: "{app}\WebUI"; Flags: ignoreversion; Components: webui
+Source: ..\files\java\jetty\start.jar; DestDir: "{app}\WebUI"; Flags: ignoreversion; Components: webui
 Source: nxmc\nxmc.war; DestDir: "{app}\WebUI\nxmc"; Flags: ignoreversion; Components: webui
+Source: nxmc\nxmc.properties; DestDir: "{app}\WebUI\nxmc\lib"; Flags: ignoreversion; Components: webui
 Source: ..\files\windows\x64\jre\*; DestDir: "{app}\bin\jre"; Flags: ignoreversion recursesubdirs; Components: jre
 
 #include "common-webui.iss"
index c2fa33d..7e79bca 100644 (file)
@@ -5,8 +5,10 @@ OutputBaseFilename=netxms-webui-1.2.12
 
 [Files]
 Source: ..\files\windows\x86\prunsrv.exe; DestDir: "{app}\WebUI"; BeforeInstall: StopAllServices; Flags: ignoreversion; Components: webui
-Source: ..\files\java\winstone\winstone-0.9.10.jar; DestDir: "{app}\WebUI"; Flags: ignoreversion; Components: webui
+Source: ..\files\java\jetty\jetty-runner.jar; DestDir: "{app}\WebUI"; Flags: ignoreversion; Components: webui
+Source: ..\files\java\jetty\start.jar; DestDir: "{app}\WebUI"; Flags: ignoreversion; Components: webui
 Source: nxmc\nxmc.war; DestDir: "{app}\WebUI\nxmc"; Flags: ignoreversion; Components: webui
+Source: nxmc\nxmc.properties; DestDir: "{app}\WebUI\nxmc\lib"; Flags: ignoreversion; Components: webui
 Source: ..\files\windows\x86\jre\*; DestDir: "{app}\bin\jre"; Flags: ignoreversion recursesubdirs; Components: jre
 
 #include "common-webui.iss"
index e666de1..f5e19c4 100644 (file)
@@ -3,7 +3,7 @@
     <parent>
         <groupId>org.netxms</groupId>
         <artifactId>netxms</artifactId>
-        <version>1.2.12</version>
+        <version>1.2.13</version>
     </parent>
 
     <modelVersion>4.0.0</modelVersion>
index f69bbac..a864139 100644 (file)
@@ -4,7 +4,7 @@
        <parent>
                <groupId>org.netxms</groupId>
                <artifactId>netxms</artifactId>
-               <version>1.2.12</version>
+               <version>1.2.13</version>
        </parent>
 
        <modelVersion>4.0.0</modelVersion>
index 6b36928..d5886c0 100644 (file)
@@ -4,7 +4,7 @@
        <parent>
                <groupId>org.netxms</groupId>
                <artifactId>netxms</artifactId>
-               <version>1.2.12</version>
+               <version>1.2.13</version>
        </parent>
 
        <modelVersion>4.0.0</modelVersion>
index 2caa0cd..edb0b60 100644 (file)
@@ -1,5 +1,5 @@
 package org.netxms.base;
 public final class BuildNumber {
-   public static final String TEXT = "7861";
-   public static final int NUMBER = 7861;
+   public static final String TEXT = "7862";
+   public static final int NUMBER = 7862;
 }
index 8cd4f46..023a696 100644 (file)
@@ -787,6 +787,7 @@ public class NXCPCodes
    public static final long VID_ALARM_STATUS_FLOW_STATE = 461;
    public static final long VID_GROUPS = 462;
    public static final long VID_EFFECTIVE_RIGHTS = 463;
+   public static final long VID_EXTENSION_COUNT = 464;
 
        public static final long VID_ACL_USER_BASE = 0x00001000L;
        public static final long VID_ACL_USER_LAST = 0x00001FFFL;
@@ -870,4 +871,5 @@ public class NXCPCodes
        public static final long VID_RADIO_LIST_BASE = 0x30000000L;
        public static final long VID_UUID_LIST_BASE = 0x10000000L;
        public static final long VID_RULE_LIST_BASE = 0x10000000L;
+       public static final long VID_EXTENSION_LIST_BASE = 0x10000000L;
 }
index b50b00c..b17a113 100644 (file)
@@ -26,7 +26,7 @@ import java.util.UUID;
 public final class NXCommon
 {
        // Version information
-       public static final String VERSION = "1.2.12";
+       public static final String VERSION = "1.2.13";
        
        public static final UUID EMPTY_GUID = UUID.fromString("00000000-0000-0000-0000-000000000000");
 }
index aaf1294..1963086 100644 (file)
@@ -4,7 +4,7 @@
        <parent>
                <groupId>org.netxms</groupId>
                <artifactId>netxms</artifactId>
-               <version>1.2.12</version>
+               <version>1.2.13</version>
        </parent>
 
        <modelVersion>4.0.0</modelVersion>
index 485c51a..193421f 100644 (file)
@@ -241,13 +241,14 @@ public interface Session
        public abstract boolean isEncrypted();
 
    /**
-    * Send KEEPALIVE message. Return nothing is connection is fine, exception thrown otherwise
+    * Send KEEPALIVE message. Return true is connection is fine and false otherwise.
+    * If connection is broken, session notification with code CONNECTION_BROKEN
+    * will be sent to all subscribers. Note that this function will not throw exception
+    * in case of error. 
     * 
-    * @return 
-    * @throws IOException
-    * @throws NXCException
+    * @return true if connection is fine
     */
-   public abstract void checkConnection() throws IOException, NetXMSClientException;
+   public abstract boolean checkConnection();
    
    /**
     * Get default date format provided by server
index 13a38b4..2d64531 100644 (file)
@@ -4,7 +4,7 @@
        <parent>
                <groupId>org.netxms</groupId>
                <artifactId>netxms</artifactId>
-               <version>1.2.12</version>
+               <version>1.2.13</version>
        </parent>
 
        <modelVersion>4.0.0</modelVersion>
@@ -1,6 +1,6 @@
 /**
  * NetXMS - open source network management system
- * Copyright (C) 2003-2013 Victor Kirhenshtein
+ * Copyright (C) 2003-2014 Raden Solutions
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-package org.netxms.base;
+package org.netxms.client;
 
-import java.util.UUID;
+import java.io.File;
 
 /**
- * Common constants
+ * Information about file received from agent
  */
-public final class NXCommon
+public class AgentFile
 {
-       // Version information
-       public static final String VERSION = "1.2.12";
-       
-       public static final UUID EMPTY_GUID = UUID.fromString("00000000-0000-0000-0000-000000000000");
+   private String id;
+   private File file;
+
+   /**
+    * Create new agent file object
+    * 
+    * @param id
+    * @param file
+    */
+   public AgentFile(String id, File file)
+   {
+      this.id = id;
+      this.file = file;
+   }
+
+   /**
+    * @return the id
+    */
+   public String getId()
+   {
+      return id;
+   }
+
+   /**
+    * @return the file
+    */
+   public File getFile()
+   {
+      return file;
+   }
 }
index f567a06..3912d98 100644 (file)
  */
 package org.netxms.client;
 
+import java.io.BufferedInputStream;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetAddress;
+import java.net.Socket;
+import java.net.UnknownHostException;
+import java.security.GeneralSecurityException;
+import java.security.Signature;
+import java.security.SignatureException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateEncodingException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.UUID;
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 import org.netxms.api.client.NetXMSClientException;
 import org.netxms.api.client.ProgressListener;
 import org.netxms.api.client.Session;
@@ -26,7 +61,12 @@ import org.netxms.api.client.images.ImageLibraryManager;
 import org.netxms.api.client.images.LibraryImage;
 import org.netxms.api.client.mt.MappingTable;
 import org.netxms.api.client.mt.MappingTableDescriptor;
-import org.netxms.api.client.reporting.*;
+import org.netxms.api.client.reporting.ReportDefinition;
+import org.netxms.api.client.reporting.ReportParameter;
+import org.netxms.api.client.reporting.ReportRenderFormat;
+import org.netxms.api.client.reporting.ReportResult;
+import org.netxms.api.client.reporting.ReportingJob;
+import org.netxms.api.client.reporting.ReportingServerManager;
 import org.netxms.api.client.scripts.Script;
 import org.netxms.api.client.scripts.ScriptLibraryManager;
 import org.netxms.api.client.servermanager.ServerManager;
@@ -36,45 +76,99 @@ import org.netxms.api.client.users.AuthCertificate;
 import org.netxms.api.client.users.User;
 import org.netxms.api.client.users.UserGroup;
 import org.netxms.api.client.users.UserManager;
-import org.netxms.base.*;
+import org.netxms.base.CompatTools;
+import org.netxms.base.EncryptionContext;
+import org.netxms.base.GeoLocation;
+import org.netxms.base.Logger;
+import org.netxms.base.NXCPCodes;
+import org.netxms.base.NXCPDataInputStream;
+import org.netxms.base.NXCPException;
+import org.netxms.base.NXCPMessage;
+import org.netxms.base.NXCPMessageReceiver;
+import org.netxms.base.NXCPMsgWaitQueue;
+import org.netxms.base.NXCommon;
 import org.netxms.client.constants.RCC;
 import org.netxms.client.dashboards.DashboardElement;
-import org.netxms.client.datacollection.*;
-import org.netxms.client.events.*;
+import org.netxms.client.datacollection.ConditionDciInfo;
+import org.netxms.client.datacollection.DataCollectionConfiguration;
+import org.netxms.client.datacollection.DataCollectionItem;
+import org.netxms.client.datacollection.DciData;
+import org.netxms.client.datacollection.DciDataRow;
+import org.netxms.client.datacollection.DciPushData;
+import org.netxms.client.datacollection.DciSummaryTable;
+import org.netxms.client.datacollection.DciSummaryTableDescriptor;
+import org.netxms.client.datacollection.DciValue;
+import org.netxms.client.datacollection.GraphSettings;
+import org.netxms.client.datacollection.PerfTabDci;
+import org.netxms.client.datacollection.Threshold;
+import org.netxms.client.datacollection.ThresholdViolationSummary;
+import org.netxms.client.datacollection.TransformationTestResult;
+import org.netxms.client.datacollection.WinPerfObject;
+import org.netxms.client.events.Alarm;
+import org.netxms.client.events.AlarmNote;
+import org.netxms.client.events.Event;
+import org.netxms.client.events.EventInfo;
+import org.netxms.client.events.EventProcessingPolicy;
+import org.netxms.client.events.EventProcessingPolicyRule;
+import org.netxms.client.events.EventTemplate;
+import org.netxms.client.events.SyslogRecord;
 import org.netxms.client.log.Log;
 import org.netxms.client.maps.NetworkMapLink;
 import org.netxms.client.maps.NetworkMapPage;
 import org.netxms.client.maps.elements.NetworkMapElement;
 import org.netxms.client.maps.elements.NetworkMapObject;
-import org.netxms.client.objects.*;
+import org.netxms.client.objects.AbstractObject;
+import org.netxms.client.objects.AccessPoint;
+import org.netxms.client.objects.AgentPolicy;
+import org.netxms.client.objects.AgentPolicyConfig;
+import org.netxms.client.objects.BusinessService;
+import org.netxms.client.objects.BusinessServiceRoot;
+import org.netxms.client.objects.Cluster;
+import org.netxms.client.objects.ClusterResource;
+import org.netxms.client.objects.ClusterSyncNetwork;
+import org.netxms.client.objects.Condition;
+import org.netxms.client.objects.Container;
+import org.netxms.client.objects.Dashboard;
+import org.netxms.client.objects.DashboardRoot;
+import org.netxms.client.objects.EntireNetwork;
+import org.netxms.client.objects.GenericObject;
+import org.netxms.client.objects.Interface;
+import org.netxms.client.objects.MobileDevice;
+import org.netxms.client.objects.NetworkMap;
+import org.netxms.client.objects.NetworkMapGroup;
+import org.netxms.client.objects.NetworkMapRoot;
+import org.netxms.client.objects.NetworkService;
+import org.netxms.client.objects.Node;
+import org.netxms.client.objects.NodeLink;
+import org.netxms.client.objects.PolicyGroup;
+import org.netxms.client.objects.PolicyRoot;
+import org.netxms.client.objects.Rack;
+import org.netxms.client.objects.Report;
+import org.netxms.client.objects.ReportGroup;
+import org.netxms.client.objects.ReportRoot;
+import org.netxms.client.objects.ServiceCheck;
+import org.netxms.client.objects.ServiceRoot;
+import org.netxms.client.objects.Subnet;
+import org.netxms.client.objects.Template;
+import org.netxms.client.objects.TemplateGroup;
+import org.netxms.client.objects.TemplateRoot;
+import org.netxms.client.objects.UnknownObject;
+import org.netxms.client.objects.Zone;
 import org.netxms.client.objecttools.ObjectTool;
 import org.netxms.client.objecttools.ObjectToolDetails;
 import org.netxms.client.packages.PackageDeploymentListener;
 import org.netxms.client.packages.PackageInfo;
 import org.netxms.client.situations.Situation;
-import org.netxms.client.snmp.*;
+import org.netxms.client.snmp.SnmpTrap;
+import org.netxms.client.snmp.SnmpTrapLogRecord;
+import org.netxms.client.snmp.SnmpUsmCredential;
+import org.netxms.client.snmp.SnmpValue;
+import org.netxms.client.snmp.SnmpWalkListener;
 import org.netxms.client.topology.ConnectionPoint;
 import org.netxms.client.topology.NetworkPath;
 import org.netxms.client.topology.VlanInfo;
 import org.netxms.client.topology.WirelessStation;
 
-import java.io.*;
-import java.net.InetAddress;
-import java.net.Socket;
-import java.net.UnknownHostException;
-import java.security.GeneralSecurityException;
-import java.security.Signature;
-import java.security.SignatureException;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateEncodingException;
-import java.util.*;
-import java.util.Map.Entry;
-import java.util.concurrent.Semaphore;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
 /**
  * Communication session with NetXMS server.
  */
@@ -5676,11 +5770,20 @@ public class NXCSession implements Session, ScriptLibraryManager, UserManager, S
         * @see org.netxms.api.client.Session#checkConnection()
         */
    @Override
-   public void checkConnection() throws IOException, NXCException
+   public boolean checkConnection()
    {
       final NXCPMessage msg = newMessage(NXCPCodes.CMD_KEEPALIVE);
-      sendMessage(msg);
-      waitForRCC(msg.getMessageId());
+      try
+      {
+         sendMessage(msg);
+         waitForRCC(msg.getMessageId());
+         return true;
+      }
+      catch(Exception e)
+      {
+         sendNotification(new NXCNotification(NXCNotification.CONNECTION_BROKEN));
+         return false;
+      }
    }
 
    /*
@@ -5950,8 +6053,36 @@ public class NXCSession implements Session, ScriptLibraryManager, UserManager, S
     * @throws NXCException if NetXMS server returns an error or operation was timed out
     */
    public ServerFile[] listServerFiles() throws IOException, NXCException
+   {
+      return listServerFiles(null);
+   }
+   
+   /**
+    * List files in server's file store.
+    * 
+    * @param filter array with required extension. Will be used as file filter. Give empty array or null if no filter should be
+    *           applyed.
+    * @return list of files in server's file store
+    * @throws IOException if socket or file I/O error occurs
+    * @throws NXCException if NetXMS server returns an error or operation was timed out
+    */
+   public ServerFile[] listServerFiles(String[] filter) throws IOException, NXCException
    {
       final NXCPMessage msg = newMessage(NXCPCodes.CMD_LIST_SERVER_FILES);
+      if(filter != null)
+      {
+         msg.setVariableInt32(NXCPCodes.VID_EXTENSION_COUNT, filter.length);
+         int i = 0;
+         long j = NXCPCodes.VID_EXTENSION_LIST_BASE;
+         for(; i < filter.length; i++, j++)
+         {
+            msg.setVariable(j, filter[i]);
+         }
+      }
+      else
+      {
+         msg.setVariableInt32(NXCPCodes.VID_EXTENSION_COUNT, 0);
+      }
       sendMessage(msg);
       final NXCPMessage response = waitForRCC(msg.getMessageId());
       int count = response.getVariableAsInteger(NXCPCodes.VID_INSTANCE_COUNT);
@@ -6016,13 +6147,16 @@ public class NXCSession implements Session, ScriptLibraryManager, UserManager, S
    /**
     * Download file from remote host via agent.
     *
-    * @param nodeId         node object ID
+    * @param nodeId node object ID
     * @param remoteFileName fully qualified file name on remote system
-    * @return handle to local copy of remote file
+    * @param maxFileSize maximum download size
+    * @param follow if set to true, server will send file updates as they appear (like for tail -f command) 
+    * @return agent file handle which contains server assigned ID and handle for local file
     * @throws IOException  if socket or file I/O error occurs
     * @throws NXCException if NetXMS server returns an error or operation was timed out
     */
-   public File downloadFileFromAgent(long nodeId, String remoteFileName, long maxFileSize, boolean follow) throws IOException, NXCException
+   public AgentFile downloadFileFromAgent(long nodeId, String remoteFileName, long maxFileSize, boolean follow) throws IOException,
+         NXCException
    {
       final NXCPMessage msg = newMessage(NXCPCodes.CMD_GET_AGENT_FILE);
       msg.setVariableInt32(NXCPCodes.VID_OBJECT_ID, (int) nodeId);
@@ -6030,8 +6164,27 @@ public class NXCSession implements Session, ScriptLibraryManager, UserManager, S
       msg.setVariableInt32(NXCPCodes.VID_FILE_SIZE_LIMIT , (int)maxFileSize);
       msg.setVariableInt16(NXCPCodes.VID_FILE_FOLLOW, follow ? 1 : 0);
       sendMessage(msg);
-      waitForRCC(msg.getMessageId()); // first confirmation - server job started
+
+      final NXCPMessage response = waitForRCC(msg.getMessageId()); // first confirmation - server job started
+      final String id = response.getVariableAsString(NXCPCodes.VID_NAME);
+
       waitForRCC(msg.getMessageId()); // second confirmation - file downloaded to server
+      return new AgentFile(id, waitForFile(msg.getMessageId(), 3600000));
+   }
+   
+   /**
+    * Download file from server file storage.
+    *
+    * @param remoteFileName fully qualified file name on remote system
+    * @throws IOException  if socket or file I/O error occurs
+    * @throws NXCException if NetXMS server returns an error or operation was timed out
+    */
+   public File downloadFileFromServer( String remoteFileName) throws IOException, NXCException
+   {
+      final NXCPMessage msg = newMessage(NXCPCodes.CMD_GET_SERVER_FILE);
+      msg.setVariable(NXCPCodes.VID_FILE_NAME, remoteFileName);
+      sendMessage(msg);
+      waitForRCC(msg.getMessageId());
       return waitForFile(msg.getMessageId(), 3600000);
    }
    
index 7854f99..4f0b539 100644 (file)
  */
 package org.netxms.client;
 
-import java.io.File;
 import java.io.FileReader;
 import java.io.IOException;
 
 /**
  * Test functionality related to server file store
- *
+ * 
  */
 public class ServerFilesTest extends SessionTest
 {
-       public void testFileList() throws Exception
-       {
-               final NXCSession session = connect();
+   public void testFileList() throws Exception
+   {
+      final NXCSession session = connect();
+
+      ServerFile[] files = session.listServerFiles();
+      for(ServerFile f : files)
+         System.out.println(f.getName() + " size=" + f.getSize() + " modified: " + f.getModifyicationTime().toString());
+
+      session.disconnect();
+   }
+
+   public void testAgentFileDownload() throws Exception
+   {
+      final NXCSession session = connect();
 
-               ServerFile[] files = session.listServerFiles();
-               for(ServerFile f : files)
-                       System.out.println(f.getName() + " size=" + f.getSize() + " modified: " + f.getModifyicationTime().toString());
+      AgentFile file = session.downloadFileFromAgent(TestConstants.NodeID, TestConstants.FileName, TestConstants.FileOfset, true);
+      // check that server returned file with correct size (offset should be less than size of file)
+      // assertEquals(file.length(), TestConstants.FileOfset);
+      String content = null;
+      try
+      {
+         FileReader reader = new FileReader(file.getFile());
+         char[] chars = new char[(int)file.getFile().length()];
+         reader.read(chars);
+         content = new String(chars);
+         reader.close();
+      }
+      catch(IOException e)
+      {
+         e.printStackTrace();
+      }
+      System.out.println("Downloaded content is: \n" + content);
+      System.out.println("*** Downloaded file: " + file.getFile().getAbsolutePath());
 
-               session.disconnect();
-       }
-       
-       public void testAgentFileDownload() throws Exception
-       {
-               final NXCSession session = connect();
-               
-               File file = session.downloadFileFromAgent(TestConstants.NodeID, TestConstants.FileName, TestConstants.FileOfset, true);
-               //check that server returned file with correct size (offset should be less than size of file)
-               //assertEquals(file.length(), TestConstants.FileOfset); 
-               String content = null;
-          try {
-              FileReader reader = new FileReader(file);
-              char[] chars = new char[(int) file.length()];
-              reader.read(chars);
-              content = new String(chars);
-              reader.close();
-          } catch (IOException e) {
-              e.printStackTrace();
-          }
-               System.out.println("Downloaded content is: \n" + content);
-               System.out.println("*** Downloaded file: " + file.getAbsolutePath());
-               
-               //get tails of provided file
-               int i = 3;
-               while(i > 0)
-               {
-                  System.out.println("Tail content: \n" + session.waitForFileTail(TestConstants.FileName, 30000));
-                  i--;
-               }
-               session.cancelFileMonitoring(TestConstants.NodeID, TestConstants.FileName);
-               System.out.println("Monitoring have been canceled.\n");
-               session.disconnect();
-       }
+      // get tails of provided file
+      int i = 3;
+      while(i > 0)
+      {
+         System.out.println("Tail content: \n" + session.waitForFileTail(TestConstants.FileName, 30000));
+         i--;
+      }
+      session.cancelFileMonitoring(TestConstants.NodeID, TestConstants.FileName);
+      System.out.println("Monitoring have been canceled.\n");
+      session.disconnect();
+   }
 }
index 4bcd19e..557c034 100644 (file)
@@ -5,6 +5,7 @@ action.terminate=Terminate
 actionDescription.openAlarmBrowser=Open Alarm Browser
 actionSet.AlarmBrowser.label=Alarm Browser
 page.Alarms.name=Alarms
+page.AlarmMelodies.name=Alarm Sounds
 provider.AlarmDetails.name=Alarm Details Provider
 tab.Alarms=Alarms
 view.AlarmBrowser.name=Alarm Browser
index 2a9ce8c..21d5410 100644 (file)
@@ -4,6 +4,7 @@ action.openAlarmBrowser=Prohl\u00ED\u017Ee\u010D alarm\u016F
 action.terminate=Ukon\u010Dit
 actionDescription.openAlarmBrowser=Otev\u0159\u00EDt prohli\u017Ee\u010D alarm\u016F
 actionSet.AlarmBrowser.label=Prohl\u00ED\u017Ee\u010D alarm\u016F
+page.AlarmMelodies.name=Alarm Sounds
 page.Alarms.name=Alarmy
 provider.AlarmDetails.name=Poskytovatel detailu alarm\u016F
 tab.Alarms=Alarmy
index 9f4e1e7..a6f27c5 100644 (file)
@@ -4,6 +4,7 @@ action.openAlarmBrowser=Explorador de Alarmas
 action.terminate=Terminar
 actionDescription.openAlarmBrowser=Abrir el Explorador de Alarmas
 actionSet.AlarmBrowser.label=Explorador de Alarmas
+page.AlarmMelodies.name=Alarm Sounds
 page.Alarms.name=Alarms
 provider.AlarmDetails.name=Alarm Details Provider
 tab.Alarms=Alarmas
index dcc6908..8b86523 100644 (file)
@@ -4,6 +4,7 @@ action.openAlarmBrowser=\u041e\u0431\u043e\u0437\u0440\u0435\u0432\u0430\u0442\u
 action.terminate=\u041f\u0440\u0435\u043a\u0440\u0430\u0442\u0438\u0442\u044c
 actionDescription.openAlarmBrowser=\u041e\u0442\u043a\u0440\u044b\u0442\u044c \u043e\u0431\u043e\u0437\u0440\u0435\u0432\u0430\u0442\u0435\u043b\u044c \u0442\u0440\u0435\u0432\u043e\u0433
 actionSet.AlarmBrowser.label=\u041e\u0431\u043e\u0437\u0440\u0435\u0432\u0430\u0442\u0435\u043b\u044c \u0442\u0440\u0435\u0432\u043e\u0433
+page.AlarmMelodies.name=Alarm Sounds
 page.Alarms.name=\u0422\u0440\u0435\u0432\u043e\u0433\u0438
 provider.AlarmDetails.name=\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0435\u0439 \u0442\u0440\u0435\u0432\u043e\u0433\u0438
 tab.Alarms=\u0422\u0440\u0435\u0432\u043e\u0433\u0438
index 4644418..2aa0f11 100644 (file)
@@ -4,6 +4,7 @@ action.openAlarmBrowser=\u544a\u8b66\u6d4f\u89c8
 action.terminate=\u544a\u8b66\u4e2d\u6b62
 actionDescription.openAlarmBrowser=\u6253\u5f00\u544a\u8b66\u6d4f\u89c8\u5668
 actionSet.AlarmBrowser.label=Alarm Browser
+page.AlarmMelodies.name=Alarm Sounds
 page.Alarms.name=Alarms
 provider.AlarmDetails.name=Alarm Details Provider
 tab.Alarms=\u544a\u8b66
index fcdd0bb..dab151d 100644 (file)
@@ -4,5 +4,4 @@ bin.includes = plugin.xml,\
                META-INF/,\
                .,\
                icons/,\
-               OSGI-INF/,\
-               OSGI-INF/l10n/bundle.properties
+               OSGI-INF/
index edf2461..fc09386 100644 (file)
             id="org.netxms.ui.eclipse.alarmviewer.preferencepages.Alarms"
             name="%page.Alarms.name">
       </page>
+      <page
+            category="org.netxms.ui.eclipse.alarmviewer.preferencepages.Alarms"
+            class="org.netxms.ui.eclipse.alarmviewer.preferencepages.AlarmMelody"
+            id="org.netxms.ui.eclipse.alarmviewer.preferencepages.AlarmMelody"
+            name="%page.AlarmMelodies.name">
+      </page>
    </extension>
    <extension
          point="org.eclipse.ui.popupMenus">
index 928b1f5..fb07744 100644 (file)
  */
 package org.netxms.ui.eclipse.alarmviewer;
 
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.nio.channels.FileChannel;
 import java.util.HashMap;
 import java.util.Map;
+import javax.sound.sampled.AudioInputStream;
+import javax.sound.sampled.AudioSystem;
+import javax.sound.sampled.Clip;
+import javax.sound.sampled.DataLine;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.swt.SWT;
@@ -33,6 +44,7 @@ import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.progress.UIJob;
 import org.netxms.api.client.Session;
 import org.netxms.api.client.SessionNotification;
+import org.netxms.client.NXCException;
 import org.netxms.client.NXCListener;
 import org.netxms.client.NXCNotification;
 import org.netxms.client.NXCSession;
@@ -42,175 +54,302 @@ import org.netxms.client.objects.AbstractObject;
 import org.netxms.ui.eclipse.alarmviewer.dialogs.AlarmReminderDialog;
 import org.netxms.ui.eclipse.console.resources.StatusDisplayInfo;
 import org.netxms.ui.eclipse.shared.ConsoleSharedData;
+import org.netxms.ui.eclipse.tools.MessageDialogHelper;
 
 /**
  * Alarm notifier
  */
 public class AlarmNotifier
 {
-       private static NXCListener listener = null;
-       private static Map<Long, Integer> alarmStates = new HashMap<Long, Integer>();
-       private static int outstandingAlarms = 0;
-       private static long lastReminderTime = 0;
-       
-       /**
-        * Initialize alarm notifier
-        */
-       public static void init(NXCSession session)
-       {
-               lastReminderTime = System.currentTimeMillis();
-               
-               try
-               {
-                       Map<Long, Alarm> alarms = session.getAlarms();
-                       for(Alarm a : alarms.values())
-                       {
-                               alarmStates.put(a.getId(), a.getState());
-                               if (a.getState() == Alarm.STATE_OUTSTANDING)
-                                       outstandingAlarms++;
-                       }
-               }
-               catch(Exception e)
-               {
-               }
-               
-               listener = new NXCListener() {
-                       @Override
-                       public void notificationHandler(SessionNotification n)
-                       {
-                               if ((n.getCode() == NXCNotification.NEW_ALARM) ||
-                                   (n.getCode() == NXCNotification.ALARM_CHANGED))
-                               {
-                                       processNewAlarm((Alarm)n.getObject());
-                               }
-                               else if ((n.getCode() == NXCNotification.ALARM_TERMINATED) ||
-                                        (n.getCode() == NXCNotification.ALARM_DELETED))
-                               {
-                                       Integer state = alarmStates.get(((Alarm)n.getObject()).getId());
-                                       if (state != null)
-                                       {
-                                               if (state == Alarm.STATE_OUTSTANDING)
-                                                       outstandingAlarms--;
-                                               alarmStates.remove(((Alarm)n.getObject()).getId());
-                                       }
-                               }
-                       }
-               };
-               session.addListener(listener);
-               
-               Thread thread = new Thread(new Runnable() {
-                       @Override
-                       public void run()
-                       {
-                               while(true)
-                               {
-                                       try
-                                       {
-                                               Thread.sleep(10000);
-                                       }
-                                       catch(InterruptedException e)
-                                       {
-                                       }
-                                       
-                                       IPreferenceStore ps = Activator.getDefault().getPreferenceStore();
-                                       long currTime = System.currentTimeMillis();
-                                       if (ps.getBoolean("OUTSTANDING_ALARMS_REMINDER") &&  //$NON-NLS-1$
-                                                       (outstandingAlarms > 0) && 
-                                                       (lastReminderTime + 300000 <= currTime))
-                                       {
-                                               Display.getDefault().syncExec(new Runnable() {
-                                                       @Override
-                                                       public void run()
-                                                       {
-                                                               AlarmReminderDialog dlg = new AlarmReminderDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
-                                                               dlg.open();
-                                                       }
-                                               });
-                                               lastReminderTime = currTime;
-                                       }
-                               }
-                       }
-               }, "AlarmReminderThread"); //$NON-NLS-1$
-               thread.setDaemon(true);
-               thread.start();
-       }
-       
-       /**
-        * Stop alarm notifier
-        */
-       public static void stop()
-       {
-               Session session = ConsoleSharedData.getSession();
-               if ((session != null) && (listener != null))
-                       session.removeListener(listener);
-       }
-
-       /**
-        * Process new alarm
-        */
-       private static void processNewAlarm(final Alarm alarm)
-       {
-               Integer state = alarmStates.get(alarm.getId());
-               if (state != null)
-               {
-                       if (state == Alarm.STATE_OUTSTANDING)
-                               outstandingAlarms--;
-               }
-               alarmStates.put(alarm.getId(), alarm.getState());
-               
-               if (alarm.getState() != Alarm.STATE_OUTSTANDING)
-                       return;
-
-               if (outstandingAlarms == 0)
-                       lastReminderTime = System.currentTimeMillis();
-               outstandingAlarms++;
-               
-               if (!Activator.getDefault().getPreferenceStore().getBoolean("SHOW_TRAY_POPUPS")) //$NON-NLS-1$
-                       return;
-               
-               final TrayItem trayIcon = ConsoleSharedData.getTrayIcon();
-               if (trayIcon != null)
-               {
-                       new UIJob("Create alarm popup") { //$NON-NLS-1$
-                               @Override
-                               public IStatus runInUIThread(IProgressMonitor monitor)
-                               {
-                                       final NXCSession session = (NXCSession)ConsoleSharedData.getSession();
-                                       final AbstractObject object = session.findObjectById(alarm.getSourceObjectId());
-                                       
-                                       int severityFlag;
-                                       if (alarm.getCurrentSeverity() == Severity.NORMAL)
-                                       {
-                                               severityFlag = SWT.ICON_INFORMATION;
-                                       }
-                                       else if (alarm.getCurrentSeverity() == Severity.CRITICAL)
-                                       {
-                                               severityFlag = SWT.ICON_ERROR;
-                                       }
-                                       else
-                                       {
-                                               severityFlag = SWT.ICON_WARNING;
-                                       }
-                                       
-                                       IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
-                                       if (window == null)
-                                       {
-                                               IWorkbenchWindow[] wl = PlatformUI.getWorkbench().getWorkbenchWindows();
-                                               if (wl.length > 0)
-                                                       window = wl[0];
-                                       }
-                                       if (window != null)
-                                       {
-                                               final ToolTip tip = new ToolTip(window.getShell(), SWT.BALLOON | severityFlag);
-                                               tip.setText(Messages.get().AlarmNotifier_ToolTip_Header + StatusDisplayInfo.getStatusText(alarm.getCurrentSeverity()) + ")"); //$NON-NLS-1$ //$NON-NLS-1$
-                                               tip.setMessage(((object != null) ? object.getObjectName() : Long.toString(alarm.getSourceObjectId())) + ": " + alarm.getMessage()); //$NON-NLS-1$
-                                               tip.setAutoHide(true);
-                                               trayIcon.setToolTip(tip);
-                                               tip.setVisible(true);
-                                       }
-                                       return Status.OK_STATUS;
-                               }
-                       }.schedule();
-               }
-       }
+   private static NXCListener listener = null;
+   private static Map<Long, Integer> alarmStates = new HashMap<Long, Integer>();
+   private static int outstandingAlarms = 0;
+   private static long lastReminderTime = 0;
+   private static NXCSession session;
+   public static String[] severityArray = { "NORMAL", "WARNING", "MINOR", "MAJOR", "CRITICAL" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+   private static IPreferenceStore ps;
+   private static URL workspaceUrl;
+
+   /**
+    * Initialize alarm notifier
+    */
+   public static void init(NXCSession sessionGiven)
+   {
+      session = sessionGiven;
+      ps = Activator.getDefault().getPreferenceStore();
+      workspaceUrl = Platform.getInstanceLocation().getURL();
+      // Check that required alarm melodies are present localy.
+      checkMelodies(session);
+
+      lastReminderTime = System.currentTimeMillis();
+
+      try
+      {
+         Map<Long, Alarm> alarms = session.getAlarms();
+         for(Alarm a : alarms.values())
+         {
+            alarmStates.put(a.getId(), a.getState());
+            if (a.getState() == Alarm.STATE_OUTSTANDING)
+               outstandingAlarms++;
+         }
+      }
+      catch(Exception e)
+      {
+      }
+
+      listener = new NXCListener() {
+         @Override
+         public void notificationHandler(SessionNotification n)
+         {
+            if ((n.getCode() == NXCNotification.NEW_ALARM) || (n.getCode() == NXCNotification.ALARM_CHANGED))
+            {
+               processNewAlarm((Alarm)n.getObject());
+            }
+            else if ((n.getCode() == NXCNotification.ALARM_TERMINATED) || (n.getCode() == NXCNotification.ALARM_DELETED))
+            {
+               Integer state = alarmStates.get(((Alarm)n.getObject()).getId());
+               if (state != null)
+               {
+                  if (state == Alarm.STATE_OUTSTANDING)
+                     outstandingAlarms--;
+                  alarmStates.remove(((Alarm)n.getObject()).getId());
+               }
+            }
+         }
+      };
+      session.addListener(listener);
+
+      Thread thread = new Thread(new Runnable() {
+         @Override
+         public void run()
+         {
+            while(true)
+            {
+               try
+               {
+                  Thread.sleep(10000);
+               }
+               catch(InterruptedException e)
+               {
+               }
+
+               IPreferenceStore ps = Activator.getDefault().getPreferenceStore();
+               long currTime = System.currentTimeMillis();
+               if (ps.getBoolean("OUTSTANDING_ALARMS_REMINDER") && //$NON-NLS-1$
+                     (outstandingAlarms > 0) && (lastReminderTime + 300000 <= currTime))
+               {
+                  Display.getDefault().syncExec(new Runnable() {
+                     @Override
+                     public void run()
+                     {
+                        AlarmReminderDialog dlg = new AlarmReminderDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+                              .getShell());
+                        dlg.open();
+                     }
+                  });
+                  lastReminderTime = currTime;
+               }
+            }
+         }
+      }, "AlarmReminderThread"); //$NON-NLS-1$
+      thread.setDaemon(true);
+      thread.start();
+   }
+
+   /**
+    * Check if required melodies exist locally and download them from server if required.
+    */
+   private static void checkMelodies(NXCSession session)
+   {
+      URL workspaceUrl = Platform.getInstanceLocation().getURL();
+      for(int i = 0; i < 5; i++)
+      {
+         getMelodyAndDownloadIfRequired(session, workspaceUrl, severityArray[i]);
+      }
+   }
+
+   private static String getMelodyAndDownloadIfRequired(NXCSession session, URL workspaceUrl, String severity)
+   {
+      String melodyName = ps.getString("ALARM_NOTIFIER.MELODY." + severity);//$NON-NLS-1$
+      if (!checkMelodyExists(melodyName, workspaceUrl))
+      {
+         try
+         {
+            File f = new File(workspaceUrl.getPath(), melodyName);
+            File fileContent = session.downloadFileFromServer(melodyName);
+            f.createNewFile();
+            FileChannel src = null;
+            FileChannel dest = null;
+            if (fileContent != null)
+            {
+               try
+               {
+                  src = new FileInputStream(fileContent).getChannel();
+                  dest = new FileOutputStream(f).getChannel();
+                  dest.transferFrom(src, 0, src.size());
+               }
+               catch(IOException e)
+               {
+                  System.out.println("Not possible to copy inside new file content."); //$NON-NLS-1$
+               }
+               finally
+               {
+                  src.close();
+                  dest.close();
+               }
+            }
+         }
+         catch(IOException | NXCException e)
+         {
+            melodyName = ""; //$NON-NLS-1$
+            ps.setValue("ALARM_NOTIFIER.MELODY." + severity, ""); //$NON-NLS-1$ //$NON-NLS-2$
+            new UIJob(Messages.get().AlarmNotifier_JobSoundNotFoundError) {
+               @Override
+               public IStatus runInUIThread(IProgressMonitor monitor)
+               {
+                  MessageDialogHelper
+                        .openError(
+                              getDisplay().getActiveShell(),
+                              Messages.get().AlarmNotifier_ErrorMelodynotExists,
+                              Messages.get().AlarmNotifier_ErrorMelodyNotExistsDescription
+                                    + e.getMessage());
+                  return Status.OK_STATUS;
+               }
+            }.schedule();
+         }
+      }
+      return melodyName;
+   }
+
+   private static boolean checkMelodyExists(String melodyName, URL workspaceUrl)
+   {
+      if ((!melodyName.equals("")) && (workspaceUrl != null)) //$NON-NLS-1$
+      {
+         File f = new File(workspaceUrl.getPath(), melodyName);
+         return f.isFile();
+      }
+      else
+      {
+         return true;
+      }
+   }
+
+   /**
+    * Stop alarm notifier
+    */
+   public static void stop()
+   {
+      Session session = ConsoleSharedData.getSession();
+      if ((session != null) && (listener != null))
+         session.removeListener(listener);
+   }
+
+   /**
+    * Process new alarm
+    */
+   private static void processNewAlarm(final Alarm alarm)
+   {
+
+      Integer state = alarmStates.get(alarm.getId());
+      if (state != null)
+      {
+         if (state == Alarm.STATE_OUTSTANDING)
+         {
+            outstandingAlarms--;
+         }
+      }
+      alarmStates.put(alarm.getId(), alarm.getState());
+
+      if (alarm.getState() != Alarm.STATE_OUTSTANDING)
+         return;
+
+      String fileName = getMelodyAndDownloadIfRequired(session, workspaceUrl, severityArray[alarm.getCurrentSeverity()]); //$NON-NLS-1$
+
+      if (!fileName.equals("") && fileName != null) //$NON-NLS-1$
+      {
+         try
+         {
+            AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(new File(workspaceUrl.getPath(), fileName)
+                  .getAbsoluteFile());
+            DataLine.Info info = new DataLine.Info(Clip.class, audioInputStream.getFormat());
+            Clip clip = (Clip)AudioSystem.getLine(info);
+            clip.open(audioInputStream);
+            clip.start();
+            while(!clip.isRunning())
+               Thread.sleep(10);
+            int i = 0;
+            while(clip.isRunning() && i < 1000)
+            {
+               Thread.sleep(10);
+               i += 10;
+            }
+            clip.close();
+         }
+         catch(final Exception e)
+         {
+            new UIJob("Send error that was not possible to play sound") {
+               @Override
+               public IStatus runInUIThread(IProgressMonitor monitor)
+               {
+                  MessageDialogHelper.openError(getDisplay().getActiveShell(), Messages.get().AlarmNotifier_ErrorPlayingSound,
+                        Messages.get().AlarmNotifier_ErrorPlayingSoundDescription + e.getMessage());
+                  return Status.OK_STATUS;
+               }
+            }.schedule();
+         }
+      }
+
+      if (outstandingAlarms == 0)
+         lastReminderTime = System.currentTimeMillis();
+      outstandingAlarms++;
+
+      if (!Activator.getDefault().getPreferenceStore().getBoolean("SHOW_TRAY_POPUPS")) //$NON-NLS-1$
+         return;
+
+      final TrayItem trayIcon = ConsoleSharedData.getTrayIcon();
+      if (trayIcon != null)
+      {
+         new UIJob("Create alarm popup") { //$NON-NLS-1$
+            @Override
+            public IStatus runInUIThread(IProgressMonitor monitor)
+            {
+               final AbstractObject object = session.findObjectById(alarm.getSourceObjectId());
+
+               int severityFlag;
+               if (alarm.getCurrentSeverity() == Severity.NORMAL)
+               {
+                  severityFlag = SWT.ICON_INFORMATION;
+               }
+               else if (alarm.getCurrentSeverity() == Severity.CRITICAL)
+               {
+                  severityFlag = SWT.ICON_ERROR;
+               }
+               else
+               {
+                  severityFlag = SWT.ICON_WARNING;
+               }
+
+               IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+               if (window == null)
+               {
+                  IWorkbenchWindow[] wl = PlatformUI.getWorkbench().getWorkbenchWindows();
+                  if (wl.length > 0)
+                     window = wl[0];
+               }
+               if (window != null)
+               {
+                  final ToolTip tip = new ToolTip(window.getShell(), SWT.BALLOON | severityFlag);
+                  tip.setText(Messages.get().AlarmNotifier_ToolTip_Header
+                        + StatusDisplayInfo.getStatusText(alarm.getCurrentSeverity()) + ")"); //$NON-NLS-1$ //$NON-NLS-1$
+                  tip.setMessage(((object != null) ? object.getObjectName() : Long.toString(alarm.getSourceObjectId()))
+                        + ": " + alarm.getMessage()); //$NON-NLS-1$
+                  tip.setAutoHide(true);
+                  trayIcon.setToolTip(tip);
+                  tip.setVisible(true);
+               }
+               return Status.OK_STATUS;
+            }
+         }.schedule();
+      }
+   }
 }
index 545df1c..f35ba67 100644 (file)
@@ -4,12 +4,12 @@ import org.eclipse.osgi.util.NLS;
 
 public class Messages extends NLS
 {
-       private static final String BUNDLE_NAME = "org.netxms.ui.eclipse.alarmviewer.messages"; //$NON-NLS-1$
+   private static final String BUNDLE_NAME = "org.netxms.ui.eclipse.alarmviewer.messages"; //$NON-NLS-1$
 
-       public static String AcknowledgeAlarm_ErrorMessage;
-       public static String AcknowledgeAlarm_JobName;
-       public static String AcknowledgeAlarm_TaskName;
-       public static String AcknowledgeCustomTimeDialog_ConfigurationInfoLabel;
+   public static String AcknowledgeAlarm_ErrorMessage;
+   public static String AcknowledgeAlarm_JobName;
+   public static String AcknowledgeAlarm_TaskName;
+   public static String AcknowledgeCustomTimeDialog_ConfigurationInfoLabel;
    public static String AcknowledgeCustomTimeDialog_CustomTimeDialogTitle;
    public static String AcknowledgeCustomTimeDialog_Days;
    public static String AcknowledgeCustomTimeDialog_Hours;
@@ -25,92 +25,101 @@ public class Messages extends NLS
    public static String AlarmAcknowledgeTimeFunctions_ZeroMinutesEntry;
    public static String AlarmComments_AckToDeleteComment;
    public static String AlarmComments_AddCommentJob;
-       public static String AlarmComments_AddCommentLink;
-       public static String AlarmComments_AddError;
-       public static String AlarmComments_Comments;
+   public static String AlarmComments_AddCommentLink;
+   public static String AlarmComments_AddError;
+   public static String AlarmComments_Comments;
    public static String AlarmComments_Confirmation;
-       public static String AlarmComments_DeleteCommentJob;
+   public static String AlarmComments_DeleteCommentJob;
    public static String AlarmComments_Details;
    public static String AlarmComments_ErrorDeleteAlarmComment;
-       public static String AlarmComments_GetComments;
-       public static String AlarmComments_GetError;
-       public static String AlarmComments_InternalError;
-       public static String AlarmCommentsEditor_DeleteLabel;
+   public static String AlarmComments_GetComments;
+   public static String AlarmComments_GetError;
+   public static String AlarmComments_InternalError;
+   public static String AlarmCommentsEditor_DeleteLabel;
    public static String AlarmCommentsEditor_Edit;
-       public static String AlarmCommentsEditor_Unknown;
-       public static String AlarmComparator_Unknown;
-       public static String AlarmDetails_Column_Message;
-       public static String AlarmDetails_Column_Name;
-       public static String AlarmDetails_Column_Severity;
-       public static String AlarmDetails_Column_Source;
-       public static String AlarmDetails_Column_Timestamp;
-       public static String AlarmDetails_LastValues;
-       public static String AlarmDetails_Overview;
-       public static String AlarmDetails_RefreshJobError;
-       public static String AlarmDetails_RefreshJobTitle;
-       public static String AlarmDetails_RelatedEvents;
-       public static String AlarmDetailsProvider_Error;
-       public static String AlarmDetailsProvider_ErrorOpeningView;
-       public static String AlarmList_AckBy;
-       public static String AlarmList_Acknowledge;
-       public static String AlarmList_ActionAlarmDetails;
-       public static String AlarmList_ActionObjectDetails;
-       public static String AlarmList_CannotResoveAlarm;
-       public static String AlarmList_ColumnCount;
-       public static String AlarmList_ColumnCreated;
-       public static String AlarmList_ColumnLastChange;
-       public static String AlarmList_ColumnMessage;
-       public static String AlarmList_ColumnSeverity;
-       public static String AlarmList_ColumnSource;
-       public static String AlarmList_ColumnState;
-       public static String AlarmList_Comments;
-       public static String AlarmList_CopyMsgToClipboard;
-       public static String AlarmList_CopyToClipboard;
-       public static String AlarmList_Error;
-       public static String AlarmList_ErrorText;
-       public static String AlarmList_OpenDetailsError;
-       public static String AlarmList_Resolve;
-       public static String AlarmList_ResolveAlarm;
-       public static String AlarmList_Resolving;
-       public static String AlarmList_StickyAck;
-
+   public static String AlarmCommentsEditor_Unknown;
+   public static String AlarmComparator_Unknown;
+   public static String AlarmDetails_Column_Message;
+   public static String AlarmDetails_Column_Name;
+   public static String AlarmDetails_Column_Severity;
+   public static String AlarmDetails_Column_Source;
+   public static String AlarmDetails_Column_Timestamp;
+   public static String AlarmDetails_LastValues;
+   public static String AlarmDetails_Overview;
+   public static String AlarmDetails_RefreshJobError;
+   public static String AlarmDetails_RefreshJobTitle;
+   public static String AlarmDetails_RelatedEvents;
+   public static String AlarmDetailsProvider_Error;
+   public static String AlarmDetailsProvider_ErrorOpeningView;
+   public static String AlarmList_AckBy;
+   public static String AlarmList_Acknowledge;
+   public static String AlarmList_ActionAlarmDetails;
+   public static String AlarmList_ActionObjectDetails;
+   public static String AlarmList_CannotResoveAlarm;
+   public static String AlarmList_ColumnCount;
+   public static String AlarmList_ColumnCreated;
+   public static String AlarmList_ColumnLastChange;
+   public static String AlarmList_ColumnMessage;
+   public static String AlarmList_ColumnSeverity;
+   public static String AlarmList_ColumnSource;
+   public static String AlarmList_ColumnState;
+   public static String AlarmList_Comments;
+   public static String AlarmList_CopyMsgToClipboard;
+   public static String AlarmList_CopyToClipboard;
+   public static String AlarmList_Error;
+   public static String AlarmList_ErrorText;
+   public static String AlarmList_OpenDetailsError;
+   public static String AlarmList_Resolve;
+   public static String AlarmList_ResolveAlarm;
+   public static String AlarmList_Resolving;
+   public static String AlarmList_StickyAck;
    public static String AlarmList_StickyAckMenutTitle;
-       public static String AlarmList_SyncJobError;
-       public static String AlarmList_SyncJobName;
-       public static String AlarmList_Terminate;
-       public static String AlarmListLabelProvider_AlarmState_Acknowledged;
-       public static String AlarmListLabelProvider_AlarmState_Outstanding;
-       public static String AlarmListLabelProvider_AlarmState_Resolved;
-       public static String AlarmListLabelProvider_AlarmState_Terminated;
-       public static String AlarmNotifier_ToolTip_Header;
-       public static String AlarmReminderDialog_Dismiss;
-       public static String AlarmReminderDialog_OutstandingAlarms;
+   public static String AlarmList_SyncJobError;
+   public static String AlarmList_SyncJobName;
+   public static String AlarmList_Terminate;
+   public static String AlarmListLabelProvider_AlarmState_Acknowledged;
+   public static String AlarmListLabelProvider_AlarmState_Outstanding;
+   public static String AlarmListLabelProvider_AlarmState_Resolved;
+   public static String AlarmListLabelProvider_AlarmState_Terminated;
+   public static String AlarmMelody_ErrorGettingMelodyList;
+   public static String AlarmMelody_ErrorGettingMelodyListDescription;
+   public static String AlarmMelody_ErrorMelodyNotExists;
+   public static String AlarmMelody_ErrorMelodyNotExistsDescription;
+   public static String AlarmMelody_JobGetMelodyList;
+   public static String AlarmMelody_SaveClientSelection;
+   public static String AlarmNotifier_ErrorMelodynotExists;
+   public static String AlarmNotifier_ErrorMelodyNotExistsDescription;
+   public static String AlarmNotifier_ErrorPlayingSound;
+   public static String AlarmNotifier_ErrorPlayingSoundDescription;
+   public static String AlarmNotifier_JobSoundNotFoundError;
+   public static String AlarmNotifier_ToolTip_Header;
+   public static String AlarmReminderDialog_Dismiss;
+   public static String AlarmReminderDialog_OutstandingAlarms;
    public static String Alarms_AcknowledgeTimeEditor;
-
    public static String Alarms_Blinking;
    public static String Alarms_SetAlarmFlowToStrict;
-
    public static String Alarms_ShowDetailedTooltips;
-       public static String Alarms_ShowPopup;
-       public static String Alarms_ShowReminder;
-       public static String EditCommentDialog_Comment;
-       public static String EditCommentDialog_EditComment;
-       public static String ObjectAlarmBrowser_TitlePrefix;
-       public static String OpenAlarmBrowser_Error;
-       public static String OpenAlarmBrowser_ErrorOpeningView;
-       public static String ShowObjectAlarms_Error;
-       public static String ShowObjectAlarms_ErrorOpeningView;
-       public static String Startup_JobName;
-       public static String TerminateAlarm_ErrorMessage;
-       public static String TerminateAlarm_JobTitle;
-       public static String TerminateAlarm_TaskName;
-       static
-       {
-               // initialize resource bundle
-               NLS.initializeMessages(BUNDLE_NAME, Messages.class);
-       }
+   public static String Alarms_ShowPopup;
+   public static String Alarms_ShowReminder;
+   public static String EditCommentDialog_Comment;
+   public static String EditCommentDialog_EditComment;
+   public static String ObjectAlarmBrowser_TitlePrefix;
+   public static String OpenAlarmBrowser_Error;
+   public static String OpenAlarmBrowser_ErrorOpeningView;
+   public static String ShowObjectAlarms_Error;
+   public static String ShowObjectAlarms_ErrorOpeningView;
+   public static String Startup_JobName;
+   public static String TerminateAlarm_ErrorMessage;
+   public static String TerminateAlarm_JobTitle;
+   public static String TerminateAlarm_TaskName;
+
+   static
+   {
+      // initialize resource bundle
+      NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+   }
 
-       private Messages()
+   private Messages()
        {
  }
 
index 1e9ca53..c9eac21 100644 (file)
@@ -73,6 +73,17 @@ AlarmList_StickyAckMenutTitle=Sticky acknowledge for
 AlarmList_SyncJobError=Cannot synchronize alarm list
 AlarmList_SyncJobName=Synchronize alarm list
 AlarmList_Terminate=&Terminate
+AlarmMelody_ErrorGettingMelodyList=Not possible to get melody list.
+AlarmMelody_ErrorGettingMelodyListDescription=Not possible to get melody list. Error: 
+AlarmMelody_ErrorMelodyNotExists=Melody does not exist.
+AlarmMelody_ErrorMelodyNotExistsDescription=Melody was not found locally and it was not possible to download it from server. Melody is removed and will not be played. Error: 
+AlarmMelody_JobGetMelodyList=Get melody list
+AlarmMelody_SaveClientSelection=Save client selection
+AlarmNotifier_ErrorMelodynotExists=Melody does not exist.
+AlarmNotifier_ErrorMelodyNotExistsDescription=Melody was not found locally and it was not possible to download it from server. Melody is removed and will not be played. Error: 
+AlarmNotifier_ErrorPlayingSound=Was not possible to play sound
+AlarmNotifier_ErrorPlayingSoundDescription=Error while playing sound. Melody will not be played. Error: 
+AlarmNotifier_JobSoundNotFoundError=Send error that sound file is not found
 AlarmNotifier_ToolTip_Header=NetXMS Alarm (
 AlarmReminderDialog_Dismiss=Dismiss
 AlarmReminderDialog_OutstandingAlarms=Outstanding Alarms
index 6f73842..418ba14 100644 (file)
@@ -73,6 +73,17 @@ AlarmList_StickyAckMenutTitle=Sticky acknowledge for
 AlarmList_SyncJobError=Nelze synchronizovat seznam alarm\u016f
 AlarmList_SyncJobName=Synchronizovat seznam alarm\u016f
 AlarmList_Terminate=&Ukon\u010dit
+AlarmMelody_ErrorGettingMelodyList=Not possible to get melody list.
+AlarmMelody_ErrorGettingMelodyListDescription=Not possible to get melody list. Error:
+AlarmMelody_ErrorMelodyNotExists=Melody does not exist.
+AlarmMelody_ErrorMelodyNotExistsDescription=Melody was not found locally and it was not possible to download it from server. Melody is removed and will not be played. Error:
+AlarmMelody_JobGetMelodyList=Get melody list
+AlarmMelody_SaveClientSelection=Save client selection
+AlarmNotifier_ErrorMelodyNotExistsDescription=Melody was not found locally and it was not possible to download it from server. Melody is removed and will not be played. Error:
+AlarmNotifier_ErrorMelodynotExists=Melody does not exist.
+AlarmNotifier_ErrorPlayingSound=Was not possible to play sound
+AlarmNotifier_ErrorPlayingSoundDescription=Error while playing sound. Melody will not be played. Error:
+AlarmNotifier_JobSoundNotFoundError=Send error that sound file is not found
 AlarmNotifier_ToolTip_Header=NetXMS Alarm (
 AlarmReminderDialog_Dismiss=Zam\u00edtnout
 AlarmReminderDialog_OutstandingAlarms=Nevy\u0159e\u0161en\u00e9 alarmy
index f0a1c99..b8b983d 100644 (file)
@@ -73,6 +73,17 @@ AlarmList_StickyAckMenutTitle=Sticky acknowledge for
 AlarmList_SyncJobError=No es posible sincronizar la lista de alarmas
 AlarmList_SyncJobName=Sincronizar la lista de alarmas
 AlarmList_Terminate=&Terminar
+AlarmMelody_ErrorGettingMelodyList=Not possible to get melody list.
+AlarmMelody_ErrorGettingMelodyListDescription=Not possible to get melody list. Error:
+AlarmMelody_ErrorMelodyNotExists=Melody does not exist.
+AlarmMelody_ErrorMelodyNotExistsDescription=Melody was not found locally and it was not possible to download it from server. Melody is removed and will not be played. Error:
+AlarmMelody_JobGetMelodyList=Get melody list
+AlarmMelody_SaveClientSelection=Save client selection
+AlarmNotifier_ErrorMelodyNotExistsDescription=Melody was not found locally and it was not possible to download it from server. Melody is removed and will not be played. Error:
+AlarmNotifier_ErrorMelodynotExists=Melody does not exist.
+AlarmNotifier_ErrorPlayingSound=Was not possible to play sound
+AlarmNotifier_ErrorPlayingSoundDescription=Error while playing sound. Melody will not be played. Error:
+AlarmNotifier_JobSoundNotFoundError=Send error that sound file is not found
 AlarmNotifier_ToolTip_Header=Alarma NetXMS (
 AlarmReminderDialog_Dismiss=Descartar
 AlarmReminderDialog_OutstandingAlarms=Alarmas Destacadas
index 050caf5..211a645 100644 (file)
@@ -73,6 +73,17 @@ AlarmList_StickyAckMenutTitle=Sticky acknowledge for
 AlarmList_SyncJobError=\u041d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0442\u0440\u0435\u0432\u043e\u0433
 AlarmList_SyncJobName=\u0421\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0442\u0440\u0435\u0432\u043e\u0433
 AlarmList_Terminate=&\u041f\u0440\u0435\u043a\u0440\u0430\u0442\u0438\u0442\u044c
+AlarmMelody_ErrorGettingMelodyList=Not possible to get melody list.
+AlarmMelody_ErrorGettingMelodyListDescription=Not possible to get melody list. Error:
+AlarmMelody_ErrorMelodyNotExists=Melody does not exist.
+AlarmMelody_ErrorMelodyNotExistsDescription=Melody was not found locally and it was not possible to download it from server. Melody is removed and will not be played. Error:
+AlarmMelody_JobGetMelodyList=Get melody list
+AlarmMelody_SaveClientSelection=Save client selection
+AlarmNotifier_ErrorMelodyNotExistsDescription=Melody was not found locally and it was not possible to download it from server. Melody is removed and will not be played. Error:
+AlarmNotifier_ErrorMelodynotExists=Melody does not exist.
+AlarmNotifier_ErrorPlayingSound=Was not possible to play sound
+AlarmNotifier_ErrorPlayingSoundDescription=Error while playing sound. Melody will not be played. Error:
+AlarmNotifier_JobSoundNotFoundError=Send error that sound file is not found
 AlarmNotifier_ToolTip_Header=\u0422\u0440\u0435\u0432\u043e\u0433\u0430 NetXMS (
 AlarmReminderDialog_Dismiss=\u041e\u0442\u043a\u043b\u043e\u043d\u0438\u0442\u044c
 AlarmReminderDialog_OutstandingAlarms=\u041d\u0435\u0440\u0435\u0448\u0435\u043d\u043d\u044b\u0435 \u0442\u0440\u0435\u0432\u043e\u0433\u0438
index 5c3df2f..11ce3da 100644 (file)
@@ -73,6 +73,17 @@ AlarmList_StickyAckMenutTitle=Sticky acknowledge for
 AlarmList_SyncJobError=\u65e0\u6cd5\u540c\u6b65\u544a\u8b66\u5217\u8868
 AlarmList_SyncJobName=\u540c\u6b65\u544a\u8b66\u5217\u8868
 AlarmList_Terminate=&Terminate
+AlarmMelody_ErrorGettingMelodyList=Not possible to get melody list.
+AlarmMelody_ErrorGettingMelodyListDescription=Not possible to get melody list. Error:
+AlarmMelody_ErrorMelodyNotExists=Melody does not exist.
+AlarmMelody_ErrorMelodyNotExistsDescription=Melody was not found locally and it was not possible to download it from server. Melody is removed and will not be played. Error:
+AlarmMelody_JobGetMelodyList=Get melody list
+AlarmMelody_SaveClientSelection=Save client selection
+AlarmNotifier_ErrorMelodyNotExistsDescription=Melody was not found locally and it was not possible to download it from server. Melody is removed and will not be played. Error:
+AlarmNotifier_ErrorMelodynotExists=Melody does not exist.
+AlarmNotifier_ErrorPlayingSound=Was not possible to play sound
+AlarmNotifier_ErrorPlayingSoundDescription=Error while playing sound. Melody will not be played. Error:
+AlarmNotifier_JobSoundNotFoundError=Send error that sound file is not found
 AlarmNotifier_ToolTip_Header=\u7f51\u7edc\u7ba1\u7406\u7cfb\u7edf\u544a\u8b66 (
 AlarmReminderDialog_Dismiss=Dismiss
 AlarmReminderDialog_OutstandingAlarms=Outstanding Alarms
diff --git a/src/java/netxms-eclipse/AlarmViewer/src/org/netxms/ui/eclipse/alarmviewer/preferencepages/AlarmMelody.java b/src/java/netxms-eclipse/AlarmViewer/src/org/netxms/ui/eclipse/alarmviewer/preferencepages/AlarmMelody.java
new file mode 100755 (executable)
index 0000000..6a2cd4b
--- /dev/null
@@ -0,0 +1,291 @@
+/**
+ * NetXMS - open source network management system
+ * Copyright (C) 2003-2013 Victor Kirhenshtein
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.netxms.ui.eclipse.alarmviewer.preferencepages;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.nio.channels.FileChannel;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.progress.UIJob;
+import org.netxms.client.NXCException;
+import org.netxms.client.NXCSession;
+import org.netxms.client.ServerFile;
+import org.netxms.ui.eclipse.alarmviewer.Activator;
+import org.netxms.ui.eclipse.alarmviewer.AlarmNotifier;
+import org.netxms.ui.eclipse.alarmviewer.Messages;
+import org.netxms.ui.eclipse.console.resources.StatusDisplayInfo;
+import org.netxms.ui.eclipse.shared.ConsoleSharedData;
+import org.netxms.ui.eclipse.tools.MessageDialogHelper;
+import org.netxms.ui.eclipse.tools.WidgetHelper;
+
+/**
+ * Alarm melody
+ */
+public class AlarmMelody extends PreferencePage implements IWorkbenchPreferencePage
+{
+   public static final String ID = "org.netxms.ui.eclipse.alarmviewer.views.AlarmMelodyView"; //$NON-NLS-1$
+
+   private NXCSession session;
+   private ServerFile[] serverFiles = null;
+   private IPreferenceStore ps;
+   private URL workspaceUrl;
+   private Set<String> melodyList = new HashSet<String>();
+   private List<String> currentMelodyList = new ArrayList<String>();
+   private Set<String> oldMelodyList = new HashSet<String>();
+   private List<String> newMelodyList = new ArrayList<String>();
+   private List<Combo> comboList = new ArrayList<Combo>();
+   private String[] severityArray = AlarmNotifier.severityArray;
+   /*
+    * (non-Javadoc)
+    * 
+    * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+    */
+   @Override
+   public void init(IWorkbench workbench)
+   {
+      setPreferenceStore(Activator.getDefault().getPreferenceStore());
+      session = (NXCSession)ConsoleSharedData.getSession();
+      ps = Activator.getDefault().getPreferenceStore();
+      workspaceUrl = Platform.getInstanceLocation().getURL();
+   }
+
+   /*
+    * (non-Javadoc)
+    * 
+    * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
+    */
+   @Override
+   protected Control createContents(Composite parent)
+   {
+      Composite dialogArea = new Composite(parent, SWT.NONE);
+      GridLayout layout = new GridLayout();
+      layout.verticalSpacing = WidgetHelper.DIALOG_SPACING;
+      layout.horizontalSpacing = WidgetHelper.DIALOG_SPACING;
+      layout.numColumns = 1;
+      layout.makeColumnsEqualWidth = true;
+      dialogArea.setLayout(layout);
+
+      Combo newCombo = null;
+
+      for(int i = 0; i < 5; i++)
+      {
+         newCombo = WidgetHelper.createLabeledCombo(dialogArea, SWT.DROP_DOWN | SWT.READ_ONLY, StatusDisplayInfo.getStatusText(i),
+               WidgetHelper.DEFAULT_LAYOUT_DATA);
+         newCombo.setEnabled(false);
+         comboList.add(i, newCombo);
+      }
+
+      new UIJob(Messages.get().AlarmMelody_JobGetMelodyList) {
+         @Override
+         public IStatus runInUIThread(IProgressMonitor monitor)
+         {
+            try
+            {
+               String[] s = { "wav" }; //$NON-NLS-1$
+               serverFiles = session.listServerFiles(s);
+            }
+            catch(final Exception e)
+            {
+               e.printStackTrace();
+               getShell().getDisplay().asyncExec(new Runnable() {
+                  @Override
+                  public void run()
+                  {
+                     MessageDialogHelper.openError(getShell(), Messages.get().AlarmMelody_ErrorGettingMelodyList,
+                           Messages.get().AlarmMelody_ErrorGettingMelodyListDescription + e.getMessage());
+                  }
+               });
+            }
+
+            for(ServerFile s : serverFiles)
+            {
+               melodyList.add(s.getName());
+            }
+            melodyList.add(""); //$NON-NLS-1$
+
+            for(int i = 0; i < 5; i++)
+            {
+               currentMelodyList.add(i, ps.getString("ALARM_NOTIFIER.MELODY." + severityArray[i])); //$NON-NLS-1$
+            }
+            melodyList.addAll(currentMelodyList);
+
+            Combo newCombo = null;
+
+            for(int i = 0; i < 5; i++)
+            {
+               newCombo = comboList.get(i);
+               newCombo.setEnabled(true);
+               newCombo.setItems(melodyList.toArray(new String[melodyList.size()]));
+               newCombo.select(newCombo.indexOf(currentMelodyList.get(i)));
+            }
+
+            return Status.OK_STATUS;
+         }
+      }.schedule();
+      return dialogArea;
+   }
+
+   /**
+    * Apply changes
+    * 
+    * @param isApply true if update operation caused by "Apply" button
+    */
+   protected void applyChanges(final boolean isApply)
+   {
+      if (isApply)
+         setValid(false);
+
+      for(int i = 0; i < 5; i++)
+      {
+         newMelodyList.add(comboList.get(i).getText());
+      }
+      new UIJob(Messages.get().AlarmMelody_SaveClientSelection) {
+         @Override
+         public IStatus runInUIThread(IProgressMonitor monitor)
+         {
+            for(int i = 0; i < 5; i++)
+            {
+               changeMelody(newMelodyList.get(i), severityArray[i], i);
+            }
+            for(String oldName : oldMelodyList)
+            {
+               if (!currentMelodyList.contains(oldName))
+               {
+                  File file = new File(workspaceUrl.getPath(), oldName);
+                  file.delete();
+               }
+            }
+            if (isApply)
+               setValid(true);
+            return Status.OK_STATUS;
+         }
+
+      }.schedule();
+   }
+
+   private void changeMelody(final String melodyName, final String severity, final int id)
+   {
+      String oldMelodyName = currentMelodyList.get(id);
+      if (!melodyName.equals(oldMelodyName))
+      {
+         try
+         {
+            if (!checkMelodyExists(melodyName, workspaceUrl))
+               downloadMelodie(session, melodyName, workspaceUrl);
+            ps.setValue("ALARM_NOTIFIER.MELODY." + severity, melodyName); //$NON-NLS-1$
+            currentMelodyList.set(id, melodyName);
+            oldMelodyList.add(oldMelodyName);
+         }
+         catch(NXCException | IOException e)
+         {
+            getShell().getDisplay().asyncExec(new Runnable() {
+               @Override
+               public void run()
+               {
+                  MessageDialogHelper
+                        .openError(
+                              getShell(),
+                              Messages.get().AlarmMelody_ErrorMelodyNotExists,
+                              Messages.get().AlarmMelody_ErrorMelodyNotExistsDescription
+                                    + e.getMessage());
+               }
+            });
+            ps.setValue("ALARM_NOTIFIER.MELODY." + severity, ""); //$NON-NLS-1$ //$NON-NLS-2$
+         }
+      }
+   }
+
+   private static boolean checkMelodyExists(String melodyName, URL workspaceUrl)
+   {
+      if (workspaceUrl != null && melodyName != null && !melodyName.equals("")) //$NON-NLS-1$
+      {
+         File f = new File(workspaceUrl.getPath(), melodyName);
+         return f.isFile();
+      }
+      else
+      {
+         return true;
+      }
+   }
+
+   private static void downloadMelodie(NXCSession session, String melodyName, URL workspaceUrl) throws NXCException, IOException
+   {
+      File f = new File(workspaceUrl.getPath(), melodyName);
+      f.createNewFile();
+      FileChannel src = null;
+      FileChannel dest = null;
+      try
+      {
+         src = new FileInputStream(session.downloadFileFromServer(melodyName)).getChannel();
+         dest = new FileOutputStream(f).getChannel();
+         dest.transferFrom(src, 0, src.size());
+      }
+      catch(NXCException | IOException e)
+      {
+         System.out.println("Not possible to copy inside new file content."); //$NON-NLS-1$
+      }
+      finally
+      {
+         src.close();
+         dest.close();
+      }
+   }
+
+   /*
+    * (non-Javadoc)
+    * 
+    * @see org.eclipse.jface.preference.PreferencePage#performOk()
+    */
+   @Override
+   public boolean performOk()
+   {
+      applyChanges(false);
+      return true;
+   }
+
+   /*
+    * (non-Javadoc)
+    * 
+    * @see org.eclipse.jface.preference.PreferencePage#performApply()
+    */
+   @Override
+   protected void performApply()
+   {
+      applyChanges(true);
+   }
+}
index 63c9d42..44fe1c9 100644 (file)
@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
-       <classpathentry exported="true" kind="lib" path="jar/certificate-manager-1.2.12.jar"/>
-       <classpathentry exported="true" kind="lib" path="jar/netxms-base-1.2.12.jar"/>
-       <classpathentry exported="true" kind="lib" path="jar/netxms-client-1.2.12.jar" sourcepath="/netxms-client"/>
-       <classpathentry exported="true" kind="lib" path="jar/netxms-client-api-1.2.12.jar"/>
+       <classpathentry exported="true" kind="lib" path="jar/certificate-manager-1.2.13.jar"/>
+       <classpathentry exported="true" kind="lib" path="jar/netxms-base-1.2.13.jar"/>
+       <classpathentry exported="true" kind="lib" path="jar/netxms-client-1.2.13.jar"/>
+       <classpathentry exported="true" kind="lib" path="jar/netxms-client-api-1.2.13.jar"/>
        <classpathentry exported="true" kind="lib" path="jar/simple-xml-2.6.4.jar"/>
        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
        <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
index 6ee4198..b1896cb 100644 (file)
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: %Bundle-Name
 Bundle-SymbolicName: org.netxms.ui.eclipse.console;singleton:=true
-Bundle-Version: 1.2.12
+Bundle-Version: 1.2.13
 Bundle-Activator: org.netxms.ui.eclipse.console.Activator
 Bundle-Vendor: netxms.org
 Require-Bundle: org.eclipse.ui;bundle-version="3.7.0",
@@ -14,10 +14,10 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Bundle-ActivationPolicy: lazy
 Bundle-ClassPath: .,
  jar/simple-xml-2.6.4.jar,
- jar/certificate-manager-1.2.12.jar,
- jar/netxms-base-1.2.12.jar,
- jar/netxms-client-1.2.12.jar,
- jar/netxms-client-api-1.2.12.jar
+ jar/certificate-manager-1.2.13.jar,
+ jar/netxms-base-1.2.13.jar,
+ jar/netxms-client-1.2.13.jar,
+ jar/netxms-client-api-1.2.13.jar
 Export-Package: org.netxms.api.client,
  org.netxms.api.client.constants,
  org.netxms.api.client.images,
index 23d5218..d0725c1 100644 (file)
@@ -8,8 +8,8 @@ bin.includes = plugin.xml,\
                splash.bmp,\
                jar/,\
                OSGI-INF/,\
-               jar/certificate-manager-1.2.12.jar,\
-               jar/netxms-base-1.2.12.jar,\
-               jar/netxms-client-1.2.12.jar,\
-               jar/netxms-client-api-1.2.12.jar
+               jar/certificate-manager-1.2.13.jar,\
+               jar/netxms-base-1.2.13.jar,\
+               jar/netxms-client-1.2.13.jar,\
+               jar/netxms-client-api-1.2.13.jar
 jars.compile.order = .
index 73f4503..600840b 100644 (file)
@@ -71,7 +71,7 @@ public class ExportToCsvAction extends Action
                // "Object Details" view can contain multiple widgets
                // with "Export to CSV" action defined, so binding it to handler service
                // will cause handler conflict
-               if (viewPart.getViewSite().getId().equals("org.netxms.ui.eclipse.objectview.view.tabbed_object_view")) //$NON-NLS-1$
+               if ((viewPart == null) || viewPart.getViewSite().getId().equals("org.netxms.ui.eclipse.objectview.view.tabbed_object_view")) //$NON-NLS-1$
                        return;
                
                final IHandlerService handlerService = (IHandlerService)viewPart.getSite().getService(IHandlerService.class);
index c04e823..202a1d3 100644 (file)
@@ -52,6 +52,7 @@ import org.netxms.ui.eclipse.console.dialogs.PasswordExpiredDialog;
 import org.netxms.ui.eclipse.console.dialogs.PasswordRequestDialog;
 import org.netxms.ui.eclipse.console.dialogs.SecurityWarningDialog;
 import org.netxms.ui.eclipse.console.resources.RegionalSettings;
+import org.netxms.ui.eclipse.jobs.LoginJob;
 import org.netxms.ui.eclipse.shared.ConsoleSharedData;
 
 /**
index 2b427d6..60fde10 100644 (file)
@@ -61,11 +61,11 @@ public class TweakletManager
        
        /**
         * Call postLogin() method for all tweaklets. This method called from login thread,
-        * why UI is blocked in wait dialog.
+        * while UI is blocked in wait dialog.
         * 
         * @param monitor
         */
-       static void postLogin(NXCSession session)
+       public static void postLogin(NXCSession session)
        {
                for(ConsoleTweaklet t : tweaklets)
                        t.postLogin(session);
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-package org.netxms.ui.eclipse.console;
+package org.netxms.ui.eclipse.jobs;
 
 import java.lang.reflect.InvocationTargetException;
 import java.security.Signature;
@@ -31,6 +31,8 @@ import org.eclipse.swt.widgets.Display;
 import org.netxms.api.client.Session;
 import org.netxms.base.NXCommon;
 import org.netxms.client.NXCSession;
+import org.netxms.ui.eclipse.console.Messages;
+import org.netxms.ui.eclipse.console.TweakletManager;
 import org.netxms.ui.eclipse.console.api.ConsoleLoginListener;
 import org.netxms.ui.eclipse.console.api.SessionProvider;
 import org.netxms.ui.eclipse.shared.ConsoleSharedData;
@@ -40,24 +42,6 @@ import org.netxms.ui.eclipse.shared.ConsoleSharedData;
  */
 public class LoginJob implements IRunnableWithProgress
 {
-   private final class KeepAliveHelper implements Runnable
-   {
-      @Override
-      public void run()
-      {
-         final Session session = ConsoleSharedData.getSession();
-         try
-         {
-            session.checkConnection();
-            Thread.sleep(1000 * 30); // send keepalive every 30 seconds
-         }
-         catch(Exception e)
-         {
-            // ignore everything
-         }
-      }
-   }
-
    private Display display;
    private String server;
    private String loginName;
@@ -159,8 +143,8 @@ public class LoginJob implements IRunnableWithProgress
          callLoginListeners(session);
          monitor.worked(1);
 
-         Runnable keepAliveTimer = new KeepAliveHelper();
-         final Thread thread = new Thread(keepAliveTimer);
+         Runnable keepAliveTimer = new KeepAliveTimer();
+         final Thread thread = new Thread(null, keepAliveTimer, "KeepAliveTimer");
          thread.setDaemon(true);
          thread.start();
       }
@@ -171,6 +155,7 @@ public class LoginJob implements IRunnableWithProgress
       finally
       {
          monitor.setTaskName(""); //$NON-NLS-1$
+         monitor.done();
       }
    }
 
@@ -274,4 +259,28 @@ public class LoginJob implements IRunnableWithProgress
       this.signature = signature;
       authMethod = NXCSession.AUTH_TYPE_CERTIFICATE;
    }
+
+   /**
+    * Keep-alive timer
+    */
+   private final class KeepAliveTimer implements Runnable
+   {
+      @Override
+      public void run()
+      {
+         while(true)
+         {
+            final Session session = ConsoleSharedData.getSession();
+            try
+            {
+               Thread.sleep(1000 * 60); // send keep-alive every 60 seconds
+               if (!session.checkConnection())
+                  break;   // session broken, application will exit (handled by workbench advisor)
+            }
+            catch(Exception e)
+            {
+            }
+         }
+      }
+   }
 }
index a59afd8..64d6275 100644 (file)
@@ -20,4 +20,5 @@ Require-Bundle: org.eclipse.ui;bundle-version="3.7.0",
  org.netxms.ui.eclipse.objectview;bundle-version="1.2.10"
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Bundle-ActivationPolicy: lazy
-Export-Package: org.netxms.ui.eclipse.dashboard.api
+Export-Package: org.netxms.ui.eclipse.dashboard.api,
+ org.netxms.ui.eclipse.dashboard.widgets
index 9969e4c..8722c46 100644 (file)
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: Data Collection Management Plug-in
 Bundle-SymbolicName: org.netxms.ui.eclipse.datacollection;singleton:=true
-Bundle-Version: 1.2.11
+Bundle-Version: 1.2.13
 Bundle-Activator: org.netxms.ui.eclipse.datacollection.Activator
 Bundle-Vendor: netxms.org
 Require-Bundle: org.eclipse.ui;bundle-version="3.7.0",
@@ -12,7 +12,7 @@ Require-Bundle: org.eclipse.ui;bundle-version="3.7.0",
  org.netxms.ui.eclipse.objectview;bundle-version="1.2.10",
  org.netxms.ui.eclipse.snmp;bundle-version="1.2.10",
  org.netxms.ui.eclipse.nxsl;bundle-version="1.2.10",
- org.netxms.ui.eclipse.console;bundle-version="1.2.11",
+ org.netxms.ui.eclipse.console;bundle-version="1.2.13",
  org.eclipse.core.expressions;bundle-version="3.4.300",
  org.netxms.ui.eclipse.charts;bundle-version="1.2.11",
  org.eclipse.ui.forms;bundle-version="3.5.101"
index 4c37b50..f0eca6f 100644 (file)
@@ -2,12 +2,12 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: NXMC Image Library Plugin
 Bundle-SymbolicName: org.netxms.ui.eclipse.imagelibrary;singleton:=true
-Bundle-Version: 1.2.10
+Bundle-Version: 1.2.13
 Bundle-Activator: org.netxms.ui.eclipse.imagelibrary.Activator
 Bundle-Vendor: netxms.org
 Require-Bundle: org.eclipse.ui;bundle-version="3.7.0",
  org.eclipse.core.runtime;bundle-version="3.7.0",
- org.netxms.ui.eclipse.console;bundle-version="1.2.10",
+ org.netxms.ui.eclipse.console;bundle-version="1.2.13",
  org.netxms.nebula.widgets.gallery;bundle-version="0.5.3"
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Bundle-ActivationPolicy: lazy
index da700bc..b3e5df3 100644 (file)
@@ -2,14 +2,14 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: NXMC Object Tools plugin
 Bundle-SymbolicName: org.netxms.ui.eclipse.objecttools;singleton:=true
-Bundle-Version: 1.2.12
+Bundle-Version: 1.2.13
 Bundle-Activator: org.netxms.ui.eclipse.objecttools.Activator
 Bundle-Vendor: netxms.org
 Require-Bundle: org.eclipse.ui;bundle-version="3.7.0",
  org.eclipse.core.runtime;bundle-version="3.7.0",
  org.eclipse.core.expressions;bundle-version="3.4.300",
  org.eclipse.ui.console;bundle-version="3.5.100",
- org.netxms.ui.eclipse.console;bundle-version="1.2.10",
+ org.netxms.ui.eclipse.console;bundle-version="1.2.13",
  org.netxms.ui.eclipse.usermanager;bundle-version="1.2.7",
  org.netxms.ui.eclipse.snmp;bundle-version="1.2.10",
  org.eclipse.ui.workbench.texteditor;bundle-version="3.7.0",
index 7d76778..d232339 100644 (file)
@@ -1,6 +1,6 @@
 /**
  * NetXMS - open source network management system
- * Copyright (C) 2003-2013 Victor Kirhenshtein
+ * Copyright (C) 2003-2014 Victor Kirhenshtein
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
index 9cc52ae..a221244 100644 (file)
@@ -1,6 +1,6 @@
 /**
  * NetXMS - open source network management system
- * Copyright (C) 2003-2013 Victor Kirhenshtein
+ * Copyright (C) 2003-2014 Victor Kirhenshtein
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -18,7 +18,6 @@
  */
 package org.netxms.ui.eclipse.objecttools;
 
-import java.io.File;
 import java.io.IOException;
 import java.net.URLEncoder;
 import java.util.Arrays;
@@ -44,6 +43,7 @@ import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.menus.IWorkbenchContribution;
 import org.eclipse.ui.services.IEvaluationService;
 import org.eclipse.ui.services.IServiceLocator;
+import org.netxms.client.AgentFile;
 import org.netxms.client.NXCSession;
 import org.netxms.client.events.Alarm;
 import org.netxms.client.objects.AbstractNode;
@@ -463,7 +463,7 @@ public class ObjectToolsDynamicMenu extends ContributionItem implements IWorkben
                        @Override
                        protected void runInternal(IProgressMonitor monitor) throws Exception
                        {
-                               final File file = session.downloadFileFromAgent(node.getObjectId(), fileName, maxFileSize, follow); 
+            final AgentFile file = session.downloadFileFromAgent(node.getObjectId(), fileName, maxFileSize, follow);
                                runInUIThread(new Runnable() {
                                        @Override
                                        public void run()
@@ -472,8 +472,9 @@ public class ObjectToolsDynamicMenu extends ContributionItem implements IWorkben
                                                try
                                                {
                                                        String secondaryId = Long.toString(node.getObjectId()) + "&" + URLEncoder.encode(fileName, "UTF-8"); //$NON-NLS-1$ //$NON-NLS-2$
-                                                       FileViewer view = (FileViewer)window.getActivePage().showView(FileViewer.ID, secondaryId, IWorkbenchPage.VIEW_ACTIVATE);
-                                                       view.showFile(file, follow);
+                     FileViewer view = (FileViewer)window.getActivePage().showView(FileViewer.ID, secondaryId,
+                           IWorkbenchPage.VIEW_ACTIVATE);
+                     view.showFile(file.getFile(), follow, file.getId());
                                                }
                                                catch(Exception e)
                                                {
index 8a1798d..f52b4b3 100644 (file)
@@ -62,6 +62,7 @@ public class FileViewer extends ViewPart
        
        private long nodeId;
        private String remoteFileName;
+   private String fileID;
        private File currentFile;
        private StyledText textViewer;
        private final NXCSession session = (NXCSession)ConsoleSharedData.getSession();
@@ -271,9 +272,10 @@ public class FileViewer extends ViewPart
        /**
         * @param file
         */
-       public void showFile(File file, boolean follow)
+   public void showFile(File file, boolean follow, String id)
        {
                currentFile = file;
+      fileID = id;
                textViewer.setText(loadFile(currentFile));
        textViewer.setTopIndex(textViewer.getLineCount());
                this.follow = follow;
@@ -293,7 +295,7 @@ public class FileViewer extends ViewPart
             {
                while(continueWork)
                {
-                  final String s = session.waitForFileTail(remoteFileName, 3000);
+                  final String s = session.waitForFileTail(fileID, 3000);
                   if (s != null)
                   {
                      runInUIThread(new Runnable() {                  
@@ -339,7 +341,7 @@ public class FileViewer extends ViewPart
             @Override
             protected void runInternal(IProgressMonitor monitor) throws Exception
             {
-               session.cancelFileMonitoring(nodeId, remoteFileName);
+               session.cancelFileMonitoring(nodeId, fileID);
             }
             
             @Override
index efa8e9b..9e2deef 100644 (file)
@@ -2,16 +2,17 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: Performance View Plug-in for NXMC
 Bundle-SymbolicName: org.netxms.ui.eclipse.perfview;singleton:=true
-Bundle-Version: 1.2.11
+Bundle-Version: 1.2.13
 Bundle-Activator: org.netxms.ui.eclipse.perfview.Activator
 Bundle-Vendor: netxms.org
 Require-Bundle: org.eclipse.ui;bundle-version="3.7.0",
  org.eclipse.core.runtime;bundle-version="3.7.0",
- org.netxms.ui.eclipse.console;bundle-version="1.2.11",
+ org.netxms.ui.eclipse.console;bundle-version="1.2.13",
  org.netxms.ui.eclipse.charts;bundle-version="1.2.11",
  org.netxms.ui.eclipse.objectview;bundle-version="1.2.10",
  org.netxms.ui.eclipse.datacollection;bundle-version="1.2.11",
  org.netxms.ui.eclipse.usermanager;bundle-version="1.2.10"
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Bundle-ActivationPolicy: lazy
-Export-Package: org.netxms.ui.eclipse.perfview.widgets
+Export-Package: org.netxms.ui.eclipse.perfview.views.helpers,
+ org.netxms.ui.eclipse.perfview.widgets
index 862f054..14db78f 100644 (file)
@@ -3,7 +3,7 @@
 
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.netxms</groupId>
-  <version>1.2.12</version>
+  <version>1.2.13</version>
   <artifactId>netxms</artifactId>
   <packaging>pom</packaging>
   <name>NetXMS Meta-package</name>
index d6bc169..0869482 100644 (file)
@@ -29,7 +29,7 @@
 static void (* s_fpWriteLog)(int, int, const TCHAR *) = NULL;
 static void (* s_fpSendTrap1)(UINT32, const TCHAR *, const char *, va_list) = NULL;
 static void (* s_fpSendTrap2)(UINT32, const TCHAR *, int, TCHAR **) = NULL;
-static bool (* s_fpSendFile)(void *, UINT32, const TCHAR *, long, long) = NULL;
+static bool (* s_fpSendFile)(void *, UINT32, const TCHAR *, long) = NULL;
 static bool (* s_fpPushData)(const TCHAR *, const TCHAR *, UINT32) = NULL;
 
 /**
@@ -38,7 +38,7 @@ static bool (* s_fpPushData)(const TCHAR *, const TCHAR *, UINT32) = NULL;
 void LIBNETXMS_EXPORTABLE InitSubAgentAPI(void (* writeLog)(int, int, const TCHAR *),
                                                                                                                void (* sendTrap1)(UINT32, const TCHAR *, const char *, va_list),
                                                                                                                void (* sendTrap2)(UINT32, const TCHAR *, int, TCHAR **),
-                                                                                                               bool (* sendFile)(void *, UINT32, const TCHAR *, long, long),
+                                                                                                               bool (* sendFile)(void *, UINT32, const TCHAR *, long),
                                                                                                                bool (* pushData)(const TCHAR *, const TCHAR *, UINT32))
 {
    s_fpWriteLog = writeLog;
@@ -251,11 +251,11 @@ BOOL LIBNETXMS_EXPORTABLE AgentGetParameterArgW(const TCHAR *param, int index, W
 /**
  * Send file to server
  */
-BOOL LIBNETXMS_EXPORTABLE AgentSendFileToServer(void *session, UINT32 requestId, const TCHAR *file, long offset, long sizeLimit)
+BOOL LIBNETXMS_EXPORTABLE AgentSendFileToServer(void *session, UINT32 requestId, const TCHAR *file, long offset)
 {
        if ((s_fpSendFile == NULL) || (session == NULL) || (file == NULL))
                return FALSE;
-       return s_fpSendFile(session, requestId, file, offset, sizeLimit);
+       return s_fpSendFile(session, requestId, file, offset);
 }
 
 /**
index 02973a4..b9a775d 100644 (file)
@@ -279,7 +279,7 @@ TCHAR LIBNETXMS_EXPORTABLE *NXCPMessageCodeName(WORD wCode, TCHAR *pszBuffer)
                _T("CMD_DELETE_IMAGE"),
                _T("CMD_MODIFY_IMAGE"),
                _T("CMD_LIST_IMAGES"),
-               _T("CMD_UPLOAD_FILE_TO_AGENT"),
+               _T("CMD_LIST_SERVER_FILES"),
                _T("CMD_GET_TABLE"),
                _T("CMD_QUERY_TABLE"),
                _T("CMD_OPEN_CONSOLE"),
@@ -538,7 +538,7 @@ CSCP_MESSAGE LIBNETXMS_EXPORTABLE *CreateRawNXCPMessage(WORD wCode, UINT32 dwId,
  * Send file over CSCP
  */
 BOOL LIBNETXMS_EXPORTABLE SendFileOverNXCP(SOCKET hSocket, UINT32 dwId, const TCHAR *pszFile,
-                                           NXCPEncryptionContext *pCtx, long offset, long sizeLimit,
+                                           NXCPEncryptionContext *pCtx, long offset,
                                                                                                                 void (* progressCallback)(INT64, void *), void *cbArg,
                                                                                                                 MUTEX mutex)
 {
@@ -555,14 +555,11 @@ BOOL LIBNETXMS_EXPORTABLE SendFileOverNXCP(SOCKET hSocket, UINT32 dwId, const TC
       NX_STAT_STRUCT st;
       NX_FSTAT(hFile, &st);
       long fileSize = (long)st.st_size;
-      long bytesToRead = (fileSize - offset) > fileSize ? (0 - offset) : (fileSize - offset);
+      if (labs(offset) > fileSize)
+         offset = 0;
+      long bytesToRead = (offset < 0) ? (0 - offset) : (fileSize - offset);
 
-      if (sizeLimit > 0)
-      {
-         offset = bytesToRead > sizeLimit ?  -sizeLimit : offset;
-      }
-
-               if (lseek(hFile, offset, offset < 0 ? SEEK_END : SEEK_SET) != -1)
+               if (lseek(hFile, offset, (offset < 0) ? SEEK_END : SEEK_SET) != -1)
                {
                        // Allocate message and prepare it's header
                        pMsg = (CSCP_MESSAGE *)malloc(FILE_BUFFER_SIZE + CSCP_HEADER_SIZE + 8);
index d67b7b3..5814a18 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
 ** NetXMS - Network Management System
 ** Client Library
 ** Copyright (C) 2003-2013 Victor Kirhenshtein
@@ -190,7 +190,7 @@ public:
    CSCP_MESSAGE *WaitForRawMessage(WORD wCode, UINT32 dwId, UINT32 dwTimeOut = 0);
    UINT32 WaitForRCC(UINT32 dwRqId, UINT32 dwTimeOut = 0);
    UINT32 CreateRqId(void) { return m_dwMsgId++; }
-   UINT32 SendFile(UINT32 dwRqId, TCHAR *pszFileName, long sizeLimit);
+   UINT32 SendFile(UINT32 dwRqId, TCHAR *pszFileName, long offset);
    UINT32 SimpleCommand(WORD wCmd);
 
    void callEventHandler(UINT32 dwEvent, UINT32 dwCode, void *pArg);
index d6772ba..873eb77 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
 ** NetXMS - Network Management System
 ** Client Library
 ** Copyright (C) 2003-2011 Victor Kirhenshtein
@@ -194,7 +194,7 @@ CSCPMessage *NXCL_Session::WaitForMessage(WORD wCode, UINT32 dwId, UINT32 dwTime
 {
    if (m_dwFlags & NXC_SF_CONN_BROKEN)
       return NULL;
-   return m_msgWaitQueue.waitForMessage(wCode, dwId, 
+   return m_msgWaitQueue.waitForMessage(wCode, dwId,
       dwTimeOut == 0 ? m_dwCommandTimeout : dwTimeOut);
 }
 
@@ -207,7 +207,7 @@ CSCP_MESSAGE *NXCL_Session::WaitForRawMessage(WORD wCode, UINT32 dwId, UINT32 dw
 {
    if (m_dwFlags & NXC_SF_CONN_BROKEN)
       return NULL;
-   return m_msgWaitQueue.waitForRawMessage(wCode, dwId, 
+   return m_msgWaitQueue.waitForRawMessage(wCode, dwId,
       dwTimeOut == 0 ? m_dwCommandTimeout : dwTimeOut);
 }
 
@@ -394,7 +394,7 @@ void NXCL_Session::processDCI(CSCPMessage *pMsg)
 
       i = m_pItemList->dwNumItems;
       m_pItemList->dwNumItems++;
-      m_pItemList->pItems = (NXC_DCI *)realloc(m_pItemList->pItems, 
+      m_pItemList->pItems = (NXC_DCI *)realloc(m_pItemList->pItems,
                                     sizeof(NXC_DCI) * m_pItemList->dwNumItems);
       m_pItemList->pItems[i].dwId = pMsg->GetVariableLong(VID_DCI_ID);
       m_pItemList->pItems[i].dwTemplateId = pMsg->GetVariableLong(VID_TEMPLATE_ID);
@@ -423,7 +423,7 @@ void NXCL_Session::processDCI(CSCPMessage *pMsg)
       for(j = 0, dwId = VID_DCI_SCHEDULE_BASE; j < m_pItemList->pItems[i].dwNumSchedules; j++, dwId++)
          m_pItemList->pItems[i].ppScheduleList[j] = pMsg->GetVariableStr(dwId);
       m_pItemList->pItems[i].dwNumThresholds = pMsg->GetVariableLong(VID_NUM_THRESHOLDS);
-      m_pItemList->pItems[i].pThresholdList = 
+      m_pItemList->pItems[i].pThresholdList =
          (NXC_DCI_THRESHOLD *)malloc(sizeof(NXC_DCI_THRESHOLD) * m_pItemList->pItems[i].dwNumThresholds);
       for(j = 0, dwId = VID_DCI_THRESHOLD_BASE; j < m_pItemList->pItems[i].dwNumThresholds; j++, dwId++)
       {
@@ -554,7 +554,7 @@ void NXCL_Session::DeleteEDBRecord(UINT32 dwEventCode)
          safe_free(m_ppEventTemplates[i]->pszDescription);
          safe_free(m_ppEventTemplates[i]->pszMessage);
          free(m_ppEventTemplates[i]);
-         memmove(&m_ppEventTemplates[i], m_ppEventTemplates[i + 1], 
+         memmove(&m_ppEventTemplates[i], m_ppEventTemplates[i + 1],
                  sizeof(NXC_EVENT_TEMPLATE *) * (m_dwNumTemplates - i));
          break;
       }
@@ -570,7 +570,7 @@ void NXCL_Session::AddEventTemplate(NXC_EVENT_TEMPLATE *pEventTemplate, BOOL bLo
 {
    if (bLock)
       MutexLock(m_mutexEventAccess);
-   m_ppEventTemplates = (NXC_EVENT_TEMPLATE **)realloc(m_ppEventTemplates, 
+   m_ppEventTemplates = (NXC_EVENT_TEMPLATE **)realloc(m_ppEventTemplates,
       sizeof(NXC_EVENT_TEMPLATE *) * (m_dwNumTemplates + 1));
    m_ppEventTemplates[m_dwNumTemplates] = pEventTemplate;
    m_dwNumTemplates++;
@@ -848,9 +848,9 @@ UINT32 NXCL_Session::LoadUserDB(void)
 // Send file to server
 //
 
-UINT32 NXCL_Session::SendFile(UINT32 dwRqId, TCHAR *pszFileName, long sizeLimit)
+UINT32 NXCL_Session::SendFile(UINT32 dwRqId, TCHAR *pszFileName, long ofset)
 {
-   return SendFileOverNXCP(m_hSocket, dwRqId, pszFileName, m_pCtx, 0, sizeLimit, NULL, NULL, m_mutexSendMsg) ? RCC_SUCCESS : RCC_IO_ERROR;
+   return SendFileOverNXCP(m_hSocket, dwRqId, pszFileName, m_pCtx, ofset, NULL, NULL, m_mutexSendMsg) ? RCC_SUCCESS : RCC_IO_ERROR;
 }
 
 
index bac9b14..572035e 100644 (file)
@@ -218,6 +218,23 @@ void AgentConnectionEx::onFileMonitoringData(CSCPMessage *pMsg)
       for(int i = 0; i < result->size(); i++)
       {
          result->get(i)->sendMessage(pMsg);
+      }
+      if(result->size() == 0)
+      {
+         DbgPrintf(6, _T("AgentConnectionEx::onFileMonitoringData: unknown subscription will be canceled."));
+         Node *node = (Node *)object;
+         AgentConnection *conn = node->createAgentConnection();
+         if(conn != NULL)
+         {
+            CSCPMessage request;
+            request.SetId(conn->generateRequestId());
+            request.SetCode(CMD_CANCEL_FILE_MONITORING);
+            request.SetVariable(VID_FILE_NAME, remoteFile);
+            request.SetVariable(VID_OBJECT_ID, node->Id());
+            CSCPMessage* response = conn->customRequest(&request);
+            delete response;
+         }
+         delete conn;
       }
        }
        else
index 6ece636..079c1e2 100644 (file)
@@ -89,7 +89,7 @@ bool FileDownloadJob::run()
        bool success = false;
 
    MONITORED_FILE * newFile = new MONITORED_FILE();
-   _tcscpy(newFile->fileName, m_remoteFile);
+   _tcscpy(newFile->fileName, m_localFile);
    newFile->nodeID = m_node->Id();
    newFile->session = m_session;
 
@@ -145,9 +145,13 @@ bool FileDownloadJob::run()
                                }
 
             //default - get parameters
-
-            msg.SetVariable(VID_FILE_SIZE_LIMIT, m_maxFileSize);
+            if (m_maxFileSize > 0)
+            {
+               msg.SetVariable(VID_FILE_OFFSET, -m_maxFileSize);
+               appendFile = false;
+            }
             msg.SetVariable(VID_FILE_FOLLOW, (INT16)(m_follow ? 1 : 0));
+            msg.SetVariable(VID_NAME, m_localFile);
 
                                response = conn->customRequest(&msg, m_localFile, appendFile, progressCallback, this);
                                if (response != NULL)
@@ -201,7 +205,7 @@ bool FileDownloadJob::run()
        {
           response.SetVariable(VID_RCC, RCC_SUCCESS);
                m_session->sendMessage(&response);
-               m_session->sendFile(m_localFile, m_requestId, m_maxFileSize);
+               m_session->sendFile(m_localFile, m_requestId, 0);
                if(m_follow)
                {
          g_monitoringList.addMonitoringFile(newFile);
index 4139d28..31cc1ad 100644 (file)
@@ -548,10 +548,13 @@ void Interface::statusPoll(ClientSession *session, UINT32 rqId, Queue *eventQueu
                DbgPrintf(7, _T("Interface::StatusPoll(%d,%s): status changed from %d to %d"), m_dwId, m_szName, m_iStatus, newStatus);
                m_iStatus = newStatus;
                m_pendingStatus = -1;   // Invalidate pending status
-               sendPollerMsg(rqId, _T("      Interface status changed to %s\r\n"), g_szStatusText[m_iStatus]);
-               PostEventEx(eventQueue, 
-                           (expectedState == IF_EXPECTED_STATE_DOWN) ? statusToEventInverted[m_iStatus] : statusToEvent[m_iStatus],
-                                               pNode->Id(), "dsaad", m_dwId, m_szName, m_dwIpAddr, m_dwIpNetMask, m_dwIfIndex);
+      if (!m_isSystem)
+      {
+                  sendPollerMsg(rqId, _T("      Interface status changed to %s\r\n"), g_szStatusText[m_iStatus]);
+                  PostEventEx(eventQueue, 
+                              (expectedState == IF_EXPECTED_STATE_DOWN) ? statusToEventInverted[m_iStatus] : statusToEvent[m_iStatus],
+                                                  pNode->Id(), "dsaad", m_dwId, m_szName, m_dwIpAddr, m_dwIpNetMask, m_dwIfIndex);
+      }
    }
        else if (expectedState == IF_EXPECTED_STATE_IGNORE)
        {
@@ -623,32 +626,36 @@ void Interface::paeStatusPoll(ClientSession *pSession, UINT32 rqId, SNMP_Transpo
        {
           sendPollerMsg(rqId, _T("      Port PAE state changed to %s...\r\n"), PAE_STATE_TEXT(paeState));
                modified = true;
+      if (!m_isSystem)
+      {
+                  PostEvent(EVENT_8021X_PAE_STATE_CHANGED, node->Id(), "dsdsds", paeState, PAE_STATE_TEXT(paeState),
+                            (UINT32)m_dot1xPaeAuthState, PAE_STATE_TEXT(m_dot1xPaeAuthState), m_dwId, m_szName);
 
-               PostEvent(EVENT_8021X_PAE_STATE_CHANGED, node->Id(), "dsdsds", paeState, PAE_STATE_TEXT(paeState),
-                         (UINT32)m_dot1xPaeAuthState, PAE_STATE_TEXT(m_dot1xPaeAuthState), m_dwId, m_szName);
-
-               if (paeState == PAE_STATE_FORCE_UNAUTH)
-               {
-                       PostEvent(EVENT_8021X_PAE_FORCE_UNAUTH, node->Id(), "ds", m_dwId, m_szName);
-               }
+                  if (paeState == PAE_STATE_FORCE_UNAUTH)
+                  {
+                          PostEvent(EVENT_8021X_PAE_FORCE_UNAUTH, node->Id(), "ds", m_dwId, m_szName);
+                  }
+      }
        }
 
        if (m_dot1xBackendAuthState != (WORD)backendState)
        {
           sendPollerMsg(rqId, _T("      Port backend state changed to %s...\r\n"), BACKEND_STATE_TEXT(backendState));
                modified = true;
-
-               PostEvent(EVENT_8021X_BACKEND_STATE_CHANGED, node->Id(), "dsdsds", backendState, BACKEND_STATE_TEXT(backendState),
-                         (UINT32)m_dot1xBackendAuthState, BACKEND_STATE_TEXT(m_dot1xBackendAuthState), m_dwId, m_szName);
-
-               if (backendState == BACKEND_STATE_FAIL)
-               {
-                       PostEvent(EVENT_8021X_AUTH_FAILED, node->Id(), "ds", m_dwId, m_szName);
-               }
-               else if (backendState == BACKEND_STATE_TIMEOUT)
-               {
-                       PostEvent(EVENT_8021X_AUTH_TIMEOUT, node->Id(), "ds", m_dwId, m_szName);
-               }
+      if (!m_isSystem)
+      {
+                  PostEvent(EVENT_8021X_BACKEND_STATE_CHANGED, node->Id(), "dsdsds", backendState, BACKEND_STATE_TEXT(backendState),
+                            (UINT32)m_dot1xBackendAuthState, BACKEND_STATE_TEXT(m_dot1xBackendAuthState), m_dwId, m_szName);
+
+                  if (backendState == BACKEND_STATE_FAIL)
+                  {
+                          PostEvent(EVENT_8021X_AUTH_FAILED, node->Id(), "ds", m_dwId, m_szName);
+                  }
+                  else if (backendState == BACKEND_STATE_TIMEOUT)
+                  {
+                          PostEvent(EVENT_8021X_AUTH_TIMEOUT, node->Id(), "ds", m_dwId, m_szName);
+                  }
+      }
        }
 
        if (modified)
@@ -850,11 +857,13 @@ void Interface::setPeer(Node *node, Interface *iface)
    m_peerNodeId = node->Id();
    m_peerInterfaceId = iface->Id();
    Modify();
-
-   static const TCHAR *names[] = { _T("localIfId"), _T("localIfIndex"), _T("localIfName"), 
-      _T("localIfIP"), _T("localIfMAC"), _T("remoteNodeId"), _T("remoteNodeName"),
-      _T("remoteIfId"), _T("remoteIfIndex"), _T("remoteIfName"), _T("remoteIfIP"), _T("remoteIfMAC") };
-   PostEventWithNames(EVENT_IF_PEER_CHANGED, getParentNodeId(), "ddsahdsddsah", names,
-      m_dwId, m_dwIfIndex, m_szName, m_dwIpAddr, m_bMacAddr, node->Id(), node->Name(),
-      iface->Id(), iface->getIfIndex(), iface->Name(), iface->IpAddr(), iface->getMacAddr());
+   if (!m_isSystem)
+   {
+      static const TCHAR *names[] = { _T("localIfId"), _T("localIfIndex"), _T("localIfName"), 
+         _T("localIfIP"), _T("localIfMAC"), _T("remoteNodeId"), _T("remoteNodeName"),
+         _T("remoteIfId"), _T("remoteIfIndex"), _T("remoteIfName"), _T("remoteIfIP"), _T("remoteIfMAC") };
+      PostEventWithNames(EVENT_IF_PEER_CHANGED, getParentNodeId(), "ddsahdsddsah", names,
+         m_dwId, m_dwIfIndex, m_szName, m_dwIpAddr, m_bMacAddr, node->Id(), node->Name(),
+         iface->Id(), iface->getIfIndex(), iface->Name(), iface->IpAddr(), iface->getMacAddr());
+   }
 }
index 164e567..5d33c15 100644 (file)
@@ -268,6 +268,7 @@ ClientSession::ClientSession(SOCKET hSocket, struct sockaddr *addr)
    m_dwActiveChannels = 0;
        m_console = NULL;
    m_loginTime = time(NULL);
+   m_musicTypeList.add(_tcsdup(_T("wav")));
 }
 
 /**
@@ -312,6 +313,7 @@ ClientSession::~ClientSession()
                delete m_console->pMsg;
                free(m_console);
        }
+   m_musicTypeList.clear();
 }
 
 /**
@@ -1528,9 +1530,9 @@ void ClientSession::sendRawMessage(CSCP_MESSAGE *msg)
 /**
  * Send file to client
  */
-BOOL ClientSession::sendFile(const TCHAR *file, UINT32 dwRqId, long sizeLimit)
+BOOL ClientSession::sendFile(const TCHAR *file, UINT32 dwRqId, long ofset)
 {
-       return SendFileOverNXCP(m_hSocket, dwRqId, file, m_pCtx, 0, sizeLimit, NULL, NULL, m_mutexSocketWrite);
+       return SendFileOverNXCP(m_hSocket, dwRqId, file, m_pCtx, ofset, NULL, NULL, m_mutexSocketWrite);
 }
 
 /**
@@ -10201,40 +10203,50 @@ void ClientSession::getServerFile(CSCPMessage *pRequest)
 {
    CSCPMessage msg;
        TCHAR name[MAX_PATH], fname[MAX_PATH];
-       int i;
+       TCHAR *lastPointRef;
+       bool musicFile;
 
    msg.SetCode(CMD_REQUEST_COMPLETED);
    msg.SetId(pRequest->GetId());
+   pRequest->GetVariableStr(VID_FILE_NAME, name, MAX_PATH);
+   for(int i = 0; i < m_musicTypeList.getSize(); i++)
+   {
+      lastPointRef = _tcsrchr(name, _T('.'));
+      if(lastPointRef != NULL)
+      {
+         lastPointRef = lastPointRef+1;
+         if(_tcscmp(lastPointRef, m_musicTypeList.getValue(i)) == 0 ? true : false)
+         {
+            musicFile = true;
+            break;
+         }
+      }
+   }
 
-       if (m_dwSystemAccess & SYSTEM_ACCESS_READ_FILES)
+       if (m_dwSystemAccess & SYSTEM_ACCESS_READ_FILES || musicFile)
        {
-               pRequest->GetVariableStr(VID_FILE_NAME, name, MAX_PATH);
-               for(i = (int)_tcslen(name) - 1; i >= 0; i--)
-                       if ((name[i] == _T('\\')) || (name[i] == '/'))
-                               break;
-               i++;
       _tcscpy(fname, g_szDataDir);
-      _tcscat(fname, DDIR_SHARED_FILES);
+      _tcscat(fname, DDIR_FILES);
       _tcscat(fname, FS_PATH_SEPARATOR);
-      _tcscat(fname, name);
-               debugPrintf(4, _T("Requested file %s"), name);
+      _tcscat(fname, GetCleanFileName(name));
+               debugPrintf(4, _T("Requested file %s"), fname);
                if (_taccess(fname, 0) == 0)
                {
-                       debugPrintf(5, _T("Sending file %s"), name);
-                       if (SendFileOverNXCP(m_hSocket, pRequest->GetId(), fname, m_pCtx, 0, 0, NULL, NULL, m_mutexSocketWrite))
+                       debugPrintf(5, _T("Sending file %s"), fname);
+                       if (SendFileOverNXCP(m_hSocket, pRequest->GetId(), fname, m_pCtx, 0, NULL, NULL, m_mutexSocketWrite))
                        {
-                               debugPrintf(5, _T("File %s was succesfully sent"), name);
+                               debugPrintf(5, _T("File %s was succesfully sent"), fname);
                      msg.SetVariable(VID_RCC, RCC_SUCCESS);
                        }
                        else
                        {
-                               debugPrintf(5, _T("Unable to send file %s: SendFileOverNXCP() failed"), name);
+                               debugPrintf(5, _T("Unable to send file %s: SendFileOverNXCP() failed"), fname);
                      msg.SetVariable(VID_RCC, RCC_IO_ERROR);
                        }
                }
                else
                {
-                       debugPrintf(5, _T("Unable to send file %s: access() failed"), name);
+                       debugPrintf(5, _T("Unable to send file %s: access() failed"), fname);
              msg.SetVariable(VID_RCC, RCC_IO_ERROR);
                }
        }
@@ -10268,6 +10280,7 @@ void ClientSession::getAgentFile(CSCPMessage *request)
                                FileDownloadJob::buildServerFileName(object->Id(), remoteFile, localFile, MAX_PATH);
             bool follow = request->GetVariableShort(VID_FILE_FOLLOW) ? true : false;
                                FileDownloadJob *job = new FileDownloadJob((Node *)object, remoteFile, request->GetVariableLong(VID_FILE_SIZE_LIMIT), follow, this, request->GetId());
+                               msg.SetVariable(VID_NAME, localFile);
                                msg.SetVariable(VID_RCC, AddJob(job) ? RCC_SUCCESS : RCC_INTERNAL_ERROR);
                        }
                        else
@@ -10289,7 +10302,7 @@ void ClientSession::getAgentFile(CSCPMessage *request)
 }
 
 /**
- * Get file from agent
+ * Cancel file monitoring
  */
 void ClientSession::cancelFileMonitoring(CSCPMessage *request)
 {
@@ -10325,8 +10338,17 @@ void ClientSession::cancelFileMonitoring(CSCPMessage *request)
             if (response != NULL)
             {
                rcc = response->GetVariableLong(VID_RCC);
-               msg.SetVariable(VID_RCC, rcc);
-               debugPrintf(6, _T("File monitoring canceled sucessfully"));
+               if(rcc == RCC_SUCCESS)
+               {
+                  msg.SetVariable(VID_RCC, rcc);
+                  debugPrintf(6, _T("File monitoring cancelled sucessfully"));
+               }
+               else
+               {
+                  msg.SetVariable(VID_RCC, RCC_INTERNAL_ERROR);
+
+                  debugPrintf(6, _T("Error on agent: %d"), rcc);
+               }
             }
             else
             {
@@ -11553,59 +11575,112 @@ void ClientSession::uploadFileToAgent(CSCPMessage *request)
 }
 
 
-//
-// Send to client list of files in server's file store
-//
+/**
+ * Send to client list of files in server's file store
+ */
 
 void ClientSession::listServerFileStore(CSCPMessage *request)
 {
        CSCPMessage msg;
        TCHAR path[MAX_PATH];
+       bool musicFiles = true;
+       bool correctType = false;
+       StringList extensionList;
+       UINT32 lenght, base;
+       TCHAR * lastPointRef;
 
        msg.SetId(request->GetId());
        msg.SetCode(CMD_REQUEST_COMPLETED);
 
-       _tcscpy(path, g_szDataDir);
-       _tcscat(path, DDIR_FILES);
-       _TDIR *dir = _topendir(path);
-       if (dir != NULL)
+       lenght = request->GetVariableLong(VID_EXTENSION_COUNT);
+       DbgPrintf(8, _T("ClientSession::listServerFileStore: Lenght of filter type array is %d."), lenght);
+   base = VID_EXTENSION_LIST_BASE;
+
+       if (0 == lenght)
+      musicFiles = false;
+       for(int i = 0; i < lenght; i++)
+   {
+      extensionList.add(request->GetVariableStr(base++));
+      for(int j = 0; j < m_musicTypeList.getSize(); j++)
+      {
+         if(_tcscmp(extensionList.getValue(i), m_musicTypeList.getValue(j)) != 0 ? true : false )
+         {
+            musicFiles = false;
+         }
+      }
+   }
+
+       if (m_dwSystemAccess & SYSTEM_ACCESS_READ_FILES || musicFiles)
        {
-               _tcscat(path, FS_PATH_SEPARATOR);
-               int pos = (int)_tcslen(path);
 
-               struct _tdirent *d;
-#ifdef _WIN32
-               struct _stat st;
-#else
-               struct stat st;
-#endif
-               UINT32 count = 0, varId = VID_INSTANCE_LIST_BASE;
-               while((d = _treaddir(dir)) != NULL)
-               {
-                       if (_tcscmp(d->d_name, _T(".")) && _tcscmp(d->d_name, _T("..")))
-                       {
-                               nx_strncpy(&path[pos], d->d_name, MAX_PATH - pos);
-                               if (_tstat(path, &st) == 0)
-                               {
-                                       if (S_ISREG(st.st_mode))
-                                       {
-                                               msg.SetVariable(varId++, d->d_name);
-                                               msg.SetVariable(varId++, (QWORD)st.st_size);
-                                               msg.SetVariable(varId++, (QWORD)st.st_mtime);
-                                               varId += 7;
-                                               count++;
-                                       }
-                               }
-                       }
-               }
-               _tclosedir(dir);
-               msg.SetVariable(VID_INSTANCE_COUNT, count);
-               msg.SetVariable(VID_RCC, RCC_SUCCESS);
-       }
+      _tcscpy(path, g_szDataDir);
+      _tcscat(path, DDIR_FILES);
+      _TDIR *dir = _topendir(path);
+      if (dir != NULL)
+      {
+         _tcscat(path, FS_PATH_SEPARATOR);
+         int pos = (int)_tcslen(path);
+
+         struct _tdirent *d;
+   #ifdef _WIN32
+         struct _stat st;
+   #else
+         struct stat st;
+   #endif
+         UINT32 count = 0, varId = VID_INSTANCE_LIST_BASE;
+         while((d = _treaddir(dir)) != NULL)
+         {
+            if (_tcscmp(d->d_name, _T(".")) && _tcscmp(d->d_name, _T("..")))
+            {
+               if(lenght != 0)
+               {
+                  correctType = false;
+                  lastPointRef = _tcsrchr(d->d_name, _T('.'));
+                  lastPointRef = lastPointRef+1;
+                  for(int j = 0; j < extensionList.getSize(); j++)
+                  {
+                     if(lastPointRef != NULL)
+                     {
+                        if(_tcscmp(lastPointRef, extensionList.getValue(j)) == 0 ? true : false )
+                        {
+                           correctType = true;
+                           break;
+                        }
+                     }
+                  }
+                  if(!correctType)
+                  {
+                     continue;
+                  }
+               }
+               nx_strncpy(&path[pos], d->d_name, MAX_PATH - pos);
+               if (_tstat(path, &st) == 0)
+               {
+                  if (S_ISREG(st.st_mode))
+                  {
+                     msg.SetVariable(varId++, d->d_name);
+                     msg.SetVariable(varId++, (QWORD)st.st_size);
+                     msg.SetVariable(varId++, (QWORD)st.st_mtime);
+                     varId += 7;
+                     count++;
+                  }
+               }
+            }
+         }
+         _tclosedir(dir);
+         msg.SetVariable(VID_INSTANCE_COUNT, count);
+         msg.SetVariable(VID_RCC, RCC_SUCCESS);
+      }
+      else
+      {
+         msg.SetVariable(VID_RCC, RCC_IO_ERROR);
+      }
+   }
        else
        {
-               msg.SetVariable(VID_RCC, RCC_IO_ERROR);
+      msg.SetVariable(VID_RCC, RCC_ACCESS_DENIED);
        }
+       extensionList.clear();
 
        sendMessage(&msg);
 }
index 3644304..151629e 100644 (file)
@@ -421,6 +421,7 @@ private:
    CONDITION m_condEncryptionSetup;
    UINT32 m_dwActiveChannels;     // Active data channels
        CONSOLE_CTX m_console;                  // Server console context
+       StringList m_musicTypeList;
 
    static THREAD_RESULT THREAD_CALL readThreadStarter(void *);
    static THREAD_RESULT THREAD_CALL writeThreadStarter(void *);
@@ -673,7 +674,7 @@ public:
    void sendMessage(CSCPMessage *pMsg);
    void sendRawMessage(CSCP_MESSAGE *pMsg);
    void sendPollerMsg(UINT32 dwRqId, const TCHAR *pszMsg);
-       BOOL sendFile(const TCHAR *file, UINT32 dwRqId, long sizeLimit);
+       BOOL sendFile(const TCHAR *file, UINT32 dwRqId, long offset);
 
    UINT32 getIndex() { return m_dwIndex; }
    void setIndex(UINT32 dwIndex) { if (m_dwIndex == INVALID_INDEX) m_dwIndex = dwIndex; }
index a5a5abc..8436c77 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
 ** NetXMS - Network Management System
 ** Server Library
 ** Copyright (C) 2003-2013 Victor Kirhenshtein
@@ -119,7 +119,7 @@ AgentConnection::~AgentConnection()
 
    // Wait for receiver thread termination
    ThreadJoin(m_hReceiverThread);
-   
+
        // Close socket if active
        lock();
    if (m_hSocket != -1)
@@ -214,7 +214,7 @@ void AgentConnection::receiverThread()
       // Check if we get too large message
       if (error == 1)
       {
-         printMsg(_T("Received too large message %s (%d bytes)"), 
+         printMsg(_T("Received too large message %s (%d bytes)"),
                   NXCPMessageCodeName(ntohs(pRawMsg->wCode), szBuffer),
                   ntohl(pRawMsg->dwSize));
          continue;
@@ -261,7 +261,7 @@ void AgentConnection::receiverThread()
                {
                   close(m_hCurrFile);
                   m_hCurrFile = -1;
-            
+
                   onFileDownload(TRUE);
                }
                                        else
@@ -277,7 +277,7 @@ void AgentConnection::receiverThread()
                // I/O error
                close(m_hCurrFile);
                m_hCurrFile = -1;
-         
+
                onFileDownload(FALSE);
             }
                        }
@@ -321,7 +321,7 @@ void AgentConnection::receiverThread()
                m_hCurrFile = -1;
                onFileDownload(FALSE);
        }
-       
+
        if (error == 0)
       shutdown(m_hSocket, SHUT_RDWR);
    closesocket(m_hSocket);
@@ -541,7 +541,7 @@ void AgentConnection::disconnect()
  * Set authentication data
  */
 void AgentConnection::setAuthData(int method, const TCHAR *secret)
-{ 
+{
    m_iAuthMethod = method;
 #ifdef UNICODE
        WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK | WC_DEFAULTCHAR, secret, -1, m_szSecret, MAX_SECRET_LENGTH, NULL, NULL);
@@ -1055,7 +1055,7 @@ UINT32 AgentConnection::uploadFile(const TCHAR *localFile, const TCHAR *destinat
 
    msg.SetCode(CMD_TRANSFER_FILE);
    msg.SetId(dwRqId);
-   for(i = (int)_tcslen(localFile) - 1; 
+   for(i = (int)_tcslen(localFile) - 1;
        (i >= 0) && (localFile[i] != '\\') && (localFile[i] != '/'); i--);
    msg.SetVariable(VID_FILE_NAME, &localFile[i + 1]);
    if (destinationFile != NULL)
@@ -1076,7 +1076,7 @@ UINT32 AgentConnection::uploadFile(const TCHAR *localFile, const TCHAR *destinat
    {
                m_fileUploadInProgress = true;
                NXCPEncryptionContext *ctx = acquireEncryptionContext();
-      if (SendFileOverNXCP(m_hSocket, dwRqId, localFile, ctx, 0, 0, progressCallback, cbArg, m_mutexSocketWrite))
+      if (SendFileOverNXCP(m_hSocket, dwRqId, localFile, ctx, 0, progressCallback, cbArg, m_mutexSocketWrite))
          dwResult = waitForRCC(dwRqId, m_dwCommandTimeout);
       else
          dwResult = ERR_IO_FAILURE;
@@ -1104,7 +1104,7 @@ UINT32 AgentConnection::startUpgrade(const TCHAR *pszPkgName)
 
    msg.SetCode(CMD_UPGRADE_AGENT);
    msg.SetId(dwRqId);
-   for(i = (int)_tcslen(pszPkgName) - 1; 
+   for(i = (int)_tcslen(pszPkgName) - 1;
        (i >= 0) && (pszPkgName[i] != '\\') && (pszPkgName[i] != '/'); i--);
    msg.SetVariable(VID_FILE_NAME, &pszPkgName[i + 1]);
 
@@ -1125,8 +1125,8 @@ UINT32 AgentConnection::startUpgrade(const TCHAR *pszPkgName)
 // Check status of network service via agent
 //
 
-UINT32 AgentConnection::checkNetworkService(UINT32 *pdwStatus, UINT32 dwIpAddr, int iServiceType, 
-                                           WORD wPort, WORD wProto, 
+UINT32 AgentConnection::checkNetworkService(UINT32 *pdwStatus, UINT32 dwIpAddr, int iServiceType,
+                                           WORD wPort, WORD wProto,
                                            const TCHAR *pszRequest, const TCHAR *pszResponse)
 {
    UINT32 dwRqId, dwResult;
@@ -1142,9 +1142,9 @@ UINT32 AgentConnection::checkNetworkService(UINT32 *pdwStatus, UINT32 dwIpAddr,
    msg.SetId(dwRqId);
    msg.SetVariable(VID_IP_ADDRESS, dwIpAddr);
    msg.SetVariable(VID_SERVICE_TYPE, (WORD)iServiceType);
-   msg.SetVariable(VID_IP_PORT, 
-      (wPort != 0) ? wPort : 
-         m_wDefaultPort[((iServiceType >= NETSRV_CUSTOM) && 
+   msg.SetVariable(VID_IP_PORT,
+      (wPort != 0) ? wPort :
+         m_wDefaultPort[((iServiceType >= NETSRV_CUSTOM) &&
                          (iServiceType <= NETSRV_HTTP)) ? iServiceType : 0]);
    msg.SetVariable(VID_IP_PROTO, (wProto != 0) ? wProto : (WORD)IPPROTO_TCP);
    msg.SetVariable(VID_SERVICE_REQUEST, pszRequest);
@@ -1340,7 +1340,7 @@ UINT32 AgentConnection::getConfigFile(TCHAR **ppszConfig, UINT32 *pdwSize)
 
             // We expect text file, so replace all non-printable characters with spaces
             for(i = 0; i < *pdwSize; i++)
-               if (((*ppszConfig)[i] < _T(' ')) && 
+               if (((*ppszConfig)[i] < _T(' ')) &&
                    ((*ppszConfig)[i] != _T('\t')) &&
                    ((*ppszConfig)[i] != _T('\r')) &&
                    ((*ppszConfig)[i] != _T('\n')))
@@ -1493,7 +1493,7 @@ void AgentConnection::setProxy(UINT32 dwAddr, WORD wPort, int iAuthMethod, const
    if (pszSecret != NULL)
    {
 #ifdef UNICODE
-      WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK | WC_DEFAULTCHAR, 
+      WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK | WC_DEFAULTCHAR,
                           pszSecret, -1, m_szProxySecret, MAX_SECRET_LENGTH, NULL, NULL);
 #else
       nx_strncpy(m_szProxySecret, pszSecret, MAX_SECRET_LENGTH);
@@ -1547,9 +1547,9 @@ UINT32 AgentConnection::enableTraps()
 }
 
 
-//
-// Send custom request to agent
-//
+/**
+ * Send custom request to agent
+ */
 
 CSCPMessage *AgentConnection::customRequest(CSCPMessage *pRequest, const TCHAR *recvFile, bool appendFile,
                                                                                                                  void (*downloadProgressCallback)(size_t, void *), void *cbArg)
@@ -1627,7 +1627,7 @@ UINT32 AgentConnection::prepareFileDownload(const TCHAR *fileName, UINT32 rqId,
                DbgPrintf(4, _T("AgentConnection::PrepareFileDownload(): cannot open file %s (%s); append=%d rqId=%d"),
                          fileName, _tcserror(errno), append, rqId);
        }
-       else 
+       else
        {
                if (append)
                        lseek(m_hCurrFile, 0, SEEK_END);
index c3bd480..9af9243 100644 (file)
@@ -167,7 +167,7 @@ Error in SNMP response packet: %1
 MessageId=
 SymbolicName=MSG_OID_PARSE_ERROR
 Language=English
-Error parsing SNMP OID '%1'
+Error parsing SNMP OID "%1" in %2 (destination IP address %3)
 .
 
 MessageId=
index 8a25153..bd1586b 100644 (file)
@@ -58,7 +58,7 @@ UINT32 LIBNXSRV_EXPORTABLE SnmpGet(UINT32 dwVersion, SNMP_Transport *pTransport,
       dwNameLen = SNMPParseOID(szOidStr, pdwVarName, MAX_OID_LEN);
       if (dwNameLen == 0)
       {
-         nxlog_write(MSG_OID_PARSE_ERROR, EVENTLOG_ERROR_TYPE, "s", szOidStr);
+         nxlog_write(MSG_OID_PARSE_ERROR, EVENTLOG_ERROR_TYPE, "ssa", szOidStr, _T("SnmpGet"), pTransport->getPeerIpAddress());
          dwResult = SNMP_ERR_BAD_OID;
       }
    }
@@ -172,7 +172,7 @@ UINT32 LIBNXSRV_EXPORTABLE SnmpWalk(UINT32 dwVersion, SNMP_Transport *pTransport
    UINT32 dwRootLen = SNMPParseOID(szRootOid, pdwRootName, MAX_OID_LEN);
    if (dwRootLen == 0)
    {
-      nxlog_write(MSG_OID_PARSE_ERROR, EVENTLOG_ERROR_TYPE, "s", szRootOid);
+      nxlog_write(MSG_OID_PARSE_ERROR, EVENTLOG_ERROR_TYPE, "ssa", szRootOid, _T("SnmpWalk"), pTransport->getPeerIpAddress());
       return SNMP_ERR_BAD_OID;
    }
 
index 4bcd19e..557c034 100644 (file)
@@ -5,6 +5,7 @@ action.terminate=Terminate
 actionDescription.openAlarmBrowser=Open Alarm Browser
 actionSet.AlarmBrowser.label=Alarm Browser
 page.Alarms.name=Alarms
+page.AlarmMelodies.name=Alarm Sounds
 provider.AlarmDetails.name=Alarm Details Provider
 tab.Alarms=Alarms
 view.AlarmBrowser.name=Alarm Browser
index 2a9ce8c..21d5410 100644 (file)
@@ -4,6 +4,7 @@ action.openAlarmBrowser=Prohl\u00ED\u017Ee\u010D alarm\u016F
 action.terminate=Ukon\u010Dit
 actionDescription.openAlarmBrowser=Otev\u0159\u00EDt prohli\u017Ee\u010D alarm\u016F
 actionSet.AlarmBrowser.label=Prohl\u00ED\u017Ee\u010D alarm\u016F
+page.AlarmMelodies.name=Alarm Sounds
 page.Alarms.name=Alarmy
 provider.AlarmDetails.name=Poskytovatel detailu alarm\u016F
 tab.Alarms=Alarmy
index 9f4e1e7..a6f27c5 100644 (file)
@@ -4,6 +4,7 @@ action.openAlarmBrowser=Explorador de Alarmas
 action.terminate=Terminar
 actionDescription.openAlarmBrowser=Abrir el Explorador de Alarmas
 actionSet.AlarmBrowser.label=Explorador de Alarmas
+page.AlarmMelodies.name=Alarm Sounds
 page.Alarms.name=Alarms
 provider.AlarmDetails.name=Alarm Details Provider
 tab.Alarms=Alarmas
index dcc6908..8b86523 100644 (file)
@@ -4,6 +4,7 @@ action.openAlarmBrowser=\u041e\u0431\u043e\u0437\u0440\u0435\u0432\u0430\u0442\u
 action.terminate=\u041f\u0440\u0435\u043a\u0440\u0430\u0442\u0438\u0442\u044c
 actionDescription.openAlarmBrowser=\u041e\u0442\u043a\u0440\u044b\u0442\u044c \u043e\u0431\u043e\u0437\u0440\u0435\u0432\u0430\u0442\u0435\u043b\u044c \u0442\u0440\u0435\u0432\u043e\u0433
 actionSet.AlarmBrowser.label=\u041e\u0431\u043e\u0437\u0440\u0435\u0432\u0430\u0442\u0435\u043b\u044c \u0442\u0440\u0435\u0432\u043e\u0433
+page.AlarmMelodies.name=Alarm Sounds
 page.Alarms.name=\u0422\u0440\u0435\u0432\u043e\u0433\u0438
 provider.AlarmDetails.name=\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0435\u0439 \u0442\u0440\u0435\u0432\u043e\u0433\u0438
 tab.Alarms=\u0422\u0440\u0435\u0432\u043e\u0433\u0438
index 4644418..2aa0f11 100644 (file)
@@ -4,6 +4,7 @@ action.openAlarmBrowser=\u544a\u8b66\u6d4f\u89c8
 action.terminate=\u544a\u8b66\u4e2d\u6b62
 actionDescription.openAlarmBrowser=\u6253\u5f00\u544a\u8b66\u6d4f\u89c8\u5668
 actionSet.AlarmBrowser.label=Alarm Browser
+page.AlarmMelodies.name=Alarm Sounds
 page.Alarms.name=Alarms
 provider.AlarmDetails.name=Alarm Details Provider
 tab.Alarms=\u544a\u8b66
index 1f4bdd8..fc09386 100644 (file)
             order="20">
       </tab>
    </extension>
+   <extension
+         point="org.netxms.ui.eclipse.loginlisteners">
+      <loginlistener
+            class="org.netxms.ui.eclipse.alarmviewer.LoginListener">
+      </loginlistener>
+   </extension>
    <extension
          point="org.eclipse.core.runtime.preferences">
       <initializer
             id="org.netxms.ui.eclipse.alarmviewer.preferencepages.Alarms"
             name="%page.Alarms.name">
       </page>
+      <page
+            category="org.netxms.ui.eclipse.alarmviewer.preferencepages.Alarms"
+            class="org.netxms.ui.eclipse.alarmviewer.preferencepages.AlarmMelody"
+            id="org.netxms.ui.eclipse.alarmviewer.preferencepages.AlarmMelody"
+            name="%page.AlarmMelodies.name">
+      </page>
    </extension>
    <extension
          point="org.eclipse.ui.popupMenus">
diff --git a/webui/webapp/AlarmViewer/src/org/netxms/ui/eclipse/alarmviewer/AlarmNotifier.java b/webui/webapp/AlarmViewer/src/org/netxms/ui/eclipse/alarmviewer/AlarmNotifier.java
new file mode 100644 (file)
index 0000000..8287f21
--- /dev/null
@@ -0,0 +1,223 @@
+/**
+ * NetXMS - open source network management system
+ * Copyright (C) 2003-2012 Victor Kirhenshtein
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.netxms.ui.eclipse.alarmviewer;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.nio.channels.FileChannel;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.rap.rwt.RWT;
+import org.eclipse.rap.rwt.client.service.JavaScriptExecutor;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.progress.UIJob;
+import org.netxms.api.client.Session;
+import org.netxms.api.client.SessionNotification;
+import org.netxms.client.NXCException;
+import org.netxms.client.NXCListener;
+import org.netxms.client.NXCNotification;
+import org.netxms.client.NXCSession;
+import org.netxms.client.events.Alarm;
+import org.netxms.ui.eclipse.console.DownloadServiceHandler;
+import org.netxms.ui.eclipse.shared.ConsoleSharedData;
+import org.netxms.ui.eclipse.tools.MessageDialogHelper;
+
+/**
+ * Alarm notifier
+ */
+public class AlarmNotifier
+{
+   private static NXCListener listener = null;
+   private NXCSession session;
+   public static String[] severityArray = { "NORMAL", "WARNING", "MINOR", "MAJOR", "CRITICAL" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+   private IPreferenceStore ps;
+   private URL workspaceUrl;
+
+   /**
+    * Get cache instance
+    * 
+    * @return
+    */
+   public static AlarmNotifier getInstance()
+   {
+      return (AlarmNotifier)ConsoleSharedData.getProperty("AlarmNotifier");
+   }
+
+   /**
+    * Attach session to cache
+    * 
+    * @param session
+    */
+   public static void attachSession(final NXCSession session, final Display display)
+   {
+      AlarmNotifier instance = new AlarmNotifier();
+      instance.init(session, display);
+      ConsoleSharedData.setProperty("AlarmNotifier", instance);
+   }
+
+   /**
+    * Initialize alarm notifier
+    */
+   public void init(final NXCSession session, final Display display)
+   {
+      this.session = session;
+      ps = Activator.getDefault().getPreferenceStore();
+      workspaceUrl = Platform.getInstanceLocation().getURL();
+      // Check that required alarm melodies are present localy.
+      checkMelodies(session);
+
+      listener = new NXCListener() {
+         @Override
+         public void notificationHandler(final SessionNotification n)
+         {
+            if ((n.getCode() == NXCNotification.NEW_ALARM) || (n.getCode() == NXCNotification.ALARM_CHANGED))
+            {
+               display.asyncExec(new Runnable() {
+                  @Override
+                  public void run()
+                  {
+                     processNewAlarm((Alarm)n.getObject());
+                  }
+               });
+            }
+         }
+      };
+      session.addListener(listener);
+   }
+
+   /**
+    * Check if required melodies exist locally and download them from server if required.
+    */
+   private void checkMelodies(NXCSession session)
+   {
+      URL workspaceUrl = Platform.getInstanceLocation().getURL();
+      for(int i = 0; i < 5; i++)
+      {
+         getMelodyAndDownloadIfRequired(session, workspaceUrl, severityArray[i]);
+      }
+   }
+
+   private String getMelodyAndDownloadIfRequired(NXCSession session, URL workspaceUrl, String severity)
+   {
+      String melodyName = ps.getString("ALARM_NOTIFIER.MELODY." + severity);//$NON-NLS-1$
+      if (!checkMelodyExists(melodyName, workspaceUrl))
+      {
+         try
+         {
+            File f = new File(workspaceUrl.getPath(), melodyName);
+            File fileContent = session.downloadFileFromServer(melodyName);
+            f.createNewFile();
+            FileChannel src = null;
+            FileChannel dest = null;
+            if (fileContent != null)
+            {
+               try
+               {
+                  src = new FileInputStream(fileContent).getChannel();
+                  dest = new FileOutputStream(f).getChannel();
+                  dest.transferFrom(src, 0, src.size());
+               }
+               catch(IOException e)
+               {
+                  System.out.println("Not possible to copy inside new file content.");
+               }
+               finally
+               {
+                  src.close();
+                  dest.close();
+               }
+            }
+         }
+         catch(IOException | NXCException e)
+         {
+            melodyName = "";
+            ps.setValue("ALARM_NOTIFIER.MELODY." + severity, "");
+            new UIJob("Send error that sound file is not found") {
+               @Override
+               public IStatus runInUIThread(IProgressMonitor monitor)
+               {
+                  MessageDialogHelper
+                        .openError(
+                              getDisplay().getActiveShell(),
+                              "Melody does not exist.",
+                              "Melody was not found "
+                                    + "locally and it was not possible to download it from server. Melody is removed and will not be played. Error: "
+                                    + e.getMessage());
+                  return Status.OK_STATUS;
+               }
+            }.schedule();
+         }
+      }
+      return melodyName;
+   }
+
+   private boolean checkMelodyExists(String melodyName, URL workspaceUrl)
+   {
+      if ((!melodyName.equals("")) && (workspaceUrl != null))
+      {
+         File f = new File(workspaceUrl.getPath(), melodyName);
+         return f.isFile();
+      }
+      else
+      {
+         return true;
+      }
+   }
+
+   /**
+    * Stop alarm notifier
+    */
+   public static void stop()
+   {
+      Session session = ConsoleSharedData.getSession();
+      if ((session != null) && (listener != null))
+         session.removeListener(listener);
+   }
+
+   /**
+    * Process new alarm
+    */
+   private void processNewAlarm(final Alarm alarm)
+   {
+      if (alarm.getState() != Alarm.STATE_OUTSTANDING)
+         return;
+
+      String fileName = getMelodyAndDownloadIfRequired(session, workspaceUrl, severityArray[alarm.getCurrentSeverity()]); //$NON-NLS-1$
+
+      if (!fileName.equals("") && fileName != null)
+      {
+         JavaScriptExecutor executor = RWT.getClient().getService(JavaScriptExecutor.class);
+         File localFile = new File(workspaceUrl.getPath(), fileName);
+         String id = localFile.getAbsolutePath();
+         DownloadServiceHandler.addDownload(id, fileName, localFile, "audio/wav");//$NON-NLS-1$
+         StringBuilder js = new StringBuilder();
+         js.append("var audio = new Audio('");//$NON-NLS-1$
+         js.append(DownloadServiceHandler.createDownloadUrl(id));
+         js.append("');");//$NON-NLS-1$
+         js.append("audio.play();");//$NON-NLS-1$  
+         executor.execute(js.toString());
+      }
+   }
+}
@@ -1,6 +1,6 @@
 /**
  * NetXMS - open source network management system
- * Copyright (C) 2003-2010 Victor Kirhenshtein
+ * Copyright (C) 2003-2012 Victor Kirhenshtein
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-package org.netxms.ui.eclipse.datacollection;
+package org.netxms.ui.eclipse.alarmviewer;
 
 import org.eclipse.swt.widgets.Display;
 import org.netxms.client.NXCSession;
 import org.netxms.ui.eclipse.console.api.ConsoleLoginListener;
 
 /**
- * Early startup class
+ * Console login listener
  */
 public class LoginListener implements ConsoleLoginListener
 {
@@ -33,6 +33,6 @@ public class LoginListener implements ConsoleLoginListener
        @Override
        public void afterLogin(NXCSession session, Display display)
        {
-               SummaryTablesCache.attachSession(session);
+               AlarmNotifier.attachSession(session, display);
        }
 }
index 9c3bc3b..9ab6454 100644 (file)
@@ -7,12 +7,12 @@ import org.eclipse.swt.widgets.Display;
 
 public class Messages extends NLS
 {
-       private static final String BUNDLE_NAME = "org.netxms.ui.eclipse.alarmviewer.messages"; //$NON-NLS-1$
+   private static final String BUNDLE_NAME = "org.netxms.ui.eclipse.alarmviewer.messages"; //$NON-NLS-1$
 
-       public String AcknowledgeAlarm_ErrorMessage;
-       public String AcknowledgeAlarm_JobName;
-       public String AcknowledgeAlarm_TaskName;
-       public String AcknowledgeCustomTimeDialog_ConfigurationInfoLabel;
+   public String AcknowledgeAlarm_ErrorMessage;
+   public String AcknowledgeAlarm_JobName;
+   public String AcknowledgeAlarm_TaskName;
+   public String AcknowledgeCustomTimeDialog_ConfigurationInfoLabel;
    public String AcknowledgeCustomTimeDialog_CustomTimeDialogTitle;
    public String AcknowledgeCustomTimeDialog_Days;
    public String AcknowledgeCustomTimeDialog_Hours;
@@ -28,92 +28,101 @@ public class Messages extends NLS
    public String AlarmAcknowledgeTimeFunctions_ZeroMinutesEntry;
    public String AlarmComments_AckToDeleteComment;
    public String AlarmComments_AddCommentJob;
-       public String AlarmComments_AddCommentLink;
-       public String AlarmComments_AddError;
-       public String AlarmComments_Comments;
+   public String AlarmComments_AddCommentLink;
+   public String AlarmComments_AddError;
+   public String AlarmComments_Comments;
    public String AlarmComments_Confirmation;
-       public String AlarmComments_DeleteCommentJob;
+   public String AlarmComments_DeleteCommentJob;
    public String AlarmComments_Details;
    public String AlarmComments_ErrorDeleteAlarmComment;
-       public String AlarmComments_GetComments;
-       public String AlarmComments_GetError;
-       public String AlarmComments_InternalError;
-       public String AlarmCommentsEditor_DeleteLabel;
+   public String AlarmComments_GetComments;
+   public String AlarmComments_GetError;
+   public String AlarmComments_InternalError;
+   public String AlarmCommentsEditor_DeleteLabel;
    public String AlarmCommentsEditor_Edit;
-       public String AlarmCommentsEditor_Unknown;
-       public String AlarmComparator_Unknown;
-       public String AlarmDetails_Column_Message;
-       public String AlarmDetails_Column_Name;
-       public String AlarmDetails_Column_Severity;
-       public String AlarmDetails_Column_Source;
-       public String AlarmDetails_Column_Timestamp;
-       public String AlarmDetails_LastValues;
-       public String AlarmDetails_Overview;
-       public String AlarmDetails_RefreshJobError;
-       public String AlarmDetails_RefreshJobTitle;
-       public String AlarmDetails_RelatedEvents;
-       public String AlarmDetailsProvider_Error;
-       public String AlarmDetailsProvider_ErrorOpeningView;
-       public String AlarmList_AckBy;
-       public String AlarmList_Acknowledge;
-       public String AlarmList_ActionAlarmDetails;
-       public String AlarmList_ActionObjectDetails;
-       public String AlarmList_CannotResoveAlarm;
-       public String AlarmList_ColumnCount;
-       public String AlarmList_ColumnCreated;
-       public String AlarmList_ColumnLastChange;
-       public String AlarmList_ColumnMessage;
-       public String AlarmList_ColumnSeverity;
-       public String AlarmList_ColumnSource;
-       public String AlarmList_ColumnState;
-       public String AlarmList_Comments;
-       public String AlarmList_CopyMsgToClipboard;
-       public String AlarmList_CopyToClipboard;
-       public String AlarmList_Error;
-       public String AlarmList_ErrorText;
-       public String AlarmList_OpenDetailsError;
-       public String AlarmList_Resolve;
-       public String AlarmList_ResolveAlarm;
-       public String AlarmList_Resolving;
-       public String AlarmList_StickyAck;
-
+   public String AlarmCommentsEditor_Unknown;
+   public String AlarmComparator_Unknown;
+   public String AlarmDetails_Column_Message;
+   public String AlarmDetails_Column_Name;
+   public String AlarmDetails_Column_Severity;
+   public String AlarmDetails_Column_Source;
+   public String AlarmDetails_Column_Timestamp;
+   public String AlarmDetails_LastValues;
+   public String AlarmDetails_Overview;
+   public String AlarmDetails_RefreshJobError;
+   public String AlarmDetails_RefreshJobTitle;
+   public String AlarmDetails_RelatedEvents;
+   public String AlarmDetailsProvider_Error;
+   public String AlarmDetailsProvider_ErrorOpeningView;
+   public String AlarmList_AckBy;
+   public String AlarmList_Acknowledge;
+   public String AlarmList_ActionAlarmDetails;
+   public String AlarmList_ActionObjectDetails;
+   public String AlarmList_CannotResoveAlarm;
+   public String AlarmList_ColumnCount;
+   public String AlarmList_ColumnCreated;
+   public String AlarmList_ColumnLastChange;
+   public String AlarmList_ColumnMessage;
+   public String AlarmList_ColumnSeverity;
+   public String AlarmList_ColumnSource;
+   public String AlarmList_ColumnState;
+   public String AlarmList_Comments;
+   public String AlarmList_CopyMsgToClipboard;
+   public String AlarmList_CopyToClipboard;
+   public String AlarmList_Error;
+   public String AlarmList_ErrorText;
+   public String AlarmList_OpenDetailsError;
+   public String AlarmList_Resolve;
+   public String AlarmList_ResolveAlarm;
+   public String AlarmList_Resolving;
+   public String AlarmList_StickyAck;
    public String AlarmList_StickyAckMenutTitle;
-       public String AlarmList_SyncJobError;
-       public String AlarmList_SyncJobName;
-       public String AlarmList_Terminate;
-       public String AlarmListLabelProvider_AlarmState_Acknowledged;
-       public String AlarmListLabelProvider_AlarmState_Outstanding;
-       public String AlarmListLabelProvider_AlarmState_Resolved;
-       public String AlarmListLabelProvider_AlarmState_Terminated;
-       public String AlarmNotifier_ToolTip_Header;
-       public String AlarmReminderDialog_Dismiss;
-       public String AlarmReminderDialog_OutstandingAlarms;
+   public String AlarmList_SyncJobError;
+   public String AlarmList_SyncJobName;
+   public String AlarmList_Terminate;
+   public String AlarmListLabelProvider_AlarmState_Acknowledged;
+   public String AlarmListLabelProvider_AlarmState_Outstanding;
+   public String AlarmListLabelProvider_AlarmState_Resolved;
+   public String AlarmListLabelProvider_AlarmState_Terminated;
+   public String AlarmMelody_ErrorGettingMelodyList;
+   public String AlarmMelody_ErrorGettingMelodyListDescription;
+   public String AlarmMelody_ErrorMelodyNotExists;
+   public String AlarmMelody_ErrorMelodyNotExistsDescription;
+   public String AlarmMelody_JobGetMelodyList;
+   public String AlarmMelody_SaveClientSelection;
+   public String AlarmNotifier_ErrorMelodynotExists;
+   public String AlarmNotifier_ErrorMelodyNotExistsDescription;
+   public String AlarmNotifier_ErrorPlayingSound;
+   public String AlarmNotifier_ErrorPlayingSoundDescription;
+   public String AlarmNotifier_JobSoundNotFoundError;
+   public String AlarmNotifier_ToolTip_Header;
+   public String AlarmReminderDialog_Dismiss;
+   public String AlarmReminderDialog_OutstandingAlarms;
    public String Alarms_AcknowledgeTimeEditor;
-
    public String Alarms_Blinking;
    public String Alarms_SetAlarmFlowToStrict;
-
    public String Alarms_ShowDetailedTooltips;
-       public String Alarms_ShowPopup;
-       public String Alarms_ShowReminder;
-       public String EditCommentDialog_Comment;
-       public String EditCommentDialog_EditComment;
-       public String ObjectAlarmBrowser_TitlePrefix;
-       public String OpenAlarmBrowser_Error;
-       public String OpenAlarmBrowser_ErrorOpeningView;
-       public String ShowObjectAlarms_Error;
-       public String ShowObjectAlarms_ErrorOpeningView;
-       public String Startup_JobName;
-       public String TerminateAlarm_ErrorMessage;
-       public String TerminateAlarm_JobTitle;
-       public String TerminateAlarm_TaskName;
-       static
-       {
-               // initialize resource bundle
-               NLS.initializeMessages(BUNDLE_NAME, Messages.class);
-       }
+   public String Alarms_ShowPopup;
+   public String Alarms_ShowReminder;
+   public String EditCommentDialog_Comment;
+   public String EditCommentDialog_EditComment;
+   public String ObjectAlarmBrowser_TitlePrefix;
+   public String OpenAlarmBrowser_Error;
+   public String OpenAlarmBrowser_ErrorOpeningView;
+   public String ShowObjectAlarms_Error;
+   public String ShowObjectAlarms_ErrorOpeningView;
+   public String Startup_JobName;
+   public String TerminateAlarm_ErrorMessage;
+   public String TerminateAlarm_JobTitle;
+   public String TerminateAlarm_TaskName;
+
+   static
+   {
+      // initialize resource bundle
+      NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+   }
 
-       
+   
 
 private Messages()
        {
index db362aa..6245d8c 100644 (file)
@@ -216,9 +216,12 @@ public class AcknowledgeTimeEditor extends FieldEditor
       {
          list.removeAll();
          String[] array = AlarmAcknowledgeTimeFunctions.getValues();
-         for(int i = 0; i < array.length; i++)
+         if(array != null)
          {
-            list.add(array[i]);
+                for(int i = 0; i < array.length; i++)
+                {
+                   list.add(array[i]);
+                }
          }
       }
    }
index 1e9ca53..c9eac21 100644 (file)
@@ -73,6 +73,17 @@ AlarmList_StickyAckMenutTitle=Sticky acknowledge for
 AlarmList_SyncJobError=Cannot synchronize alarm list
 AlarmList_SyncJobName=Synchronize alarm list
 AlarmList_Terminate=&Terminate
+AlarmMelody_ErrorGettingMelodyList=Not possible to get melody list.
+AlarmMelody_ErrorGettingMelodyListDescription=Not possible to get melody list. Error: 
+AlarmMelody_ErrorMelodyNotExists=Melody does not exist.
+AlarmMelody_ErrorMelodyNotExistsDescription=Melody was not found locally and it was not possible to download it from server. Melody is removed and will not be played. Error: 
+AlarmMelody_JobGetMelodyList=Get melody list
+AlarmMelody_SaveClientSelection=Save client selection
+AlarmNotifier_ErrorMelodynotExists=Melody does not exist.
+AlarmNotifier_ErrorMelodyNotExistsDescription=Melody was not found locally and it was not possible to download it from server. Melody is removed and will not be played. Error: 
+AlarmNotifier_ErrorPlayingSound=Was not possible to play sound
+AlarmNotifier_ErrorPlayingSoundDescription=Error while playing sound. Melody will not be played. Error: 
+AlarmNotifier_JobSoundNotFoundError=Send error that sound file is not found
 AlarmNotifier_ToolTip_Header=NetXMS Alarm (
 AlarmReminderDialog_Dismiss=Dismiss
 AlarmReminderDialog_OutstandingAlarms=Outstanding Alarms
index 6f73842..418ba14 100644 (file)
@@ -73,6 +73,17 @@ AlarmList_StickyAckMenutTitle=Sticky acknowledge for
 AlarmList_SyncJobError=Nelze synchronizovat seznam alarm\u016f
 AlarmList_SyncJobName=Synchronizovat seznam alarm\u016f
 AlarmList_Terminate=&Ukon\u010dit
+AlarmMelody_ErrorGettingMelodyList=Not possible to get melody list.
+AlarmMelody_ErrorGettingMelodyListDescription=Not possible to get melody list. Error:
+AlarmMelody_ErrorMelodyNotExists=Melody does not exist.
+AlarmMelody_ErrorMelodyNotExistsDescription=Melody was not found locally and it was not possible to download it from server. Melody is removed and will not be played. Error:
+AlarmMelody_JobGetMelodyList=Get melody list
+AlarmMelody_SaveClientSelection=Save client selection
+AlarmNotifier_ErrorMelodyNotExistsDescription=Melody was not found locally and it was not possible to download it from server. Melody is removed and will not be played. Error:
+AlarmNotifier_ErrorMelodynotExists=Melody does not exist.
+AlarmNotifier_ErrorPlayingSound=Was not possible to play sound
+AlarmNotifier_ErrorPlayingSoundDescription=Error while playing sound. Melody will not be played. Error:
+AlarmNotifier_JobSoundNotFoundError=Send error that sound file is not found
 AlarmNotifier_ToolTip_Header=NetXMS Alarm (
 AlarmReminderDialog_Dismiss=Zam\u00edtnout
 AlarmReminderDialog_OutstandingAlarms=Nevy\u0159e\u0161en\u00e9 alarmy
index f0a1c99..b8b983d 100644 (file)
@@ -73,6 +73,17 @@ AlarmList_StickyAckMenutTitle=Sticky acknowledge for
 AlarmList_SyncJobError=No es posible sincronizar la lista de alarmas
 AlarmList_SyncJobName=Sincronizar la lista de alarmas
 AlarmList_Terminate=&Terminar
+AlarmMelody_ErrorGettingMelodyList=Not possible to get melody list.
+AlarmMelody_ErrorGettingMelodyListDescription=Not possible to get melody list. Error:
+AlarmMelody_ErrorMelodyNotExists=Melody does not exist.
+AlarmMelody_ErrorMelodyNotExistsDescription=Melody was not found locally and it was not possible to download it from server. Melody is removed and will not be played. Error:
+AlarmMelody_JobGetMelodyList=Get melody list
+AlarmMelody_SaveClientSelection=Save client selection
+AlarmNotifier_ErrorMelodyNotExistsDescription=Melody was not found locally and it was not possible to download it from server. Melody is removed and will not be played. Error:
+AlarmNotifier_ErrorMelodynotExists=Melody does not exist.
+AlarmNotifier_ErrorPlayingSound=Was not possible to play sound
+AlarmNotifier_ErrorPlayingSoundDescription=Error while playing sound. Melody will not be played. Error:
+AlarmNotifier_JobSoundNotFoundError=Send error that sound file is not found
 AlarmNotifier_ToolTip_Header=Alarma NetXMS (
 AlarmReminderDialog_Dismiss=Descartar
 AlarmReminderDialog_OutstandingAlarms=Alarmas Destacadas
index 050caf5..211a645 100644 (file)
@@ -73,6 +73,17 @@ AlarmList_StickyAckMenutTitle=Sticky acknowledge for
 AlarmList_SyncJobError=\u041d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0442\u0440\u0435\u0432\u043e\u0433
 AlarmList_SyncJobName=\u0421\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0442\u0440\u0435\u0432\u043e\u0433
 AlarmList_Terminate=&\u041f\u0440\u0435\u043a\u0440\u0430\u0442\u0438\u0442\u044c
+AlarmMelody_ErrorGettingMelodyList=Not possible to get melody list.
+AlarmMelody_ErrorGettingMelodyListDescription=Not possible to get melody list. Error:
+AlarmMelody_ErrorMelodyNotExists=Melody does not exist.
+AlarmMelody_ErrorMelodyNotExistsDescription=Melody was not found locally and it was not possible to download it from server. Melody is removed and will not be played. Error:
+AlarmMelody_JobGetMelodyList=Get melody list
+AlarmMelody_SaveClientSelection=Save client selection
+AlarmNotifier_ErrorMelodyNotExistsDescription=Melody was not found locally and it was not possible to download it from server. Melody is removed and will not be played. Error:
+AlarmNotifier_ErrorMelodynotExists=Melody does not exist.
+AlarmNotifier_ErrorPlayingSound=Was not possible to play sound
+AlarmNotifier_ErrorPlayingSoundDescription=Error while playing sound. Melody will not be played. Error:
+AlarmNotifier_JobSoundNotFoundError=Send error that sound file is not found
 AlarmNotifier_ToolTip_Header=\u0422\u0440\u0435\u0432\u043e\u0433\u0430 NetXMS (
 AlarmReminderDialog_Dismiss=\u041e\u0442\u043a\u043b\u043e\u043d\u0438\u0442\u044c
 AlarmReminderDialog_OutstandingAlarms=\u041d\u0435\u0440\u0435\u0448\u0435\u043d\u043d\u044b\u0435 \u0442\u0440\u0435\u0432\u043e\u0433\u0438
index 5c3df2f..11ce3da 100644 (file)
@@ -73,6 +73,17 @@ AlarmList_StickyAckMenutTitle=Sticky acknowledge for
 AlarmList_SyncJobError=\u65e0\u6cd5\u540c\u6b65\u544a\u8b66\u5217\u8868
 AlarmList_SyncJobName=\u540c\u6b65\u544a\u8b66\u5217\u8868
 AlarmList_Terminate=&Terminate
+AlarmMelody_ErrorGettingMelodyList=Not possible to get melody list.
+AlarmMelody_ErrorGettingMelodyListDescription=Not possible to get melody list. Error:
+AlarmMelody_ErrorMelodyNotExists=Melody does not exist.
+AlarmMelody_ErrorMelodyNotExistsDescription=Melody was not found locally and it was not possible to download it from server. Melody is removed and will not be played. Error:
+AlarmMelody_JobGetMelodyList=Get melody list
+AlarmMelody_SaveClientSelection=Save client selection
+AlarmNotifier_ErrorMelodyNotExistsDescription=Melody was not found locally and it was not possible to download it from server. Melody is removed and will not be played. Error:
+AlarmNotifier_ErrorMelodynotExists=Melody does not exist.
+AlarmNotifier_ErrorPlayingSound=Was not possible to play sound
+AlarmNotifier_ErrorPlayingSoundDescription=Error while playing sound. Melody will not be played. Error:
+AlarmNotifier_JobSoundNotFoundError=Send error that sound file is not found
 AlarmNotifier_ToolTip_Header=\u7f51\u7edc\u7ba1\u7406\u7cfb\u7edf\u544a\u8b66 (
 AlarmReminderDialog_Dismiss=Dismiss
 AlarmReminderDialog_OutstandingAlarms=Outstanding Alarms
diff --git a/webui/webapp/AlarmViewer/src/org/netxms/ui/eclipse/alarmviewer/preferencepages/AlarmMelody.java b/webui/webapp/AlarmViewer/src/org/netxms/ui/eclipse/alarmviewer/preferencepages/AlarmMelody.java
new file mode 100755 (executable)
index 0000000..c4ec534
--- /dev/null
@@ -0,0 +1,291 @@
+/**
+ * NetXMS - open source network management system
+ * Copyright (C) 2003-2013 Victor Kirhenshtein
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.netxms.ui.eclipse.alarmviewer.preferencepages;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.nio.channels.FileChannel;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.eclipse.ui.progress.UIJob;
+import org.netxms.client.NXCException;
+import org.netxms.client.NXCSession;
+import org.netxms.client.ServerFile;
+import org.netxms.ui.eclipse.alarmviewer.Activator;
+import org.netxms.ui.eclipse.alarmviewer.AlarmNotifier;
+import org.netxms.ui.eclipse.console.resources.StatusDisplayInfo;
+import org.netxms.ui.eclipse.shared.ConsoleSharedData;
+import org.netxms.ui.eclipse.tools.MessageDialogHelper;
+import org.netxms.ui.eclipse.tools.WidgetHelper;
+
+/**
+ * Alarm melody
+ */
+public class AlarmMelody extends PreferencePage implements IWorkbenchPreferencePage
+{
+   public static final String ID = "org.netxms.ui.eclipse.alarmviewer.views.AlarmMelodyView"; //$NON-NLS-1$
+
+   private NXCSession session;
+   private ServerFile[] serverFiles = null;
+   private IPreferenceStore ps;
+   private URL workspaceUrl;
+   private Set<String> melodyList = new HashSet<String>();
+   private List<String> currentMelodyList = new ArrayList<String>();
+   private Set<String> oldMelodyList = new HashSet<String>();
+   private List<String> newMelodyList = new ArrayList<String>();
+   private List<Combo> comboList = new ArrayList<Combo>();
+   private String[] severityArray = AlarmNotifier.severityArray;
+   /*
+    * (non-Javadoc)
+    * 
+    * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+    */
+   @Override
+   public void init(IWorkbench workbench)
+   {
+      setPreferenceStore(Activator.getDefault().getPreferenceStore());
+      session = (NXCSession)ConsoleSharedData.getSession();
+      ps = Activator.getDefault().getPreferenceStore();
+      workspaceUrl = Platform.getInstanceLocation().getURL();
+   }
+
+   /*
+    * (non-Javadoc)
+    * 
+    * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
+    */
+   @Override
+   protected Control createContents(Composite parent)
+   {
+      Composite dialogArea = new Composite(parent, SWT.NONE);
+      GridLayout layout = new GridLayout();
+      layout.verticalSpacing = WidgetHelper.DIALOG_SPACING;
+      layout.horizontalSpacing = WidgetHelper.DIALOG_SPACING;
+      layout.numColumns = 1;
+      layout.makeColumnsEqualWidth = true;
+      dialogArea.setLayout(layout);
+
+      Combo newCombo = null;
+
+      for(int i = 0; i < 5; i++)
+      {
+         newCombo = WidgetHelper.createLabeledCombo(dialogArea, SWT.DROP_DOWN | SWT.READ_ONLY, StatusDisplayInfo.getStatusText(i),
+               WidgetHelper.DEFAULT_LAYOUT_DATA);
+         newCombo.setEnabled(false);
+         comboList.add(i, newCombo);
+      }
+
+      new UIJob("Start alarm melody save") {
+         @Override
+         public IStatus runInUIThread(IProgressMonitor monitor)
+         {
+            try
+            {
+               String[] s = { "wav" }; //$NON-NLS-1$
+               serverFiles = session.listServerFiles(s);
+            }
+            catch(final Exception e)
+            {
+               e.printStackTrace();
+               getShell().getDisplay().asyncExec(new Runnable() {
+                  @Override
+                  public void run()
+                  {
+                     MessageDialogHelper.openError(getShell(), "Not possible to get melody list.",
+                           "Not possible to get melody list. Error: " + e.getMessage());
+                  }
+               });
+            }
+
+            for(ServerFile s : serverFiles)
+            {
+               melodyList.add(s.getName());
+            }
+            melodyList.add("");
+
+            for(int i = 0; i < 5; i++)
+            {
+               currentMelodyList.add(i, ps.getString("ALARM_NOTIFIER.MELODY." + severityArray[i]));
+            }
+            melodyList.addAll(currentMelodyList);
+
+            Combo newCombo = null;
+
+            for(int i = 0; i < 5; i++)
+            {
+               newCombo = comboList.get(i);
+               newCombo.setEnabled(true);
+               newCombo.setItems(melodyList.toArray(new String[melodyList.size()]));
+               newCombo.select(newCombo.indexOf(currentMelodyList.get(i)));
+            }
+
+            return Status.OK_STATUS;
+         }
+      }.schedule();
+      return dialogArea;
+   }
+
+   /**
+    * Apply changes
+    * 
+    * @param isApply true if update operation caused by "Apply" button
+    */
+   protected void applyChanges(final boolean isApply)
+   {
+      if (isApply)
+         setValid(false);
+
+      for(int i = 0; i < 5; i++)
+      {
+         newMelodyList.add(comboList.get(i).getText());
+      }
+      new UIJob("Start alarm melody save") {
+         @Override
+         public IStatus runInUIThread(IProgressMonitor monitor)
+         {
+            for(int i = 0; i < 5; i++)
+            {
+               changeMelody(newMelodyList.get(i), severityArray[i], i);
+            }
+            for(String oldName : oldMelodyList)
+            {
+               if (!currentMelodyList.contains(oldName))
+               {
+                  File file = new File(workspaceUrl.getPath(), oldName);
+                  file.delete();
+               }
+            }
+            if (isApply)
+               setValid(true);
+            return Status.OK_STATUS;
+         }
+
+      }.schedule();
+   }
+
+   private void changeMelody(final String melodyName, final String severity, final int id)
+   {
+      String oldMelodyName = currentMelodyList.get(id);
+      if (!melodyName.equals(oldMelodyName))
+      {
+         try
+         {
+            if (!checkMelodyExists(melodyName, workspaceUrl))
+               downloadMelodie(session, melodyName, workspaceUrl);
+            ps.setValue("ALARM_NOTIFIER.MELODY." + severity, melodyName);
+            currentMelodyList.set(id, melodyName);
+            oldMelodyList.add(oldMelodyName);
+         }
+         catch(NXCException | IOException e)
+         {
+            getShell().getDisplay().asyncExec(new Runnable() {
+               @Override
+               public void run()
+               {
+                  MessageDialogHelper
+                        .openError(
+                              getShell(),
+                              "Melody does not exist.",
+                              "Melody was not found "
+                                    + "locally and it was not possible to download it from server. Melody is removed and will not be played. Error: "
+                                    + e.getMessage());
+               }
+            });
+            ps.setValue("ALARM_NOTIFIER.MELODY." + severity, "");
+         }
+      }
+   }
+
+   private static boolean checkMelodyExists(String melodyName, URL workspaceUrl)
+   {
+      if (workspaceUrl != null && melodyName != null && !melodyName.equals(""))
+      {
+         File f = new File(workspaceUrl.getPath(), melodyName);
+         return f.isFile();
+      }
+      else
+      {
+         return true;
+      }
+   }
+
+   private static void downloadMelodie(NXCSession session, String melodyName, URL workspaceUrl) throws NXCException, IOException
+   {
+      File f = new File(workspaceUrl.getPath(), melodyName);
+      f.createNewFile();
+      FileChannel src = null;
+      FileChannel dest = null;
+      try
+      {
+         src = new FileInputStream(session.downloadFileFromServer(melodyName)).getChannel();
+         dest = new FileOutputStream(f).getChannel();
+         dest.transferFrom(src, 0, src.size());
+      }
+      catch(NXCException | IOException e)
+      {
+         System.out.println("Not possible to copy inside new file content.");
+      }
+      finally
+      {
+         src.close();
+         dest.close();
+      }
+   }
+
+   /*
+    * (non-Javadoc)
+    * 
+    * @see org.eclipse.jface.preference.PreferencePage#performOk()
+    */
+   @Override
+   public boolean performOk()
+   {
+      applyChanges(false);
+      return true;
+   }
+
+   /*
+    * (non-Javadoc)
+    * 
+    * @see org.eclipse.jface.preference.PreferencePage#performApply()
+    */
+   @Override
+   protected void performApply()
+   {
+      applyChanges(true);
+   }
+}
index 1aa0111..44fe1c9 100644 (file)
@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
-       <classpathentry exported="true" kind="lib" path="jar/certificate-manager-1.2.12.jar"/>
-       <classpathentry exported="true" kind="lib" path="jar/netxms-base-1.2.12.jar"/>
-       <classpathentry exported="true" kind="lib" path="jar/netxms-client-1.2.12.jar"/>
-       <classpathentry exported="true" kind="lib" path="jar/netxms-client-api-1.2.12.jar"/>
+       <classpathentry exported="true" kind="lib" path="jar/certificate-manager-1.2.13.jar"/>
+       <classpathentry exported="true" kind="lib" path="jar/netxms-base-1.2.13.jar"/>
+       <classpathentry exported="true" kind="lib" path="jar/netxms-client-1.2.13.jar"/>
+       <classpathentry exported="true" kind="lib" path="jar/netxms-client-api-1.2.13.jar"/>
        <classpathentry exported="true" kind="lib" path="jar/simple-xml-2.6.4.jar"/>
        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
        <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
index 1f35ca2..9891418 100644 (file)
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: NetXMS WebUI Core
 Bundle-SymbolicName: org.netxms.webui.core; singleton:=true
-Bundle-Version: 1.2.12
+Bundle-Version: 1.2.13
 Bundle-Activator: org.netxms.ui.eclipse.console.Activator
 Bundle-Vendor: netxms.org
 Require-Bundle: org.eclipse.core.runtime;bundle-version="3.8.0",
@@ -14,10 +14,10 @@ Import-Package: javax.servlet;version="2.5.0",
  javax.servlet.http;version="2.5.0"
 Bundle-ClassPath: .,
  jar/simple-xml-2.6.4.jar,
- jar/certificate-manager-1.2.12.jar,
- jar/netxms-base-1.2.12.jar,
- jar/netxms-client-1.2.12.jar,
- jar/netxms-client-api-1.2.12.jar
+ jar/certificate-manager-1.2.13.jar,
+ jar/netxms-base-1.2.13.jar,
+ jar/netxms-client-1.2.13.jar,
+ jar/netxms-client-api-1.2.13.jar
 Export-Package: org.netxms.api.client,
  org.netxms.api.client.constants,
  org.netxms.api.client.images,
@@ -42,6 +42,7 @@ Export-Package: org.netxms.api.client,
  org.netxms.client.snmp,
  org.netxms.client.topology,
  org.netxms.ui.eclipse.actions,
+ org.netxms.ui.eclipse.console,
  org.netxms.ui.eclipse.console.api,
  org.netxms.ui.eclipse.console.resources,
  org.netxms.ui.eclipse.jobs,
index 0095b43..0c455ec 100644 (file)
@@ -7,7 +7,7 @@ bin.includes = plugin.xml,\
                icons/,\
                theme/,\
                jar/,\
-               jar/certificate-manager-1.2.12.jar,\
-               jar/netxms-base-1.2.12.jar,\
-               jar/netxms-client-1.2.12.jar,\
-               jar/netxms-client-api-1.2.12.jar
+               jar/certificate-manager-1.2.13.jar,\
+               jar/netxms-base-1.2.13.jar,\
+               jar/netxms-client-1.2.13.jar,\
+               jar/netxms-client-api-1.2.13.jar
index a61a2b3..0806ca3 100644 (file)
@@ -73,7 +73,7 @@ public class ExportToCsvAction extends Action
                // "Object Details" view can contain multiple widgets
                // with "Export to CSV" action defined, so binding it to handler service
                // will cause handler conflict
-               if (viewPart.getViewSite().getId().equals("org.netxms.ui.eclipse.objectview.view.tabbed_object_view")) //$NON-NLS-1$
+               if ((viewPart == null) || viewPart.getViewSite().getId().equals("org.netxms.ui.eclipse.objectview.view.tabbed_object_view")) //$NON-NLS-1$
                        return;
                
                final IHandlerService handlerService = (IHandlerService)viewPart.getSite().getService(IHandlerService.class);
index 7969c15..078145a 100644 (file)
@@ -38,6 +38,7 @@ import org.netxms.api.client.Session;
 import org.netxms.client.NXCSession;
 import org.netxms.ui.eclipse.console.api.LoginForm;
 import org.netxms.ui.eclipse.console.dialogs.PasswordExpiredDialog;
+import org.netxms.ui.eclipse.jobs.LoginJob;
 
 /**
  * Workbench advisor for NetXMS console application
index 242b3a5..5edda44 100644 (file)
@@ -196,8 +196,8 @@ private Messages()
         */
        public static Messages get(Display display)
        {
-               CallHelper r = new CallHelper();
-               display.syncExec(r);
+      CallHelper r = new CallHelper();
+          RWT.getUISession(display).exec(r);
                return r.messages;
        }
 
index 5ec4bf1..7d3da19 100644 (file)
@@ -61,7 +61,7 @@ public abstract class ConsoleJob extends Job
                siteService = (wbPart != null) ? 
                                        (IWorkbenchSiteProgressService)wbPart.getSite().getService(IWorkbenchSiteProgressService.class) : null;
                setUser(true);
-               display = PlatformUI.getWorkbench().getDisplay();
+               display = Display.getCurrent();
                if (display == null)
                        throw new IllegalThreadStateException("ConsoleJob constructor called from non-UI thread");
        }
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-package org.netxms.ui.eclipse.console;
+package org.netxms.ui.eclipse.jobs;
 
 import java.lang.reflect.InvocationTargetException;
 import java.security.Signature;
@@ -32,6 +32,7 @@ import org.eclipse.swt.widgets.Display;
 import org.netxms.api.client.Session;
 import org.netxms.base.NXCommon;
 import org.netxms.client.NXCSession;
+import org.netxms.ui.eclipse.console.Messages;
 import org.netxms.ui.eclipse.console.api.ConsoleLoginListener;
 import org.netxms.ui.eclipse.console.api.SessionProvider;
 
@@ -40,24 +41,6 @@ import org.netxms.ui.eclipse.console.api.SessionProvider;
  */
 public class LoginJob implements IRunnableWithProgress
 {
-   private final class KeepAliveHelper implements Runnable
-   {
-      @Override
-      public void run()
-      {
-         final Session session = (Session)RWT.getUISession(display).getAttribute("netxms.sesion"); //$NON-NLS-1$
-         try
-         {
-            session.checkConnection();
-            Thread.sleep(1000 * 30); // send keepalive every 30 seconds
-         }
-         catch(Exception e)
-         {
-            // ignore everything
-         }
-      }
-   }
-
    private Display display;
    private String server;
    private String loginName;
@@ -162,8 +145,8 @@ public class LoginJob implements IRunnableWithProgress
          callLoginListeners(session);
          monitor.worked(5);
 
-         Runnable keepAliveTimer = new KeepAliveHelper();
-         final Thread thread = new Thread(keepAliveTimer);
+         Runnable keepAliveTimer = new KeepAliveTimer();
+         final Thread thread = new Thread(null, keepAliveTimer, "KeepAliveTimer");
          thread.setDaemon(true);
          thread.start();
       }
@@ -173,6 +156,7 @@ public class LoginJob implements IRunnableWithProgress
       }
       finally
       {
+         monitor.setTaskName(""); //$NON-NLS-1$
          monitor.done();
       }
    }
@@ -277,4 +261,28 @@ public class LoginJob implements IRunnableWithProgress
       this.signature = signature;
       authMethod = NXCSession.AUTH_TYPE_CERTIFICATE;
    }
+
+   /**
+    * Keep-alive timer
+    */
+   private final class KeepAliveTimer implements Runnable
+   {
+      @Override
+      public void run()
+      {
+         while(true)
+         {
+            final Session session = (Session)RWT.getUISession(display).getAttribute("netxms.sesion"); //$NON-NLS-1$
+            try
+            {
+               Thread.sleep(1000 * 60); // send keep-alive every 60 seconds
+               if (!session.checkConnection())
+                  break;   // session broken, application will exit (handled by workbench advisor)
+            }
+            catch(Exception e)
+            {
+            }
+         }
+      }
+   }
 }
index cfa4718..c3e5174 100644 (file)
@@ -19,6 +19,7 @@
 package org.netxms.ui.eclipse.shared;
 
 import org.eclipse.rap.rwt.RWT;
+import org.eclipse.swt.widgets.Display;
 import org.netxms.api.client.Session;
 
 /**
@@ -47,6 +48,16 @@ public class ConsoleSharedData
                return RWT.getUISession().getAttribute("netxms." + name);
        }
        
+   /**
+    * @param display
+    * @param name
+    * @return
+    */
+   public static Object getProperty(Display display, final String name)
+   {
+      return RWT.getUISession(display).getAttribute("netxms." + name);
+   }
+   
        /**
         * Set value of console property
         * 
@@ -57,4 +68,16 @@ public class ConsoleSharedData
        {
                RWT.getUISession().setAttribute("netxms." + name, value);
        }
+
+   /**
+    * Set value of console property
+    * 
+    * @param display
+    * @param name
+    * @param value
+    */
+   public static void setProperty(Display display, final String name, final Object value)
+   {
+      RWT.getUISession(display).setAttribute("netxms." + name, value);
+   }
 }
index 01c203c..2b00cf9 100644 (file)
@@ -20,4 +20,5 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.8.0",
  org.eclipse.rap.addons.filedialog;bundle-version="0.5.0"
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Bundle-ActivationPolicy: lazy
-Export-Package: org.netxms.ui.eclipse.dashboard.api
+Export-Package: org.netxms.ui.eclipse.dashboard.api,
+ org.netxms.ui.eclipse.dashboard.widgets
index 5c66f92..75eebac 100644 (file)
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: Data Collection Management Plug-in
 Bundle-SymbolicName: org.netxms.ui.eclipse.datacollection;singleton:=true
-Bundle-Version: 1.2.11
+Bundle-Version: 1.2.13
 Bundle-Activator: org.netxms.ui.eclipse.datacollection.Activator
 Bundle-Vendor: netxms.org
 Require-Bundle: org.netxms.ui.eclipse.objectbrowser;bundle-version="1.2.10",
@@ -10,7 +10,7 @@ Require-Bundle: org.netxms.ui.eclipse.objectbrowser;bundle-version="1.2.10",
  org.netxms.ui.eclipse.snmp;bundle-version="1.2.10",
  org.netxms.ui.eclipse.nxsl;bundle-version="1.2.11",
  org.eclipse.core.expressions;bundle-version="3.4.500",
- org.netxms.webui.core;bundle-version="1.2.11",
+ org.netxms.webui.core;bundle-version="1.2.13",
  org.eclipse.rap.ui;bundle-version="2.2.0",
  org.netxms.ui.eclipse.charts;bundle-version="1.2.11",
  org.eclipse.rap.ui.forms;bundle-version="2.2.0",
index 2c80c47..2ca7298 100644 (file)
@@ -33,6 +33,6 @@ public class LoginListener implements ConsoleLoginListener
        @Override
        public void afterLogin(NXCSession session, Display display)
        {
-               SummaryTablesCache.attachSession(session);
+               SummaryTablesCache.attachSession(display, session);
        }
 }
index dfcabc5..74c1e8c 100644 (file)
@@ -43,10 +43,10 @@ public class SummaryTablesCache
     * 
     * @param session
     */
-   public static void attachSession(NXCSession session)
+   public static void attachSession(Display display, NXCSession session)
    {
-      SummaryTablesCache instance = new SummaryTablesCache(session);
-      ConsoleSharedData.setProperty("SummaryTablesCache", instance);
+      SummaryTablesCache instance = new SummaryTablesCache(display, session);
+      ConsoleSharedData.setProperty(display, "SummaryTablesCache", instance);
    }
 
    /**
@@ -63,10 +63,10 @@ public class SummaryTablesCache
         * Initialize object tools cache. Should be called when connection with
         * the server already established.
         */
-       private SummaryTablesCache(NXCSession session)
+       private SummaryTablesCache(Display display, NXCSession session)
        {
                this.session = session;
-      display = Display.getCurrent();
+      this.display = display;
                
                reload();
                
@@ -103,7 +103,11 @@ public class SummaryTablesCache
                                        tables.put(d.getId(), d);
                                }
                        }
-             SourceProvider.getInstance(display).update();
+                       SourceProvider p = SourceProvider.getInstance(display);
+                       if (p != null)
+                       {
+                          p.update();
+                       }
                }
                catch(Exception e)
                {
index 540803b..8e338fc 100644 (file)
@@ -2,12 +2,12 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: NXMC Image Library Plugin
 Bundle-SymbolicName: org.netxms.ui.eclipse.imagelibrary;singleton:=true
-Bundle-Version: 1.2.10
+Bundle-Version: 1.2.13
 Bundle-Activator: org.netxms.ui.eclipse.imagelibrary.Activator
 Bundle-Vendor: netxms.org
 Require-Bundle: org.eclipse.rap.ui;bundle-version="2.2.0",
  org.netxms.nebula.widgets.gallery;bundle-version="0.5.3",
- org.netxms.webui.core;bundle-version="1.2.10",
+ org.netxms.webui.core;bundle-version="1.2.13",
  org.eclipse.rap.addons.filedialog;bundle-version="0.5.0"
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Bundle-ActivationPolicy: lazy
index 59e7d08..0c62991 100644 (file)
@@ -46,7 +46,7 @@ public class LoginListener implements ConsoleLoginListener
        public void afterLogin(final NXCSession session, final Display display)
        {
                ImageProvider.createInstance(display, session);
-               Job job = new Job(Messages.get().LoginListener_JobName) {
+               Job job = new Job(Messages.get(display).LoginListener_JobName) {
                        @Override
                        protected IStatus run(IProgressMonitor monitor)
                        {
index e93159b..f1561e5 100644 (file)
@@ -69,7 +69,7 @@ private Messages()
        public static Messages get(Display display)
        {
                CallHelper r = new CallHelper();
-               display.syncExec(r);
+               RWT.getUISession(display).exec(r);
                return r.messages;
        }
 
@@ -86,5 +86,4 @@ private Messages()
                        messages = RWT.NLS.getISO8859_1Encoded(BUNDLE_NAME, Messages.class);
                }
        }
-
 }
index 9fa2b97..84ad271 100644 (file)
@@ -12,7 +12,6 @@ import java.util.Set;
 import java.util.UUID;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.rap.rwt.SingletonUtil;
 import org.eclipse.swt.SWTException;
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.widgets.Display;
@@ -23,6 +22,7 @@ import org.netxms.client.NXCSession;
 import org.netxms.ui.eclipse.imagelibrary.Activator;
 import org.netxms.ui.eclipse.imagelibrary.Messages;
 import org.netxms.ui.eclipse.jobs.ConsoleJob;
+import org.netxms.ui.eclipse.shared.ConsoleSharedData;
 
 public class ImageProvider
 {
@@ -35,14 +35,15 @@ public class ImageProvider
         */
        public static void createInstance(final Display display, final NXCSession session)
        {
-               display.syncExec(new Runnable() {
-                       @Override
-                       public void run()
-                       {
-                               ImageProvider p = SingletonUtil.getSessionInstance(ImageProvider.class);
-                               p.init(display, session);
-                       }
-               });
+          display.syncExec(new Runnable() {
+         @Override
+         public void run()
+         {
+            ImageProvider p = new ImageProvider();
+            p.init(display, session);
+            ConsoleSharedData.setProperty("ImageProvider", p);
+         }
+      });
        }
 
        /**
@@ -52,23 +53,7 @@ public class ImageProvider
         */
        public static ImageProvider getInstance(Display display)
        {
-               InstanceQuery q = new InstanceQuery();
-               display.syncExec(q);
-               return q.instance;
-       }
-       
-       /**
-        * Helper class for query instance on UI thread
-        */
-       private static class InstanceQuery implements Runnable
-       {
-               public ImageProvider instance;
-
-               @Override
-               public void run()
-               {
-                       instance = SingletonUtil.getSessionInstance(ImageProvider.class);
-               }
+          return (ImageProvider)ConsoleSharedData.getProperty(display, "ImageProvider");
        }
 
        private Image missingImage;
diff --git a/webui/webapp/Mobile/.classpath b/webui/webapp/Mobile/.classpath
new file mode 100644 (file)
index 0000000..db7e57c
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry exported="true" kind="lib" path="jar/tabris-1.2.0.jar" sourcepath="C:/Users/Victor/.m2/repository/com/eclipsesource/tabris/tabris/1.2.0/tabris-1.2.0-sources.jar"/>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/webui/webapp/Mobile/.project b/webui/webapp/Mobile/.project
new file mode 100644 (file)
index 0000000..ec7de3e
--- /dev/null
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>Mobile</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ds.core.builder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
diff --git a/webui/webapp/Mobile/.settings/org.eclipse.jdt.core.prefs b/webui/webapp/Mobile/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..c537b63
--- /dev/null
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/webui/webapp/Mobile/META-INF/MANIFEST.MF b/webui/webapp/Mobile/META-INF/MANIFEST.MF
new file mode 100644 (file)
index 0000000..a264a79
--- /dev/null
@@ -0,0 +1,18 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Mobile
+Bundle-SymbolicName: org.netxms.webui.mobile;singleton:=true
+Bundle-Version: 1.3.0
+Bundle-Activator: org.netxms.webui.mobile.Activator
+Bundle-Vendor: Raden Solutions
+Require-Bundle: org.eclipse.core.runtime;bundle-version="3.9.0",
+ org.eclipse.rap.ui;bundle-version="2.2.0",
+ org.netxms.webui.core;bundle-version="1.2.12",
+ javax.servlet;bundle-version="3.0.0",
+ org.netxms.ui.eclipse.perfview;bundle-version="1.2.11",
+ org.netxms.ui.eclipse.dashboard;bundle-version="1.2.11"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-ActivationPolicy: lazy
+Bundle-ClassPath: jar/tabris-1.2.0.jar,
+ .
+Service-Component: OSGI-INF/configuration.xml
diff --git a/webui/webapp/Mobile/OSGI-INF/configuration.xml b/webui/webapp/Mobile/OSGI-INF/configuration.xml
new file mode 100644 (file)
index 0000000..fa5dcea
--- /dev/null
@@ -0,0 +1,7 @@
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0">
+  <implementation class="org.netxms.webui.mobile.Configuration"/>
+  <service>
+     <provide interface="org.eclipse.rap.rwt.application.ApplicationConfiguration"/>
+  </service>
+  <property name="contextName" type="String" value="mobile"/>
+</scr:component>
diff --git a/webui/webapp/Mobile/build.properties b/webui/webapp/Mobile/build.properties
new file mode 100644 (file)
index 0000000..2753493
--- /dev/null
@@ -0,0 +1,6 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .,\
+               jar/tabris-1.2.0.jar,\
+               plugin.xml
diff --git a/webui/webapp/Mobile/icons/alarms.png b/webui/webapp/Mobile/icons/alarms.png
new file mode 100644 (file)
index 0000000..54d4b7b
Binary files /dev/null and b/webui/webapp/Mobile/icons/alarms.png differ
diff --git a/webui/webapp/Mobile/icons/dashboard.png b/webui/webapp/Mobile/icons/dashboard.png
new file mode 100644 (file)
index 0000000..6aee19a
Binary files /dev/null and b/webui/webapp/Mobile/icons/dashboard.png differ
diff --git a/webui/webapp/Mobile/icons/entire_network.png b/webui/webapp/Mobile/icons/entire_network.png
new file mode 100644 (file)
index 0000000..1d9264c
Binary files /dev/null and b/webui/webapp/Mobile/icons/entire_network.png differ
diff --git a/webui/webapp/Mobile/icons/graphs.png b/webui/webapp/Mobile/icons/graphs.png
new file mode 100644 (file)
index 0000000..049a8b8
Binary files /dev/null and b/webui/webapp/Mobile/icons/graphs.png differ
diff --git a/webui/webapp/Mobile/icons/nodes.png b/webui/webapp/Mobile/icons/nodes.png
new file mode 100644 (file)
index 0000000..8bdf31b
Binary files /dev/null and b/webui/webapp/Mobile/icons/nodes.png differ
diff --git a/webui/webapp/Mobile/icons/object_cluster.png b/webui/webapp/Mobile/icons/object_cluster.png
new file mode 100644 (file)
index 0000000..05d223f
Binary files /dev/null and b/webui/webapp/Mobile/icons/object_cluster.png differ
diff --git a/webui/webapp/Mobile/icons/object_container.png b/webui/webapp/Mobile/icons/object_container.png
new file mode 100644 (file)
index 0000000..0cee323
Binary files /dev/null and b/webui/webapp/Mobile/icons/object_container.png differ
diff --git a/webui/webapp/Mobile/icons/object_mobiledevice.png b/webui/webapp/Mobile/icons/object_mobiledevice.png
new file mode 100644 (file)
index 0000000..c01d8f9
Binary files /dev/null and b/webui/webapp/Mobile/icons/object_mobiledevice.png differ
diff --git a/webui/webapp/Mobile/icons/object_node.png b/webui/webapp/Mobile/icons/object_node.png
new file mode 100644 (file)
index 0000000..9fdfc6b
Binary files /dev/null and b/webui/webapp/Mobile/icons/object_node.png differ
diff --git a/webui/webapp/Mobile/icons/object_subnet.png b/webui/webapp/Mobile/icons/object_subnet.png
new file mode 100644 (file)
index 0000000..ad8382a
Binary files /dev/null and b/webui/webapp/Mobile/icons/object_subnet.png differ
diff --git a/webui/webapp/Mobile/icons/object_unknown.png b/webui/webapp/Mobile/icons/object_unknown.png
new file mode 100644 (file)
index 0000000..77c86d1
Binary files /dev/null and b/webui/webapp/Mobile/icons/object_unknown.png differ
diff --git a/webui/webapp/Mobile/icons/object_zone.png b/webui/webapp/Mobile/icons/object_zone.png
new file mode 100644 (file)
index 0000000..ab74ece
Binary files /dev/null and b/webui/webapp/Mobile/icons/object_zone.png differ
diff --git a/webui/webapp/Mobile/jar/tabris-1.2.0.jar b/webui/webapp/Mobile/jar/tabris-1.2.0.jar
new file mode 100644 (file)
index 0000000..142bfbc
Binary files /dev/null and b/webui/webapp/Mobile/jar/tabris-1.2.0.jar differ
diff --git a/webui/webapp/Mobile/plugin.xml b/webui/webapp/Mobile/plugin.xml
new file mode 100644 (file)
index 0000000..5535690
--- /dev/null
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+
+</plugin>
diff --git a/webui/webapp/Mobile/src/org/netxms/webui/mobile/Activator.java b/webui/webapp/Mobile/src/org/netxms/webui/mobile/Activator.java
new file mode 100644 (file)
index 0000000..cf8cee1
--- /dev/null
@@ -0,0 +1,69 @@
+package org.netxms.webui.mobile;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin
+{
+
+   // The plug-in ID
+   public static final String PLUGIN_ID = "org.netxms.webui.mobile"; //$NON-NLS-1$
+
+   // The shared instance
+   private static Activator plugin;
+
+   /**
+    * The constructor
+    */
+   public Activator()
+   {
+   }
+
+   /*
+    * (non-Javadoc)
+    * 
+    * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+    */
+   public void start(BundleContext context) throws Exception
+   {
+      super.start(context);
+      plugin = this;
+   }
+
+   /*
+    * (non-Javadoc)
+    * 
+    * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+    */
+   public void stop(BundleContext context) throws Exception
+   {
+      plugin = null;
+      super.stop(context);
+   }
+
+   /**
+    * Returns the shared instance
+    * 
+    * @return the shared instance
+    */
+   public static Activator getDefault()
+   {
+      return plugin;
+   }
+
+   /**
+    * Returns an image descriptor for the image file at the given
+    * plug-in relative path
+    *
+    * @param path the path
+    * @return the image descriptor
+    */
+   public static ImageDescriptor getImageDescriptor(String path)
+   {
+      return imageDescriptorFromPlugin(PLUGIN_ID, path);
+   }
+}
diff --git a/webui/webapp/Mobile/src/org/netxms/webui/mobile/Configuration.java b/webui/webapp/Mobile/src/org/netxms/webui/mobile/Configuration.java
new file mode 100644 (file)
index 0000000..d105bfb
--- /dev/null
@@ -0,0 +1,84 @@
+/**
+ * 
+ */
+package org.netxms.webui.mobile;
+
+import org.eclipse.rap.rwt.application.Application;
+import org.eclipse.rap.rwt.application.Application.OperationMode;
+import org.eclipse.rap.rwt.application.ApplicationConfiguration;
+import org.netxms.webui.mobile.pages.Alarms;
+import org.netxms.webui.mobile.pages.DashboardPage;
+import org.netxms.webui.mobile.pages.HomePage;
+import org.netxms.webui.mobile.pages.ObjectBrowser;
+import org.netxms.webui.mobile.pages.PredefinedGraphTree;
+import com.eclipsesource.tabris.TabrisClientInstaller;
+import com.eclipsesource.tabris.ui.PageConfiguration;
+import com.eclipsesource.tabris.ui.TabrisUIEntrypointFactory;
+import com.eclipsesource.tabris.ui.UIConfiguration;
+
+/**
+ * Application configuration for mobile client
+ */
+public class Configuration implements ApplicationConfiguration
+{
+   /* (non-Javadoc)
+    * @see org.eclipse.rap.rwt.application.ApplicationConfiguration#configure(org.eclipse.rap.rwt.application.Application)
+    */
+   @Override
+   public void configure(Application application)
+   {
+      TabrisClientInstaller.install(application);
+      application.addEntryPoint("/client", new TabrisUIEntrypointFactory(createUIConfiguration()), null);
+      application.setOperationMode(OperationMode.SWT_COMPATIBILITY);
+   }
+
+   /**
+    * @return
+    */
+   private UIConfiguration createUIConfiguration()
+   {
+      UIConfiguration uiConfiguration = new UIConfiguration();
+      
+      // Add a top level page
+      PageConfiguration homePage = new PageConfiguration("page.home", HomePage.class);
+      homePage.setTopLevel(true);
+      homePage.setTitle("NetXMS Client");
+      uiConfiguration.addPageConfiguration(homePage);
+
+      PageConfiguration page = new PageConfiguration("page.alarms", Alarms.class);
+      page.setTitle("Alarms");
+      uiConfiguration.addPageConfiguration(page);
+      
+      page = new PageConfiguration("page.objectBrowser", ObjectBrowser.class);
+      page.setTitle("Object Browser");
+      uiConfiguration.addPageConfiguration(page);
+      
+      page = new PageConfiguration("page.graphs", PredefinedGraphTree.class);
+      page.setTitle("Graphs");
+      uiConfiguration.addPageConfiguration(page);
+      
+      page = new PageConfiguration("page.dashboard", DashboardPage.class);
+      page.setTitle("Dashboard");
+      uiConfiguration.addPageConfiguration(page);
+      
+      /*
+      uiConfiguration.addTransitionListener(new TransitionListener() {
+         @Override
+         public void before(UI ui, Page from, Page to)
+         {
+         }
+         
+         @Override
+         public void after(UI ui, Page from, Page to)
+         {
+            if ((to instanceof HomePage) && !(from instanceof LoginPage))
+            {
+               ((AbstractPage)to).openPage("page.login");
+            }
+         }
+      });
+      */
+      
+      return uiConfiguration;
+   }
+}
diff --git a/webui/webapp/Mobile/src/org/netxms/webui/mobile/dialogs/ProgressDialog.java b/webui/webapp/Mobile/src/org/netxms/webui/mobile/dialogs/ProgressDialog.java
new file mode 100644 (file)
index 0000000..0d9e86a
--- /dev/null
@@ -0,0 +1,197 @@
+/**
+ * 
+ */
+package org.netxms.webui.mobile.dialogs;
+
+import java.lang.reflect.InvocationTargetException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.rap.rwt.service.ServerPushSession;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.ProgressBar;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * Progress dialog
+ */
+public class ProgressDialog extends Dialog
+{
+   private Label task;
+   private ProgressBar progressBar;
+   private IRunnableWithProgress runnable;
+   private InvocationTargetException exception = null;
+   
+   /**
+    * @param parentShell
+    */
+   public ProgressDialog(Shell parentShell)
+   {
+      super(parentShell);
+   }
+
+   @Override
+   protected void configureShell(Shell newShell)
+   {
+      super.configureShell(newShell);
+      newShell.setText("Connecting");
+      newShell.setAlpha(64);
+   }
+
+   /* (non-Javadoc)
+    * @see org.eclipse.jface.dialogs.Dialog#createContents(org.eclipse.swt.widgets.Composite)
+    */
+   @Override
+   protected Control createContents(Composite parent)
+   {
+      Composite content = new Composite(parent, SWT.NONE);
+      applyDialogFont(content);
+      content.setLayout(new GridLayout());
+      
+      task = new Label(content, SWT.NONE);
+      GridData gd = new GridData();
+      gd.horizontalAlignment = SWT.FILL;
+      gd.grabExcessHorizontalSpace = true;
+      task.setLayoutData(gd);
+      
+      progressBar = new ProgressBar(content, SWT.HORIZONTAL | SWT.READ_ONLY);
+      gd = new GridData();
+      gd.horizontalAlignment = SWT.FILL;
+      gd.grabExcessHorizontalSpace = true;
+      gd.heightHint = 15;
+      progressBar.setLayoutData(gd);
+      
+      startWorkerThread();
+      return content;
+   }
+   
+   /**
+    * 
+    */
+   private void startWorkerThread()
+   {
+      final Display display = getShell().getDisplay();
+      final ServerPushSession pushSession = new ServerPushSession();
+      final Thread workerThread = new Thread(new Runnable() {
+         @Override
+         public void run()
+         {
+            try
+            {
+               runnable.run(new IProgressMonitor() {        
+                  @Override
+                  public void worked(final int work)
+                  {
+                     display.asyncExec(new Runnable() {
+                        @Override
+                        public void run()
+                        {
+                           progressBar.setSelection(progressBar.getSelection() + work);
+                        }
+                     });
+                     display.wake();
+                     try
+                     {
+                        Thread.sleep(1000);
+                     }
+                     catch(InterruptedException e)
+                     {
+                        // TODO Auto-generated catch block
+                        e.printStackTrace();
+                     }
+                  }
+                  
+                  @Override
+                  public void subTask(String name)
+                  {
+                  }
+                  
+                  @Override
+                  public void setTaskName(final String name)
+                  {
+                     display.asyncExec(new Runnable() {
+                        @Override
+                        public void run()
+                        {
+                           task.setText(name);
+                        }
+                     });
+                  }
+                  
+                  @Override
+                  public void setCanceled(boolean value)
+                  {
+                  }
+                  
+                  @Override
+                  public boolean isCanceled()
+                  {
+                     return false;
+                  }
+                  
+                  @Override
+                  public void internalWorked(double work)
+                  {
+                  }
+                  
+                  @Override
+                  public void done()
+                  {
+                  }
+                  
+                  @Override
+                  public void beginTask(final String name, final int totalWork)
+                  {
+                     display.asyncExec(new Runnable() {
+                        @Override
+                        public void run()
+                        {
+                           progressBar.setMinimum(0);
+                           progressBar.setMaximum(totalWork);
+                           progressBar.setSelection(0);
+                           task.setText(name);
+                        }
+                     });
+                  }
+               });
+            }
+            catch(Exception e)
+            {
+               exception = new InvocationTargetException(e);
+            }
+            display.asyncExec(new Runnable() {
+               @Override
+               public void run()
+               {
+                  close();
+               }
+            });
+            display.asyncExec(null);
+            pushSession.stop();
+         }
+      });
+      pushSession.start();
+      workerThread.start();
+   }
+
+   /**
+    * @param runnable
+    * @throws InvocationTargetException
+    * @throws InterruptedException
+    */
+   public void run(final IRunnableWithProgress runnable) throws InvocationTargetException
+   {
+      this.runnable = runnable;
+      setBlockOnOpen(true);
+      open();
+      
+      if (exception != null)
+         throw exception;
+   }
+}
diff --git a/webui/webapp/Mobile/src/org/netxms/webui/mobile/pages/Alarms.java b/webui/webapp/Mobile/src/org/netxms/webui/mobile/pages/Alarms.java
new file mode 100644 (file)
index 0000000..e5a7951
--- /dev/null
@@ -0,0 +1,138 @@
+/**
+ * 
+ */
+package org.netxms.webui.mobile.pages;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.netxms.api.client.SessionNotification;
+import org.netxms.client.NXCException;
+import org.netxms.client.NXCListener;
+import org.netxms.client.NXCNotification;
+import org.netxms.client.NXCSession;
+import org.netxms.client.events.Alarm;
+import org.netxms.ui.eclipse.shared.ConsoleSharedData;
+import org.netxms.ui.eclipse.widgets.SortableTableViewer;
+import org.netxms.webui.mobile.pages.helpers.AlarmListLabelProvider;
+import com.eclipsesource.tabris.ui.AbstractPage;
+import com.eclipsesource.tabris.ui.PageData;
+
+/**
+ * Alarm viewer
+ */
+public class Alarms extends BasePage
+{
+   private Display display;
+   private NXCSession session = (NXCSession)ConsoleSharedData.getSession();
+   private NXCListener clientListener = null;
+   private Map<Long, Alarm> alarmList = new HashMap<Long, Alarm>();
+   private SortableTableViewer viewer;
+   
+   /* (non-Javadoc)
+    * @see org.netxms.webui.mobile.pages.BasePage#createPageContent(org.eclipse.swt.widgets.Composite, com.eclipsesource.tabris.ui.PageData)
+    */
+   @Override
+   public void createPageContent(Composite parent, PageData pageData)
+   {
+      final String[] names = { "Source", "Message" };
+      final int[] widths = { -1, -1 };
+      viewer = new SortableTableViewer(parent, names, widths, 0, SWT.DOWN, SWT.FULL_SELECTION);
+      viewer.setContentProvider(new ArrayContentProvider());
+      viewer.setLabelProvider(new AlarmListLabelProvider());
+      
+      // Add client library listener
+      clientListener = new NXCListener() {
+         @Override
+         public void notificationHandler(SessionNotification n)
+         {
+            switch(n.getCode())
+            {
+               case NXCNotification.NEW_ALARM:
+               case NXCNotification.ALARM_CHANGED:
+                  synchronized(alarmList)
+                  {
+                     alarmList.put(((Alarm)n.getObject()).getId(), (Alarm)n.getObject());
+                  }
+                  scheduleAlarmViewerUpdate();
+                  break;
+               case NXCNotification.ALARM_TERMINATED:
+               case NXCNotification.ALARM_DELETED:
+                  synchronized(alarmList)
+                  {
+                     alarmList.remove(((Alarm)n.getObject()).getId());
+                  }
+                  scheduleAlarmViewerUpdate();
+                  break;
+               default:
+                  break;
+            }
+         }
+      };
+      session.addListener(clientListener);
+
+      refresh();
+   }
+   
+   /**
+    * Refresh view 
+    */
+   private void refresh()
+   {
+      try
+      {
+         final HashMap<Long, Alarm> list = session.getAlarms();
+         synchronized(alarmList)
+         {
+            alarmList.clear();
+            alarmList.putAll(list);
+            viewer.setInput(alarmList.values().toArray());
+         }
+      }
+      catch(NXCException e)
+      {
+         // TODO Auto-generated catch block
+         e.printStackTrace();
+      }
+      catch(IOException e)
+      {
+         // TODO Auto-generated catch block
+         e.printStackTrace();
+      }
+   }
+
+   /**
+    * Schedule alarm viewer update
+    */
+   private void scheduleAlarmViewerUpdate()
+   {
+      display.asyncExec(new Runnable() {
+         @Override
+         public void run()
+         {
+            if (!viewer.getControl().isDisposed())
+            {
+               synchronized(alarmList)
+               {
+                  viewer.setInput(alarmList.values().toArray());
+               }
+            }
+         }
+      });
+   }
+
+   /* (non-Javadoc)
+    * @see org.netxms.webui.mobile.pages.BasePage#getTitle()
+    */
+   @Override
+   protected String getTitle()
+   {
+      return "Alarms";
+   }
+}
diff --git a/webui/webapp/Mobile/src/org/netxms/webui/mobile/pages/BasePage.java b/webui/webapp/Mobile/src/org/netxms/webui/mobile/pages/BasePage.java
new file mode 100644 (file)
index 0000000..528659b
--- /dev/null
@@ -0,0 +1,136 @@
+/**
+ * 
+ */
+package org.netxms.webui.mobile.pages;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.netxms.client.NXCSession;
+import org.netxms.ui.eclipse.shared.ConsoleSharedData;
+import org.netxms.webui.mobile.widgets.NavigationBar;
+import com.eclipsesource.tabris.ui.AbstractPage;
+import com.eclipsesource.tabris.ui.PageData;
+import com.eclipsesource.tabris.widgets.swipe.Swipe;
+import com.eclipsesource.tabris.widgets.swipe.SwipeContext;
+import com.eclipsesource.tabris.widgets.swipe.SwipeItem;
+import com.eclipsesource.tabris.widgets.swipe.SwipeItemProvider;
+
+/**
+ * Base page for all client pages
+ */
+public abstract class BasePage extends AbstractPage
+{
+   protected NXCSession session;
+   
+   private Swipe swipe;
+   private SwipeItem[] swipeItems = new SwipeItem[2];
+   private NavigationBar navigation;
+   private Composite content;
+   
+   /* (non-Javadoc)
+    * @see com.eclipsesource.tabris.ui.AbstractPage#createContent(org.eclipse.swt.widgets.Composite, com.eclipsesource.tabris.ui.PageData)
+    */
+   @Override
+   public final void createContent(Composite parent, final PageData pageData)
+   {
+      session = (NXCSession)ConsoleSharedData.getSession();
+      
+      parent.setLayout(new FillLayout());
+      
+      swipeItems[0] = new SwipeItem() {
+         @Override
+         public Control load(Composite parent)
+         {
+            navigation = new NavigationBar(parent);
+            return navigation;
+         }
+         
+         @Override
+         public boolean isPreloadable()
+         {
+            return true;
+         }
+         
+         @Override
+         public void deactivate(SwipeContext context)
+         {
+         }
+         
+         @Override
+         public void activate(SwipeContext context)
+         {
+            setTitle("Navigation");
+            Point size = navigation.getSize();
+            size.x -= 100;
+            navigation.setSize(size);
+         }
+      };
+      
+      swipeItems[1] = new SwipeItem() {
+         @Override
+         public Control load(Composite parent)
+         {
+            content = new Composite(parent, SWT.NONE);
+            content.setLayout(new FillLayout());
+            createPageContent(content, pageData);
+            return content;
+         }
+         
+         @Override
+         public boolean isPreloadable()
+         {
+            return true;
+         }
+         
+         @Override
+         public void deactivate(SwipeContext context)
+         {
+         }
+         
+         @Override
+         public void activate(SwipeContext context)
+         {
+            setTitle(getTitle());
+         }
+      };
+
+      /*
+      swipe = new Swipe(parent, new SwipeItemProvider() {
+         @Override
+         public int getItemCount()
+         {
+            return swipeItems.length;
+         }
+         
+         @Override
+         public SwipeItem getItem(int index)
+         {
+            return swipeItems[index];
+         }
+      });
+      swipe.show(1);
+      */
+      content = new Composite(parent, SWT.NONE);
+      content.setLayout(new FillLayout());
+      createPageContent(content, pageData);
+      
+   }
+
+   /**
+    * Create actual page content.
+    * 
+    * @param parent
+    * @param pageData
+    */
+   protected abstract void createPageContent(Composite parent, PageData pageData);
+   
+   /**
+    * Get page title
+    * 
+    * @return
+    */
+   protected abstract String getTitle();
+}
diff --git a/webui/webapp/Mobile/src/org/netxms/webui/mobile/pages/DashboardPage.java b/webui/webapp/Mobile/src/org/netxms/webui/mobile/pages/DashboardPage.java
new file mode 100644 (file)
index 0000000..0f1a2ab
--- /dev/null
@@ -0,0 +1,43 @@
+/**
+ * 
+ */
+package org.netxms.webui.mobile.pages;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.netxms.client.objects.Dashboard;
+import org.netxms.ui.eclipse.dashboard.widgets.DashboardControl;
+import com.eclipsesource.tabris.ui.PageData;
+
+/**
+ * @author Victor
+ *
+ */
+public class DashboardPage extends BasePage
+{
+   private Dashboard dashboard;
+   private DashboardControl dbc;
+   
+   /* (non-Javadoc)
+    * @see org.netxms.webui.mobile.pages.BasePage#createPageContent(org.eclipse.swt.widgets.Composite, com.eclipsesource.tabris.ui.PageData)
+    */
+   @Override
+   protected void createPageContent(Composite parent, PageData pageData)
+   {
+      Long id = pageData.get("object", Long.class);
+      dashboard = (Dashboard)((id != null) ? session.findObjectById(id, Dashboard.class) : null);
+      if (dashboard != null)
+      {
+         dbc = new DashboardControl(parent, SWT.NONE, dashboard, null, false);
+      }
+   }
+
+   /* (non-Javadoc)
+    * @see org.netxms.webui.mobile.pages.BasePage#getTitle()
+    */
+   @Override
+   protected String getTitle()
+   {
+      return (dashboard != null) ? dashboard.getObjectName() : "Error";
+   }
+}
diff --git a/webui/webapp/Mobile/src/org/netxms/webui/mobile/pages/HomePage.java b/webui/webapp/Mobile/src/org/netxms/webui/mobile/pages/HomePage.java
new file mode 100644 (file)
index 0000000..f715ad6
--- /dev/null
@@ -0,0 +1,187 @@
+package org.netxms.webui.mobile.pages;
+
+import java.lang.reflect.InvocationTargetException;
+import java.sql.ClientInfoStatus;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.rap.rwt.RWT;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.netxms.client.NXCSession;
+import org.netxms.ui.eclipse.jobs.LoginJob;
+import org.netxms.ui.eclipse.shared.ConsoleSharedData;
+import org.netxms.ui.eclipse.tools.ImageCache;
+import org.netxms.ui.eclipse.widgets.LabeledText;
+import org.netxms.webui.mobile.Activator;
+import org.netxms.webui.mobile.dialogs.ProgressDialog;
+import org.netxms.webui.mobile.widgets.ProgressWidget;
+import com.eclipsesource.tabris.device.ClientDevice;
+import com.eclipsesource.tabris.device.ClientDeviceListener;
+import com.eclipsesource.tabris.device.ClientDevice.ConnectionType;
+import com.eclipsesource.tabris.device.ClientDevice.Orientation;
+import com.eclipsesource.tabris.ui.AbstractPage;
+import com.eclipsesource.tabris.ui.PageData;
+import com.eclipsesource.tabris.widgets.enhancement.Widgets;
+
+/**
+ * Client home page
+ */
+public class HomePage extends AbstractPage
+{
+   private Composite content;
+   private LabeledText login;
+   private LabeledText password;
+   
+   /* (non-Javadoc)
+    * @see com.eclipsesource.tabris.ui.AbstractPage#createContent(org.eclipse.swt.widgets.Composite, com.eclipsesource.tabris.ui.PageData)
+    */
+   @Override
+   public void createContent(final Composite parent, PageData data)
+   {
+      NXCSession session = (NXCSession)ConsoleSharedData.getSession();
+      content = parent;
+      if (session != null)
+      {
+         createHomeScreen(parent);
+      }
+      else
+      {
+         createLoginForm(parent);
+      }
+      
+   }
+   
+   private void createHomeScreen(final Composite parent)
+   {
+      ClientDevice device = RWT.getClient().getService(ClientDevice.class);
+      
+      parent.setLayout(new GridLayout(device != null && device.getOrientation() == ClientDevice.Orientation.LANDSCAPE ? 3 : 2, true));
+      //parent.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));
+      
+      ImageCache imageCache = new ImageCache(parent);
+
+      addSelector(parent, "Alarms", imageCache.add(Activator.getImageDescriptor("icons/alarms.png")), "page.alarms", null);
+      PageData pd = new PageData();
+      pd.set("rootObject", Long.valueOf(7));
+      addSelector(parent, "Dashboards", imageCache.add(Activator.getImageDescriptor("icons/dashboard.png")), "page.objectBrowser", pd);
+      pd = new PageData();
+      pd.set("rootObject", Long.valueOf(2));
+      addSelector(parent, "Nodes", imageCache.add(Activator.getImageDescriptor("icons/nodes.png")), "page.objectBrowser", pd);
+      pd = new PageData();
+      pd.set("rootObject", Long.valueOf(1));
+      addSelector(parent, "Network", imageCache.add(Activator.getImageDescriptor("icons/entire_network.png")), "page.objectBrowser", pd);
+      addSelector(parent, "Graphs", imageCache.add(Activator.getImageDescriptor("icons/graphs.png")), "page.graphs", null);
+      
+      if (device != null)
+      {
+         device.addClientDeviceListener(new ClientDeviceListener() {
+            @Override
+            public void orientationChange(Orientation o)
+            {
+               ((GridLayout)parent.getLayout()).numColumns = (o == ClientDevice.Orientation.LANDSCAPE) ? 3 : 2;
+               parent.layout(true, true);
+            }
+            
+            @Override
+            public void connectionTypeChanged(ConnectionType ct)
+            {
+            }
+         });
+      }
+   }
+
+   private void addSelector(Composite parent, String name, Image icon, final String pageId, final PageData pageData)
+   {
+      Composite selector = new Composite(parent, SWT.BORDER);
+      selector.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+      
+      GridLayout layout = new GridLayout();
+      selector.setLayout(layout);
+      
+      Label image = new Label(selector, SWT.NONE);
+      image.setImage(icon);
+      image.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false));
+      
+      Label text = new Label(selector, SWT.NONE);
+      text.setText(name);
+      text.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false));
+      
+      Widgets.onComposite(selector).addGroupedListener(SWT.TOUCHSTATE_UP, new Listener() {
+         @Override
+         public void handleEvent(Event event)
+         {
+         &nbs