- Container objects can be created from GUI
authorVictor Kirhenshtein <victor@netxms.org>
Sun, 19 Sep 2004 05:57:10 +0000 (05:57 +0000)
committerVictor Kirhenshtein <victor@netxms.org>
Sun, 19 Sep 2004 05:57:10 +0000 (05:57 +0000)
- Container categories can be loaded to client
- Added Net.* parameters to Wndows agent
- Windows agent now can obtain network connection names
- Minor fixes

33 files changed:
TODO
doc/admin_guide.doc
include/nms_cscp.h
include/nms_util.h
include/nxclapi.h
src/agent/core/actions.cpp
src/agent/core/getparam.cpp
src/agent/core/netinfo.cpp
src/agent/core/nxagentd.cpp
src/agent/core/nxagentd.h
src/console/win32/EventPolicyEditor.cpp
src/console/win32/ObjectBrowser.cpp
src/console/win32/ObjectBrowser.h
src/console/win32/ObjectSelDlg.cpp
src/console/win32/ObjectSelDlg.h
src/console/win32/comm.cpp
src/console/win32/globals.cpp
src/console/win32/globals.h
src/console/win32/nxcon.clw
src/console/win32/nxcon.cpp
src/console/win32/nxcon.dsp
src/console/win32/nxcon.h
src/console/win32/nxcon.rc
src/console/win32/resource.h
src/libnetxms/config.cpp
src/libnxcl/objects.cpp
src/server/core/config.cpp
src/server/core/container.cpp
src/server/core/nms_core.h
src/server/core/nms_objects.h
src/server/core/objects.cpp
src/server/core/session.cpp
src/server/libnxsrv/agent.cpp

diff --git a/TODO b/TODO
index e6f9645..47f575f 100644 (file)
--- a/TODO
+++ b/TODO
@@ -33,6 +33,7 @@ SERVER:
 - Implement sending of all alarms from database
 - Add signal handlers for UNIX
 - Implement normal mailer shutdown
+- Implement locks table in memory
 
 
 CORE AGENT:
index b3df2ce..56228ff 100644 (file)
Binary files a/doc/admin_guide.doc and b/doc/admin_guide.doc differ
index 9b21760..2a71116 100644 (file)
@@ -246,6 +246,11 @@ typedef struct
 #define CMD_CREATE_ACTION           0x0051
 #define CMD_DELETE_ACTION           0x0052
 #define CMD_ACTION_DATA             0x0053
+#define CMD_GET_CONTAINER_CAT_LIST  0x0054
+#define CMD_CONTAINER_CAT_DATA      0x0055
+#define CMD_DELETE_CONTAINER_CAT    0x0056
+#define CMD_CREATE_CONTAINER_CAT    0x0057
+#define CMD_MODIFY_CONTAINER_CAT    0x0058
 
 
 //
@@ -354,6 +359,8 @@ typedef struct
 #define VID_ACTION_DATA             ((DWORD)100)
 #define VID_EMAIL_SUBJECT           ((DWORD)101)
 #define VID_RCPT_ADDR               ((DWORD)102)
+#define VID_CATEGORY_NAME           ((DWORD)103)
+#define VID_CATEGORY_ID             ((DWORD)104)
 
 // Variable ranges for object's ACL
 #define VID_ACL_USER_BASE           ((DWORD)0x00001000)
index f68134f..e05ef7c 100644 (file)
@@ -153,7 +153,8 @@ extern "C"
 
    DWORD LIBNETXMS_EXPORTABLE IcmpPing(DWORD dwAddr, int iNumRetries, DWORD dwTimeout, DWORD *pdwRTT);
 
-   DWORD LIBNETXMS_EXPORTABLE NxLoadConfig(char *pszFileName, NX_CFG_TEMPLATE *pTemplateList, BOOL bPrint);
+   DWORD LIBNETXMS_EXPORTABLE NxLoadConfig(char *pszFileName, char *pszSection, 
+                                           NX_CFG_TEMPLATE *pTemplateList, BOOL bPrint);
 
    HMODULE LIBNETXMS_EXPORTABLE DLOpen(char *szLibName, char *pszErrorText);
    void LIBNETXMS_EXPORTABLE DLClose(HMODULE hModule);
index be5e4c7..b56f9f8 100644 (file)
@@ -733,6 +733,30 @@ typedef struct
 } NXC_OBJECT_CREATE_INFO;
 
 
+//
+// Container category
+//
+
+typedef struct
+{
+   DWORD dwId;
+   DWORD dwImageId;
+   char szName[MAX_OBJECT_NAME];
+   char *pszDescription;
+} NXC_CONTAINER_CATEGORY;
+
+
+//
+// Container categories list
+//
+
+typedef struct
+{
+   DWORD dwNumElements;
+   NXC_CONTAINER_CATEGORY *pElements;
+} NXC_CC_LIST;
+
+
 //
 // Functions
 //
@@ -768,6 +792,9 @@ DWORD LIBNXCL_EXPORTABLE NXCCreateObject(NXC_OBJECT_CREATE_INFO *pCreateInfo, DW
 DWORD LIBNXCL_EXPORTABLE NXCBindObject(DWORD dwParentObject, DWORD dwChildObject);
 DWORD LIBNXCL_EXPORTABLE NXCUnbindObject(DWORD dwParentObject, DWORD dwChildObject);
 
+DWORD LIBNXCL_EXPORTABLE NXCLoadCCList(NXC_CC_LIST **ppList);
+void LIBNXCL_EXPORTABLE NXCDestroyCCList(NXC_CC_LIST *pList);
+
 DWORD LIBNXCL_EXPORTABLE NXCSyncEvents(void);
 DWORD LIBNXCL_EXPORTABLE NXCOpenEventDB(void);
 DWORD LIBNXCL_EXPORTABLE NXCCloseEventDB(BOOL bSaveChanges);
index 8de7ded..0d99768 100644 (file)
@@ -70,7 +70,7 @@ BOOL AddActionFromConfig(char *pszLine)
    pCmdLine++;
    StrStrip(pszLine);
    StrStrip(pCmdLine);
-   return AddAction(pszLine, ACTION_EXEC, pCmdLine);
+   return AddAction(pszLine, AGENT_ACTION_EXEC, pCmdLine);
 }
 
 
@@ -88,7 +88,7 @@ DWORD ExecAction(char *pszAction, NETXMS_VALUES_LIST *pArgs)
          DebugPrintf("Executing action %s of type %d", pszAction, m_pActionList[i].iType);
          switch(m_pActionList[i].iType)
          {
-            case ACTION_EXEC:
+            case AGENT_ACTION_EXEC:
                dwErrorCode = ExecuteCommand(m_pActionList[i].pszCmdLine, pArgs);
                break;
             default:
index 28c4f91..6680dfd 100644 (file)
@@ -47,6 +47,8 @@ LONG H_MemoryInfo(char *cmd, char *arg, char *value);
 LONG H_HostName(char *cmd, char *arg, char *value);
 LONG H_SystemUname(char *cmd, char *arg, char *value);
 LONG H_ThreadCount(char *cmd, char *arg, char *value);
+LONG H_NetIPStats(char *cmd, char *arg, char *value);
+LONG H_NetInterfaceStats(char *cmd, char *arg, char *value);
 #endif
 
 
@@ -136,6 +138,17 @@ static AGENT_PARAM m_stdParams[] =
    { "Disk.Free(*)", H_DiskInfo, NULL },
    { "Disk.Total(*)", H_DiskInfo, NULL },
    { "Disk.Used(*)", H_DiskInfo, NULL },
+   { "Net.Interface.AdminStatus(*)", H_NetInterfaceStats, (char *)NET_IF_ADMIN_STATUS },
+   { "Net.Interface.BytesIn(*)", H_NetInterfaceStats, (char *)NET_IF_BYTES_IN },
+   { "Net.Interface.BytesOut(*)", H_NetInterfaceStats, (char *)NET_IF_BYTES_OUT },
+   { "Net.Interface.Description(*)", H_NetInterfaceStats, (char *)NET_IF_DESCR },
+   { "Net.Interface.InErrors(*)", H_NetInterfaceStats, (char *)NET_IF_IN_ERRORS },
+   { "Net.Interface.Link(*)", H_NetInterfaceStats, (char *)NET_IF_LINK },
+   { "Net.Interface.OutErrors(*)", H_NetInterfaceStats, (char *)NET_IF_OUT_ERRORS },
+   { "Net.Interface.PacketsIn(*)", H_NetInterfaceStats, (char *)NET_IF_PACKETS_IN },
+   { "Net.Interface.PacketsOut(*)", H_NetInterfaceStats, (char *)NET_IF_PACKETS_OUT },
+   { "Net.Interface.Speed(*)", H_NetInterfaceStats, (char *)NET_IF_SPEED },
+   { "Net.IP.Forwarding", H_NetIPStats, (char *)NET_IP_FORWARDING },
    { "Process.Count(*)", H_ProcCountSpecific, NULL },
    { "Process.GdiObj(*)", H_ProcInfo, (char *)PROCINFO_GDI_OBJ },
    { "Process.IO.OtherB(*)", H_ProcInfo, (char *)PROCINFO_IO_OTHER_B },
@@ -187,14 +200,14 @@ static AGENT_PARAM m_stdParams[] =
 
 static NETXMS_SUBAGENT_ENUM m_stdEnums[] =
 {
-   { "Actions", H_ActionList, NULL },
+   { "Agent.ActionList", H_ActionList, NULL },
 #ifdef _WIN32
-   { "ArpCache", H_ArpCache, NULL },
-   { "InterfaceList", H_InterfaceList, NULL },
+   { "Net.ArpCache", H_ArpCache, NULL },
+   { "Net.InterfaceList", H_InterfaceList, NULL },
 #endif
-   { "SubAgents", H_SubAgentList, NULL },
-   { "SupportedEnums", H_EnumList, NULL },
-   { "SupportedParameters", H_ParamList, NULL }
+   { "Agent.SubAgentList", H_SubAgentList, NULL },
+   { "Agent.SupportedEnums", H_EnumList, NULL },
+   { "Agent.SupportedParameters", H_ParamList, NULL }
 };
 
 
index a4db074..b1c6e48 100644 (file)
@@ -72,44 +72,229 @@ LONG H_ArpCache(char *cmd, char *arg, NETXMS_VALUES_LIST *value)
 
 LONG H_InterfaceList(char *cmd, char *arg, NETXMS_VALUES_LIST *value)
 {
-   MIB_IPADDRTABLE *ifTable;
-   MIB_IFROW ifRow;
-   DWORD i, dwSize, dwError, dwIfType;
-   char szBuffer[2048], szIfName[32], *pszIfName;
+   DWORD dwSize;
+   IP_ADAPTER_INFO *pBuffer, *pInfo;
+   LONG iResult = SYSINFO_RC_SUCCESS;
+   char szAdapterName[MAX_OBJECT_NAME], szBuffer[256];
+   IP_ADDR_STRING *pAddr;
 
-   ifTable = (MIB_IPADDRTABLE *)malloc(SIZEOF_IPADDRTABLE(256));
-   if (ifTable == NULL)
+   if (GetAdaptersInfo(NULL, &dwSize) != ERROR_BUFFER_OVERFLOW)
       return SYSINFO_RC_ERROR;
 
-   dwSize = SIZEOF_IPADDRTABLE(256);
-   dwError = GetIpAddrTable(ifTable, &dwSize, FALSE);
-   if (dwError != NO_ERROR)
+   pBuffer = (IP_ADAPTER_INFO *)malloc(dwSize);
+   if (GetAdaptersInfo(pBuffer, &dwSize) == ERROR_SUCCESS)
    {
-      free(ifTable);
-      return SYSINFO_RC_ERROR;
+      for(pInfo = pBuffer; pInfo != NULL; pInfo = pInfo->Next)
+      {
+         // Get network connection name from adapter name, if possible
+         if (imp_HrLanConnectionNameFromGuidOrPath != NULL)
+         {
+            WORD wGUID[256], wName[256];
+
+            // Resolve GUID to network connection name
+            MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, pInfo->AdapterName, -1, wGUID, 256);
+            dwSize = 256;
+            if (imp_HrLanConnectionNameFromGuidOrPath(NULL, wGUID, wName, &dwSize) == 0)
+            {
+               WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK | WC_DEFAULTCHAR, 
+                                   wName, dwSize, szAdapterName, MAX_OBJECT_NAME, NULL, NULL);
+            }
+            else
+            {
+               strncpy(szAdapterName, pInfo->AdapterName, MAX_OBJECT_NAME);
+            }
+         }
+         else
+         {
+            // We don't have a GUID resolving function, use GUID as name
+            strncpy(szAdapterName, pInfo->AdapterName, MAX_OBJECT_NAME);
+         }
+
+         // Compose result string for each ip address
+         for(pAddr = &pInfo->IpAddressList; pAddr != NULL; pAddr = pAddr->Next)
+         {
+            sprintf(szBuffer, "%d %s/%d %d %s", pInfo->Index, 
+                    pAddr->IpAddress.String, 
+                    BitsInMask(inet_addr(pAddr->IpMask.String)),
+                    pInfo->Type, szAdapterName);
+            NxAddResultString(value, szBuffer);
+         }
+      }
+   }
+   else
+   {
+      iResult = SYSINFO_RC_ERROR;
+   }
+
+   free(pBuffer);
+   return iResult;
+}
+
+
+//
+// Get IP statistics
+//
+
+LONG H_NetIPStats(char *cmd, char *arg, char *value)
+{
+   MIB_IPSTATS ips;
+   LONG iResult = SYSINFO_RC_SUCCESS;
+
+   if (GetIpStatistics(&ips) == NO_ERROR)
+   {
+      switch((int)arg)
+      {
+         case NET_IP_FORWARDING:
+            ret_int(value, ips.dwForwarding);
+            break;
+         default:
+            iResult = SYSINFO_RC_UNSUPPORTED;
+            break;
+      }
+   }
+   else
+   {
+      iResult = SYSINFO_RC_ERROR;
+   }
+
+   return iResult;
+}
+
+
+//
+// Get adapter index from name
+//
+
+static DWORD AdapterNameToIndex(char *pszName)
+{
+   DWORD dwSize, dwIndex = 0;
+   IP_ADAPTER_INFO *pBuffer, *pInfo;
+   char szAdapterName[MAX_OBJECT_NAME];
+
+   if (GetAdaptersInfo(NULL, &dwSize) != ERROR_BUFFER_OVERFLOW)
+      return 0;
+
+   pBuffer = (IP_ADAPTER_INFO *)malloc(dwSize);
+   if (GetAdaptersInfo(pBuffer, &dwSize) == ERROR_SUCCESS)
+   {
+      for(pInfo = pBuffer; pInfo != NULL; pInfo = pInfo->Next)
+      {
+         // Get network connection name from adapter name, if possible
+         if (imp_HrLanConnectionNameFromGuidOrPath != NULL)
+         {
+            WORD wGUID[256], wName[256];
+
+            // Resolve GUID to network connection name
+            MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, pInfo->AdapterName, -1, wGUID, 256);
+            dwSize = 256;
+            if (imp_HrLanConnectionNameFromGuidOrPath(NULL, wGUID, wName, &dwSize) == 0)
+            {
+               WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK | WC_DEFAULTCHAR, 
+                                   wName, dwSize, szAdapterName, MAX_OBJECT_NAME, NULL, NULL);
+            }
+            else
+            {
+               strncpy(szAdapterName, pInfo->AdapterName, MAX_OBJECT_NAME);
+            }
+         }
+         else
+         {
+            // We don't have a GUID resolving function, use GUID as name
+            strncpy(szAdapterName, pInfo->AdapterName, MAX_OBJECT_NAME);
+         }
+
+         if (!stricmp(szAdapterName, pszName))
+         {
+            dwIndex = pInfo->Index;
+            break;
+         }
+      }
    }
 
-   for(i = 0; i < ifTable->dwNumEntries; i++)
+   free(pBuffer);
+   return dwIndex;
+}
+
+
+//
+// Get interface statistics
+//
+
+LONG H_NetInterfaceStats(char *cmd, char *arg, char *value)
+{
+   LONG iResult = SYSINFO_RC_SUCCESS;
+   char *eptr, szBuffer[256];
+   DWORD dwIndex;
+
+   NxGetParameterArg(cmd, 1, szBuffer, 256);
+   if (szBuffer[0] == 0)
    {
-      ifRow.dwIndex = ifTable->table[i].dwIndex;
-      if (GetIfEntry(&ifRow) == NO_ERROR)
+      iResult = SYSINFO_RC_UNSUPPORTED;
+   }
+   else
+   {
+      // Determine if it index or name
+      dwIndex = strtoul(szBuffer, &eptr, 10);
+      if (*eptr != 0)
+      {
+         // It's a name, determine index
+         dwIndex = AdapterNameToIndex(szBuffer);
+      }
+
+      if (dwIndex != 0)
       {
-         dwIfType = ifRow.dwType;
-         pszIfName = (char *)ifRow.bDescr;
+         MIB_IFROW info;
+
+         info.dwIndex = dwIndex;
+         if (GetIfEntry(&info) == NO_ERROR)
+         {
+            switch((int)arg)
+            {
+               case NET_IF_BYTES_IN:
+                  ret_uint(value, info.dwInOctets);
+                  break;
+               case NET_IF_BYTES_OUT:
+                  ret_uint(value, info.dwOutOctets);
+                  break;
+               case NET_IF_DESCR:
+                  ret_string(value, (char *)info.bDescr);
+                  break;
+               case NET_IF_IN_ERRORS:
+                  ret_uint(value, info.dwInErrors);
+                  break;
+               case NET_IF_LINK:
+                  ret_uint(value, (info.dwOperStatus == MIB_IF_OPER_STATUS_CONNECTED) ? 1 : 0);
+                  break;
+               case NET_IF_OUT_ERRORS:
+                  ret_uint(value, info.dwOutErrors);
+                  break;
+               case NET_IF_PACKETS_IN:
+                  ret_uint(value, info.dwInUcastPkts + info.dwInNUcastPkts);
+                  break;
+               case NET_IF_PACKETS_OUT:
+                  ret_uint(value, info.dwOutUcastPkts + info.dwOutNUcastPkts);
+                  break;
+               case NET_IF_SPEED:
+                  ret_uint(value, info.dwSpeed);
+                  break;
+               case NET_IF_ADMIN_STATUS:
+                  ret_uint(value, info.dwAdminStatus ? 1 : 0);
+                  break;
+               default:
+                  iResult = SYSINFO_RC_UNSUPPORTED;
+                  break;
+            }
+         }
+         else
+         {
+            iResult = SYSINFO_RC_ERROR;
+         }
       }
       else
       {
-         dwIfType = IFTYPE_OTHER;
-         sprintf(szIfName, "IF-UNKNOWN-%d", ifTable->table[i].dwIndex);
-         pszIfName = szIfName;
+         iResult = SYSINFO_RC_UNSUPPORTED;
       }
-      sprintf(szBuffer, "%d %d.%d.%d.%d/%d %d %s", ifTable->table[i].dwIndex,
-              ifTable->table[i].dwAddr & 255, (ifTable->table[i].dwAddr >> 8) & 255,
-              (ifTable->table[i].dwAddr >> 16) & 255, ifTable->table[i].dwAddr >> 24,
-              BitsInMask(ifTable->table[i].dwMask), dwIfType, pszIfName);
-      NxAddResultString(value, szBuffer);
    }
 
-   free(ifTable);
-   return SYSINFO_RC_SUCCESS;
+   return iResult;
 }
index f96bf64..4c322ae 100644 (file)
@@ -82,6 +82,7 @@ DWORD (__stdcall *imp_GetGuiResources)(HANDLE, DWORD);
 BOOL (__stdcall *imp_GetProcessIoCounters)(HANDLE, PIO_COUNTERS);
 BOOL (__stdcall *imp_GetPerformanceInfo)(PPERFORMANCE_INFORMATION, DWORD);
 BOOL (__stdcall *imp_GlobalMemoryStatusEx)(LPMEMORYSTATUSEX);
+DWORD (__stdcall *imp_HrLanConnectionNameFromGuidOrPath)(LPWSTR, LPWSTR, LPWSTR, LPDWORD);
 #endif   /* _WIN32 */
 
 
@@ -164,6 +165,7 @@ static void ImportSymbols(void)
 {
    HMODULE hModule;
 
+   // USER32.DLL
    hModule = GetModuleHandle("USER32.DLL");
    if (hModule != NULL)
    {
@@ -174,6 +176,7 @@ static void ImportSymbols(void)
       WriteLog(MSG_NO_DLL, EVENTLOG_WARNING_TYPE, "s", "USER32.DLL");
    }
 
+   // KERNEL32.DLL
    hModule = GetModuleHandle("KERNEL32.DLL");
    if (hModule != NULL)
    {
@@ -185,6 +188,7 @@ static void ImportSymbols(void)
       WriteLog(MSG_NO_DLL, EVENTLOG_WARNING_TYPE, "s", "KERNEL32.DLL");
    }
 
+   // PSAPI.DLL
    hModule = GetModuleHandle("PSAPI.DLL");
    if (hModule != NULL)
    {
@@ -194,6 +198,19 @@ static void ImportSymbols(void)
    {
       WriteLog(MSG_NO_DLL, EVENTLOG_WARNING_TYPE, "s", "PSAPI.DLL");
    }
+
+   // NETMAN.DLL
+   hModule = LoadLibrary("NETMAN.DLL");
+   if (hModule != NULL)
+   {
+      imp_HrLanConnectionNameFromGuidOrPath = 
+         (DWORD (__stdcall *)(LPWSTR, LPWSTR, LPWSTR, LPDWORD))GetProcAddressAndLog(hModule,
+            "HrLanConnectionNameFromGuidOrPath");
+   }
+   else
+   {
+      WriteLog(MSG_NO_DLL, EVENTLOG_WARNING_TYPE, "s", "NETMAN.DLL");
+   }
 }
 
 #endif   /* _WIN32 */
@@ -404,7 +421,7 @@ int main(int argc, char *argv[])
    switch(iAction)
    {
       case ACTION_RUN_AGENT:
-         if (NxLoadConfig(szConfigFile, cfgTemplate, !(g_dwFlags & AF_DAEMON)) == NXCFG_ERR_OK)
+         if (NxLoadConfig(szConfigFile, "", cfgTemplate, !(g_dwFlags & AF_DAEMON)) == NXCFG_ERR_OK)
          {
             if ((!stricmp(g_szLogFile, "{syslog}")) || 
                 (!stricmp(g_szLogFile, "{eventlog}")))
@@ -462,7 +479,7 @@ int main(int argc, char *argv[])
          }
          break;
       case ACTION_CHECK_CONFIG:
-         if (NxLoadConfig(szConfigFile, cfgTemplate, !(g_dwFlags & AF_DAEMON)) != NXCFG_ERR_OK)
+         if (NxLoadConfig(szConfigFile, "", cfgTemplate, !(g_dwFlags & AF_DAEMON)) != NXCFG_ERR_OK)
          {
             ConsolePrintf("Configuration file check failed\n");
             iExitCode = 2;
index 619d733..52266e1 100644 (file)
 #define INFOTYPE_SUM             3
 
 
+//
+// Attributes for H_NetIPStats and H_NetInterfacStats
+//
+
+#ifdef _WIN32
+#define NET_IP_FORWARDING        1
+
+#define NET_IF_BYTES_IN          1
+#define NET_IF_BYTES_OUT         2
+#define NET_IF_DESCR             3
+#define NET_IF_IN_ERRORS         4
+#define NET_IF_LINK              5
+#define NET_IF_OUT_ERRORS        6
+#define NET_IF_PACKETS_IN        7
+#define NET_IF_PACKETS_OUT       8
+#define NET_IF_SPEED             9
+#define NET_IF_ADMIN_STATUS      10
+#endif
+
+
 //
 // Request types for H_MemoryInfo
 //
 // Action types
 //
 
-#define ACTION_EXEC        1
-#define ACTION_SUBAGENT    2
+#define AGENT_ACTION_EXEC        1
+#define AGENT_ACTION_SUBAGENT    2
 
 
 //
@@ -281,6 +301,7 @@ extern DWORD (__stdcall *imp_GetGuiResources)(HANDLE, DWORD);
 extern BOOL (__stdcall *imp_GetProcessIoCounters)(HANDLE, PIO_COUNTERS);
 extern BOOL (__stdcall *imp_GetPerformanceInfo)(PPERFORMANCE_INFORMATION, DWORD);
 extern BOOL (__stdcall *imp_GlobalMemoryStatusEx)(LPMEMORYSTATUSEX);
+extern DWORD (__stdcall *imp_HrLanConnectionNameFromGuidOrPath)(LPWSTR, LPWSTR, LPWSTR, LPDWORD);
 #endif   /* _WIN32 */
 
 #endif   /* _nxagentd_h_ */
index 005fbf3..f469872 100644 (file)
@@ -561,6 +561,7 @@ void CEventPolicyEditor::AddSource(void)
    DWORD i, j;
    int iRow;
 
+   dlg.m_dwAllowedClasses = SCL_NODE | SCL_CONTAINER | SCL_SUBNET | SCL_NETWORK | SCL_SERVICEROOT;
    if (dlg.DoModal() == IDOK)
    {
       iRow = m_wndRuleList.GetCurrentRow();
index a705e19..3dbfa64 100644 (file)
@@ -163,6 +163,8 @@ BEGIN_MESSAGE_MAP(CObjectBrowser, CMDIChildWnd)
        ON_UPDATE_COMMAND_UI(ID_OBJECT_MANAGE, OnUpdateObjectManage)
        ON_COMMAND(ID_OBJECT_BIND, OnObjectBind)
        ON_UPDATE_COMMAND_UI(ID_OBJECT_BIND, OnUpdateObjectBind)
+       ON_COMMAND(ID_OBJECT_CREATE_CONTAINER, OnObjectCreateContainer)
+       ON_COMMAND(ID_OBJECT_CREATE_NODE, OnObjectCreateNode)
        //}}AFX_MSG_MAP
    ON_NOTIFY(TVN_SELCHANGED, IDC_TREE_VIEW, OnTreeViewSelChange)
        ON_NOTIFY(LVN_COLUMNCLICK, IDC_LIST_VIEW, OnListViewColumnClick)
@@ -1256,6 +1258,7 @@ void CObjectBrowser::OnObjectBind()
    CObjectSelDlg dlg;
    DWORD i, dwResult;
 
+   dlg.m_dwAllowedClasses = SCL_NODE | SCL_CONTAINER | SCL_SUBNET;
    if (dlg.DoModal() == IDOK)
    {
       for(i = 0; i < dlg.m_dwNumObjects; i++)
@@ -1270,3 +1273,25 @@ void CObjectBrowser::OnObjectBind()
       }
    }
 }
+
+
+//
+// WM_COMMAND::ID_OBJECT_CREATE_CONTAINER message handler
+//
+
+void CObjectBrowser::OnObjectCreateContainer() 
+{
+   theApp.CreateObject(OBJECT_CONTAINER, 
+                       (m_pCurrentObject != NULL) ? m_pCurrentObject->dwId : 0);
+}
+
+
+//
+// WM_COMMAND::ID_OBJECT_CREATE_NODE message handler
+//
+
+void CObjectBrowser::OnObjectCreateNode() 
+{
+   theApp.CreateObject(OBJECT_NODE, 
+                       (m_pCurrentObject != NULL) ? m_pCurrentObject->dwId : 0);
+}
index 5e2c199..495eff8 100644 (file)
@@ -137,6 +137,8 @@ protected:
        afx_msg void OnUpdateObjectManage(CCmdUI* pCmdUI);
        afx_msg void OnObjectBind();
        afx_msg void OnUpdateObjectBind(CCmdUI* pCmdUI);
+       afx_msg void OnObjectCreateContainer();
+       afx_msg void OnObjectCreateNode();
        //}}AFX_MSG
    afx_msg void OnFindObject(WPARAM wParam, LPARAM lParam);
    afx_msg void OnTreeViewSelChange(LPNMTREEVIEW lpnmt);
index 9dee39d..3e8298d 100644 (file)
@@ -23,6 +23,7 @@ CObjectSelDlg::CObjectSelDlg(CWnd* pParent /*=NULL*/)
        //}}AFX_DATA_INIT
    m_dwNumObjects = 0;
    m_pdwObjectList = NULL;
+   m_dwAllowedClasses = 0xFFFF;  // Allow all classes by default
 }
 
 
@@ -62,6 +63,9 @@ BOOL CObjectSelDlg::OnInitDialog()
    DWORD i, dwNumObjects;
    int iItem;
    CBitmap bmp;
+   static DWORD dwClassMask[8] = { 0, SCL_SUBNET, SCL_NODE, SCL_INTERFACE,
+                                   SCL_NETWORK, SCL_CONTAINER, SCL_ZONE,
+                                   SCL_SERVICEROOT };
 
        CDialog::OnInitDialog();
 
@@ -80,11 +84,7 @@ BOOL CObjectSelDlg::OnInitDialog()
    NXCLockObjectIndex();
    pIndex = (NXC_OBJECT_INDEX *)NXCGetObjectIndex(&dwNumObjects);
    for(i = 0; i < dwNumObjects; i++)
-      if ((pIndex[i].pObject->iClass == OBJECT_NODE) ||
-          (pIndex[i].pObject->iClass == OBJECT_SUBNET) ||
-          (pIndex[i].pObject->iClass == OBJECT_NETWORK) ||
-          (pIndex[i].pObject->iClass == OBJECT_CONTAINER) ||
-          (pIndex[i].pObject->iClass == OBJECT_SERVICEROOT))
+      if (dwClassMask[pIndex[i].pObject->iClass] & m_dwAllowedClasses)
       {
          iItem = m_wndListCtrl.InsertItem(0x7FFFFFFF, pIndex[i].pObject->szName,
                                           GetObjectImageIndex(pIndex[i].pObject));
index 5261797..00ccfbe 100644 (file)
@@ -7,6 +7,19 @@
 // ObjectSelDlg.h : header file
 //
 
+//
+// Allowed classes
+//
+
+#define SCL_NODE        0x0001
+#define SCL_INTERFACE   0x0002
+#define SCL_CONTAINER   0x0004
+#define SCL_SUBNET      0x0008
+#define SCL_NETWORK     0x0010
+#define SCL_SERVICEROOT 0x0020
+#define SCL_ZONE        0x0040
+
+
 /////////////////////////////////////////////////////////////////////////////
 // CObjectSelDlg dialog
 
@@ -14,6 +27,7 @@ class CObjectSelDlg : public CDialog
 {
 // Construction
 public:
+       DWORD m_dwAllowedClasses;
        DWORD m_dwNumObjects;
        DWORD *m_pdwObjectList;
        CObjectSelDlg(CWnd* pParent = NULL);   // standard constructor
index e410f91..48f8661 100644 (file)
@@ -103,9 +103,17 @@ static DWORD WINAPI LoginThread(void *pArg)
    DWORD dwResult;
 
    dwResult = NXCConnect(g_szServer, g_szLogin, g_szPassword);
+
+   // If successful, load container objects' categories
+   if (dwResult == RCC_SUCCESS)
+   {
+      SetInfoText(hWnd, "Loading container categories...");
+      dwResult = NXCLoadCCList(&g_pCCList);
+   }
+
+   // Synchronize objects
    if (dwResult == RCC_SUCCESS)
    {
-      // Now we are connected, request data sync
       SetInfoText(hWnd, "Synchronizing objects...");
       dwResult = NXCSyncObjects();
    }
index 6fc604d..2132f8b 100644 (file)
@@ -203,3 +203,10 @@ DEF_IMG *g_pDefImgList = NULL;
 DWORD g_dwNumActions = 0;
 NXC_ACTION *g_pActionList = NULL;
 HANDLE g_mutexActionListAccess = INVALID_HANDLE_VALUE;
+
+
+//
+// Container categories list
+//
+
+NXC_CC_LIST *g_pCCList = NULL;
index 866b5dc..bc900da 100644 (file)
@@ -208,6 +208,7 @@ extern DEF_IMG *g_pDefImgList;
 extern DWORD g_dwNumActions;
 extern NXC_ACTION *g_pActionList;
 extern HANDLE g_mutexActionListAccess;
+extern NXC_CC_LIST *g_pCCList;
 
 
 //
index 1207ed8..a2dbf23 100644 (file)
@@ -2,35 +2,35 @@
 
 [General Info]
 Version=1
-LastClass=CActionSelDlg
+LastClass=CCreateObjectDlg
 LastTemplate=CDialog
 NewFileInclude1=#include "stdafx.h"
 NewFileInclude2=#include "nxcon.h"
 LastPage=0
 
-ClassCount=59
+ClassCount=60
 Class1=CConsoleApp
 Class3=CMainFrame
 Class4=CChildFrame
 Class7=CEventBrowser
 Class9=CMapView
 
-ResourceCount=76
+ResourceCount=77
 Resource1=IDD_EDIT_RULE_COMMENT (English (U.S.))
-Resource2=IDD_USER_PROPERTIES
+Resource2=IDR_MAINFRAME
 Resource3=IDD_NEW_USER (English (U.S.))
-Resource4=IDM_CONTEXT
-Resource5=IDA_OBJECT_BROWSER
+Resource4=IDD_SELECT_ACTION
+Resource5=IDD_DCI_COLLECTION
 Class2=CChildView
 Class5=CAboutDlg
 Class6=CControlPanel
 Class8=CMapFrame
 Class10=CLoginDialog
-Resource6=IDD_EDIT_RULE_ALARM
+Resource6=IDD_OBJECT_SECURITY
 Class11=CProgressDialog
-Resource7=IDD_LOGIN
+Resource7=IDD_SELECT_OBJECT
 Class12=CObjectBrowser
-Resource8=IDA_MDI_DEFAULT
+Resource8=IDD_SET_PASSWORD
 Class13=CObjectPropDlg
 Resource9=IDD_REQUEST_PROCESSING (English (U.S.))
 Resource10=IDA_EPP (English (U.S.))
@@ -46,7 +46,7 @@ Resource17=IDA_ALARM_BROWSER (English (U.S.))
 Class16=CDebugFrame
 Resource18=IDR_MAINFRAME (English (U.S.))
 Resource19=IDD_OBJECT_PROPERTIES (English (U.S.))
-Resource20=IDD_THRESHOLD
+Resource20=IDD_ABOUTBOX
 Class17=CObjectPreview
 Resource21=IDD_THRESHOLD (English (U.S.))
 Class18=CToolBox
@@ -59,32 +59,32 @@ Class23=CNodePropsGeneral
 Resource23=IDD_ABOUTBOX (English (U.S.))
 Class24=CObjectPropCaps
 Class25=CObjectPropSheet
-Resource24=IDD_DCI_COLLECTION
+Resource24=IDA_EPP
 Class26=CRequestProcessingDlg
 Resource25=IDM_VIEW_SPECIFIC (English (U.S.))
 Resource26=IDD_PROGRESS (English (U.S.))
-Resource27=IDD_OBJECT_NODE_GENERAL
+Resource27=IDD_SELECT_EVENT
 Resource28=IDD_CP_GENERAL (English (U.S.))
 Class27=CObjectPropsGeneral
 Resource29=IDD_SET_PASSWORD (English (U.S.))
 Class28=CObjectPropsSecurity
 Resource30=IDD_SELECT_USER (English (U.S.))
-Resource31=IDD_ACTION_PROPERTIES
-Resource32=IDD_EDIT_EVENT
+Resource31=IDD_USER_PROPERTIES
+Resource32=IDD_EDIT_RULE_COMMENT
 Class29=CUserSelectDlg
-Resource33=IDD_EDIT_RULE_SEVERITY
+Resource33=IDD_OBJECT_GENERAL
 Class30=CUserEditor
 Resource34=IDD_DCI_PROPERTIES
 Class31=CNewUserDlg
-Resource35=IDD_OBJECT_PRESENTATION
-Resource36=IDD_DCI_THRESHOLDS
+Resource35=IDD_REQUEST_PROCESSING
+Resource36=IDA_ALARM_BROWSER
 Class32=CUserPropDlg
 Resource37=IDD_MIB_BROWSER (English (U.S.))
-Resource38=IDD_NEW_USER
+Resource38=IDM_VIEW_SPECIFIC
 Class33=CGroupPropDlg
-Resource39=IDD_ABOUTBOX
-Resource40=IDD_GROUP_PROPERTIES
-Resource41=IDD_OBJECT_GENERAL
+Resource39=IDD_MIB_BROWSER
+Resource40=IDA_MDI_DEFAULT
+Resource41=IDD_CP_GENERAL
 Resource42=IDD_EDIT_RULE_SEVERITY (English (U.S.))
 Class34=CPasswordChangeDlg
 Class35=CNodeSummary
@@ -100,52 +100,54 @@ Class41=CGraphFrame
 Class42=CDCIThresholdsPage
 Resource46=IDD_GROUP_PROPERTIES (English (U.S.))
 Resource47=IDD_LOGIN (English (U.S.))
-Resource48=IDD_EDIT_RULE_COMMENT
+Resource48=IDD_OBJECT_NODE_GENERAL
 Class43=CThresholdDlg
 Resource49=IDD_NEW_ACTION (English (U.S.))
-Resource50=IDD_CP_GENERAL
+Resource50=IDD_SELECT_USER
 Class44=CMIBBrowserDlg
 Class45=CEventPolicyEditor
 Class46=CRuleList
 Class47=CRuleHeader
 Resource51=IDD_USER_PROPERTIES (English (U.S.))
-Resource52=IDM_VIEW_SPECIFIC
+Resource52=IDM_CONTEXT
 Class48=CObjectSelDlg
-Resource53=IDD_OBJECT_SECURITY
-Resource54=IDD_OBJECT_CAPS
+Resource53=IDD_NEW_ACTION
+Resource54=IDD_EDIT_RULE_SEVERITY
 Class49=CRuleCommentDlg
-Resource55=IDD_SELECT_EVENT
+Resource55=IDD_OBJECT_CAPS
 Class50=CEventSelDlg
-Resource56=IDD_NEW_ACTION
+Resource56=IDD_NEW_USER
 Resource57=IDM_CONTEXT (English (U.S.))
 Resource58=IDD_DCI_COLLECTION (English (U.S.))
 Resource59=IDD_OBJECT_SECURITY (English (U.S.))
 Resource60=IDD_SELECT_OBJECT (English (U.S.))
 Class51=CObjectPropsPresentation
 Resource61=IDD_SELECT_EVENT (English (U.S.))
-Resource62=IDD_SELECT_OBJECT
+Resource62=IDD_EDIT_EVENT
 Class52=CRuleSeverityDlg
-Resource63=IDA_ALARM_BROWSER
+Resource63=IDD_THRESHOLD
 Class53=CRuleAlarmDlg
 Class54=CAlarmBrowser
-Resource64=IDR_MAINFRAME
-Resource65=IDD_SELECT_USER
+Resource64=IDD_SELECT_ACTION (English (U.S.))
+Resource65=IDD_ACTION_PROPERTIES
 Resource66=IDD_ACTION_PROPERTIES (English (U.S.))
 Resource67=IDD_OBJECT_PRESENTATION (English (U.S.))
 Resource68=IDD_DCI_THRESHOLDS (English (U.S.))
 Class55=CConsolePropsGeneral
 Class56=CActionEditor
-Resource69=IDD_MIB_BROWSER
-Resource70=IDD_REQUEST_PROCESSING
+Resource69=IDD_LOGIN
+Resource70=IDD_EDIT_RULE_ALARM
 Class57=CNewActionDlg
-Resource71=IDA_EPP
+Resource71=IDD_DCI_THRESHOLDS
 Class58=CEditActionDlg
-Resource72=IDD_SET_PASSWORD
+Resource72=IDA_OBJECT_BROWSER
 Class59=CActionSelDlg
-Resource73=IDD_SELECT_ACTION
+Resource73=IDD_GROUP_PROPERTIES
 Resource74=IDD_EDIT_EVENT (English (U.S.))
 Resource75=IDD_OBJECT_NODE_GENERAL (English (U.S.))
-Resource76=IDD_SELECT_ACTION (English (U.S.))
+Resource76=IDD_OBJECT_PRESENTATION
+Class60=CCreateObjectDlg
+Resource77=IDD_CREATE_OBJECT
 
 [CLS:CConsoleApp]
 Type=0
@@ -1900,10 +1902,11 @@ ImplementationFile=ActionSelDlg.cpp
 BaseClass=CDialog
 Filter=D
 VirtualFilter=dWC
+LastObject=CActionSelDlg
 
 [DLG:IDD_NEW_ACTION (English (U.S.))]
 Type=1
-Class=?
+Class=CNewActionDlg
 ControlCount=4
 Control1=IDC_EDIT_NAME,edit,1350631552
 Control2=IDOK,button,1342242817
@@ -1912,7 +1915,7 @@ Control4=IDC_STATIC,static,1342308352
 
 [DLG:IDD_ACTION_PROPERTIES (English (U.S.))]
 Type=1
-Class=?
+Class=CEditActionDlg
 ControlCount=15
 Control1=IDC_EDIT_NAME,edit,1350631552
 Control2=IDC_RADIO_EXEC,button,1342308361
@@ -1932,9 +1935,37 @@ Control15=IDC_STATIC,static,1342308352
 
 [DLG:IDD_SELECT_ACTION (English (U.S.))]
 Type=1
-Class=?
+Class=CActionSelDlg
 ControlCount=3
 Control1=IDOK,button,1342242817
 Control2=IDCANCEL,button,1342242816
 Control3=IDC_LIST_ACTIONS,SysListView32,1342275609
 
+[DLG:IDD_CREATE_OBJECT]
+Type=1
+Class=CCreateObjectDlg
+ControlCount=14
+Control1=IDC_EDIT_NAME,edit,1350631552
+Control2=IDC_COMBO_CATEGORY,combobox,1344340227
+Control3=IDC_EDIT_DESCRIPTION,edit,1350631552
+Control4=IDC_SELECT_PARENT,button,1342242816
+Control5=IDOK,button,1342242817
+Control6=IDCANCEL,button,1342242816
+Control7=IDC_STATIC,button,1342177287
+Control8=IDC_STATIC,static,1342308352
+Control9=IDC_STATIC_CATEGORY,static,1342308352
+Control10=IDC_STATIC,button,1342177287
+Control11=IDC_ICON_PARENT,static,1342177283
+Control12=IDC_STATIC_ID,static,1342308352
+Control13=IDC_STATIC_NAME,static,1342308352
+Control14=IDC_STATIC,static,1342308352
+
+[CLS:CCreateObjectDlg]
+Type=0
+HeaderFile=CreateObjectDlg.h
+ImplementationFile=CreateObjectDlg.cpp
+BaseClass=CDialog
+Filter=D
+VirtualFilter=dWC
+LastObject=CCreateObjectDlg
+
index 2991cf9..1a2fb92 100644 (file)
@@ -6,6 +6,7 @@
 
 #include "MainFrm.h"
 #include "LoginDialog.h"
+#include "CreateObjectDlg.h"
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
@@ -294,6 +295,7 @@ int CConsoleApp::ExitInstance()
    NXCSetDebugCallback(NULL);
    NXCDisconnect();
    NXCShutdown();
+   NXCDestroyCCList(g_pCCList);
 
    // Save configuration
    WriteProfileInt(_T("General"), _T("Options"), g_dwOptions);
@@ -1166,3 +1168,38 @@ HMENU CConsoleApp::LoadAppMenu(HMENU hViewMenu)
 
    return hMenu;
 }
+
+
+//
+// Create new object
+//
+
+void CConsoleApp::CreateObject(int iClass, DWORD dwParent)
+{
+   CCreateObjectDlg dlg;
+   DWORD dwResult, dwObjectId;
+   NXC_OBJECT_CREATE_INFO ci;
+
+   dlg.m_pParentObject = NXCFindObjectById(dwParent);
+   if (dlg.DoModal() == IDOK)
+   {
+      ci.dwParentId = (dlg.m_pParentObject != NULL) ? dlg.m_pParentObject->dwId : 0;
+      ci.iClass = iClass;
+      ci.pszName = (char *)((LPCTSTR)dlg.m_strObjectName);
+      switch(iClass)
+      {
+         case OBJECT_NODE:
+            break;
+         case OBJECT_CONTAINER:
+            ci.cs.container.dwCategory = 1;
+            ci.cs.container.pszDescription = (char *)((LPCTSTR)dlg.m_strDescription);
+            break;
+      }
+
+      dwResult = DoRequestArg2(NXCCreateObject, &ci, &dwObjectId, "Creating object...");
+      if (dwResult != RCC_SUCCESS)
+      {
+         ErrorBox(dwResult, "Error creating object: %s");
+      }
+   }
+}
index fee2ec5..0264649 100644 (file)
@@ -125,6 +125,10 @@ SOURCE=.\ControlPanel.cpp
 # End Source File
 # Begin Source File
 
+SOURCE=.\CreateObjectDlg.cpp
+# End Source File
+# Begin Source File
+
 SOURCE=.\DataCollectionEditor.cpp
 # End Source File
 # Begin Source File
@@ -362,6 +366,10 @@ SOURCE=.\ControlPanel.h
 # End Source File
 # Begin Source File
 
+SOURCE=.\CreateObjectDlg.h
+# End Source File
+# Begin Source File
+
 SOURCE=.\DataCollectionEditor.h
 # End Source File
 # Begin Source File
index 676834c..d9bb020 100644 (file)
@@ -165,6 +165,7 @@ private:
    DC_EDITOR m_openDCEditors[MAX_DC_EDITORS];
 
 public:
+       void CreateObject(int iClass, DWORD dwParent);
    NXC_EPP *m_pEventPolicy;
 
        void ShowDCIGraph(DWORD dwNodeId, DWORD dwItemId, char *pszItemName);
index 3b46fe8..97343ec 100644 (file)
@@ -196,7 +196,7 @@ BEGIN
         POPUP "&Create..."
         BEGIN
             MENUITEM "&Node...",                    ID_OBJECT_CREATE_NODE
-            MENUITEM "&Container",                  ID_OBJECT_CREATE_CONTAINER
+            MENUITEM "&Container...",               ID_OBJECT_CREATE_CONTAINER
 
         END
         MENUITEM "&Bind...\tCtrl+B",            ID_OBJECT_BIND
@@ -296,7 +296,7 @@ BEGIN
         POPUP "&Create"
         BEGIN
             MENUITEM "&Node...",                    ID_OBJECT_CREATE_NODE
-            MENUITEM "&Container",                  ID_OBJECT_CREATE_CONTAINER
+            MENUITEM "&Container...",               ID_OBJECT_CREATE_CONTAINER
 
         END
         MENUITEM "&Bind...",                    ID_OBJECT_BIND
@@ -1020,6 +1020,28 @@ BEGIN
                     WS_TABSTOP,7,7,189,132,WS_EX_CLIENTEDGE
 END
 
+IDD_CREATE_OBJECT DIALOG DISCARDABLE  0, 0, 229, 153
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Create Object"
+FONT 8, "MS Sans Serif"
+BEGIN
+    EDITTEXT        IDC_EDIT_NAME,13,27,146,14,ES_AUTOHSCROLL
+    COMBOBOX        IDC_COMBO_CATEGORY,13,55,146,30,CBS_DROPDOWNLIST | 
+                    CBS_SORT | WS_VSCROLL | WS_TABSTOP
+    EDITTEXT        IDC_EDIT_DESCRIPTION,13,80,146,14,ES_AUTOHSCROLL
+    PUSHBUTTON      "&Select...",IDC_SELECT_PARENT,110,115,50,12
+    DEFPUSHBUTTON   "OK",IDOK,172,7,50,14
+    PUSHBUTTON      "Cancel",IDCANCEL,172,24,50,14
+    GROUPBOX        "New object",IDC_STATIC,7,7,158,93
+    LTEXT           "Name",IDC_STATIC,13,18,20,8
+    LTEXT           "Category",IDC_STATIC_CATEGORY,13,45,29,8
+    GROUPBOX        "Parent object",IDC_STATIC,7,104,158,42
+    ICON            "",IDC_ICON_PARENT,14,117,21,20
+    LTEXT           "ID:",IDC_STATIC_ID,43,117,54,8
+    LTEXT           "Name",IDC_STATIC_NAME,44,131,112,9
+    LTEXT           "Description",IDC_STATIC,13,71,36,8
+END
+
 
 #ifndef _MAC
 /////////////////////////////////////////////////////////////////////////////
@@ -1287,6 +1309,14 @@ BEGIN
         TOPMARGIN, 7
         BOTTOMMARGIN, 139
     END
+
+    IDD_CREATE_OBJECT, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 222
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 146
+    END
 END
 #endif    // APSTUDIO_INVOKED
 
index 2ce1e39..3ac6a7b 100644 (file)
 #define IDD_NEW_ACTION                  217
 #define IDD_ACTION_PROPERTIES           218
 #define IDD_SELECT_ACTION               219
+#define IDD_CREATE_OBJECT               220
 #define IDC_EDIT_SERVER                 1000
 #define IDC_EDIT_LOGIN                  1001
 #define IDC_EDIT_PASSWORD               1002
 #define IDC_RADIO_EMAIL                 1149
 #define IDC_RADIO4                      1150
 #define IDC_LIST_ACTIONS                1152
+#define IDC_COMBO_CATEGORY              1154
+#define IDC_ICON_PARENT                 1155
+#define IDC_STATIC_ID                   1156
+#define IDC_STATIC_NAME                 1157
+#define IDC_STATIC_CATEGORY             1158
+#define IDC_SELECT_PARENT               1159
 #define ID_VIEW_CONTROLPANEL            32771
 #define ID_VIEW_EVENTS                  32774
 #define ID_VIEW_MAP                     32776
 #ifdef APSTUDIO_INVOKED
 #ifndef APSTUDIO_READONLY_SYMBOLS
 #define _APS_3D_CONTROLS                     1
-#define _APS_NEXT_RESOURCE_VALUE        220
+#define _APS_NEXT_RESOURCE_VALUE        221
 #define _APS_NEXT_COMMAND_VALUE         32876
-#define _APS_NEXT_CONTROL_VALUE         1153
+#define _APS_NEXT_CONTROL_VALUE         1161
 #define _APS_NEXT_SYMED_VALUE           119
 #endif
 #endif
index 12f7f11..b92f6a8 100644 (file)
 // Universal configuration loader
 //
 
-DWORD LIBNETXMS_EXPORTABLE NxLoadConfig(char *pszFileName, NX_CFG_TEMPLATE *pTemplateList, BOOL bPrint)
+DWORD LIBNETXMS_EXPORTABLE NxLoadConfig(char *pszFileName, char *pszSection,
+                                        NX_CFG_TEMPLATE *pTemplateList, BOOL bPrint)
 {
    FILE *cfg;
    char *ptr, *eptr, szBuffer[4096];
    int i, iSourceLine = 0, iErrors = 0;
+   BOOL bActiveSection = (pszSection[0] == 0);
 
    cfg = fopen(pszFileName, "r");
    if (cfg == NULL)
@@ -59,80 +61,92 @@ DWORD LIBNETXMS_EXPORTABLE NxLoadConfig(char *pszFileName, NX_CFG_TEMPLATE *pTem
       if (szBuffer[0] == 0)
          continue;
 
-      // Divide on two parts at = sign
-      ptr = strchr(szBuffer, '=');
-      if (ptr == NULL)
+      // Check if it's a section name
+      if (szBuffer[0] == '*')
       {
-         iErrors++;
-         if (bPrint)
-            printf("Syntax error in configuration file at line %d\n", iSourceLine);
-         continue;
+         if (!stricmp(&szBuffer[1], pszSection))
+            bActiveSection = TRUE;
       }
-      *ptr = 0;
-      ptr++;
-      StrStrip(szBuffer);
-      StrStrip(ptr);
+      else
+      {
+         if (!bActiveSection)
+            continue;
 
-      // Find corresponding token in template list
-      for(i = 0; pTemplateList[i].iType != CT_END_OF_LIST; i++)
-         if (!stricmp(pTemplateList[i].szToken, szBuffer))
+         // Divide on two parts at = sign
+         ptr = strchr(szBuffer, '=');
+         if (ptr == NULL)
          {
-            switch(pTemplateList[i].iType)
+            iErrors++;
+            if (bPrint)
+               printf("Syntax error in configuration file at line %d\n", iSourceLine);
+            continue;
+         }
+         *ptr = 0;
+         ptr++;
+         StrStrip(szBuffer);
+         StrStrip(ptr);
+
+         // Find corresponding token in template list
+         for(i = 0; pTemplateList[i].iType != CT_END_OF_LIST; i++)
+            if (!stricmp(pTemplateList[i].szToken, szBuffer))
             {
-               case CT_LONG:
-                  *((long *)pTemplateList[i].pBuffer) = strtol(ptr, &eptr, 0);
-                  if (*eptr != 0)
-                  {
-                     iErrors++;
-                     if (bPrint)
-                        printf("Invalid number '%s' in configuration file at line %d\n", ptr, iSourceLine);
-                  }
-                  break;
-               case CT_WORD:
-                  *((WORD *)pTemplateList[i].pBuffer) = (WORD)strtoul(ptr, &eptr, 0);
-                  if (*eptr != 0)
-                  {
-                     iErrors++;
-                     if (bPrint)
-                        printf("Invalid number '%s' in configuration file at line %d\n", ptr, iSourceLine);
-                  }
-                  break;
-               case CT_BOOLEAN:
-                  if (!stricmp(ptr, "yes") || !stricmp(ptr, "true") ||
-                      !stricmp(ptr, "on") || !stricmp(ptr, "1"))
-                  {
-                     *((DWORD *)pTemplateList[i].pBuffer) |= pTemplateList[i].dwBufferSize;
-                  }
-                  else
-                  {
-                     *((DWORD *)pTemplateList[i].pBuffer) &= ~(pTemplateList[i].dwBufferSize);
-                  }
-                  break;
-               case CT_STRING:
-                  strncpy((char *)pTemplateList[i].pBuffer, ptr, pTemplateList[i].dwBufferSize);
-                  break;
-               case CT_STRING_LIST:
-                  if (pTemplateList[i].dwBufferPos < pTemplateList[i].dwBufferSize)
-                  {
-                     strncpy((char *)pTemplateList[i].pBuffer + pTemplateList[i].dwBufferPos, 
-                             ptr, pTemplateList[i].dwBufferSize - pTemplateList[i].dwBufferPos - 1);
-                     pTemplateList[i].dwBufferPos += strlen(ptr);
+               switch(pTemplateList[i].iType)
+               {
+                  case CT_LONG:
+                     *((long *)pTemplateList[i].pBuffer) = strtol(ptr, &eptr, 0);
+                     if (*eptr != 0)
+                     {
+                        iErrors++;
+                        if (bPrint)
+                           printf("Invalid number '%s' in configuration file at line %d\n", ptr, iSourceLine);
+                     }
+                     break;
+                  case CT_WORD:
+                     *((WORD *)pTemplateList[i].pBuffer) = (WORD)strtoul(ptr, &eptr, 0);
+                     if (*eptr != 0)
+                     {
+                        iErrors++;
+                        if (bPrint)
+                           printf("Invalid number '%s' in configuration file at line %d\n", ptr, iSourceLine);
+                     }
+                     break;
+                  case CT_BOOLEAN:
+                     if (!stricmp(ptr, "yes") || !stricmp(ptr, "true") ||
+                         !stricmp(ptr, "on") || !stricmp(ptr, "1"))
+                     {
+                        *((DWORD *)pTemplateList[i].pBuffer) |= pTemplateList[i].dwBufferSize;
+                     }
+                     else
+                     {
+                        *((DWORD *)pTemplateList[i].pBuffer) &= ~(pTemplateList[i].dwBufferSize);
+                     }
+                     break;
+                  case CT_STRING:
+                     strncpy((char *)pTemplateList[i].pBuffer, ptr, pTemplateList[i].dwBufferSize);
+                     break;
+                  case CT_STRING_LIST:
                      if (pTemplateList[i].dwBufferPos < pTemplateList[i].dwBufferSize)
-                        ((char *)pTemplateList[i].pBuffer)[pTemplateList[i].dwBufferPos++] = pTemplateList[i].cSeparator;
-                  }
-                  break;
-               default:
-                  break;
+                     {
+                        strncpy((char *)pTemplateList[i].pBuffer + pTemplateList[i].dwBufferPos, 
+                                ptr, pTemplateList[i].dwBufferSize - pTemplateList[i].dwBufferPos - 1);
+                        pTemplateList[i].dwBufferPos += strlen(ptr);
+                        if (pTemplateList[i].dwBufferPos < pTemplateList[i].dwBufferSize)
+                           ((char *)pTemplateList[i].pBuffer)[pTemplateList[i].dwBufferPos++] = pTemplateList[i].cSeparator;
+                     }
+                     break;
+                  default:
+                     break;
+               }
+               break;
             }
-            break;
-         }
 
-      // Invalid keyword
-      if (pTemplateList[i].iType == CT_END_OF_LIST)
-      {
-         iErrors++;
-         if (bPrint)
-            printf("Invalid keyword %s in configuration file at line %d\n", szBuffer, iSourceLine);
+         // Invalid keyword
+         if (pTemplateList[i].iType == CT_END_OF_LIST)
+         {
+            iErrors++;
+            if (bPrint)
+               printf("Invalid keyword %s in configuration file at line %d\n", szBuffer, iSourceLine);
+         }
       }
    }
    fclose(cfg);
index d4d920a..0fb1095 100644 (file)
@@ -576,3 +576,81 @@ DWORD LIBNXCL_EXPORTABLE NXCUnbindObject(DWORD dwParentObject, DWORD dwChildObje
 {
    return ChangeObjectBinding(dwParentObject, dwChildObject, FALSE);
 }
+
+
+//
+// Load container categories
+//
+
+DWORD LIBNXCL_EXPORTABLE NXCLoadCCList(NXC_CC_LIST **ppList)
+{
+   CSCPMessage msg, *pResponce;
+   DWORD dwRqId, dwRetCode = RCC_SUCCESS, dwNumCats = 0, dwCatId = 0;
+
+   dwRqId = g_dwMsgId++;
+
+   msg.SetCode(CMD_GET_CONTAINER_CAT_LIST);
+   msg.SetId(dwRqId);
+   SendMsg(&msg);
+
+   *ppList = (NXC_CC_LIST *)malloc(sizeof(NXC_CC_LIST));
+   (*ppList)->dwNumElements = 0;
+   (*ppList)->pElements = NULL;
+
+   do
+   {
+      pResponce = WaitForMessage(CMD_CONTAINER_CAT_DATA, dwRqId, 2000);
+      if (pResponce != NULL)
+      {
+         dwCatId = pResponce->GetVariableLong(VID_CATEGORY_ID);
+         if (dwCatId != 0)  // 0 is end of list indicator
+         {
+            (*ppList)->pElements = (NXC_CONTAINER_CATEGORY *)realloc((*ppList)->pElements, 
+               sizeof(NXC_CONTAINER_CATEGORY) * ((*ppList)->dwNumElements + 1));
+            (*ppList)->pElements[(*ppList)->dwNumElements].dwId = dwCatId;
+            (*ppList)->pElements[(*ppList)->dwNumElements].dwImageId =
+               pResponce->GetVariableLong(VID_IMAGE_ID);
+            pResponce->GetVariableStr(VID_CATEGORY_NAME, 
+               (*ppList)->pElements[(*ppList)->dwNumElements].szName, MAX_OBJECT_NAME);
+            (*ppList)->pElements[(*ppList)->dwNumElements].pszDescription =
+               pResponce->GetVariableStr(VID_DESCRIPTION);
+            (*ppList)->dwNumElements++;
+         }
+         delete pResponce;
+      }
+      else
+      {
+         dwRetCode = RCC_TIMEOUT;
+         dwCatId = 0;
+      }
+   }
+   while(dwCatId != 0);
+
+   // Destroy results on failure
+   if (dwRetCode != RCC_SUCCESS)
+   {
+      safe_free((*ppList)->pElements);
+      free(*ppList);
+      *ppList = NULL;
+   }
+
+   return dwRetCode;
+}
+
+
+//
+// Destroy list of container categories
+//
+
+void LIBNXCL_EXPORTABLE NXCDestroyCCList(NXC_CC_LIST *pList)
+{
+   DWORD i;
+
+   if (pList == NULL)
+      return;
+
+   for(i = 0; i < pList->dwNumElements; i++)
+      safe_free(pList->pElements[i].pszDescription);
+   safe_free(pList->pElements);
+   free(pList);
+}
index 79667db..98e249d 100644 (file)
@@ -85,7 +85,7 @@ BOOL LoadConfig(void)
    if (IsStandalone())
       printf("Using configuration file \"%s\"\n", g_szConfigFile);
 
-   if (NxLoadConfig(g_szConfigFile, m_cfgTemplate, IsStandalone()) == NXCFG_ERR_OK)
+   if (NxLoadConfig(g_szConfigFile, "", m_cfgTemplate, IsStandalone()) == NXCFG_ERR_OK)
    {
       if ((!stricmp(g_szLogFile,"{EventLog}")) ||
           (!stricmp(g_szLogFile,"{syslog}")))
index 6eb3455..8db8fec 100644 (file)
@@ -43,6 +43,7 @@ CONTAINER_CATEGORY *FindContainerCategory(DWORD dwId)
 //
 
 Container::Container()
+          :NetObj()
 {
    m_pszDescription = NULL;
    m_pdwChildIdList = NULL;
@@ -56,7 +57,9 @@ Container::Container()
 //
 
 Container::Container(char *pszName, DWORD dwCategory, char *pszDescription)
+          :NetObj()
 {
+   strncpy(m_szName, pszName, MAX_OBJECT_NAME);
    m_pszDescription = strdup(pszDescription);
    m_pdwChildIdList = NULL;
    m_dwChildIdListSize = 0;
index 4269067..2f8ec18 100644 (file)
@@ -284,6 +284,7 @@ private:
    void DeleteAction(CSCPMessage *pRequest);
    void LockActionDB(DWORD dwRqId, BOOL bLock);
    void SendAllActions(DWORD dwRqId);
+   void SendContainerCategories(DWORD dwRqId);
 
 public:
    ClientSession(SOCKET hSocket, DWORD dwHostAddr);
index dcdb879..0d258bc 100644 (file)
@@ -432,6 +432,7 @@ struct CONTAINER_CATEGORY
    DWORD dwCatId;
    char szName[MAX_OBJECT_NAME];
    char *pszDescription;
+   DWORD dwImageId;
 };
 
 
index c1edd87..ed278a7 100644 (file)
@@ -414,6 +414,7 @@ BOOL LoadObjects(void)
       {
          g_pContainerCatList[i].dwCatId = DBGetFieldULong(hResult, i, 0);
          strncpy(g_pContainerCatList[i].szName, DBGetField(hResult, i, 1), MAX_OBJECT_NAME);
+         g_pContainerCatList[i].dwImageId = DBGetFieldULong(hResult, i, 2);
          g_pContainerCatList[i].pszDescription = strdup(DBGetField(hResult, i, 3));
       }
       DBFreeResult(hResult);
index 1219974..f8eb57f 100644 (file)
@@ -468,6 +468,9 @@ void ClientSession::ProcessingThread(void)
          case CMD_LOAD_ACTIONS:
             SendAllActions(pMsg->GetId());
             break;
+         case CMD_GET_CONTAINER_CAT_LIST:
+            SendContainerCategories(pMsg->GetId());
+            break;
          default:
             break;
       }
@@ -2452,3 +2455,32 @@ void ClientSession::SendAllActions(DWORD dwRqId)
       SendMessage(&msg);
    }
 }
+
+
+//
+// Send list of configured container categories to client
+//
+
+void ClientSession::SendContainerCategories(DWORD dwRqId)
+{
+   CSCPMessage msg;
+   DWORD i;
+
+   // Prepare responce message
+   msg.SetCode(CMD_CONTAINER_CAT_DATA);
+   msg.SetId(dwRqId);
+
+   for(i = 0; i < g_dwNumCategories; i++)
+   {
+      msg.SetVariable(VID_CATEGORY_ID, g_pContainerCatList[i].dwCatId);
+      msg.SetVariable(VID_CATEGORY_NAME, g_pContainerCatList[i].szName);
+      msg.SetVariable(VID_IMAGE_ID, g_pContainerCatList[i].dwImageId);
+      msg.SetVariable(VID_DESCRIPTION, g_pContainerCatList[i].pszDescription);
+      SendMessage(&msg);
+      msg.DeleteAllVariables();
+   }
+
+   // Send end-of-list indicator
+   msg.SetVariable(VID_CATEGORY_ID, (DWORD)0);
+   SendMessage(&msg);
+}
index 582b8c3..156c594 100644 (file)
@@ -323,7 +323,7 @@ INTERFACE_LIST *AgentConnection::GetInterfaceList(void)
    DWORD i;
    char *pChar, *pBuf;
 
-   if (GetList("InterfaceList") == ERR_SUCCESS)
+   if (GetList("Net.InterfaceList") == ERR_SUCCESS)
    {
       pIfList = (INTERFACE_LIST *)malloc(sizeof(INTERFACE_LIST));
       pIfList->iNumEntries = m_dwNumDataLines;
@@ -440,7 +440,7 @@ ARP_CACHE *AgentConnection::GetArpCache(void)
    char szByte[4], *pBuf, *pChar;
    DWORD i, j;
 
-   if (GetList("ArpCache") == ERR_SUCCESS)
+   if (GetList("Net.ArpCache") == ERR_SUCCESS)
    {
       // Create empty structure
       pArpCache = (ARP_CACHE *)malloc(sizeof(ARP_CACHE));