Support for redefined graphs ready on server side and in client library; GUI not...
authorVictor Kirhenshtein <victor@netxms.org>
Thu, 8 Feb 2007 22:25:22 +0000 (22:25 +0000)
committerVictor Kirhenshtein <victor@netxms.org>
Thu, 8 Feb 2007 22:25:22 +0000 (22:25 +0000)
29 files changed:
.gitattributes
include/nms_cscp.h
include/nxclapi.h
src/console/win32/ControlPanel.cpp
src/console/win32/GraphFrame.cpp
src/console/win32/GraphFrame.h
src/console/win32/Makefile.am
src/console/win32/ViewEditor.cpp [deleted file]
src/console/win32/ViewEditor.h [deleted file]
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/console/win32/tools.cpp
src/libnetxms/nxcp.cpp
src/libnxcl/Makefile.am
src/libnxcl/datacoll.cpp
src/libnxcl/graph.cpp [new file with mode: 0644]
src/libnxcl/libnxcl.dsp
src/libnxcl/main.cpp
src/server/core/id.cpp
src/server/core/session.cpp
src/server/include/nms_core.h
src/server/libnxsrv/log.cpp

index daa282f..c541110 100644 (file)
@@ -894,8 +894,6 @@ src/console/win32/VPNCPropsGeneral.cpp -text
 src/console/win32/VPNCPropsGeneral.h -text
 src/console/win32/ValueList.cpp -text
 src/console/win32/ValueList.h -text
-src/console/win32/ViewEditor.cpp -text
-src/console/win32/ViewEditor.h -text
 src/console/win32/WaitView.cpp -text
 src/console/win32/WaitView.h -text
 src/console/win32/WebBrowser.cpp -text
@@ -1057,6 +1055,7 @@ src/libnxcl/datacoll.cpp -text
 src/libnxcl/epp.cpp -text
 src/libnxcl/eventdb.cpp -text
 src/libnxcl/events.cpp -text
+src/libnxcl/graph.cpp -text
 src/libnxcl/image.cpp -text
 src/libnxcl/libnxcl.dsp -text
 src/libnxcl/libnxcl.dsw -text
index 96f5dd8..b8531c0 100644 (file)
@@ -717,6 +717,8 @@ typedef struct
 #define VID_PDU_SIZE                                           ((DWORD)270)
 #define VID_IS_SYSTEM                                  ((DWORD)271)
 #define VID_GRAPH_CONFIG                               ((DWORD)272)
+#define VID_NUM_GRAPHS                                 ((DWORD)273)
+#define VID_GRAPH_ID                                           ((DWORD)274)
 
 // Variable ranges for object's ACL
 #define VID_ACL_USER_BASE           ((DWORD)0x00001000)
@@ -831,6 +833,10 @@ typedef struct
 // Base value for trap configuration records
 #define VID_TRAP_INFO_BASE          ((DWORD)0x10000000)
 
+// Base value for graph list
+#define VID_GRAPH_LIST_BASE         ((DWORD)0x10000000)
+#define VID_GRAPH_ACL_BASE                             ((DWORD)0x20000000)
+
 
 //
 // Inline functions
index c1a9bef..0b734cc 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: nxclapi.h,v 1.256 2007-01-27 20:00:22 victor Exp $ */
+/* $Id: nxclapi.h,v 1.257 2007-02-08 22:25:20 victor Exp $ */
 /* 
 ** NetXMS - Network Management System
 ** Client Library API
@@ -304,6 +304,7 @@ enum
 #define NX_NOTIFY_OBJTOOLS_CHANGED  9
 #define NX_NOTIFY_DBCONN_STATUS     10
 #define NX_NOTIFY_ALARM_TERMINATED  11
+#define NX_NOTIFY_GRAPHS_CHANGED               12
 
 
 //
@@ -380,6 +381,7 @@ enum
 #define RCC_NOT_PUSH_DCI            ((DWORD)67)
 #define RCC_NXMP_PARSE_ERROR        ((DWORD)68)
 #define RCC_NXMP_VALIDATION_ERROR   ((DWORD)69)
+#define RCC_INVALID_GRAPH_ID                   ((DWORD)70)
 
 
 //
@@ -617,6 +619,14 @@ enum
 #define NXMPIF_REPLACE_EVENT_BY_NAME   0x0002
 
 
+//
+// Graph access flags
+//
+
+#define NXGRAPH_ACCESS_READ            0x01
+#define NXGRAPH_ACCESS_WRITE           0x02
+
+
 //
 // Cluster types
 //
@@ -1585,6 +1595,32 @@ typedef struct
 } NXC_ADDR_ENTRY;
 
 
+//
+// Graph ACL element
+//
+
+typedef struct
+{
+       DWORD dwUserId;
+       DWORD dwAccess;
+} NXC_GRAPH_ACL_ENTRY;
+
+
+//
+// Graph information
+//
+
+typedef struct
+{
+       DWORD dwId;
+       TCHAR *pszName;
+       TCHAR *pszConfig;
+       DWORD dwOwner;
+       DWORD dwAclSize;
+       NXC_GRAPH_ACL_ENTRY *pACL;
+} NXC_GRAPH;
+
+
 //
 // Functions
 //
@@ -1874,6 +1910,11 @@ DWORD LIBNXCL_EXPORTABLE NXCCreateMPFile(NXC_SESSION hSession, TCHAR *pszDescr,
 DWORD LIBNXCL_EXPORTABLE NXCInstallMP(NXC_SESSION hSession, TCHAR *pszContent,
                                       DWORD dwFlags, TCHAR *pszErrorText, int nErrorLen);
 
+DWORD LIBNXCL_EXPORTABLE NXCGetGraphList(NXC_SESSION hSession, DWORD *pdwNumGraphs, NXC_GRAPH **ppGraphList);
+void LIBNXCL_EXPORTABLE NXCDestroyGraphList(DWORD dwNumGraphs, NXC_GRAPH *pList);
+DWORD LIBNXCL_EXPORTABLE NXCDefineGraph(NXC_SESSION hSession, NXC_GRAPH *pGraph);
+DWORD LIBNXCL_EXPORTABLE NXCDeleteGraph(NXC_SESSION hSession, DWORD dwGraphId);
+
 #ifdef __cplusplus
 }
 #endif
index 1935588..c7d09f1 100644 (file)
@@ -117,7 +117,6 @@ int CControlPanel::OnCreate(LPCREATESTRUCT lpCreateStruct)
    AddItem(_T("Object Tools"), 8, ID_CONTROLPANEL_OBJECTTOOLS);
    AddItem(_T("Script Library"), 9, ID_CONTROLPANEL_SCRIPTLIBRARY);
    AddItem(_T("Modules"), 10, ID_CONTROLPANEL_MODULES);
-   //AddItem(_T("View Builder"), 10, ID_CONTROLPANEL_VIEWBUILDER);
    AddItem(_T("Agent Configurations"), 11, ID_CONTROLPANEL_AGENTCONFIGS);
    AddItem(_T("Network Discovery"), 12, ID_CONTROLPANEL_NETWORKDISCOVERY);
 
index f9182e4..b7e42d0 100644 (file)
@@ -109,6 +109,7 @@ BEGIN_MESSAGE_MAP(CGraphFrame, CMDIChildWnd)
        ON_UPDATE_COMMAND_UI(ID_GRAPH_PRESETS_LASTMONTH, OnUpdateGraphPresetsLastmonth)
        ON_UPDATE_COMMAND_UI(ID_GRAPH_PRESETS_LASTWEEK, OnUpdateGraphPresetsLastweek)
        ON_UPDATE_COMMAND_UI(ID_GRAPH_PRESETS_LASTYEAR, OnUpdateGraphPresetsLastyear)
+       ON_COMMAND(ID_GRAPH_DEFINE, OnGraphDefine)
        //}}AFX_MSG_MAP
    ON_MESSAGE(NXCM_GET_SAVE_INFO, OnGetSaveInfo)
    ON_MESSAGE(NXCM_UPDATE_GRAPH_POINT, OnUpdateGraphPoint)
@@ -898,3 +899,15 @@ void CGraphFrame::OnUpdateGraphPresetsLastyear(CCmdUI* pCmdUI)
 {
    pCmdUI->SetCheck((m_iTimeFrameType == 1) && (m_dwTimeFrame == 31536000));
 }
+
+
+//
+// Save graph as predefined
+//
+
+void CGraphFrame::OnGraphDefine() 
+{
+       DWORD dwResult;
+
+//     SendMessage(NXCM_GET_SAVE_INFO
+}
index 9b90621..702b34b 100644 (file)
@@ -111,6 +111,7 @@ protected:
        afx_msg void OnUpdateGraphPresetsLastmonth(CCmdUI* pCmdUI);
        afx_msg void OnUpdateGraphPresetsLastweek(CCmdUI* pCmdUI);
        afx_msg void OnUpdateGraphPresetsLastyear(CCmdUI* pCmdUI);
+       afx_msg void OnGraphDefine();
        //}}AFX_MSG
    afx_msg LRESULT OnGetSaveInfo(WPARAM wParam, WINDOW_SAVE_INFO *pInfo);
    afx_msg void OnUpdateGraphPoint(DWORD dwTimeStamp, double *pdValue);
index d07bcee..e720ab4 100644 (file)
@@ -145,7 +145,6 @@ EXTRA_DIST = \
        UserPropDlg.cpp UserPropDlg.h \
        UserSelectDlg.cpp UserSelectDlg.h \
        ValueList.cpp ValueList.h \
-       ViewEditor.cpp ViewEditor.h \
        VPNCPropsGeneral.cpp VPNCPropsGeneral.h \
        WaitView.cpp WaitView.h \
        WebBrowser.cpp WebBrowser.h
diff --git a/src/console/win32/ViewEditor.cpp b/src/console/win32/ViewEditor.cpp
deleted file mode 100644 (file)
index 976c2f9..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-// ViewEditor.cpp : implementation file
-//
-
-#include "stdafx.h"
-#include "nxcon.h"
-#include "ViewEditor.h"
-
-#ifdef _DEBUG
-#define new DEBUG_NEW
-#undef THIS_FILE
-static char THIS_FILE[] = __FILE__;
-#endif
-
-/////////////////////////////////////////////////////////////////////////////
-// CViewEditor
-
-IMPLEMENT_DYNCREATE(CViewEditor, CMDIChildWnd)
-
-CViewEditor::CViewEditor()
-{
-}
-
-CViewEditor::~CViewEditor()
-{
-}
-
-
-BEGIN_MESSAGE_MAP(CViewEditor, CMDIChildWnd)
-       //{{AFX_MSG_MAP(CViewEditor)
-       ON_WM_CREATE()
-       ON_WM_DESTROY()
-       ON_WM_PAINT()
-       //}}AFX_MSG_MAP
-END_MESSAGE_MAP()
-
-/////////////////////////////////////////////////////////////////////////////
-// CViewEditor message handlers
-
-BOOL CViewEditor::PreCreateWindow(CREATESTRUCT& cs) 
-{
-   if (cs.lpszClass == NULL)
-      cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW, 
-                                         NULL, 
-                                         GetSysColorBrush(COLOR_WINDOW), 
-                                         AfxGetApp()->LoadIcon(IDI_ALARM));
-       return CMDIChildWnd::PreCreateWindow(cs);
-}
-
-
-//
-// WM_CREATE message handler
-//
-
-int CViewEditor::OnCreate(LPCREATESTRUCT lpCreateStruct) 
-{
-       if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1)
-               return -1;
-       
-   theApp.OnViewCreate(VIEW_BUILDER, this);
-       
-       return 0;
-}
-
-
-//
-// WM_DESTROY message handler
-//
-
-void CViewEditor::OnDestroy() 
-{
-   theApp.OnViewDestroy(VIEW_BUILDER, this);
-       CMDIChildWnd::OnDestroy();
-}
-
-
-//
-// WM_PAINT message handler
-//
-
-void CViewEditor::OnPaint() 
-{
-       CPaintDC dc(this); // device context for painting
-   RECT rect;
-
-   GetClientRect(&rect);
-
-ViewElement e;
-e.m_pos.x = 0;
-e.m_pos.y = 0;
-e.m_size.cx = 80;
-e.m_size.cy = 80;
-DrawElement(dc, rect, &e);
-}
-
-
-//
-// Draw single view element
-//
-
-void CViewEditor::DrawElement(CDC &dc, RECT &clRect, ViewElement *pElement)
-{
-   CBrush brush, *pBrush;
-   RECT rect;
-
-   rect.left = clRect.right * pElement->m_pos.x / 100;
-   rect.top = clRect.bottom * pElement->m_pos.y / 100;
-   rect.right = clRect.right * (pElement->m_pos.x + pElement->m_size.cx) / 100;
-   rect.bottom = clRect.bottom * (pElement->m_pos.y + pElement->m_size.cy) / 100;
-
-   brush.CreateSolidBrush(RGB(0, 0, 200));
-   pBrush = dc.SelectObject(&brush);
-   dc.Rectangle(&rect);
-   dc.SelectObject(pBrush);
-}
diff --git a/src/console/win32/ViewEditor.h b/src/console/win32/ViewEditor.h
deleted file mode 100644 (file)
index 86306cd..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-#if !defined(AFX_VIEWEDITOR_H__05F3512E_B415_46B9_A7ED_B1BD9684AD2F__INCLUDED_)
-#define AFX_VIEWEDITOR_H__05F3512E_B415_46B9_A7ED_B1BD9684AD2F__INCLUDED_
-
-#if _MSC_VER > 1000
-#pragma once
-#endif // _MSC_VER > 1000
-// ViewEditor.h : header file
-//
-
-
-//
-// View element
-//
-
-class ViewElement
-{
-public:
-   POINT m_pos;
-   SIZE m_size;
-
-   ViewElement() {};
-   ~ViewElement() {};
-};
-
-
-/////////////////////////////////////////////////////////////////////////////
-// CViewEditor frame
-
-class CViewEditor : public CMDIChildWnd
-{
-       DECLARE_DYNCREATE(CViewEditor)
-protected:
-       CViewEditor();           // protected constructor used by dynamic creation
-
-// Attributes
-public:
-
-// Operations
-public:
-
-// Overrides
-       // ClassWizard generated virtual function overrides
-       //{{AFX_VIRTUAL(CViewEditor)
-       protected:
-       virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
-       //}}AFX_VIRTUAL
-
-// Implementation
-protected:
-       void DrawElement(CDC &dc, RECT &clRect, ViewElement *pElement);
-       virtual ~CViewEditor();
-
-       // Generated message map functions
-       //{{AFX_MSG(CViewEditor)
-       afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
-       afx_msg void OnDestroy();
-       afx_msg void OnPaint();
-       //}}AFX_MSG
-       DECLARE_MESSAGE_MAP()
-};
-
-/////////////////////////////////////////////////////////////////////////////
-
-//{{AFX_INSERT_LOCATION}}
-// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
-
-#endif // !defined(AFX_VIEWEDITOR_H__05F3512E_B415_46B9_A7ED_B1BD9684AD2F__INCLUDED_)
index 98e523f..03c5138 100644 (file)
@@ -325,6 +325,14 @@ static DWORD WINAPI LoginThread(void *pArg)
       dwResult = LoadObjectTools();
    }
 
+   // Load predefined graphs
+   if (dwResult == RCC_SUCCESS)
+   {
+      SetInfoText(hWnd, _T("Loading predefined graphs..."));
+               NXCDestroyGraphList(g_dwNumGraphs, g_pGraphList);
+      dwResult = NXCGetGraphList(g_hSession, &g_dwNumGraphs, &g_pGraphList);
+   }
+
    // Synchronizing alarms
    if (dwResult == RCC_SUCCESS)
    {
@@ -343,6 +351,8 @@ static DWORD WINAPI LoginThread(void *pArg)
    }
 
    PostMessage(hWnd, NXCM_REQUEST_COMPLETED, 0, dwResult);
+       if (dwResult == RCC_SUCCESS)
+               theApp.PostThreadMessage(NXCM_GRAPH_LIST_UPDATED, 0, 0);
    return dwResult;
 }
 
index 71755db..9b19b2f 100644 (file)
@@ -41,6 +41,15 @@ NXC_SESSION g_hSession = NULL;
 SNMP_MIBObject *g_pMIBRoot = NULL;
 
 
+//
+// Graphs
+//
+
+DWORD g_dwNumGraphs = 0;
+NXC_GRAPH *g_pGraphList = NULL;
+HANDLE g_mutexGraphListAccess = INVALID_HANDLE_VALUE;
+
+
 //
 // Connection parameters
 //
index b686579..8689871 100644 (file)
@@ -49,6 +49,9 @@ extern CConsoleApp theApp;
 #define OBJTOOL_MENU_FIRST_ID 4000
 #define OBJTOOL_MENU_LAST_ID  4999
 
+#define GRAPH_MENU_FIRST_ID    5000
+#define GRAPH_MENU_LAST_ID             5999
+
 #define NXCON_ALARM_SOUND_KEY _T("Software\\NetXMS\\NetXMS Console\\AlarmSounds")
 
 #define NXCON_CONFIG_VERSION  1
@@ -126,6 +129,7 @@ extern CConsoleApp theApp;
 #define NXCM_GRAPH_ZOOM_CHANGED    (WM_USER + 124)
 #define NXCM_SET_OBJECT            (WM_USER + 125)
 #define NXCM_ACTIVATE_OBJECT_TREE  (WM_USER + 126)
+#define NXCM_GRAPH_LIST_UPDATED    (WM_USER + 127)
 
 
 //
@@ -337,6 +341,7 @@ HTREEITEM FindTreeCtrlItemEx(CTreeCtrl &ctrl, HTREEITEM hRoot, DWORD dwData);
 void SaveListCtrlColumns(CListCtrl &wndListCtrl, TCHAR *pszSection, TCHAR *pszPrefix);
 void LoadListCtrlColumns(CListCtrl &wndListCtrl, TCHAR *pszSection, TCHAR *pszPrefix);
 HGLOBAL CopyGlobalMem(HGLOBAL hSrc);
+void UpdateGraphList(void);
 
 
 //
@@ -408,6 +413,9 @@ extern SNMP_MIBObject *g_pMIBRoot;
 extern ALARM_SOUND_CFG g_soundCfg;
 extern char g_szConfigKeywords[];
 extern char g_szScriptKeywords[];
+extern DWORD g_dwNumGraphs;
+extern NXC_GRAPH *g_pGraphList;
+extern HANDLE g_mutexGraphListAccess;
 
 
 //
@@ -425,6 +433,21 @@ inline void UnlockActions(void)
 }
 
 
+//
+// Lock/unlock access to graph list
+//
+
+inline void LockGraphs(void)
+{
+   WaitForSingleObject(g_mutexGraphListAccess, INFINITE);
+}
+
+inline void UnlockGraphs(void)
+{
+   ReleaseMutex(g_mutexGraphListAccess);
+}
+
+
 //
 // Utility inline functions
 //
index 9fc0a85..9be6c9a 100644 (file)
@@ -17,20 +17,20 @@ Class9=CMapView
 
 ResourceCount=193
 Resource1=IDD_CP_GENERAL (English (U.S.))
-Resource2=IDD_OBJECT_RELATIONS
+Resource2=IDD_OBJECT_SECURITY
 Resource3=IDD_DCI_DATA_EXPORT (English (U.S.))
-Resource4=IDM_VIEW_SPECIFIC
-Resource5=IDD_SAVE_AGENT_CFG
+Resource4=IDD_CREATE_CONDITION
+Resource5=IDD_SELECT_OBJECT
 Class2=CChildView
 Class5=CAboutDlg
 Class6=CControlPanel
 Class8=CMapFrame
 Class10=CLoginDialog
-Resource6=IDD_LASTVAL_PROP
+Resource6=IDD_GROUP_PROPERTIES
 Class11=CProgressDialog
-Resource7=IDD_SELECT_EVENT
+Resource7=IDA_ALARM_BROWSER
 Class12=CAddrEntryDlg
-Resource8=IDD_OBJECT_NODE_POLL
+Resource8=IDD_OBJECT_GENERAL
 Class13=CObjectPropDlg
 Resource9=IDD_THRESHOLD (English (U.S.))
 Resource10=IDD_SELECT_OBJECT (English (U.S.))
@@ -46,45 +46,45 @@ Resource17=IDD_NEW_USER (English (U.S.))
 Class16=CDebugFrame
 Resource18=IDD_NEW_ACTION (English (U.S.))
 Resource19=IDD_OBJECT_PROPERTIES (English (U.S.))
-Resource20=IDD_CREATE_CONTAINER
+Resource20=IDA_SERVER_CFG_EDITOR
 Class17=CObjectPreview
 Resource21=IDA_OBJECT_BROWSER (English (U.S.))
 Class18=CToolBox
 Class19=CObjectInfoBox
 Class20=CObjectSearchBox
-Resource22=IDD_ADDR_ENTRY
+Resource22=IDD_OBJECT_NODE_POLL
 Class21=CEditBox
 Class22=COPGeneral
 Class23=CNodePropsGeneral
 Resource23=IDD_GRAPH_PROPERTIES (English (U.S.))
 Class24=CObjectPropCaps
 Class25=CObjectPropSheet
-Resource24=IDM_CONTEXT
+Resource24=IDD_CREATE_VPNC
 Class26=CRequestProcessingDlg
 Resource25=IDD_SELECT_USER (English (U.S.))
 Resource26=IDD_PROGRESS (English (U.S.))
-Resource27=IDD_DISCOVERY_RANGES
+Resource27=IDD_OBJECT_NETSRV_GENERAL
 Resource28=IDD_DCI_COLLECTION (English (U.S.))
 Class27=CObjectPropsGeneral
 Resource29=IDR_MAINFRAME (English (U.S.))
 Class28=CObjectPropsSecurity
 Resource30=IDD_SAVE_AGENT_CFG (English (U.S.))
-Resource31=IDA_LAST_VALUES
-Resource32=IDD_DCI_THRESHOLDS
+Resource31=IDD_OBJTOOL_COLUMNS
+Resource32=IDD_OBJECT_CLUSTER_RESOURCES
 Class29=CUserSelectDlg
-Resource33=IDD_REQUEST_PROCESSING
+Resource33=IDD_DISCOVERY_TARGETS
 Class30=CUserEditor
 Resource34=IDD_DCI_PROPERTIES
 Class31=CNewUserDlg
-Resource35=IDD_EDIT_VARIABLE
-Resource36=IDD_DISCOVERY_GENERAL
+Resource35=IDD_DCI_COLLECTION
+Resource36=IDD_INPUT_BOX
 Class32=CUserPropDlg
 Resource37=IDD_EDIT_VARIABLE (English (U.S.))
-Resource38=IDD_GRAPH_PROP_DATA
+Resource38=IDD_USER_PROPERTIES
 Class33=CGroupPropDlg
-Resource39=IDR_MAINFRAME
-Resource40=IDD_OBJECT_NODE_GENERAL
-Resource41=IDD_ABOUTBOX
+Resource39=IDD_EDIT_IP_SUBNET
+Resource40=IDD_EDIT_RULE_SCRIPT
+Resource41=IDD_COND_DCI_PROP
 Resource42=IDA_ACTION_EDITOR (English (U.S.))
 Class34=CPasswordChangeDlg
 Class35=CNodeSummary
@@ -100,55 +100,55 @@ Class41=CGraphFrame
 Class42=CDCIThresholdsPage
 Resource46=IDA_OBJECT_TOOLS_EDITOR (English (U.S.))
 Resource47=IDM_CONTEXT (English (U.S.))
-Resource48=IDD_OBJTOOL_OPTIONS
+Resource48=IDD_EDIT_RULE_ALARM
 Class43=CThresholdDlg
 Resource49=IDD_DESKTOP_SAVE_AS (English (U.S.))
-Resource50=IDD_THRESHOLD
+Resource50=IDR_MAINFRAME
 Class44=CMIBBrowserDlg
 Class45=CEventPolicyEditor
 Class46=CRuleList
 Class47=CRuleHeader
 Resource51=IDD_SELECT_AGENT_PARAM (English (U.S.))
-Resource52=IDD_CREATE_VPNC
+Resource52=IDD_DCI_THRESHOLDS
 Class48=CObjectSelDlg
-Resource53=IDD_CHANGE_IP
-Resource54=IDD_CREATE_NODE
+Resource53=IDD_CP_GENERAL
+Resource54=IDA_AGENT_CFG_EDITOR
 Class49=CRuleCommentDlg
-Resource55=IDA_TRAP_EDITOR
+Resource55=IDD_OBJTOOL_OPTIONS
 Class50=CEventSelDlg
-Resource56=IDD_DATA_QUERY
+Resource56=IDA_DATA_VIEW
 Resource57=IDA_EPP (English (U.S.))
-Resource58=IDA_NETMAP
+Resource58=IDD_OBJECT_STATUS
 Resource59=IDA_PACKAGE_MGR (English (U.S.))
 Resource60=IDD_OBJTOOL_GENERAL (English (U.S.))
 Class51=CObjectPropsPresentation
 Resource61=IDD_CREATE_TEMPLATE (English (U.S.))
-Resource62=IDA_AGENT_CONFIG_MANAGER
+Resource62=IDD_OBJECT_COND_DATA
 Class52=CRuleSeverityDlg
-Resource63=IDD_OBJECT_CLUSTER_RESOURCES
+Resource63=IDD_EDIT_VARIABLE
 Class53=CRuleAlarmDlg
 Class54=CAlarmBrowser
 Resource64=IDA_MDI_DEFAULT (English (U.S.))
-Resource65=IDD_OBJECT_SECURITY
+Resource65=IDD_ADDR_ENTRY
 Resource66=IDD_EDIT_IP_SUBNET (English (U.S.))
 Resource67=IDD_EDIT_RULE_SEVERITY (English (U.S.))
 Resource68=IDD_ACTION_PROPERTIES (English (U.S.))
 Class55=CConsolePropsGeneral
 Class56=CActionEditor
-Resource69=IDD_OBJECT_CAPS
-Resource70=IDD_CREATE_NETSRV
+Resource69=IDD_DISCOVERY_GENERAL
+Resource70=IDD_OBJECT_CAPS
 Class57=CNewActionDlg
-Resource71=IDD_COND_DCI_PROP
+Resource71=IDD_EDIT_TRAP_ARG
 Class58=CEditActionDlg
-Resource72=IDD_CREATE_TEMPLATE
+Resource72=IDA_SCRIPT_MANAGER
 Class59=CActionSelDlg
-Resource73=IDD_DISCOVERY_TARGETS
+Resource73=IDD_CREATE_NETSRV
 Resource74=IDD_EDIT_TRAP (English (U.S.))
 Resource75=IDD_USER_PROPERTIES (English (U.S.))
-Resource76=IDD_SELECT_USER
+Resource76=IDD_CREATE_MP
 Class60=CCreateObjectDlg
 Class61=CCreateContainerDlg
-Resource77=IDD_SNMP_WALK
+Resource77=IDD_SELECT_ACTION
 Class62=CCreateNodeDlg
 Resource78=IDD_OBJECT_NODE_GENERAL (English (U.S.))
 Resource79=IDT_MAP (English (U.S.))
@@ -158,31 +158,31 @@ Resource81=IDD_LASTVAL_PROP (English (U.S.))
 Class64=CPollNodeDlg
 Resource82=IDD_POLL_NODE (English (U.S.))
 Class65=CNodePoller
-Resource83=IDD_OBJECT_CLUSTER_GENERAL
-Resource84=IDD_GRAPH_PROP_SETTINGS
+Resource83=IDD_DCI_DATA_EXPORT
+Resource84=IDD_NEW_USER
 Class66=CCreateTemplateDlg
 Class67=CCreateTGDlg
-Resource85=IDD_EDIT_RULE_COMMENT
-Resource86=IDA_ACTION_EDITOR
+Resource85=IDA_EPP
+Resource86=IDD_NEW_OBJECT_TOOL
 Class68=CTrapEditor
-Resource87=IDD_USER_PROPERTIES
-Resource88=IDD_SELECT_AGENT_PARAM
-Resource89=IDD_DCI_TRANSFORM
+Resource87=IDD_SELECT_TRAP
+Resource88=IDD_EDIT_EVENT
+Resource89=IDA_DC_EDITOR
 Class69=CDataQueryDlg
-Resource90=IDD_CREATE_TG
+Resource90=IDA_OBJECT_TOOLS_EDITOR
 Class70=CTrapEditDlg
 Resource91=IDM_VIEW_SPECIFIC (English (U.S.))
 Class71=CTrapParamDlg
-Resource92=IDD_SET_PASSWORD
-Resource93=IDD_EDIT_RULE_SEVERITY
+Resource92=IDD_CREATE_CLUSTER
+Resource93=IDA_EVENT_EDITOR
 Class72=CGraphPropDlg
 Class73=CColorSelector
 Class74=CPackageMgr
-Resource94=IDD_CLUSTER_RESOURCE
+Resource94=IDD_CHANGE_PASSWORD
 Resource95=IDA_SCRIPT_MANAGER (English (U.S.))
 Resource96=IDD_SET_PASSWORD (English (U.S.))
 Resource97=IDD_DCI_TRANSFORM (English (U.S.))
-Resource98=IDD_DCI_DATA_EXPORT
+Resource98=IDD_SET_PASSWORD
 Resource99=IDD_OBJECT_NETSRV_GENERAL (English (U.S.))
 Resource100=IDD_OBJTOOL_OPTIONS (English (U.S.))
 Resource101=IDA_LAST_VALUES (English (U.S.))
@@ -244,7 +244,7 @@ Class102=CWaitView
 Class103=CWebBrowser
 Class104=CSyslogBrowser
 Class105=CLPPList
-Resource129=IDD_GROUP_PROPERTIES
+Resource129=IDD_UPGRADE
 Class106=CDCISchedulePage
 Resource130=IDD_OBJECT_CAPS (English (U.S.))
 Class107=CObjectPropsStatus
@@ -270,91 +270,91 @@ Class119=CMapControlBox
 Resource138=IDD_OBJECT_GENERAL (English (U.S.))
 Class120=CSubmapBkgndDlg
 Resource139=IDD_SUBMAP_BKGND (English (U.S.))
-Resource140=IDD_SELECT_TRAP
-Resource141=IDA_GRAPH
-Resource142=IDD_OBJTOOL_GENERAL
-Resource143=IDD_NEW_USER
-Resource144=IDD_DCI_COLLECTION
-Resource145=IDD_AGENT_CONFIG
-Resource146=IDD_NEW_ACTION
-Resource147=IDD_EDIT_RULE_SCRIPT
-Resource148=IDD_OBJECT_PRESENTATION
-Resource149=IDA_EPP
-Resource150=IDA_OBJECT_TOOLS_EDITOR
-Resource151=IDD_UPGRADE
-Resource152=IDD_DESKTOP_SAVE_AS
-Resource153=IDD_REMOVE_TEMPLATE
-Resource154=IDD_ACTION_PROPERTIES
-Resource155=IDD_MIB_BROWSER
-Resource156=IDD_OBJECT_COND_DATA
-Resource157=IDD_EDIT_EVENT
-Resource158=IDA_AGENT_CFG_EDITOR
-Resource159=IDD_OBJTOOL_COLUMNS
-Resource160=IDD_OBJECT_STATUS
-Resource161=IDA_ALARM_BROWSER
-Resource162=IDA_SCRIPT_MANAGER
-Resource163=IDD_EDIT_TRAP
-Resource164=IDD_CREATE_CLUSTER
-Resource165=IDA_DATA_VIEW
-Resource166=IDD_INPUT_BOX
-Resource167=IDD_EDIT_TRAP_ARG
-Resource168=IDA_PACKAGE_MGR
-Resource169=IDD_OBJECT_COND_GENERAL
-Resource170=IDD_SELECT_OBJECT
-Resource171=IDD_NEW_OBJECT_TOOL
+Resource140=IDD_GRAPH_PROP_SETTINGS
+Resource141=IDD_CHANGE_IP
+Resource142=IDD_OBJECT_PRESENTATION
+Resource143=IDD_SELECT_MP
+Resource144=IDD_OBJECT_CLUSTER_GENERAL
+Resource145=IDD_SELECT_INTERNAL_ITEM
+Resource146=IDA_GRAPH
+Resource147=IDD_SELECT_AGENT_PARAM
+Resource148=IDA_NETMAP
+Resource149=IDD_SAVE_AGENT_CFG
+Resource150=IDM_CONTEXT
+Resource151=IDD_GRAPH_PROP_DATA
+Resource152=IDD_SELECT_USER
+Resource153=IDD_NEW_ACTION
+Resource154=IDA_PACKAGE_MGR
+Resource155=IDA_MDI_DEFAULT
+Resource156=IDD_DATA_QUERY
+Resource157=IDD_AGENT_CONFIG
+Resource158=IDD_SUBMAP_BKGND
+Resource159=IDD_ACTION_PROPERTIES
+Resource160=IDD_SELECT_EVENT
+Resource161=IDD_DCI_SCHEDULE
+Resource162=IDD_DISCOVERY_RANGES
+Resource163=IDA_AGENT_CONFIG_MANAGER
+Resource164=IDD_LASTVAL_PROP
+Resource165=IDD_OBJECT_COND_SCRIPT
+Resource166=IDD_OBJECT_NODE_GENERAL
+Resource167=IDA_OBJECT_COMMENTS
+Resource168=IDD_REMOVE_TEMPLATE
+Resource169=IDD_CREATE_TG
+Resource170=IDA_OBJECT_BROWSER
+Resource171=IDD_EDIT_RULE_SEVERITY
 Class121=CModuleManager
 Class122=CDesktopManager
-Resource172=IDD_OBJECT_GENERAL
-Resource173=IDA_EVENT_EDITOR
+Resource172=IDD_OBJECT_COND_GENERAL
+Resource173=IDD_OBJTOOL_GENERAL
 Class123=CCreateCondDlg
 Class124=CCondPropsGeneral
 Class125=CCondPropsScript
 Class126=CCondPropsData
-Resource174=IDD_CREATE_CONDITION
+Resource174=IDD_DCI_TRANSFORM
 Class127=CAddDCIDlg
-Resource175=IDD_CHANGE_PASSWORD
+Resource175=IDD_CREATE_NODE
 Class128=CCondDCIPropDlg
-Resource176=IDD_CREATE_MP
+Resource176=IDD_OBJECT_RELATIONS
 Class129=CAgentConfigMgr
-Resource177=IDD_SELECT_MP
-Resource178=IDD_CP_GENERAL
+Resource177=IDD_DESKTOP_SAVE_AS
+Resource178=IDA_TRAP_EDITOR
 Class130=CAgentCfgDlg
 Class131=CObjectCommentsEditor
-Resource179=IDD_OBJECT_VPNC_GENERAL
+Resource179=IDD_THRESHOLD
 Class132=CRuleScriptDlg
 Class133=CDetailsView
-Resource180=IDD_OBJECT_NETSRV_GENERAL
+Resource180=IDD_REQUEST_PROCESSING
 Class134=CDiscoveryPropGeneral
-Resource181=IDD_DCI_SCHEDULE
+Resource181=IDD_EDIT_RULE_COMMENT
 Class135=CDiscoveryPropTargets
-Resource182=IDA_MDI_DEFAULT
+Resource182=IDD_OBJECT_VPNC_GENERAL
 Class136=CDiscoveryPropAddrList
-Resource183=IDD_SELECT_ACTION
+Resource183=IDA_LAST_VALUES
 Class138=CObjectView
 Class139=CObjectOverview
 Class140=CAlarmView
 Class141=CObjectDepView
-Resource184=IDD_SELECT_INTERNAL_ITEM
+Resource184=IDD_ABOUTBOX
 Class137=CObjectBrowser
 Class142=CCreateMPDlg
-Resource185=IDD_ADD_DCI
+Resource185=IDD_EDIT_TRAP
 Class143=CSelectMPDlg
-Resource186=IDA_DC_EDITOR
+Resource186=IDM_VIEW_SPECIFIC
 Class144=CTrapSelDlg
-Resource187=IDA_SERVER_CFG_EDITOR
+Resource187=IDD_SNMP_WALK
 Class145=CConsoleUpgradeDlg
-Resource188=IDD_EDIT_IP_SUBNET
+Resource188=IDD_MIB_BROWSER
 Class146=CCreateClusterDlg
-Resource189=IDD_OBJECT_COND_SCRIPT
+Resource189=IDD_CREATE_TEMPLATE
 Class147=CClusterPropsGeneral
-Resource190=IDD_SUBMAP_BKGND
+Resource190=IDD_CREATE_CONTAINER
 Class148=CClusterPropsResources
-Resource191=IDD_EDIT_RULE_ALARM
+Resource191=IDA_ACTION_EDITOR
 Class149=CClusterResDlg
-Resource192=IDA_OBJECT_COMMENTS
+Resource192=IDD_ADD_DCI
 Class150=CClusterView
 Class151=CExtEditCtrl
-Resource193=IDA_OBJECT_BROWSER
+Resource193=IDD_CLUSTER_RESOURCE
 
 [CLS:CConsoleApp]
 Type=0
@@ -432,11 +432,12 @@ Command22=ID_VIEW_REFRESH
 Command23=ID_TOOLS_ADDNODE
 Command24=ID_TOOLS_MIBBROWSER
 Command25=ID_TOOLS_SNMPWALK
-Command26=ID_TOOLS_CHANGEPASSWORD
-Command27=ID_TOOLS_CREATEMP
-Command28=ID_TOOLS_IMPORTMP
-Command29=ID_APP_ABOUT
-CommandCount=29
+Command26=ID_TOOLS_GRAPHS_MANAGE
+Command27=ID_TOOLS_CHANGEPASSWORD
+Command28=ID_TOOLS_CREATEMP
+Command29=ID_TOOLS_IMPORTMP
+Command30=ID_APP_ABOUT
+CommandCount=30
 
 [ACL:IDR_MAINFRAME]
 Type=1
@@ -825,56 +826,56 @@ Command78=ID_CONTROLPANEL_SCRIPTLIBRARY
 Command79=ID_CONTROLPANEL_SERVERCFG
 Command80=ID_CONTROLPANEL_SNMPTRAPS
 Command81=ID_CONTROLPANEL_USERS
-Command82=ID_CONTROLPANEL_VIEWBUILDER
-Command83=ID_OBJECT_OPEN
-Command84=ID_OBJECT_OPENPARENT
-Command85=ID_OBJECT_FIND
-Command86=ID_OBJECT_CREATE_CLUSTER
-Command87=ID_OBJECT_CREATE_CONDITION
-Command88=ID_OBJECT_CREATE_CONTAINER
-Command89=ID_OBJECT_CREATE_NODE
-Command90=ID_OBJECT_CREATE_SERVICE
-Command91=ID_OBJECT_CREATE_TEMPLATE
-Command92=ID_OBJECT_CREATE_TEMPLATEGROUP
-Command93=ID_OBJECT_CREATE_VPNCONNECTOR
-Command94=ID_OBJECT_BIND
-Command95=ID_OBJECT_UNBIND
-Command96=ID_OBJECT_RENAME
-Command97=ID_OBJECT_DELETE
-Command98=ID_OBJECT_MOVE
-Command99=ID_OBJECT_CHANGEIPADDRESS
-Command100=ID_OBJECT_AGENTCFG
-Command101=ID_OBJECT_APPLY
-Command102=ID_OBJECT_MANAGE
-Command103=ID_OBJECT_UNMANAGE
-Command104=ID_OBJECT_POLL_STATUS
-Command105=ID_OBJECT_POLL_CONFIGURATION
-Command106=ID_OBJECT_DATACOLLECTION
-Command107=ID_OBJECT_LASTDCIVALUES
-Command108=ID_OBJECT_COMMENTS
-Command109=ID_OBJECT_PROPERTIES
-Command110=ID_EVENT_NEW
-Command111=ID_EVENT_EDIT
-Command112=ID_EVENT_DELETE
-Command113=ID_ACTION_NEW
-Command114=ID_ACTION_RENAME
-Command115=ID_ACTION_DELETE
-Command116=ID_ACTION_PROPERTIES
-Command117=ID_TRAP_NEW
-Command118=ID_TRAP_EDIT
-Command119=ID_TRAP_DELETE
-Command120=ID_GRAPH_PRESETS_LAST10MINUTES
-Command121=ID_GRAPH_PRESETS_LAST30MINUTES
-Command122=ID_GRAPH_PRESETS_LASTHOUR
-Command123=ID_GRAPH_PRESETS_LAST2HOURS
-Command124=ID_GRAPH_PRESETS_LAST4HOURS
-Command125=ID_GRAPH_PRESETS_LASTDAY
-Command126=ID_GRAPH_PRESETS_LASTWEEK
-Command127=ID_GRAPH_PRESETS_LASTMONTH
-Command128=ID_GRAPH_PRESETS_LASTYEAR
-Command129=ID_GRAPH_AUTOSCALE
-Command130=ID_GRAPH_LEGEND
-Command131=ID_GRAPH_RULER
+Command82=ID_OBJECT_OPEN
+Command83=ID_OBJECT_OPENPARENT
+Command84=ID_OBJECT_FIND
+Command85=ID_OBJECT_CREATE_CLUSTER
+Command86=ID_OBJECT_CREATE_CONDITION
+Command87=ID_OBJECT_CREATE_CONTAINER
+Command88=ID_OBJECT_CREATE_NODE
+Command89=ID_OBJECT_CREATE_SERVICE
+Command90=ID_OBJECT_CREATE_TEMPLATE
+Command91=ID_OBJECT_CREATE_TEMPLATEGROUP
+Command92=ID_OBJECT_CREATE_VPNCONNECTOR
+Command93=ID_OBJECT_BIND
+Command94=ID_OBJECT_UNBIND
+Command95=ID_OBJECT_RENAME
+Command96=ID_OBJECT_DELETE
+Command97=ID_OBJECT_MOVE
+Command98=ID_OBJECT_CHANGEIPADDRESS
+Command99=ID_OBJECT_AGENTCFG
+Command100=ID_OBJECT_APPLY
+Command101=ID_OBJECT_MANAGE
+Command102=ID_OBJECT_UNMANAGE
+Command103=ID_OBJECT_POLL_STATUS
+Command104=ID_OBJECT_POLL_CONFIGURATION
+Command105=ID_OBJECT_DATACOLLECTION
+Command106=ID_OBJECT_LASTDCIVALUES
+Command107=ID_OBJECT_COMMENTS
+Command108=ID_OBJECT_PROPERTIES
+Command109=ID_EVENT_NEW
+Command110=ID_EVENT_EDIT
+Command111=ID_EVENT_DELETE
+Command112=ID_ACTION_NEW
+Command113=ID_ACTION_RENAME
+Command114=ID_ACTION_DELETE
+Command115=ID_ACTION_PROPERTIES
+Command116=ID_TRAP_NEW
+Command117=ID_TRAP_EDIT
+Command118=ID_TRAP_DELETE
+Command119=ID_GRAPH_PRESETS_LAST10MINUTES
+Command120=ID_GRAPH_PRESETS_LAST30MINUTES
+Command121=ID_GRAPH_PRESETS_LASTHOUR
+Command122=ID_GRAPH_PRESETS_LAST2HOURS
+Command123=ID_GRAPH_PRESETS_LAST4HOURS
+Command124=ID_GRAPH_PRESETS_LASTDAY
+Command125=ID_GRAPH_PRESETS_LASTWEEK
+Command126=ID_GRAPH_PRESETS_LASTMONTH
+Command127=ID_GRAPH_PRESETS_LASTYEAR
+Command128=ID_GRAPH_AUTOSCALE
+Command129=ID_GRAPH_LEGEND
+Command130=ID_GRAPH_RULER
+Command131=ID_GRAPH_DEFINE
 Command132=ID_FILE_PRINT
 Command133=ID_GRAPH_COPYTOCLIPBOARD
 Command134=ID_GRAPH_ZOOMOUT
@@ -3024,10 +3025,12 @@ Type=1
 Class=?
 Command1=ID_GRAPH_AUTOSCALE
 Command2=ID_GRAPH_COPYTOCLIPBOARD
-Command3=ID_GRAPH_PROPERTIES
-Command4=ID_GRAPH_RULER
-Command5=ID_GRAPH_ZOOMOUT
-CommandCount=5
+Command3=ID_GRAPH_LEGEND
+Command4=ID_GRAPH_PROPERTIES
+Command5=ID_GRAPH_RULER
+Command6=ID_GRAPH_DEFINE
+Command7=ID_GRAPH_ZOOMOUT
+CommandCount=7
 
 [CLS:CGraphPropDlg]
 Type=0
index f296194..67b0893 100644 (file)
@@ -53,7 +53,6 @@
 #include "DCIDataView.h"
 #include "LPPList.h"
 #include "ObjectBrowser.h"
-#include "ViewEditor.h"
 #include "PackageMgr.h"
 #include "ModuleManager.h"
 #include "DesktopManager.h"
@@ -120,7 +119,6 @@ BEGIN_MESSAGE_MAP(CConsoleApp, CWinApp)
        ON_COMMAND(ID_CONTROLPANEL_OBJECTTOOLS, OnControlpanelObjecttools)
        ON_COMMAND(ID_CONTROLPANEL_SCRIPTLIBRARY, OnControlpanelScriptlibrary)
        ON_COMMAND(ID_VIEW_SNMPTRAPLOG, OnViewSnmptraplog)
-       ON_COMMAND(ID_CONTROLPANEL_VIEWBUILDER, OnControlpanelViewbuilder)
        ON_COMMAND(ID_CONTROLPANEL_MODULES, OnControlpanelModules)
        ON_COMMAND(ID_DESKTOP_MANAGE, OnDesktopManage)
        ON_COMMAND(ID_TOOLS_CHANGEPASSWORD, OnToolsChangepassword)
@@ -130,6 +128,7 @@ BEGIN_MESSAGE_MAP(CConsoleApp, CWinApp)
        ON_COMMAND(ID_FILE_PAGESETUP, OnFilePagesetup)
        ON_COMMAND(ID_TOOLS_IMPORTMP, OnToolsImportmp)
        //}}AFX_MSG_MAP
+       ON_THREAD_MESSAGE(NXCM_GRAPH_LIST_UPDATED, OnGraphListUpdate)
 END_MESSAGE_MAP()
 
 
@@ -310,8 +309,9 @@ BOOL CConsoleApp::InitInstance()
       WriteProfileInt(_T("General"), _T("CfgVersion"), NXCON_CONFIG_VERSION);
    }
 
-   // Create mutex for action list access
+   // Create mutexes for action and graph lists access
    g_mutexActionListAccess = CreateMutex(NULL, FALSE, NULL);
+   g_mutexGraphListAccess = CreateMutex(NULL, FALSE, NULL);
 
        // To create the main window, this code creates a new frame window
        // object and then sets it as the application's main window object.
@@ -329,7 +329,7 @@ BOOL CConsoleApp::InitInstance()
        // Load shared MDI menus and accelerator table
        HINSTANCE hInstance = AfxGetResourceHandle();
 
-       hMenu  = ::LoadMenu(hInstance, MAKEINTRESOURCE(IDM_VIEW_SPECIFIC));
+       hMenu = ::LoadMenu(hInstance, MAKEINTRESOURCE(IDM_VIEW_SPECIFIC));
 
    // Modify application menu as needed
    if (g_dwOptions & UI_OPT_EXPAND_CTRLPANEL)
@@ -539,6 +539,7 @@ int CConsoleApp::ExitInstance()
    SafeFreeResource(m_hObjectCommentsAccel);
 
    CloseHandle(g_mutexActionListAccess);
+   CloseHandle(g_mutexGraphListAccess);
 
    SpeakerShutdown();
 
@@ -1049,6 +1050,9 @@ void CConsoleApp::EventHandler(DWORD dwEvent, DWORD dwCode, void *pArg)
             case NX_NOTIFY_ACTION_DELETED:
                UpdateActions(dwCode, (NXC_ACTION *)pArg);
                break;
+                               case NX_NOTIFY_GRAPHS_CHANGED:
+                                       UpdateGraphList();
+                                       break;
             default:
                break;
          }
@@ -1624,27 +1628,6 @@ void CConsoleApp::OnControlpanelLogprocessing()
 }
 
 
-//
-// Open view builder
-//
-
-void CConsoleApp::OnControlpanelViewbuilder() 
-{
-       // create a new MDI child window or open existing
-   if (m_viewState[VIEW_BUILDER].bActive)
-   {
-      m_viewState[VIEW_BUILDER].pWnd->BringWindowToTop();
-   }
-   else
-   {
-       CMainFrame *pFrame = STATIC_DOWNCAST(CMainFrame, m_pMainWnd);
-
-          pFrame->CreateNewChild(RUNTIME_CLASS(CViewEditor), IDR_VIEW_BUILDER,
-                             m_hViewBuilderMenu, m_hViewBuilderAccel);
-   }
-}
-
-
 //
 // Show alarm browser window
 //
@@ -3574,3 +3557,82 @@ BOOL CConsoleApp::StartConsoleUpgrade()
        }
        return bRet;
 }
+
+
+//
+// Update Tools->Graph submenu
+//
+
+static void UpdateGraphSubmenu(CMenu *pToolsMenu)
+{
+       CMenu *pMenu;
+       DWORD i;
+
+       if (pToolsMenu == NULL)
+               return;
+
+       pMenu = pToolsMenu->GetSubMenu(3);
+       if (pMenu != NULL)
+       {
+               // Clear menu
+               while(pMenu->GetMenuItemCount() > 2)
+                       pMenu->DeleteMenu(0, MF_BYPOSITION);
+
+               // Add new items
+               if (g_dwNumGraphs > 0)
+               {
+                       for(i = 0; i < g_dwNumGraphs; i++)
+                               pMenu->InsertMenu(i, MF_BYPOSITION, GRAPH_MENU_FIRST_ID + i, g_pGraphList[i].pszName);
+               }
+               else
+               {
+                       pMenu->InsertMenu(0, MF_BYPOSITION, ID_ALWAYS_DISABLED, _T("<no graphs defined>"));
+               }
+       }
+}
+
+
+//
+// Update UI after graph list update
+//
+
+#define UPDATE_MENU(handle, pos) \
+{ \
+       menu.Attach(handle); \
+       UpdateGraphSubmenu(menu.GetSubMenu(pos)); \
+       menu.Detach(); \
+}
+
+void CConsoleApp::OnGraphListUpdate(WPARAM wParam, LPARAM lParam)
+{
+       CMenu menu;
+
+       LockGraphs();
+
+       UpdateGraphSubmenu(m_pMainWnd->GetMenu()->GetSubMenu(3));
+
+       UPDATE_MENU(m_hMDIMenu, 3);
+       UPDATE_MENU(m_hAlarmBrowserMenu, 4);
+       UPDATE_MENU(m_hEventBrowserMenu, 4);
+       UPDATE_MENU(m_hEventEditorMenu, 4);
+       UPDATE_MENU(m_hUserEditorMenu, 4);
+       UPDATE_MENU(m_hDCEditorMenu, 4);
+       UPDATE_MENU(m_hLPPEditorMenu, 4);
+       UPDATE_MENU(m_hPolicyEditorMenu, 4);
+       UPDATE_MENU(m_hMapMenu, 5);
+       UPDATE_MENU(m_hTrapEditorMenu, 4);
+       UPDATE_MENU(m_hActionEditorMenu, 4);
+       UPDATE_MENU(m_hGraphMenu, 4);
+       UPDATE_MENU(m_hPackageMgrMenu, 4);
+       UPDATE_MENU(m_hLastValuesMenu, 4);
+       UPDATE_MENU(m_hServerCfgEditorMenu, 4);
+       UPDATE_MENU(m_hAgentCfgEditorMenu, 5);
+       UPDATE_MENU(m_hObjToolsEditorMenu, 4);
+       UPDATE_MENU(m_hScriptManagerMenu, 5);
+       UPDATE_MENU(m_hDataViewMenu, 4);
+       UPDATE_MENU(m_hAgentCfgMgrMenu, 4);
+       UPDATE_MENU(m_hObjectCommentsMenu, 5);
+       UPDATE_MENU(m_hObjectBrowserMenu, 4);
+
+       UnlockGraphs();
+}
index 317ace4..3a733b2 100644 (file)
@@ -729,10 +729,6 @@ SOURCE=.\ValueList.cpp
 # End Source File
 # Begin Source File
 
-SOURCE=.\ViewEditor.cpp
-# End Source File
-# Begin Source File
-
 SOURCE=.\VPNCPropsGeneral.cpp
 # End Source File
 # Begin Source File
@@ -1341,10 +1337,6 @@ SOURCE=.\ValueList.h
 # End Source File
 # Begin Source File
 
-SOURCE=.\ViewEditor.h
-# End Source File
-# Begin Source File
-
 SOURCE=.\VPNCPropsGeneral.h
 # End Source File
 # Begin Source File
index f71817c..cee6201 100644 (file)
@@ -217,8 +217,6 @@ protected:
        HACCEL m_hObjToolsEditorAccel;// Accelerator for object tools editor
        HMENU m_hScriptManagerMenu;   // Menu for script manager
        HACCEL m_hScriptManagerAccel; // Accelerator for script manager
-       HMENU m_hViewBuilderMenu;     // Menu for view builder
-       HACCEL m_hViewBuilderAccel;   // Accelerator for view builder
        HMENU m_hDataViewMenu;        // Menu for DCI data viewer
        HACCEL m_hDataViewAccel;      // Accelerator for DCI data viewer
        HMENU m_hAgentCfgMgrMenu;     // Menu for agent configuration manager
@@ -256,7 +254,6 @@ public:
        afx_msg void OnControlpanelObjecttools();
        afx_msg void OnControlpanelScriptlibrary();
        afx_msg void OnViewSnmptraplog();
-       afx_msg void OnControlpanelViewbuilder();
        afx_msg void OnControlpanelModules();
        afx_msg void OnDesktopManage();
        afx_msg void OnToolsChangepassword();
@@ -266,6 +263,7 @@ public:
        afx_msg void OnFilePagesetup();
        afx_msg void OnToolsImportmp();
        //}}AFX_MSG
+       afx_msg void OnGraphListUpdate(WPARAM wParam, LPARAM lParam);
        DECLARE_MESSAGE_MAP()
 private:
    CONSOLE_VIEW m_viewState[MAX_VIEW_ID];
index 8c19d64..9fd2ae4 100644 (file)
@@ -204,6 +204,11 @@ BEGIN
         MENUITEM "&Add node...\tF11",           ID_TOOLS_ADDNODE
         MENUITEM "&MIB Browser\tCtrl+Alt+M",    ID_TOOLS_MIBBROWSER
         MENUITEM "SNMP &walk...\tCtrl+Shift+F11", ID_TOOLS_SNMPWALK
+        POPUP "&Graphs"
+        BEGIN
+            MENUITEM SEPARATOR
+            MENUITEM "&Manage...",                  ID_TOOLS_GRAPHS_MANAGE
+        END
         MENUITEM SEPARATOR
         MENUITEM "&Change password...",         ID_TOOLS_CHANGEPASSWORD
         MENUITEM SEPARATOR
@@ -367,7 +372,6 @@ BEGIN
         MENUITEM "Server &configuration",       ID_CONTROLPANEL_SERVERCFG
         MENUITEM "&SNMP Traps",                 ID_CONTROLPANEL_SNMPTRAPS
         MENUITEM "&Users",                      ID_CONTROLPANEL_USERS
-        MENUITEM "&View Builder",               ID_CONTROLPANEL_VIEWBUILDER
     END
     POPUP "&Object (map)"
     BEGIN
@@ -461,16 +465,17 @@ BEGIN
 
         END
         MENUITEM SEPARATOR
-        MENUITEM "&Autoscale\tAlt+A",           ID_GRAPH_AUTOSCALE
-        MENUITEM "&Legend\tAlt+L",              ID_GRAPH_LEGEND
-        MENUITEM "R&uler\tAlt+R",               ID_GRAPH_RULER
+        MENUITEM "&Autoscale\tCtrl+Alt+A",      ID_GRAPH_AUTOSCALE
+        MENUITEM "&Legend\tCtrl+Alt+L",         ID_GRAPH_LEGEND
+        MENUITEM "R&uler\tCtrl+Alt+R",          ID_GRAPH_RULER
         MENUITEM SEPARATOR
+        MENUITEM "&Save as predefined...\tCtrl+S", ID_GRAPH_DEFINE
         MENUITEM "Pr&int...",                   ID_FILE_PRINT
         MENUITEM "&Copy to clipboard\tCtrl+C",  ID_GRAPH_COPYTOCLIPBOARD
         MENUITEM SEPARATOR
         MENUITEM "&Zoom out\tBksp",             ID_GRAPH_ZOOMOUT
         MENUITEM SEPARATOR
-        MENUITEM "&Properties...\tAlt+P",       ID_GRAPH_PROPERTIES
+        MENUITEM "&Properties...\tCtrl+Alt+P",  ID_GRAPH_PROPERTIES
     END
     POPUP "Package"
     BEGIN
@@ -1050,10 +1055,12 @@ END
 
 IDA_GRAPH ACCELERATORS DISCARDABLE 
 BEGIN
-    "A",            ID_GRAPH_AUTOSCALE,     VIRTKEY, ALT, NOINVERT
+    "A",            ID_GRAPH_AUTOSCALE,     VIRTKEY, CONTROL, ALT, NOINVERT
     "C",            ID_GRAPH_COPYTOCLIPBOARD, VIRTKEY, CONTROL, NOINVERT
-    "P",            ID_GRAPH_PROPERTIES,    VIRTKEY, ALT, NOINVERT
-    "R",            ID_GRAPH_RULER,         VIRTKEY, ALT, NOINVERT
+    "L",            ID_GRAPH_LEGEND,        VIRTKEY, CONTROL, ALT, NOINVERT
+    "P",            ID_GRAPH_PROPERTIES,    VIRTKEY, CONTROL, ALT, NOINVERT
+    "R",            ID_GRAPH_RULER,         VIRTKEY, CONTROL, ALT, NOINVERT
+    "S",            ID_GRAPH_DEFINE,        VIRTKEY, CONTROL, NOINVERT
     VK_BACK,        ID_GRAPH_ZOOMOUT,       VIRTKEY, NOINVERT
 END
 
index 2292722..89e84b6 100644 (file)
 #define ID_TOOLS_IMPORTMP               33048
 #define ID_GRAPH_COPYTOCLIPBOARD        33049
 #define ID_OBJECT_CREATE_CLUSTER        33050
+#define ID_TOOLS_GRAPHS_MANAGE          33051
+#define ID_GRAPH_DEFINE                 33052
+#define ID_ALWAYS_DISABLED              43210
 #define IDS_GETFOLDERPATH_FAILED        61216
 #define IDS_WORKDIR_CREATION_FAILED     61217
 #define IDS_SCINTILLA_INIT_FAILED       61218
 #ifndef APSTUDIO_READONLY_SYMBOLS
 #define _APS_3D_CONTROLS                     1
 #define _APS_NEXT_RESOURCE_VALUE        358
-#define _APS_NEXT_COMMAND_VALUE         33051
+#define _APS_NEXT_COMMAND_VALUE         33053
 #define _APS_NEXT_CONTROL_VALUE         1442
-#define _APS_NEXT_SYMED_VALUE           133
+#define _APS_NEXT_SYMED_VALUE           134
 #endif
 #endif
index c6ca89a..a489cce 100644 (file)
@@ -391,6 +391,26 @@ void UpdateActions(DWORD dwCode, NXC_ACTION *pAction)
 }
 
 
+//
+// Update graph list
+//
+
+static void GraphUpdater(void *)
+{
+       LockGraphs();
+       if (g_pGraphList != NULL)
+               NXCDestroyGraphList(g_dwNumGraphs, g_pGraphList);
+       NXCGetGraphList(g_hSession, &g_dwNumGraphs, &g_pGraphList);
+       UnlockGraphs();
+       theApp.PostThreadMessage(NXCM_GRAPH_LIST_UPDATED, 0, 0);
+}
+
+void UpdateGraphList(void)
+{
+       _beginthread(GraphUpdater, 0, NULL);
+}
+
+
 //
 // Restore placement of MDI child window
 //
index 3a26478..526082b 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: nxcp.cpp,v 1.11 2007-02-01 20:03:03 victor Exp $ */
+/* $Id: nxcp.cpp,v 1.12 2007-02-08 22:25:21 victor Exp $ */
 /* 
 ** NetXMS - Network Management System
 ** NetXMS Foundation Library
@@ -236,7 +236,7 @@ TCHAR LIBNETXMS_EXPORTABLE *NXCPMessageCodeName(WORD wCode, TCHAR *pszBuffer)
       _T("CMD_GET_TRAP_CFG_RO"),
                _T("CMD_SNMP_REQUEST"),
                _T("CMD_GET_DCI_INFO"),
-               _T("CMD_GET_GRAPH_LIST")
+               _T("CMD_GET_GRAPH_LIST"),
                _T("CMD_DEFINE_GRAPH"),
                _T("CMD_DELETE_GRAPH")
    };
index 0472568..0526a17 100644 (file)
@@ -2,10 +2,10 @@ INCLUDES=-I@top_srcdir@/include
 
 lib_LTLIBRARIES = libnxcl.la
 libnxcl_la_SOURCES = actions.cpp agentcfg.cpp alarms.cpp comm.cpp datacoll.cpp \
-                    epp.cpp eventdb.cpp events.cpp image.cpp lpp.cpp main.cpp \
-                    map.cpp mib.cpp mp.cpp objects.cpp objtools.cpp \
-                    package.cpp script.cpp server.cpp session.cpp \
-                    snmptrap.cpp snmp.cpp users.cpp
+                    epp.cpp eventdb.cpp events.cpp graph.cpp image.cpp \
+                    lpp.cpp main.cpp map.cpp mib.cpp mp.cpp objects.cpp \
+                    objtools.cpp package.cpp script.cpp server.cpp \
+                    session.cpp snmptrap.cpp snmp.cpp users.cpp
 libnxcl_la_LDFLAGS = -version-info $(NETXMS_LIBRARY_VERSION)
 libnxcl_la_LIBADD = ../libnetxms/libnetxms.la ../libnxmap/libnxmap.la
 
index ca7f66a..9802592 100644 (file)
@@ -1,7 +1,7 @@
 /* 
 ** NetXMS - Network Management System
 ** Client Library
-** Copyright (C) 2004 Victor Kirhenshtein
+** Copyright (C) 2004, 2005, 2006, 2007 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
@@ -17,7 +17,7 @@
 ** along with this program; if not, write to the Free Software
 ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 **
-** $module: datacoll.cpp
+** File: datacoll.cpp
 **
 **/
 
diff --git a/src/libnxcl/graph.cpp b/src/libnxcl/graph.cpp
new file mode 100644 (file)
index 0000000..5b14387
--- /dev/null
@@ -0,0 +1,139 @@
+/* 
+** NetXMS - Network Management System
+** Client Library
+** Copyright (C) 2004, 2005, 2006, 2007 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: graph.cpp
+**
+**/
+
+#include "libnxcl.h"
+
+
+//
+// Get list of configured graphs
+//
+
+DWORD LIBNXCL_EXPORTABLE NXCGetGraphList(NXC_SESSION hSession, DWORD *pdwNumGraphs, NXC_GRAPH **ppGraphList)
+{
+   DWORD i, dwId, dwRqId, dwResult;
+   CSCPMessage msg, *pResponse;
+
+   dwRqId = ((NXCL_Session *)hSession)->CreateRqId();
+
+   msg.SetCode(CMD_GET_GRAPH_LIST);
+   msg.SetId(dwRqId);
+   ((NXCL_Session *)hSession)->SendMsg(&msg);
+
+       *pdwNumGraphs = 0;
+       *ppGraphList = NULL;
+
+       pResponse = ((NXCL_Session *)hSession)->WaitForMessage(CMD_REQUEST_COMPLETED, dwRqId);
+       if (pResponse != NULL)
+       {
+               dwResult = pResponse->GetVariableLong(VID_RCC);
+               if (dwResult == RCC_SUCCESS)
+               {
+                       *pdwNumGraphs = pResponse->GetVariableLong(VID_NUM_GRAPHS);
+                       if (*pdwNumGraphs > 0)
+                       {
+                               *ppGraphList = (NXC_GRAPH *)malloc(sizeof(NXC_GRAPH) * (*pdwNumGraphs));
+                               memset(*ppGraphList, 0, sizeof(NXC_GRAPH) * (*pdwNumGraphs));
+                               for(i = 0, dwId = VID_GRAPH_LIST_BASE; i < *pdwNumGraphs; i++)
+                               {
+                                       (*ppGraphList)[i].dwId = pResponse->GetVariableLong(dwId++);
+                                       (*ppGraphList)[i].dwOwner = pResponse->GetVariableLong(dwId++);
+                                       (*ppGraphList)[i].pszName = pResponse->GetVariableStr(dwId++);
+                                       (*ppGraphList)[i].pszConfig = pResponse->GetVariableStr(dwId++);
+                                       dwId += 6;
+                               }
+                       }
+               }
+               delete pResponse;
+       }
+       else
+       {
+               dwResult = RCC_TIMEOUT;
+       }
+       return dwResult;
+}
+
+
+//
+// Destroy graph list
+//
+
+void LIBNXCL_EXPORTABLE NXCDestroyGraphList(DWORD dwNumGraphs, NXC_GRAPH *pList)
+{
+       DWORD i;
+
+       for(i = 0; i < dwNumGraphs; i++)
+       {
+               safe_free(pList[i].pACL);
+               safe_free(pList[i].pszConfig);
+               safe_free(pList[i].pszName);
+       }
+       safe_free(pList);
+}
+
+
+//
+// Delete graph
+//
+
+DWORD LIBNXCL_EXPORTABLE NXCDeleteGraph(NXC_SESSION hSession, DWORD dwGraphId)
+{
+   DWORD dwRqId;
+   CSCPMessage msg;
+
+   dwRqId = ((NXCL_Session *)hSession)->CreateRqId();
+
+   msg.SetCode(CMD_DELETE_GRAPH);
+   msg.SetId(dwRqId);
+   msg.SetVariable(VID_GRAPH_ID, dwGraphId);
+   ((NXCL_Session *)hSession)->SendMsg(&msg);
+   
+   return ((NXCL_Session *)hSession)->WaitForRCC(dwRqId);
+}
+
+
+//
+// Define graph
+//
+
+DWORD LIBNXCL_EXPORTABLE NXCDefineGraph(NXC_SESSION hSession, NXC_GRAPH *pGraph)
+{
+   DWORD i, dwId, dwRqId;
+   CSCPMessage msg;
+
+   dwRqId = ((NXCL_Session *)hSession)->CreateRqId();
+
+   msg.SetCode(CMD_DEFINE_GRAPH);
+   msg.SetId(dwRqId);
+   msg.SetVariable(VID_GRAPH_ID, pGraph->dwId);
+       msg.SetVariable(VID_NAME, pGraph->pszName);
+       msg.SetVariable(VID_GRAPH_CONFIG, pGraph->pszConfig);
+       msg.SetVariable(VID_ACL_SIZE, pGraph->dwAclSize);
+       for(i = 0, dwId = VID_GRAPH_ACL_BASE; i < pGraph->dwAclSize; i++)
+       {
+               msg.SetVariable(dwId++, pGraph->pACL[i].dwUserId);
+               msg.SetVariable(dwId++, pGraph->pACL[i].dwAccess);
+       }
+   ((NXCL_Session *)hSession)->SendMsg(&msg);
+   
+   return ((NXCL_Session *)hSession)->WaitForRCC(dwRqId);
+}
index 574652f..bce9764 100644 (file)
@@ -200,6 +200,10 @@ SOURCE=.\events.cpp
 # End Source File
 # Begin Source File
 
+SOURCE=.\graph.cpp
+# End Source File
+# Begin Source File
+
 SOURCE=.\image.cpp
 # End Source File
 # Begin Source File
index 1b9ab14..3a02f21 100644 (file)
@@ -278,9 +278,10 @@ const TCHAR LIBNXCL_EXPORTABLE *NXCGetErrorText(DWORD dwError)
       _T("Alarm is not in \"outstanding\" state"),
       _T("DCI data source is not a push agent"),
       _T("Error parsing management pack file"),
-      _T("Management pack validation error")
+      _T("Management pack validation error"),
+               _T("Invalid graph ID")
    };
-   return ((dwError >= 0) && (dwError <= RCC_NXMP_VALIDATION_ERROR)) ? pszErrorText[dwError] : _T("No text message for this error");
+   return ((dwError >= 0) && (dwError <= RCC_INVALID_GRAPH_ID)) ? pszErrorText[dwError] : _T("No text message for this error");
 }
 
 
index ac5fd86..43e8ec5 100644 (file)
@@ -27,7 +27,7 @@
 // Constants
 //
 
-#define NUMBER_OF_GROUPS   18
+#define NUMBER_OF_GROUPS   19
 
 
 //
@@ -38,13 +38,13 @@ static MUTEX m_mutexTableAccess;
 static DWORD m_dwFreeIdTable[NUMBER_OF_GROUPS] = { 10, 1, FIRST_USER_EVENT_ID, 1, 1, 
                                                    1000, 1, 0x80000000,
                                                    1, 1, 0x80000001, 1, 1, 1, 1,
-                                                   10000, 10000, 1
+                                                   10000, 10000, 1, 1
                                                  };
 static DWORD m_dwIdLimits[NUMBER_OF_GROUPS] = { 0xFFFFFFFE, 0xFFFFFFFE, 0x7FFFFFFF, 0x7FFFFFFF, 
                                                 0x7FFFFFFF, 0xFFFFFFFE, 0x7FFFFFFF, 0xFFFFFFFF,
                                                 0x7FFFFFFF, 0x7FFFFFFF, 0xFFFFFFFE, 0xFFFFFFFE,
                                                 0xFFFFFFFE, 0xFFFFFFFE, 0xFFFFFFFE, 0xFFFFFFFE,
-                                                0xFFFFFFFE, 0xFFFFFFFE
+                                                0xFFFFFFFE, 0xFFFFFFFE, 0xFFFFFFFF
                                               };
 static QWORD m_qwFreeEventId = 1;
 static char *m_pszGroupNames[NUMBER_OF_GROUPS] =
@@ -66,7 +66,8 @@ static char *m_pszGroupNames[NUMBER_OF_GROUPS] =
    "Log Processing Policies",
    "Object Tools",
    "Scripts",
-   "Agent Configs"
+   "Agent Configs",
+       "Graphs"
 };
 
 
@@ -137,6 +138,14 @@ BOOL InitIdTable(void)
                                                    DBGetFieldULong(hResult, 0, 0) + 1);
       DBFreeResult(hResult);
    }
+   hResult = DBSelect(g_hCoreDB, "SELECT max(id) FROM clusters");
+   if (hResult != NULL)
+   {
+      if (DBGetNumRows(hResult) > 0)
+         m_dwFreeIdTable[IDG_NETWORK_OBJECT] = max(m_dwFreeIdTable[IDG_NETWORK_OBJECT],
+                                                   DBGetFieldULong(hResult, 0, 0) + 1);
+      DBFreeResult(hResult);
+   }
    hResult = DBSelect(g_hCoreDB, "SELECT max(object_id) FROM deleted_objects");
    if (hResult != NULL)
    {
@@ -320,6 +329,16 @@ BOOL InitIdTable(void)
                                                  DBGetFieldULong(hResult, 0, 0) + 1);
       DBFreeResult(hResult);
    }
+
+   // Get first available graph id
+   hResult = DBSelect(g_hCoreDB, "SELECT max(graph_id) FROM graphs");
+   if (hResult != NULL)
+   {
+      if (DBGetNumRows(hResult) > 0)
+         m_dwFreeIdTable[IDG_GRAPH] = max(m_dwFreeIdTable[IDG_GRAPH],
+                                          DBGetFieldULong(hResult, 0, 0) + 1);
+      DBFreeResult(hResult);
+   }
    return TRUE;
 }
 
index dfc2ddb..d953268 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: session.cpp,v 1.262 2007-02-01 20:03:03 victor Exp $ */
+/* $Id: session.cpp,v 1.263 2007-02-08 22:25:21 victor Exp $ */
 /* 
 ** NetXMS - Network Management System
 ** Copyright (C) 2003, 2004, 2005, 2006, 2007 Victor Kirhenshtein
@@ -74,6 +74,18 @@ typedef struct
 } OBJECT_TOOL_ACL;
 
 
+//
+// Graph ACL entry
+//
+
+struct GRAPH_ACL_ENTRY
+{
+       DWORD dwGraphId;
+       DWORD dwUserId;
+       DWORD dwAccess;
+};
+
+
 //
 // Fill CSCP message with user data
 //
@@ -269,16 +281,17 @@ void ClientSession::Run(void)
 // Print debug information
 //
 
-void ClientSession::DebugPrintf(char *szFormat, ...)
+void ClientSession::DebugPrintf(TCHAR *pszFormat, ...)
 {
-   if ((g_dwFlags & AF_STANDALONE) && (g_dwFlags & AF_DEBUG_CSCP))
+   if (g_dwFlags & AF_DEBUG_CSCP)
    {
       va_list args;
+               TCHAR szBuffer[4096];
 
-      printf("*CSCP(%d)* ", m_dwIndex);
-      va_start(args, szFormat);
-      vprintf(szFormat, args);
+      va_start(args, pszFormat);
+      _vsntprintf(szBuffer, 4096, pszFormat, args);
       va_end(args);
+               DbgPrintf(AF_DEBUG_CSCP, _T("[CLSN-%d] %s"), m_dwIndex, szBuffer);
    }
 }
 
@@ -315,7 +328,7 @@ void ClientSession::ReadThread(void)
       // Check if message is too large
       if (iErr == 1)
       {
-         DebugPrintf("Received message %s is too large (%d bytes)\n",
+         DebugPrintf("Received message %s is too large (%d bytes)",
                      NXCPMessageCodeName(ntohs(pRawMsg->wCode), szBuffer),
                      ntohl(pRawMsg->dwSize));
          continue;
@@ -324,14 +337,14 @@ void ClientSession::ReadThread(void)
       // Check for decryption error
       if (iErr == 2)
       {
-         DebugPrintf("Unable to decrypt received message\n");
+         DebugPrintf("Unable to decrypt received message");
          continue;
       }
 
       // Check that actual received packet size is equal to encoded in packet
       if ((int)ntohl(pRawMsg->dwSize) != iErr)
       {
-         DebugPrintf("Actual message size doesn't match wSize value (%d,%d)\n", iErr, ntohl(pRawMsg->dwSize));
+         DebugPrintf("Actual message size doesn't match wSize value (%d,%d)", iErr, ntohl(pRawMsg->dwSize));
          continue;   // Bad packet, wait for next
       }
 
@@ -343,7 +356,7 @@ void ClientSession::ReadThread(void)
          pRawMsg->dwId = ntohl(pRawMsg->dwId);
          pRawMsg->wCode = ntohs(pRawMsg->wCode);
          pRawMsg->dwNumVars = ntohl(pRawMsg->dwNumVars);
-         DebugPrintf("Received raw message %s\n", NXCPMessageCodeName(pRawMsg->wCode, szBuffer));
+         DebugPrintf("Received raw message %s", NXCPMessageCodeName(pRawMsg->wCode, szBuffer));
 
          if ((pRawMsg->wCode == CMD_FILE_DATA) || 
              (pRawMsg->wCode == CMD_ABORT_FILE_TRANSFER))
@@ -396,7 +409,7 @@ void ClientSession::ReadThread(void)
             }
             else
             {
-               DebugPrintf("Out of state message (ID: %d)\n", pRawMsg->dwId);
+               DebugPrintf("Out of state message (ID: %d)", pRawMsg->dwId);
             }
          }
       }
@@ -413,7 +426,7 @@ void ClientSession::ReadThread(void)
          }
          else if (pMsg->GetCode() == CMD_KEEPALIVE)
                        {
-                     DebugPrintf("Received message %s\n", NXCPMessageCodeName(pMsg->GetCode(), szBuffer));
+                     DebugPrintf("Received message %s", NXCPMessageCodeName(pMsg->GetCode(), szBuffer));
                                RespondToKeepalive(pMsg->GetId());
                                delete pMsg;
                        }
@@ -466,14 +479,14 @@ void ClientSession::ReadThread(void)
    // Waiting while reference count becomes 0
    if (m_dwRefCount > 0)
    {
-      DebugPrintf("Waiting for pending requests...\n");
+      DebugPrintf("Waiting for pending requests...");
       do
       {
          ThreadSleep(1);
       } while(m_dwRefCount > 0);
    }
 
-   DebugPrintf("Session closed\n");
+   DebugPrintf("Session closed");
 }
 
 
@@ -494,7 +507,7 @@ void ClientSession::WriteThread(void)
       if (pRawMsg == INVALID_POINTER_VALUE)    // Session termination indicator
          break;
 
-      DebugPrintf("Sending message %s\n", NXCPMessageCodeName(ntohs(pRawMsg->wCode), szBuffer));
+      DebugPrintf("Sending message %s", NXCPMessageCodeName(ntohs(pRawMsg->wCode), szBuffer));
       if (m_pCtx != NULL)
       {
          pEnMsg = CSCPEncryptMessage(m_pCtx, pRawMsg);
@@ -620,7 +633,7 @@ void ClientSession::ProcessingThread(void)
          break;
 
       m_wCurrentCmd = pMsg->GetCode();
-      DebugPrintf("Received message %s\n", NXCPMessageCodeName(m_wCurrentCmd, szBuffer));
+      DebugPrintf("Received message %s", NXCPMessageCodeName(m_wCurrentCmd, szBuffer));
       if (!(m_dwFlags & CSF_AUTHENTICATED) && 
           (m_wCurrentCmd != CMD_LOGIN) && 
           (m_wCurrentCmd != CMD_GET_SERVER_INFO) &&
@@ -1181,7 +1194,7 @@ void ClientSession::Login(CSCPMessage *pRequest)
          msg.SetVariable(VID_USER_ID, m_dwUserId);
          msg.SetVariable(VID_CHANGE_PASSWD_FLAG, (WORD)bChangePasswd);
          msg.SetVariable(VID_DBCONN_STATUS, (WORD)((g_dwFlags & AF_DB_CONNECTION_LOST) ? FALSE : TRUE));
-         DebugPrintf("User %s authenticated\n", m_szUserName);
+         DebugPrintf("User %s authenticated", m_szUserName);
       }
       else
       {
@@ -3008,7 +3021,7 @@ void ClientSession::SaveEPP(CSCPMessage *pRequest)
             m_ppEPPRuleList = (EPRule **)malloc(sizeof(EPRule *) * m_dwNumRecordsToUpload);
             memset(m_ppEPPRuleList, 0, sizeof(EPRule *) * m_dwNumRecordsToUpload);
          }
-         DebugPrintf("Accepted EPP upload request for %d rules\n", m_dwNumRecordsToUpload);
+         DebugPrintf("Accepted EPP upload request for %d rules", m_dwNumRecordsToUpload);
       }
       else
       {
@@ -3052,7 +3065,7 @@ void ClientSession::ProcessEPPRecord(CSCPMessage *pRequest)
             CSCPMessage msg;
 
             // All records received, replace event policy...
-            DebugPrintf("Replacing event processing policy with a new one at %p (%d rules)\n",
+            DebugPrintf("Replacing event processing policy with a new one at %p (%d rules)",
                         m_ppEPPRuleList, m_dwNumRecordsToUpload);
             g_pEventPolicy->ReplacePolicy(m_dwNumRecordsToUpload, m_ppEPPRuleList);
             g_pEventPolicy->SaveToDB();
@@ -8353,6 +8366,76 @@ void ClientSession::SendDCIInfo(CSCPMessage *pRequest)
 }
 
 
+//
+// Check access to the graph
+//
+
+static BOOL CheckGraphAccess(GRAPH_ACL_ENTRY *pACL, int nACLSize, DWORD dwGraphId,
+                                                                         DWORD dwUserId, DWORD dwDesiredAccess)
+{
+       int i;
+
+       for(i = 0; i < nACLSize; i++)
+       {
+               if (pACL[i].dwGraphId == dwGraphId)
+               {
+                       if ((pACL[i].dwUserId == dwUserId) ||
+                                ((pACL[i].dwUserId & GROUP_FLAG) && CheckUserMembership(dwUserId, pACL[i].dwUserId)))
+                       {
+                               if ((pACL[i].dwAccess & dwDesiredAccess) == dwDesiredAccess)
+                                       return TRUE;
+                       }
+               }
+       }
+       return FALSE;
+}
+
+
+//
+// Load graph's ACL - load for all graphs if dwGraphId is 0
+//
+
+static GRAPH_ACL_ENTRY *LoadGraphACL(DWORD dwGraphId, int *pnACLSize)
+{
+       int i, nSize;
+       GRAPH_ACL_ENTRY *pACL = NULL;
+       DB_RESULT hResult;
+
+       if (dwGraphId == 0)
+       {
+               hResult = DBSelect(g_hCoreDB, _T("SELECT graph_id,user_id,user_rights FROM graph_acl"));
+       }
+       else
+       {
+               TCHAR szQuery[256];
+
+               _stprintf(szQuery, _T("SELECT graph_id,user_id,user_rights FROM graph_acl WHERE graph_id=%d"), dwGraphId);
+               hResult = DBSelect(g_hCoreDB, szQuery);
+       }
+       if (hResult != NULL)
+       {
+               nSize = DBGetNumRows(hResult);
+               if (nSize > 0)
+               {
+                       pACL = (GRAPH_ACL_ENTRY *)malloc(sizeof(GRAPH_ACL_ENTRY) * nSize);
+                       for(i = 0; i < nSize; i++)
+                       {
+                               pACL[i].dwGraphId = DBGetFieldULong(hResult, i, 0);
+                               pACL[i].dwUserId = DBGetFieldULong(hResult, i, 1);
+                               pACL[i].dwAccess = DBGetFieldULong(hResult, i, 2);
+                       }
+               }
+               *pnACLSize = nSize;
+               DBFreeResult(hResult);
+       }
+       else
+       {
+               *pnACLSize = -1;        // Database error
+       }
+       return pACL;
+}
+
+
 //
 // Send list of available graphs to client
 //
@@ -8361,21 +8444,56 @@ void ClientSession::SendGraphList(DWORD dwRqId)
 {
    CSCPMessage msg;
        DB_RESULT hResult;
-       int i, nRows;
+       GRAPH_ACL_ENTRY *pACL = NULL;
+       int i, nRows, nACLSize;
+       DWORD dwId, dwNumGraphs, dwGraphId, dwOwner;
+       TCHAR *pszStr;
 
    msg.SetCode(CMD_REQUEST_COMPLETED);
    msg.SetId(dwRqId);
 
-       hResult = DBSelect(g_hCoreDB, _T("SELECT graph_id,owner_id,name,config FROM graphs"));
-       if (hResult != NULL)
+       pACL = LoadGraphACL(0, &nACLSize);
+       if (nACLSize != -1)
        {
-               nRows = DBGetNumRows(hResult);
-               for(i = 0; i < nRows; i++)
+               hResult = DBSelect(g_hCoreDB, _T("SELECT graph_id,owner_id,name,config FROM graphs"));
+               if (hResult != NULL)
                {
-
+                       nRows = DBGetNumRows(hResult);
+                       for(i = 0, dwNumGraphs = 0, dwId = VID_GRAPH_LIST_BASE; i < nRows; i++)
+                       {
+                               dwGraphId = DBGetFieldULong(hResult, i, 0);
+                               dwOwner = DBGetFieldULong(hResult, i, 1);
+                               if ((m_dwUserId == 0) ||
+                                   (m_dwUserId == dwOwner) ||
+                                   CheckGraphAccess(pACL, nACLSize, dwGraphId, m_dwUserId, FALSE))
+                               {
+                                       msg.SetVariable(dwId++, dwGraphId);
+                                       msg.SetVariable(dwId++, dwOwner);
+                                       pszStr = DBGetField(hResult, i, 2, NULL, 0);
+                                       if (pszStr != NULL)
+                                       {
+                                               DecodeSQLStringAndSetVariable(&msg, dwId++, pszStr);
+                                               free(pszStr);
+                                       }
+                                       pszStr = DBGetField(hResult, i, 3, NULL, 0);
+                                       if (pszStr != NULL)
+                                       {
+                                               DecodeSQLStringAndSetVariable(&msg, dwId++, pszStr);
+                                               free(pszStr);
+                                       }
+                                       dwId += 6;
+                                       dwNumGraphs++;
+                               }
+                       }
+                       DBFreeResult(hResult);
+                       msg.SetVariable(VID_NUM_GRAPHS, dwNumGraphs);
+                       msg.SetVariable(VID_RCC, RCC_SUCCESS);
                }
-               DBFreeResult(hResult);
-               msg.SetVariable(VID_RCC, RCC_SUCCESS);
+               else
+               {
+                       msg.SetVariable(VID_RCC, RCC_DB_FAILURE);
+               }
+               safe_free(pACL);
        }
        else
        {
@@ -8387,16 +8505,146 @@ void ClientSession::SendGraphList(DWORD dwRqId)
 
 
 //
-// Define grap
+// Define graph
 //
 
 void ClientSession::DefineGraph(CSCPMessage *pRequest)
 {
    CSCPMessage msg;
+       BOOL bNew, bSuccess;
+       DWORD dwId, dwGraphId, dwOwner, dwUserId, dwAccess;
+       TCHAR szQuery[16384], *pszEscName, *pszEscData, *pszTemp;
+       GRAPH_ACL_ENTRY *pACL = NULL;
+       int i, nACLSize;
+       DB_RESULT hResult;
 
    msg.SetCode(CMD_REQUEST_COMPLETED);
    msg.SetId(pRequest->GetId());
 
+       dwGraphId = pRequest->GetVariableLong(VID_GRAPH_ID);
+       if (dwGraphId == 0)
+       {
+               // New graph
+               dwGraphId = CreateUniqueId(IDG_GRAPH);
+               bNew = TRUE;
+               bSuccess = TRUE;
+       }
+       else
+       {
+               bNew = FALSE;
+               bSuccess = FALSE;
+
+               // Check existence and access rights
+               _stprintf(szQuery, _T("SELECT owner_id FROM graphs WHERE graph_id=%d"), dwGraphId);
+               hResult = DBSelect(g_hCoreDB, szQuery);
+               if (hResult != NULL)
+               {
+                       if (DBGetNumRows(hResult) > 0)
+                       {
+                               dwOwner = DBGetFieldULong(hResult, 0, 0);
+                               pACL = LoadGraphACL(dwGraphId, &nACLSize);
+                               if (nACLSize != -1)
+                               {
+                                       if ((m_dwUserId == 0) ||
+                                                (m_dwUserId == dwOwner) ||
+                                                CheckGraphAccess(pACL, nACLSize, dwGraphId, m_dwUserId, NXGRAPH_ACCESS_WRITE))
+                                       {
+                                               bSuccess = TRUE;
+                                       }
+                                       else
+                                       {
+                                               msg.SetVariable(VID_RCC, RCC_ACCESS_DENIED);
+                                       }
+                                       safe_free(pACL);
+                               }
+                               else
+                               {
+                                       msg.SetVariable(VID_RCC, RCC_DB_FAILURE);
+                               }
+                       }
+                       else
+                       {
+                               msg.SetVariable(VID_RCC, RCC_INVALID_GRAPH_ID);
+                       }
+                       DBFreeResult(hResult);
+               }
+               else
+               {
+                       msg.SetVariable(VID_RCC, RCC_DB_FAILURE);
+               }
+       }
+
+       // Create/update graph
+       if (bSuccess)
+       {
+               DebugPrintf(_T("%s graph %d"), bNew ? _T("Creating") : _T("Updating"), dwGraphId);
+               bSuccess = FALSE;
+               if (DBBegin(g_hCoreDB))
+               {
+                       pRequest->GetVariableStr(VID_NAME, szQuery, 256);
+                       pszEscName = EncodeSQLString(szQuery);
+                       pszTemp = pRequest->GetVariableStr(VID_GRAPH_CONFIG);
+                       if (pszTemp != NULL)
+                       {
+                               pszEscData = EncodeSQLString(CHECK_NULL(pszTemp));
+                               free(pszTemp);
+                       }
+                       if (bNew)
+                       {
+                               _sntprintf(szQuery, 16384, _T("INSERT INTO graphs (graph_id,owner_id,name,config) VALUES (%d,%d,'%s','%s')"),
+                                          dwGraphId, m_dwUserId, pszEscName, pszEscData);
+                       }
+                       else
+                       {
+                               _stprintf(szQuery, _T("DELETE FROM graph_acl WHERE graph_id=%d"), dwGraphId);
+                               DBQuery(g_hCoreDB, szQuery);
+
+                               _sntprintf(szQuery, 16384, _T("UPDATE graphs SET name='%s',config='%s' WHERE graph_id=%d"),
+                                          pszEscName, pszEscData, dwGraphId);
+                       }
+                       free(pszEscName);
+                       free(pszEscData);
+
+                       if (DBQuery(g_hCoreDB, szQuery))
+                       {
+                               // Insert new ACL
+                               nACLSize = (int)pRequest->GetVariableLong(VID_ACL_SIZE);
+                               for(i = 0, dwId = VID_GRAPH_ACL_BASE, bSuccess = TRUE; i < nACLSize; i++)
+                               {
+                                       dwUserId = pRequest->GetVariableLong(dwId++);
+                                       dwAccess = pRequest->GetVariableLong(dwId++);
+                                       _stprintf(szQuery, _T("INSERT INTO graph_acl (graph_id,user_id,user_rights) VALUES (%d,%d,%d)"),
+                                                 dwGraphId, dwUserId, dwAccess);
+                                       if (!DBQuery(g_hCoreDB, szQuery))
+                                       {
+                                               bSuccess = FALSE;
+                                               msg.SetVariable(VID_RCC, RCC_DB_FAILURE);
+                                               break;
+                                       }
+                               }
+                       }
+                       else
+                       {
+                               msg.SetVariable(VID_RCC, RCC_DB_FAILURE);
+                       }
+
+                       if (bSuccess)
+                       {
+                               DBCommit(g_hCoreDB);
+                               msg.SetVariable(VID_RCC, RCC_SUCCESS);
+                               Notify(NX_NOTIFY_GRAPHS_CHANGED);
+                       }
+                       else
+                       {
+                               DBRollback(g_hCoreDB);
+                       }
+               }
+               else
+               {
+                       msg.SetVariable(VID_RCC, RCC_DB_FAILURE);
+               }
+       }
+
    SendMessage(&msg);
 }
 
@@ -8408,9 +8656,64 @@ void ClientSession::DefineGraph(CSCPMessage *pRequest)
 void ClientSession::DeleteGraph(CSCPMessage *pRequest)
 {
    CSCPMessage msg;
+       DWORD dwGraphId, dwOwner;
+       GRAPH_ACL_ENTRY *pACL = NULL;
+       int nACLSize;
+       DB_RESULT hResult;
+       TCHAR szQuery[256];
 
    msg.SetCode(CMD_REQUEST_COMPLETED);
    msg.SetId(pRequest->GetId());
 
+       dwGraphId = pRequest->GetVariableLong(VID_GRAPH_ID);
+       _stprintf(szQuery, _T("SELECT owner_id FROM graphs WHERE graph_id=%d"), dwGraphId);
+       hResult = DBSelect(g_hCoreDB, szQuery);
+       if (hResult != NULL)
+       {
+               if (DBGetNumRows(hResult) > 0)
+               {
+                       dwOwner = DBGetFieldULong(hResult, 0, 0);
+                       pACL = LoadGraphACL(dwGraphId, &nACLSize);
+                       if (nACLSize != -1)
+                       {
+                               if ((m_dwUserId == 0) ||
+                                   (m_dwUserId == dwOwner) ||
+                                   CheckGraphAccess(pACL, nACLSize, dwGraphId, m_dwUserId, NXGRAPH_ACCESS_READ))
+                               {
+                                       _stprintf(szQuery, _T("DELETE FROM graphs WHERE graph_id=%d"), dwGraphId);
+                                       if (DBQuery(g_hCoreDB, szQuery))
+                                       {
+                                               _stprintf(szQuery, _T("DELETE FROM graph_acl WHERE graph_id=%d"), dwGraphId);
+                                               DBQuery(g_hCoreDB, szQuery);
+                                               msg.SetVariable(VID_RCC, RCC_SUCCESS);
+                                               Notify(NX_NOTIFY_GRAPHS_CHANGED);
+                                       }
+                                       else
+                                       {
+                                               msg.SetVariable(VID_RCC, RCC_DB_FAILURE);
+                                       }
+                               }
+                               else
+                               {
+                                       msg.SetVariable(VID_RCC, RCC_ACCESS_DENIED);
+                               }
+                               safe_free(pACL);
+                       }
+                       else
+                       {
+                               msg.SetVariable(VID_RCC, RCC_DB_FAILURE);
+                       }
+               }
+               else
+               {
+                       msg.SetVariable(VID_RCC, RCC_INVALID_GRAPH_ID);
+               }
+               DBFreeResult(hResult);
+       }
+       else
+       {
+               msg.SetVariable(VID_RCC, RCC_DB_FAILURE);
+       }
+
    SendMessage(&msg);
 }
index f4a6948..93b70e9 100644 (file)
@@ -150,6 +150,7 @@ typedef void * HSNMPSESSION;
 #define IDG_OBJECT_TOOL       15
 #define IDG_SCRIPT            16
 #define IDG_AGENT_CONFIG      17
+#define IDG_GRAPH                                      18
 
 
 //
@@ -359,7 +360,7 @@ private:
    void SetupEncryption(DWORD dwRqId);
    void RespondToKeepalive(DWORD dwRqId);
    void OnFileUpload(BOOL bSuccess);
-   void DebugPrintf(char *szFormat, ...);
+   void DebugPrintf(TCHAR *pszFormat, ...);
    void SendServerInfo(DWORD dwRqId);
    void Login(CSCPMessage *pRequest);
    void SendAllObjects(CSCPMessage *pRequest);
index 0b42671..eda59bb 100644 (file)
@@ -347,13 +347,13 @@ void LIBNXSRV_EXPORTABLE WriteLog(DWORD msg, WORD wType, char *format, ...)
 void LIBNXSRV_EXPORTABLE DbgPrintf(DWORD dwFlags, TCHAR *szFormat, ...)
 {
    va_list args;
-   TCHAR szBuffer[1024];
+   TCHAR szBuffer[4096];
 
    if (!(g_dwFlags & dwFlags))
       return;     // Required application flag(s) not set
 
    va_start(args, szFormat);
-   _vsntprintf(szBuffer, 1024, szFormat, args);
+   _vsntprintf(szBuffer, 4096, szFormat, args);
    va_end(args);
    WriteLog(MSG_DEBUG, EVENTLOG_INFORMATION_TYPE, _T("s"), szBuffer);
 }