[SVN-NetXMS] revision 3367

From: NetXMS.org SVN Server <svn_at_DOMAIN_REMOVED>
Date: Sun, 6 Jul 2008 13:45:32 +0300

* { font-family: Consolas, Lucida Console, Courier New; font-size: 100%; }
h1 { font-size: 150%; }
td.linenos { background-color: #f0f0f0; padding-right: 10px; }
span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }
pre { line-height: 100%; width: 100%; }
.highlight span { width: 100%; display:-moz-inline-stack; display:inline-block; zoom:1; *display:inline; }
body { background: #ffffff; }
body .c { color: #999988; font-style: italic } /* Comment */
body .err { color: #a61717; background-color: #e3d2d2 } /* Error */
body .k { font-weight: bold } /* Keyword */
body .o { font-weight: bold } /* Operator */
body .cm { color: #999988; font-style: italic } /* Comment.Multiline */
body .cp { color: #999999; font-weight: bold } /* Comment.Preproc */
body .c1 { color: #999988; font-style: italic } /* Comment.Single */
body .cs { color: #999999; font-weight: bold; font-style: italic } /* Comment.Special */
body .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
body .ge { font-style: italic } /* Generic.Emph */
body .gr { color: #aa0000 } /* Generic.Error */
body .gh { color: #999999 } /* Generic.Heading */
body .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
body .go { color: #888888 } /* Generic.Output */
body .gp { color: #555555 } /* Generic.Prompt */
body .gs { font-weight: bold } /* Generic.Strong */
body .gu { color: #aaaaaa } /* Generic.Subheading */
body .gt { color: #aa0000 } /* Generic.Traceback */
body .kc { font-weight: bold } /* Keyword.Constant */
body .kd { font-weight: bold } /* Keyword.Declaration */
body .kp { font-weight: bold } /* Keyword.Pseudo */
body .kr { font-weight: bold } /* Keyword.Reserved */
body .kt { color: #445588; font-weight: bold } /* Keyword.Type */
body .m { color: #009999 } /* Literal.Number */
body .s { color: #bb8844 } /* Literal.String */
body .na { color: #008080 } /* Name.Attribute */
body .nb { color: #999999 } /* Name.Builtin */
body .nc { color: #445588; font-weight: bold } /* Name.Class */
body .no { color: #008080 } /* Name.Constant */
body .ni { color: #800080 } /* Name.Entity */
body .ne { color: #990000; font-weight: bold } /* Name.Exception */
body .nf { color: #990000; font-weight: bold } /* Name.Function */
body .nn { color: #555555 } /* Name.Namespace */
body .nt { color: #000080 } /* Name.Tag */
body .nv { color: #008080 } /* Name.Variable */
body .ow { font-weight: bold } /* Operator.Word */
body .w { color: #bbbbbb } /* Text.Whitespace */
body .mf { color: #009999 } /* Literal.Number.Float */
body .mh { color: #009999 } /* Literal.Number.Hex */
body .mi { color: #009999 } /* Literal.Number.Integer */
body .mo { color: #009999 } /* Literal.Number.Oct */
body .sb { color: #bb8844 } /* Literal.String.Backtick */
body .sc { color: #bb8844 } /* Literal.String.Char */
body .sd { color: #bb8844 } /* Literal.String.Doc */
body .s2 { color: #bb8844 } /* Literal.String.Double */
body .se { color: #bb8844 } /* Literal.String.Escape */
body .sh { color: #bb8844 } /* Literal.String.Heredoc */
body .si { color: #bb8844 } /* Literal.String.Interpol */
body .sx { color: #bb8844 } /* Literal.String.Other */
body .sr { color: #808000 } /* Literal.String.Regex */
body .s1 { color: #bb8844 } /* Literal.String.Single */
body .ss { color: #bb8844 } /* Literal.String.Symbol */
body .bp { color: #999999 } /* Name.Builtin.Pseudo */
body .vc { color: #008080 } /* Name.Variable.Class */
body .vg { color: #008080 } /* Name.Variable.Global */
body .vi { color: #008080 } /* Name.Variable.Instance */
body .il { color: #009999 } /* Literal.Number.Integer.Long */

Info

Revision:3367
Author:victor

Date:2008-07-06 13:45:32 +0300 (Sun, 06 Jul 2008)

Comment:fully implemented api for webmaps; nxcp documentation updated

Changes
U trunk/doc/manuals/nxcp_reference.odt
U trunk/include/nms_cscp.h
U trunk/include/nxclapi.h
U trunk/src/install/windows/files.txt
U trunk/src/install/windows/netxms.iss
U trunk/src/libnxcl/main.cpp
U trunk/src/server/core/Makefile.am
U trunk/src/server/core/config.cpp
U trunk/src/server/core/id.cpp
U trunk/src/server/core/nxcore.dsp
U trunk/src/server/core/session.cpp
A trunk/src/server/core/webmaps.cpp
U trunk/src/server/include/nms_core.h
U trunk/src/server/include/nxcore_maps.h

Diff
Modified: trunk/include/nms_cscp.h
===================================================================
--- trunk/include/nms_cscp.h 2008-07-05 10:14:42 UTC (rev 3366)
+++ trunk/include/nms_cscp.h 2008-07-06 10:45:32 UTC (rev 3367)
@@ -535,7 +535,7 @@
 #define VID_MIB_NAME ((DWORD)59)
 #define VID_MIB_FILE_SIZE ((DWORD)60)
 #define VID_MIB_FILE ((DWORD)61)
-//#define VID_COMMENT ((DWORD)62)
+#define VID_PROPERTIES ((DWORD)62)
 #define VID_ALARM_SEVERITY ((DWORD)63)
 #define VID_ALARM_KEY ((DWORD)64)
 #define VID_ALARM_TIMEOUT ((DWORD)65)
@@ -783,6 +783,7 @@
 #define VID_TRUSTED_NODES ((DWORD)307)
 #define VID_TIMEZONE ((DWORD)308)
 #define VID_NUM_CUSTOM_ATTRIBUTES ((DWORD)309)
+#define VID_MAP_DATA ((DWORD)310)
 
 // Variable ranges for object&#39;s ACL
 #define VID_ACL_USER_BASE ((DWORD)0x00001000)
@@ -925,7 +926,9 @@
 #define VID_OBJECT_LINKS_BASE ((DWORD)0x10000000)
 #define VID_SUBMAP_LINK_NAMES_BASE ((DWORD)0x20000000)
 
+#define VID_WEBMAP_LIST_BASE ((DWORD)0x30000000)
 
+
 //
 // Inline functions
 //

Modified: trunk/include/nxclapi.h
===================================================================
--- trunk/include/nxclapi.h 2008-07-05 10:14:42 UTC (rev 3366)
+++ trunk/include/nxclapi.h 2008-07-06 10:45:32 UTC (rev 3367)
@@ -408,6 +408,7 @@
 #define RCC_INSTANCE_NOT_FOUND ((DWORD)78)
 #define RCC_INVALID_EVENT_ID ((DWORD)79)
 #define RCC_AGENT_ERROR ((DWORD)80)
+#define RCC_UNKNOWN_VARIABLE ((DWORD)81)
 
 
 //

Modified: trunk/src/install/windows/files.txt
===================================================================
--- trunk/src/install/windows/files.txt 2008-07-05 10:14:42 UTC (rev 3366)
+++ trunk/src/install/windows/files.txt 2008-07-06 10:45:32 UTC (rev 3367)
@@ -18,6 +18,8 @@
 OCI.DLL
 ORANNZSBB10.DLL
 ORAOCIICUS10.DLL
+LIBEXPAT.DLL
+LIBEXPATW.DLL
 wxbase28u_vc.dll
 wxbase28u_xml_vc.dll
 wxmsw28u_adv_vc.dll

Modified: trunk/src/install/windows/netxms.iss
===================================================================
--- trunk/src/install/windows/netxms.iss 2008-07-05 10:14:42 UTC (rev 3366)
+++ trunk/src/install/windows/netxms.iss 2008-07-06 10:45:32 UTC (rev 3367)
@@ -3,8 +3,8 @@
 
 [Setup]
 AppName=NetXMS
-AppVerName=NetXMS 0.2.21
-AppVersion=0.2.21
+AppVerName=NetXMS 0.2.22-rc1
+AppVersion=0.2.22-rc1
 AppPublisher=NetXMS Team
 AppPublisherURL=http://www.netxms.org
 AppSupportURL=http://www.netxms.org
@@ -13,7 +13,7 @@
 DefaultGroupName=NetXMS
 AllowNoIcons=yes
 LicenseFile=..\..\..\copying
-OutputBaseFilename=netxms-0.2.21
+OutputBaseFilename=netxms-0.2.22-rc1
 Compression=lzma
 SolidCompression=yes
 LanguageDetectionMethod=none
@@ -172,6 +172,8 @@
 Source: &quot;Files\bgd.dll&quot;; DestDir: &quot;{app}\bin&quot;; Flags: ignoreversion; Components: websrv
 Source: &quot;Files\zlib1.dll&quot;; DestDir: &quot;{app}\bin&quot;; Flags: ignoreversion; Components: base
 Source: &quot;Files\dbghelp.dll&quot;; DestDir: &quot;{app}\bin&quot;; Flags: ignoreversion; Components: base
+Source: &quot;Files\libexpat.dll&quot;; DestDir: &quot;{app}\bin&quot;; Flags: ignoreversion; Components: base
+Source: &quot;Files\libexpatw.dll&quot;; DestDir: &quot;{app}\bin&quot;; Flags: ignoreversion; Components: base
 Source: &quot;Files\wxbase28u_vc.dll&quot;; DestDir: &quot;{app}\bin&quot;; Flags: ignoreversion; Components: console
 Source: &quot;Files\wxbase28u_xml_vc.dll&quot;; DestDir: &quot;{app}\bin&quot;; Flags: ignoreversion; Components: console
 Source: &quot;Files\wxmsw28u_adv_vc.dll&quot;; DestDir: &quot;{app}\bin&quot;; Flags: ignoreversion; Components: console

Modified: trunk/src/libnxcl/main.cpp
===================================================================
--- trunk/src/libnxcl/main.cpp 2008-07-05 10:14:42 UTC (rev 3366)
+++ trunk/src/libnxcl/main.cpp 2008-07-06 10:45:32 UTC (rev 3367)
@@ -366,9 +366,10 @@
                 _T(&quot;Invalid situation ID&quot;),
                 _T(&quot;Named instance not found&quot;),
                 _T(&quot;Invalid event ID&quot;),
- _T(&quot;Operation cannot be completed due to agent error&quot;)
+ _T(&quot;Operation cannot be completed due to agent error&quot;),
+ _T(&quot;Unknown variable&quot;)
    };
- return ((dwError &gt;= 0) &amp;&amp; (dwError &lt;= RCC_AGENT_ERROR)) ? pszErrorText[dwError] : _T(&quot;No text message for this error&quot;);
+ return ((dwError &gt;= 0) &amp;&amp; (dwError &lt;= RCC_UNKNOWN_VARIABLE)) ? pszErrorText[dwError] : _T(&quot;No text message for this error&quot;);
 }
 
 

Modified: trunk/src/server/core/Makefile.am
===================================================================
--- trunk/src/server/core/Makefile.am 2008-07-05 10:14:42 UTC (rev 3366)
+++ trunk/src/server/core/Makefile.am 2008-07-06 10:45:32 UTC (rev 3367)
@@ -20,7 +20,8 @@
                         rootobj.cpp script.cpp session.cpp situation.cpp \
                         sms.cpp snmp.cpp snmptrap.cpp subnet.cpp syncer.cpp \
                         syslogd.cpp template.cpp tools.cpp tracert.cpp \
- uniroot.cpp users.cpp vpnconn.cpp watchdog.cpp zone.cpp
+ uniroot.cpp users.cpp vpnconn.cpp watchdog.cpp \
+ webmaps.cpp zone.cpp
 libnxcore_la_LDFLAGS = -version-info $(NETXMS_LIBRARY_VERSION)
 libnxcore_la_LIBADD = ../../libnetxms/libnetxms.la \
                       ../../libnxsnmp/libnxsnmp.la \

Modified: trunk/src/server/core/config.cpp
===================================================================
--- trunk/src/server/core/config.cpp 2008-07-05 10:14:42 UTC (rev 3366)
+++ trunk/src/server/core/config.cpp 2008-07-06 10:45:32 UTC (rev 3367)
@@ -199,7 +199,7 @@
    TCHAR *pszEscValue, szQuery[1024];
    BOOL bVarExist = FALSE;
 
- if (strlen(szVar) &gt; 127)
+ if (_tcslen(szVar) &gt; 127)
       return FALSE;
 
    // Check for variable existence
@@ -269,3 +269,84 @@
       _stprintf(&amp;szBuffer[j], _T(&quot;%02X&quot;), (char)((pnArray[i] &gt; 127) ? 127 : ((pnArray[i] &lt; -127) ? -127 : pnArray[i])));
    return ConfigWriteStr(pszVar, szBuffer, bCreate);
 }
+
+
+//
+// Read large string (clob) value from configuration table
+//
+
+TCHAR NXCORE_EXPORTABLE *ConfigReadCLOB(const TCHAR *var, const TCHAR *defValue)
+{
+ DB_RESULT hResult;
+ TCHAR query[256], *result = NULL;
+ BOOL bSuccess = FALSE;
+
+ if (_tcslen(var) &lt;= 127)
+ {
+ _sntprintf(query, 256, _T(&quot;SELECT var_value FROM config_clob WHERE var_name=&#39;%s&#39;&quot;), var);
+ hResult = DBSelect(g_hCoreDB, query);
+ if (hResult != NULL)
+ {
+ if (DBGetNumRows(hResult) &gt; 0)
+ {
+ result = DBGetField(hResult, 0, 0, NULL, 0);
+ if (result != NULL)
+ DecodeSQLString(result);
+ }
+ DBFreeResult(hResult);
+ }
+ }
+
+ // Return default value in case of error
+ if ((result == NULL) &amp;&amp; (defValue != NULL))
+ result = _tcsdup(defValue);
+
+ return result;
+}
+
+
+//
+// Write large string (clob) value to configuration table
+//
+
+BOOL NXCORE_EXPORTABLE ConfigWriteCLOB(const TCHAR *var, const TCHAR *value, BOOL bCreate)
+{
+ DB_RESULT hResult;
+ TCHAR *escValue, *query;
+ int len;
+ BOOL bVarExist = FALSE, success = FALSE;
+
+ if (_tcslen(var) &gt; 127)
+ return FALSE;
+
+ escValue = EncodeSQLString(CHECK_NULL_EX(value));
+ len = _tcslen(escValue) + 256;
+ query = (TCHAR *)malloc(len * sizeof(TCHAR));
+
+ // Check for variable existence
+ _sntprintf(query, len, _T(&quot;SELECT var_value FROM config_clob WHERE var_name=&#39;%s&#39;&quot;), var);
+ hResult = DBSelect(g_hCoreDB, query);
+ if (hResult != NULL)
+ {
+ if (DBGetNumRows(hResult) &gt; 0)
+ bVarExist = TRUE;
+ DBFreeResult(hResult);
+ }
+
+ // Don&#39;t create non-existing variable if creation flag not set
+ if (bCreate || bVarExist)
+ {
+ // Create or update variable value
+ if (bVarExist)
+ _sntprintf(query, len, _T(&quot;UPDATE config_clob SET var_value=&#39;%s&#39; WHERE var_name=&#39;%s&#39;&quot;),
+ escValue, var);
+ else
+ _sntprintf(query, len, _T(&quot;INSERT INTO config_clob (var_name,var_value) VALUES (&#39;%s&#39;,&#39;%s&#39;)&quot;),
+ var, escValue);
+ success = DBQuery(g_hCoreDB, query);
+ }
+
+ free(query);
+ free(escValue);
+ return success;
+}

Modified: trunk/src/server/core/id.cpp
===================================================================
--- trunk/src/server/core/id.cpp 2008-07-05 10:14:42 UTC (rev 3366)
+++ trunk/src/server/core/id.cpp 2008-07-06 10:45:32 UTC (rev 3367)
@@ -374,6 +374,15 @@
                                         DBGetFieldULong(hResult, 0, 0) + 1);
       DBFreeResult(hResult);
    }
+ hResult = DBSelect(g_hCoreDB, &quot;SELECT max(id) FROM web_maps&quot;);
+ if (hResult != NULL)
+ {
+ if (DBGetNumRows(hResult) &gt; 0)
+ m_dwFreeIdTable[IDG_MAP] = max(m_dwFreeIdTable[IDG_MAP],
+ DBGetFieldULong(hResult, 0, 0) + 1);
+ DBFreeResult(hResult);
+ }
+
    return TRUE;
 }
 

Modified: trunk/src/server/core/nxcore.dsp
===================================================================
--- trunk/src/server/core/nxcore.dsp 2008-07-05 10:14:42 UTC (rev 3366)
+++ trunk/src/server/core/nxcore.dsp 2008-07-06 10:45:32 UTC (rev 3367)
@@ -454,6 +454,10 @@
 # End Source File
 # Begin Source File
 
+SOURCE=.\webmaps.cpp
+# End Source File
+# Begin Source File
+
 SOURCE=.\zone.cpp
 # End Source File
 # End Group

Modified: trunk/src/server/core/session.cpp
===================================================================
--- trunk/src/server/core/session.cpp 2008-07-05 10:14:42 UTC (rev 3366)
+++ trunk/src/server/core/session.cpp 2008-07-06 10:45:32 UTC (rev 3367)
@@ -758,6 +758,12 @@
          case CMD_DELETE_CONFIG_VARIABLE:
             DeleteConfigVariable(pMsg);
             break;
+ case CMD_CONFIG_GET_CLOB:
+ GetConfigCLOB(pMsg);
+ break;
+ case CMD_CONFIG_SET_CLOB:
+ SetConfigCLOB(pMsg);
+ break;
          case CMD_LOAD_EVENT_DB:
             SendEventDB(pMsg-&gt;GetId());
             break;
@@ -1180,6 +1186,24 @@
                         case CMD_DEL_SITUATION_INSTANCE:
                                 DeleteSituationInstance(pMsg);
                                 break;
+ case CMD_WEBMAP_ADD:
+ WebMapAdd(pMsg);
+ break;
+ case CMD_WEBMAP_UPDATE_PROPS:
+ WebMapUpdateProps(pMsg);
+ break;
+ case CMD_WEBMAP_UPDATE_DATA:
+ WebMapUpdateData(pMsg);
+ break;
+ case CMD_WEBMAP_DELETE:
+ WebMapDelete(pMsg);
+ break;
+ case CMD_WEBMAP_GET_DATA:
+ WebMapGetData(pMsg);
+ break;
+ case CMD_WEBMAP_GET_LIST:
+ WebMapGetList(pMsg-&gt;GetId());
+ break;
          default:
             // Pass message to loaded modules
             for(i = 0; i &lt; g_dwNumModules; i++)
@@ -2054,6 +2078,77 @@
 
 
 //
+// Set configuration clob
+//
+
+void ClientSession::SetConfigCLOB(CSCPMessage *pRequest)
+{
+ CSCPMessage msg;
+ TCHAR name[MAX_OBJECT_NAME], *value;
+
+ msg.SetId(pRequest-&gt;GetId());
+ msg.SetCode(CMD_REQUEST_COMPLETED);
+
+ if (m_dwSystemAccess &amp; SYSTEM_ACCESS_SERVER_CONFIG)
+ {
+ pRequest-&gt;GetVariableStr(VID_NAME, name, MAX_OBJECT_NAME);
+ value = pRequest-&gt;GetVariableStr(VID_VALUE);
+ if (value != NULL)
+ {
+ msg.SetVariable(VID_RCC, ConfigWriteCLOB(name, value, TRUE) ? RCC_SUCCESS : RCC_DB_FAILURE);
+ free(value);
+ }
+ else
+ {
+ msg.SetVariable(VID_RCC, RCC_INVALID_REQUEST);
+ }
+ }
+ else
+ {
+ msg.SetVariable(VID_RCC, RCC_ACCESS_DENIED);
+ }
+
+ SendMessage(&amp;msg);
+}
+
+
+//
+// Get value of configuration clob
+//
+
+void ClientSession::GetConfigCLOB(CSCPMessage *pRequest)
+{
+ CSCPMessage msg;
+ TCHAR name[MAX_OBJECT_NAME], *value;
+
+ msg.SetId(pRequest-&gt;GetId());
+ msg.SetCode(CMD_REQUEST_COMPLETED);
+
+ if (m_dwSystemAccess &amp; SYSTEM_ACCESS_SERVER_CONFIG)
+ {
+ pRequest-&gt;GetVariableStr(VID_NAME, name, MAX_OBJECT_NAME);
+ value = ConfigReadCLOB(name, NULL);
+ if (value != NULL)
+ {
+ msg.SetVariable(VID_VALUE, value);
+ msg.SetVariable(VID_RCC, RCC_SUCCESS);
+ free(value);
+ }
+ else
+ {
+ msg.SetVariable(VID_RCC, RCC_UNKNOWN_VARIABLE);
+ }
+ }
+ else
+ {
+ msg.SetVariable(VID_RCC, RCC_ACCESS_DENIED);
+ }
+
+ SendMessage(&amp;msg);
+}
+
+
+//
 // Close session forcibly
 //
 
@@ -9670,3 +9765,205 @@
       m_pUpdateQueue-&gt;Put(pUpdate);
    }
 }
+
+
+//
+// Add new webmap
+//
+
+void ClientSession::WebMapAdd(CSCPMessage *pRequest)
+{
+ CSCPMessage msg;
+ TCHAR name[64], *props;
+ DWORD mapId, rcc;
+
+ msg.SetCode(CMD_REQUEST_COMPLETED);
+ msg.SetId(pRequest-&gt;GetId());
+
+ if (m_dwSystemAccess &amp; SYSTEM_ACCESS_MANAGE_MAPS)
+ {
+ pRequest-&gt;GetVariableStr(VID_NAME, name, 64);
+ if (IsValidObjectName(name, TRUE))
+ {
+ props = pRequest-&gt;GetVariableStr(VID_PROPERTIES);
+ rcc = CreateWebMap(name, props, &amp;mapId);
+ msg.SetVariable(VID_RCC, rcc);
+ if (rcc == RCC_SUCCESS)
+ msg.SetVariable(VID_MAP_ID, mapId);
+ safe_free(props);
+ }
+ else
+ {
+ msg.SetVariable(VID_RCC, RCC_INVALID_OBJECT_NAME);
+ }
+ }
+ else
+ {
+ msg.SetVariable(VID_RCC, RCC_ACCESS_DENIED);
+ }
+
+ SendMessage(&amp;msg);
+}
+
+
+//
+// Update webmap data
+//
+
+void ClientSession::WebMapUpdateData(CSCPMessage *pRequest)
+{
+ CSCPMessage msg;
+ TCHAR *data;
+ DWORD mapId;
+
+ msg.SetCode(CMD_REQUEST_COMPLETED);
+ msg.SetId(pRequest-&gt;GetId());
+
+ if (m_dwSystemAccess &amp; SYSTEM_ACCESS_MANAGE_MAPS)
+ {
+ mapId = pRequest-&gt;GetVariableLong(VID_MAP_ID);
+ data = pRequest-&gt;GetVariableStr(VID_MAP_DATA);
+ msg.SetVariable(VID_RCC, UpdateWebMapData(mapId, data));
+ free(data);
+ }
+ else
+ {
+ msg.SetVariable(VID_RCC, RCC_ACCESS_DENIED);
+ }
+
+ SendMessage(&amp;msg);
+}
+
+
+//
+// Update webmap properties
+//
+
+void ClientSession::WebMapUpdateProps(CSCPMessage *pRequest)
+{
+ CSCPMessage msg;
+ TCHAR *props, name[64];
+ DWORD mapId;
+
+ msg.SetCode(CMD_REQUEST_COMPLETED);
+ msg.SetId(pRequest-&gt;GetId());
+
+ if (m_dwSystemAccess &amp; SYSTEM_ACCESS_MANAGE_MAPS)
+ {
+ mapId = pRequest-&gt;GetVariableLong(VID_MAP_ID);
+ props = pRequest-&gt;GetVariableStr(VID_PROPERTIES);
+ pRequest-&gt;GetVariableStr(VID_NAME, name, 64);
+ msg.SetVariable(VID_RCC, UpdateWebMapProperties(mapId, name, props));
+ free(props);
+ }
+ else
+ {
+ msg.SetVariable(VID_RCC, RCC_ACCESS_DENIED);
+ }
+
+ SendMessage(&amp;msg);
+}
+
+
+//
+// Delete webmap
+//
+
+void ClientSession::WebMapDelete(CSCPMessage *pRequest)
+{
+ CSCPMessage msg;
+
+ msg.SetCode(CMD_REQUEST_COMPLETED);
+ msg.SetId(pRequest-&gt;GetId());
+
+ if (m_dwSystemAccess &amp; SYSTEM_ACCESS_MANAGE_MAPS)
+ {
+ msg.SetVariable(VID_RCC, DeleteWebMap(pRequest-&gt;GetVariableLong(VID_MAP_ID)));
+ }
+ else
+ {
+ msg.SetVariable(VID_RCC, RCC_ACCESS_DENIED);
+ }
+
+ SendMessage(&amp;msg);
+}
+
+
+//
+// Get webmap&#39;s data
+//
+
+void ClientSession::WebMapGetData(CSCPMessage *pRequest)
+{
+ CSCPMessage msg;
+ DWORD mapId;
+ TCHAR *data, query[256];
+ DB_RESULT hResult;
+
+ msg.SetCode(CMD_REQUEST_COMPLETED);
+ msg.SetId(pRequest-&gt;GetId());
+
+ mapId = pRequest-&gt;GetVariableLong(VID_MAP_ID);
+ _sntprintf(query, 256, _T(&quot;SELECT data FROM web_maps WHERE id=%d&quot;), mapId);
+ hResult = DBSelect(g_hCoreDB, query);
+ if (hResult != NULL)
+ {
+ if (DBGetNumRows(hResult) &gt; 0)
+ {
+ data = DBGetField(hResult, 0, 0, NULL, 0);
+ if (data != NULL)
+ DecodeSQLString(data);
+ msg.SetVariable(VID_RCC, RCC_SUCCESS);
+ msg.SetVariable(VID_MAP_DATA, CHECK_NULL_EX(data));
+ safe_free(data);
+ }
+ else
+ {
+ msg.SetVariable(VID_RCC, RCC_INVALID_MAP_ID);
+ }
+ }
+ else
+ {
+ msg.SetVariable(VID_RCC, RCC_DB_FAILURE);
+ }
+
+ SendMessage(&amp;msg);
+}
+
+
+//
+// Get list of webmaps
+//
+
+void ClientSession::WebMapGetList(DWORD dwRqId)
+{
+ CSCPMessage msg;
+ DB_RESULT hResult;
+ DWORD i, id, count;
+ TCHAR name[256];
+
+ msg.SetCode(CMD_REQUEST_COMPLETED);
+ msg.SetId(dwRqId);
+
+ hResult = DBSelect(g_hCoreDB, _T(&quot;SELECT id,title FROM web_maps&quot;));
+ if (hResult != NULL)
+ {
+ count = DBGetNumRows(hResult);
+ msg.SetVariable(VID_NUM_MAPS, count);
+ for(i = 0, id = VID_WEBMAP_LIST_BASE; i &lt; count; i++)
+ {
+ msg.SetVariable(id++, DBGetFieldULong(hResult, i, 0));
+ DBGetField(hResult, i, 1, name, 256);
+ msg.SetVariable(id++, name);
+ id += 8;
+ }
+ msg.SetVariable(VID_RCC, RCC_SUCCESS);
+ DBFreeResult(hResult);
+ }
+ else
+ {
+ msg.SetVariable(VID_RCC, RCC_DB_FAILURE);
+ }
+
+ SendMessage(&amp;msg);
+}

Added: trunk/src/server/core/webmaps.cpp
===================================================================
--- trunk/src/server/core/webmaps.cpp (rev 0)
+++ trunk/src/server/core/webmaps.cpp 2008-07-06 10:45:32 UTC (rev 3367)
@@ -0,0 +1,148 @@
+/* $Id$ */
+/*
+** NetXMS - Network Management System
+** Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 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.
+**
+** File: webmaps.cpp
+**
+**/
+
+#include &quot;nxcore.h&quot;
+
+
+//
+// Check existence of webmap
+//
+
+static BOOL IsWebMapExist(DWORD id)
+{
+ TCHAR query[256];
+ DB_RESULT hResult;
+ BOOL isExist = FALSE;
+
+ _sntprintf(query, 256, _T(&quot;SELECT id FROM web_maps WHERE id=%d&quot;), id);
+ hResult = DBSelect(g_hCoreDB, query);
+ if (hResult != NULL)
+ {
+ isExist = (DBGetNumRows(hResult) &gt; 0);
+ DBFreeResult(hResult);
+ }
+ return isExist;
+}
+
+
+//
+// Create webmap. Returns RCC.
+//
+
+DWORD CreateWebMap(const TCHAR *name, const TCHAR *props, DWORD *id)
+{
+ TCHAR *escProps, *query;
+ int len;
+ DWORD mapId, rcc;
+
+ escProps = EncodeSQLString(CHECK_NULL_EX(props));
+ len = _tcslen(escProps) + 256;
+ query = (TCHAR *)malloc(len * sizeof(TCHAR));
+ mapId = CreateUniqueId(IDG_MAP);
+ _sntprintf(query, len, _T(&quot;INSERT INTO web_maps (id,title,properties,data) VALUES (%d,&#39;%s&#39;,&#39;%s&#39;,&#39;#00&#39;)&quot;),
+ mapId, name, escProps);
+ free(escProps);
+ rcc = DBQuery(g_hCoreDB, query) ? RCC_SUCCESS : RCC_DB_FAILURE;
+ *id = mapId;
+ free(query);
+ return rcc;
+}
+
+
+//
+// Delete webmap. Returns RCC.
+//
+
+DWORD DeleteWebMap(DWORD id)
+{
+ DWORD rcc;
+ TCHAR query[256];
+
+ if (IsWebMapExist(id))
+ {
+ _sntprintf(query, 256, _T(&quot;DELETE FROM web_maps WHERE id=%d&quot;), id);
+ rcc = DBQuery(g_hCoreDB, query) ? RCC_SUCCESS : RCC_DB_FAILURE;
+ }
+ else
+ {
+ rcc = RCC_INVALID_MAP_ID;
+ }
+ return rcc;
+}
+
+
+//
+// Update webmap&#39;s data. Returns RCC.
+//
+
+DWORD UpdateWebMapData(DWORD mapId, const TCHAR *data)
+{
+ DWORD rcc;
+ int len;
+ TCHAR *query, *escData;
+
+ if (IsWebMapExist(mapId))
+ {
+ escData = EncodeSQLString(CHECK_NULL_EX(data));
+ len = _tcslen(escData) + 256;
+ query = (TCHAR *)malloc(len * sizeof(TCHAR));
+ _sntprintf(query, len, _T(&quot;UPDATE web_maps SET data=&#39;%s&#39; WHERE id=%d&quot;), escData, mapId);
+ free(escData);
+ rcc = DBQuery(g_hCoreDB, query) ? RCC_SUCCESS : RCC_DB_FAILURE;
+ free(query);
+ }
+ else
+ {
+ rcc = RCC_INVALID_MAP_ID;
+ }
+ return rcc;
+}
+
+
+//
+// Update webmap&#39;s properties. Returns RCC.
+//
+
+DWORD UpdateWebMapProperties(DWORD mapId, const TCHAR *name, const TCHAR *props)
+{
+ DWORD rcc;
+ int len;
+ TCHAR *query, *escProps;
+
+ if (IsWebMapExist(mapId))
+ {
+ escProps = EncodeSQLString(CHECK_NULL_EX(props));
+ len = _tcslen(escProps) + 256;
+ query = (TCHAR *)malloc(len * sizeof(TCHAR));
+ _sntprintf(query, len, _T(&quot;UPDATE web_maps SET title=&#39;%s&#39;,properties=&#39;%s&#39; WHERE id=%d&quot;),
+ name, escProps, mapId);
+ free(escProps);
+ rcc = DBQuery(g_hCoreDB, query) ? RCC_SUCCESS : RCC_DB_FAILURE;
+ free(query);
+ }
+ else
+ {
+ rcc = RCC_INVALID_MAP_ID;
+ }
+ return rcc;
+}

Property changes on: trunk/src/server/core/webmaps.cpp
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: trunk/src/server/include/nms_core.h
===================================================================
--- trunk/src/server/include/nms_core.h 2008-07-05 10:14:42 UTC (rev 3366)
+++ trunk/src/server/include/nms_core.h 2008-07-06 10:45:32 UTC (rev 3367)
@@ -1,7 +1,7 @@
 /* $Id$ */
 /*
 ** NetXMS - Network Management System
-** Copyright (C) 2003, 2004, 2005, 2006, 2007 Victor Kirhenshtein
+** Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 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
@@ -534,6 +534,14 @@
         void UpdateSituation(CSCPMessage *pRequest);
         void DeleteSituation(CSCPMessage *pRequest);
         void DeleteSituationInstance(CSCPMessage *pRequest);
+ void SetConfigCLOB(CSCPMessage *pRequest);
+ void GetConfigCLOB(CSCPMessage *pRequest);
+ void WebMapAdd(CSCPMessage *pRequest);
+ void WebMapUpdateData(CSCPMessage *pRequest);
+ void WebMapUpdateProps(CSCPMessage *pRequest);
+ void WebMapDelete(CSCPMessage *pRequest);
+ void WebMapGetData(CSCPMessage *pRequest);
+ void WebMapGetList(DWORD dwRqId);
 
 public:
    ClientSession(SOCKET hSocket, DWORD dwHostAddr);
@@ -588,6 +596,8 @@
 BOOL NXCORE_EXPORTABLE ConfigWriteULong(const TCHAR *szVar, DWORD dwValue, BOOL bCreate);
 BOOL NXCORE_EXPORTABLE ConfigWriteByteArray(const TCHAR *pszVar, int *pnArray,
                                             int nSize, BOOL bCreate);
+TCHAR NXCORE_EXPORTABLE *ConfigReadCLOB(const TCHAR *var, const TCHAR *defValue);
+BOOL NXCORE_EXPORTABLE ConfigWriteCLOB(const TCHAR *var, const TCHAR *value, BOOL bCreate);
 
 BOOL NXCORE_EXPORTABLE LoadConfig(void);
 

Modified: trunk/src/server/include/nxcore_maps.h
===================================================================
--- trunk/src/server/include/nxcore_maps.h 2008-07-05 10:14:42 UTC (rev 3366)
+++ trunk/src/server/include/nxcore_maps.h 2008-07-06 10:45:32 UTC (rev 3367)
@@ -78,4 +78,14 @@
 nxMapSrv *FindMapByID(DWORD dwMapId);
 
 
+//
+// Webmaps functions
+//
+
+DWORD CreateWebMap(const TCHAR *name, const TCHAR *props, DWORD *id);
+DWORD DeleteWebMap(DWORD id);
+DWORD UpdateWebMapData(DWORD mapId, const TCHAR *data);
+DWORD UpdateWebMapProperties(DWORD mapId, const TCHAR *name, const TCHAR *props);
+
+
 #endif /* _nxcore_maps_h_ */
Received on Sun Jul 06 2008 - 13:45:32 EEST

This archive was generated by hypermail 2.2.0 : Sun Jul 06 2008 - 13:39:54 EEST