Action management basically working
authorVictor Kirhenshtein <victor@netxms.org>
Thu, 9 Sep 2004 08:45:37 +0000 (08:45 +0000)
committerVictor Kirhenshtein <victor@netxms.org>
Thu, 9 Sep 2004 08:45:37 +0000 (08:45 +0000)
22 files changed:
.gitattributes
include/nxclapi.h
include/nxcscpapi.h
src/console/win32/ActionEditor.cpp
src/console/win32/ActionEditor.h
src/console/win32/ActionSelDlg.cpp [new file with mode: 0644]
src/console/win32/ActionSelDlg.h [new file with mode: 0644]
src/console/win32/EditActionDlg.cpp [new file with mode: 0644]
src/console/win32/EditActionDlg.h [new file with mode: 0644]
src/console/win32/EventPolicyEditor.cpp
src/console/win32/EventPolicyEditor.h
src/console/win32/EventSelDlg.cpp
src/console/win32/NewActionDlg.cpp [new file with mode: 0644]
src/console/win32/NewActionDlg.h [new file with mode: 0644]
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.rc
src/console/win32/resource.h
src/console/win32/tools.cpp

index 6d9b0b0..507571f 100644 (file)
@@ -103,6 +103,8 @@ src/console/cmdline/nxcmd.dsw -text
 src/console/cmdline/nxcmd.h -text
 src/console/win32/ActionEditor.cpp -text
 src/console/win32/ActionEditor.h -text
+src/console/win32/ActionSelDlg.cpp -text
+src/console/win32/ActionSelDlg.h -text
 src/console/win32/AlarmBrowser.cpp -text
 src/console/win32/AlarmBrowser.h -text
 src/console/win32/ConsolePropsGeneral.cpp -text
@@ -119,6 +121,8 @@ src/console/win32/DataCollectionEditor.cpp -text
 src/console/win32/DataCollectionEditor.h -text
 src/console/win32/DebugFrame.cpp -text
 src/console/win32/DebugFrame.h -text
+src/console/win32/EditActionDlg.cpp -text
+src/console/win32/EditActionDlg.h -text
 src/console/win32/EditBox.cpp -text
 src/console/win32/EditBox.h -text
 src/console/win32/EditEventDlg.cpp -text
@@ -149,6 +153,8 @@ src/console/win32/MapView.cpp -text
 src/console/win32/MapView.h -text
 src/console/win32/NetSummaryFrame.cpp -text
 src/console/win32/NetSummaryFrame.h -text
+src/console/win32/NewActionDlg.cpp -text
+src/console/win32/NewActionDlg.h -text
 src/console/win32/NewUserDlg.cpp -text
 src/console/win32/NewUserDlg.h -text
 src/console/win32/NodePropsGeneral.cpp -text
index 9ee5abf..be5e4c7 100644 (file)
@@ -28,6 +28,7 @@
 #include <nms_util.h>
 #include <nxevent.h>
 #include <nximage.h>
+#include <nxcscpapi.h>
 
 #ifdef _WIN32
 #ifdef LIBNXCL_EXPORTS
index 29dda9e..4cba326 100644 (file)
 
 
 //
+// Encryption methods
+//
+
+#define CSCP_ENCRYPTION_NONE           0
+#define CSCP_ENCRYPTION_BLOWFISH_SHA1  1
+
+
+//
 // Temporary buffer structure for RecvCSCPMessage() function
 //
 
index c358625..6f35536 100644 (file)
@@ -4,6 +4,8 @@
 #include "stdafx.h"
 #include "nxcon.h"
 #include "ActionEditor.h"
+#include "NewActionDlg.h"
+#include "EditActionDlg.h"
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
@@ -33,6 +35,12 @@ BEGIN_MESSAGE_MAP(CActionEditor, CMDIChildWnd)
        ON_WM_SIZE()
        ON_WM_CLOSE()
        ON_COMMAND(ID_VIEW_REFRESH, OnViewRefresh)
+       ON_WM_CONTEXTMENU()
+       ON_UPDATE_COMMAND_UI(ID_ACTION_DELETE, OnUpdateActionDelete)
+       ON_UPDATE_COMMAND_UI(ID_ACTION_PROPERTIES, OnUpdateActionProperties)
+       ON_UPDATE_COMMAND_UI(ID_ACTION_RENAME, OnUpdateActionRename)
+       ON_COMMAND(ID_ACTION_NEW, OnActionNew)
+       ON_COMMAND(ID_ACTION_PROPERTIES, OnActionProperties)
        //}}AFX_MSG_MAP
 END_MESSAGE_MAP()
 
@@ -141,5 +149,194 @@ void CActionEditor::OnClose()
 
 void CActionEditor::OnViewRefresh() 
 {
+   DWORD i;
+
    m_wndListCtrl.DeleteAllItems();
+   LockActions();
+   for(i = 0; i < g_dwNumActions; i++)
+      AddItem(&g_pActionList[i]);
+   UnlockActions();
+}
+
+
+//
+// WM_CONTEXTMENU message handler
+//
+
+void CActionEditor::OnContextMenu(CWnd* pWnd, CPoint point) 
+{
+   CMenu *pMenu;
+
+   pMenu = theApp.GetContextMenu(7);
+   pMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this, NULL);
+}
+
+
+//
+// Replace data in existing item
+//
+
+void CActionEditor::ReplaceItem(int iItem, NXC_ACTION *pAction)
+{
+   if (iItem != -1)
+   {
+      m_wndListCtrl.SetItem(iItem, 0, LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM, 
+                            pAction->szName, pAction->iType, 0, 0, pAction->dwId);
+      m_wndListCtrl.SetItemText(iItem, 1, g_szActionType[pAction->iType]);
+      m_wndListCtrl.SetItemText(iItem, 2, pAction->szRcptAddr);
+      m_wndListCtrl.SetItemText(iItem, 3, pAction->pszData);
+   }
+
+}
+
+
+//
+// Add new item to list
+//
+
+int CActionEditor::AddItem(NXC_ACTION *pAction)
+{
+   int iIndex;
+
+   iIndex = m_wndListCtrl.InsertItem(0x7FFFFFFF, pAction->szName, pAction->iType);
+   if (iIndex != -1)
+   {
+      m_wndListCtrl.SetItemData(iIndex, pAction->dwId);
+      m_wndListCtrl.SetItemText(iIndex, 1, g_szActionType[pAction->iType]);
+      m_wndListCtrl.SetItemText(iIndex, 2, pAction->szRcptAddr);
+      m_wndListCtrl.SetItemText(iIndex, 3, pAction->pszData);
+   }
+   return iIndex;
+}
+
+
+//
+// Update status for menu items
+//
+
+void CActionEditor::OnUpdateActionDelete(CCmdUI* pCmdUI) 
+{
+   pCmdUI->Enable(m_wndListCtrl.GetSelectedCount() > 0);
+}
+
+void CActionEditor::OnUpdateActionProperties(CCmdUI* pCmdUI) 
+{
+   pCmdUI->Enable(m_wndListCtrl.GetSelectedCount() == 1);
+}
+
+void CActionEditor::OnUpdateActionRename(CCmdUI* pCmdUI) 
+{
+   pCmdUI->Enable(m_wndListCtrl.GetSelectedCount() == 1);
+}
+
+
+//
+// WM_COMMAND::ID_ACTION_NEW message handler
+//
+
+void CActionEditor::OnActionNew() 
+{
+   CNewActionDlg dlg;
+   DWORD i, dwActionId, dwResult;
+   int iItem;
+
+   if (dlg.DoModal() == IDOK)
+   {
+      dwResult = DoRequestArg2(NXCCreateAction, (void *)((LPCTSTR)dlg.m_strName), 
+                               &dwActionId, "Creating new action...");
+      if (dwResult == RCC_SUCCESS)
+      {
+         LockActions();
+
+         // Check if we already received an update from server
+         for(i = 0; i < g_dwNumActions; i++)
+            if (g_pActionList[i].dwId == dwActionId)
+               break;   // Already have this action in list
+         if (i == g_dwNumActions)
+         {
+            // Action still not in list, add it
+            g_dwNumActions++;
+            g_pActionList = (NXC_ACTION *)realloc(g_pActionList, sizeof(NXC_ACTION) * g_dwNumActions);
+            memset(&g_pActionList[i], 0, sizeof(NXC_ACTION));
+            g_pActionList[i].dwId = dwActionId;
+            g_pActionList[i].iType = ACTION_EXEC;
+            strncpy(g_pActionList[i].szName, dlg.m_strName, MAX_OBJECT_NAME);
+            g_pActionList[i].pszData = strdup("");
+         }
+
+         iItem = AddItem(&g_pActionList[i]);
+         SelectListViewItem(&m_wndListCtrl, iItem);
+         PostMessage(WM_COMMAND, ID_ACTION_PROPERTIES, 0);
+
+         UnlockActions();
+      }
+      else
+      {
+         theApp.ErrorBox(dwResult, "Error creating action: %s");
+      }
+   }
+}
+
+
+//
+// WM_COMMAND::ID_ACTION_PROPERTIES message handler
+//
+
+void CActionEditor::OnActionProperties() 
+{
+   int iItem;
+
+   if (m_wndListCtrl.GetSelectedCount() == 1)
+   {
+      iItem = m_wndListCtrl.GetSelectionMark();
+      if (iItem != -1)
+      {
+         NXC_ACTION *pAction;
+
+         LockActions();
+
+         pAction = FindActionById(m_wndListCtrl.GetItemData(iItem));
+         if (pAction != NULL)
+         {
+            CEditActionDlg dlg;
+
+            dlg.m_iType = pAction->iType;
+            dlg.m_strData = pAction->pszData;
+            dlg.m_strName = pAction->szName;
+            dlg.m_strRcpt = pAction->szRcptAddr;
+            dlg.m_strSubject = pAction->szEmailSubject;
+            UnlockActions();
+
+            if (dlg.DoModal() == IDOK)
+            {
+               NXC_ACTION action;
+               DWORD dwResult;
+
+               memset(&action, 0, sizeof(NXC_ACTION));
+               action.dwId = m_wndListCtrl.GetItemData(iItem);
+               action.iType = dlg.m_iType;
+               action.pszData = strdup((LPCTSTR)dlg.m_strData);
+               strncpy(action.szEmailSubject, (LPCTSTR)dlg.m_strSubject, MAX_EMAIL_SUBJECT_LEN);
+               strncpy(action.szName, (LPCTSTR)dlg.m_strName, MAX_OBJECT_NAME);
+               strncpy(action.szRcptAddr, (LPCTSTR)dlg.m_strRcpt, MAX_RCPT_ADDR_LEN);
+
+               dwResult = DoRequestArg1(NXCModifyAction, &action, "Updating action configuration...");
+               if (dwResult == RCC_SUCCESS)
+               {
+                  ReplaceItem(iItem, &action);
+               }
+               else
+               {
+                  theApp.ErrorBox(dwResult, "Error updating action configuration: %s");
+               }
+               free(action.pszData);
+            }
+         }
+         else
+         {
+            UnlockActions();
+            MessageBox("Internal error: cannot find requested action entry in list", "Internal Error", MB_OK | MB_ICONSTOP);
+         }
+      }
+   }
 }
index ca8ee2c..3427b1f 100644 (file)
@@ -31,6 +31,8 @@ public:
 
 // Implementation
 protected:
+       void ReplaceItem(int iItem, NXC_ACTION *pAction);
+       int AddItem(NXC_ACTION *pAction);
        virtual ~CActionEditor();
 
        // Generated message map functions
@@ -41,6 +43,12 @@ protected:
        afx_msg void OnSize(UINT nType, int cx, int cy);
        afx_msg void OnClose();
        afx_msg void OnViewRefresh();
+       afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
+       afx_msg void OnUpdateActionDelete(CCmdUI* pCmdUI);
+       afx_msg void OnUpdateActionProperties(CCmdUI* pCmdUI);
+       afx_msg void OnUpdateActionRename(CCmdUI* pCmdUI);
+       afx_msg void OnActionNew();
+       afx_msg void OnActionProperties();
        //}}AFX_MSG
        DECLARE_MESSAGE_MAP()
 private:
diff --git a/src/console/win32/ActionSelDlg.cpp b/src/console/win32/ActionSelDlg.cpp
new file mode 100644 (file)
index 0000000..ccc9b0f
--- /dev/null
@@ -0,0 +1,135 @@
+// ActionSelDlg.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "nxcon.h"
+#include "ActionSelDlg.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CActionSelDlg dialog
+
+
+CActionSelDlg::CActionSelDlg(CWnd* pParent /*=NULL*/)
+       : CDialog(CActionSelDlg::IDD, pParent)
+{
+   m_pdwActionList = NULL;
+
+       //{{AFX_DATA_INIT(CActionSelDlg)
+               // NOTE: the ClassWizard will add member initialization here
+       //}}AFX_DATA_INIT
+}
+
+CActionSelDlg::~CActionSelDlg()
+{
+   safe_free(m_pdwActionList);
+}
+
+
+void CActionSelDlg::DoDataExchange(CDataExchange* pDX)
+{
+       CDialog::DoDataExchange(pDX);
+       //{{AFX_DATA_MAP(CActionSelDlg)
+       DDX_Control(pDX, IDC_LIST_ACTIONS, m_wndListCtrl);
+       //}}AFX_DATA_MAP
+}
+
+
+BEGIN_MESSAGE_MAP(CActionSelDlg, CDialog)
+       //{{AFX_MSG_MAP(CActionSelDlg)
+       ON_NOTIFY(NM_DBLCLK, IDC_LIST_ACTIONS, OnDblclkListActions)
+       //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CActionSelDlg message handlers
+
+
+//
+// WM_INITDIALOG message handler
+//
+
+BOOL CActionSelDlg::OnInitDialog() 
+{
+   DWORD i;
+   int iItem;
+   RECT rect;
+
+       CDialog::OnInitDialog();
+       
+   // Create image list
+   m_imageList.Create(16, 16, ILC_COLOR8 | ILC_MASK, 8, 8);
+   m_imageList.Add(AfxGetApp()->LoadIcon(IDI_EXEC));
+   m_imageList.Add(AfxGetApp()->LoadIcon(IDI_REXEC));
+   m_imageList.Add(AfxGetApp()->LoadIcon(IDI_EMAIL));
+   m_imageList.Add(AfxGetApp()->LoadIcon(IDI_SMS));
+
+   // Setup list control
+   m_wndListCtrl.SetImageList(&m_imageList, LVSIL_SMALL);
+   m_wndListCtrl.GetClientRect(&rect);
+   m_wndListCtrl.InsertColumn(0, "Name", LVCFMT_LEFT, 200);
+   m_wndListCtrl.InsertColumn(1, "Type", LVCFMT_LEFT, 
+                              rect.right - 200 - GetSystemMetrics(SM_CXVSCROLL));
+   m_wndListCtrl.SetExtendedStyle(LVS_EX_FULLROWSELECT);
+       
+   // Fill in event list
+   LockActions();
+   for(i = 0; i < g_dwNumActions; i++)
+   {
+      iItem = m_wndListCtrl.InsertItem(0x7FFFFFFF, g_pActionList[i].szName, g_pActionList[i].iType);
+      if (iItem != -1)
+      {
+         m_wndListCtrl.SetItemText(iItem, 1, g_szActionType[g_pActionList[i].iType]);
+         m_wndListCtrl.SetItemData(iItem, g_pActionList[i].dwId);
+      }
+   }
+   UnlockActions();
+
+       return TRUE;
+}
+
+
+//
+// WM_COMMAND::IDOK message handler
+//
+
+void CActionSelDlg::OnOK() 
+{
+   int iItem;
+   DWORD i;
+
+   m_dwNumActions = m_wndListCtrl.GetSelectedCount();
+   if (m_dwNumActions > 0)
+   {
+      // Build list of selected objects
+      m_pdwActionList = (DWORD *)malloc(sizeof(DWORD) * m_dwNumActions);
+      iItem = m_wndListCtrl.GetNextItem(-1, LVIS_SELECTED);
+      for(i = 0; iItem != -1; i++)
+      {
+         m_pdwActionList[i] = m_wndListCtrl.GetItemData(iItem);
+         iItem = m_wndListCtrl.GetNextItem(iItem, LVIS_SELECTED);
+      }
+          CDialog::OnOK();
+   }
+   else
+   {
+      MessageBox("You should select at least one action", "Warning", MB_OK | MB_ICONEXCLAMATION);
+   }
+}
+
+
+//
+// Handler for list control double click
+//
+
+void CActionSelDlg::OnDblclkListActions(NMHDR* pNMHDR, LRESULT* pResult) 
+{
+   if (m_wndListCtrl.GetSelectedCount() > 0)
+      PostMessage(WM_COMMAND, IDOK, 0);
+       *pResult = 0;
+}
diff --git a/src/console/win32/ActionSelDlg.h b/src/console/win32/ActionSelDlg.h
new file mode 100644 (file)
index 0000000..7118933
--- /dev/null
@@ -0,0 +1,52 @@
+#if !defined(AFX_ACTIONSELDLG_H__79C67B60_B619_4AE0_A40D_82D153048479__INCLUDED_)
+#define AFX_ACTIONSELDLG_H__79C67B60_B619_4AE0_A40D_82D153048479__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+// ActionSelDlg.h : header file
+//
+
+/////////////////////////////////////////////////////////////////////////////
+// CActionSelDlg dialog
+
+class CActionSelDlg : public CDialog
+{
+// Construction
+public:
+       DWORD *m_pdwActionList;
+       DWORD m_dwNumActions;
+       CActionSelDlg(CWnd* pParent = NULL);   // standard constructor
+   virtual ~CActionSelDlg();
+
+// Dialog Data
+       //{{AFX_DATA(CActionSelDlg)
+       enum { IDD = IDD_SELECT_ACTION };
+       CListCtrl       m_wndListCtrl;
+       //}}AFX_DATA
+
+
+// Overrides
+       // ClassWizard generated virtual function overrides
+       //{{AFX_VIRTUAL(CActionSelDlg)
+       protected:
+       virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
+       //}}AFX_VIRTUAL
+
+// Implementation
+protected:
+       CImageList m_imageList;
+
+       // Generated message map functions
+       //{{AFX_MSG(CActionSelDlg)
+       virtual BOOL OnInitDialog();
+       virtual void OnOK();
+       afx_msg void OnDblclkListActions(NMHDR* pNMHDR, LRESULT* pResult);
+       //}}AFX_MSG
+       DECLARE_MESSAGE_MAP()
+};
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_ACTIONSELDLG_H__79C67B60_B619_4AE0_A40D_82D153048479__INCLUDED_)
diff --git a/src/console/win32/EditActionDlg.cpp b/src/console/win32/EditActionDlg.cpp
new file mode 100644 (file)
index 0000000..1300bda
--- /dev/null
@@ -0,0 +1,55 @@
+// EditActionDlg.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "nxcon.h"
+#include "EditActionDlg.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CEditActionDlg dialog
+
+
+CEditActionDlg::CEditActionDlg(CWnd* pParent /*=NULL*/)
+       : CDialog(CEditActionDlg::IDD, pParent)
+{
+       //{{AFX_DATA_INIT(CEditActionDlg)
+       m_strData = _T("");
+       m_strName = _T("");
+       m_strRcpt = _T("");
+       m_strSubject = _T("");
+       m_iType = -1;
+       //}}AFX_DATA_INIT
+}
+
+
+void CEditActionDlg::DoDataExchange(CDataExchange* pDX)
+{
+       CDialog::DoDataExchange(pDX);
+       //{{AFX_DATA_MAP(CEditActionDlg)
+       DDX_Text(pDX, IDC_EDIT_DATA, m_strData);
+       DDV_MaxChars(pDX, m_strData, 4095);
+       DDX_Text(pDX, IDC_EDIT_NAME, m_strName);
+       DDV_MaxChars(pDX, m_strName, 63);
+       DDX_Text(pDX, IDC_EDIT_RCPT, m_strRcpt);
+       DDV_MaxChars(pDX, m_strRcpt, 255);
+       DDX_Text(pDX, IDC_EDIT_SUBJECT, m_strSubject);
+       DDV_MaxChars(pDX, m_strSubject, 255);
+       DDX_Radio(pDX, IDC_RADIO_EXEC, m_iType);
+       //}}AFX_DATA_MAP
+}
+
+
+BEGIN_MESSAGE_MAP(CEditActionDlg, CDialog)
+       //{{AFX_MSG_MAP(CEditActionDlg)
+               // NOTE: the ClassWizard will add message map macros here
+       //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CEditActionDlg message handlers
diff --git a/src/console/win32/EditActionDlg.h b/src/console/win32/EditActionDlg.h
new file mode 100644 (file)
index 0000000..20f3cb2
--- /dev/null
@@ -0,0 +1,50 @@
+#if !defined(AFX_EDITACTIONDLG_H__C1450122_B42F_452B_9F7C_E7D46C630564__INCLUDED_)
+#define AFX_EDITACTIONDLG_H__C1450122_B42F_452B_9F7C_E7D46C630564__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+// EditActionDlg.h : header file
+//
+
+/////////////////////////////////////////////////////////////////////////////
+// CEditActionDlg dialog
+
+class CEditActionDlg : public CDialog
+{
+// Construction
+public:
+       CEditActionDlg(CWnd* pParent = NULL);   // standard constructor
+
+// Dialog Data
+       //{{AFX_DATA(CEditActionDlg)
+       enum { IDD = IDD_ACTION_PROPERTIES };
+       CString m_strData;
+       CString m_strName;
+       CString m_strRcpt;
+       CString m_strSubject;
+       int             m_iType;
+       //}}AFX_DATA
+
+
+// Overrides
+       // ClassWizard generated virtual function overrides
+       //{{AFX_VIRTUAL(CEditActionDlg)
+       protected:
+       virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
+       //}}AFX_VIRTUAL
+
+// Implementation
+protected:
+
+       // Generated message map functions
+       //{{AFX_MSG(CEditActionDlg)
+               // NOTE: the ClassWizard will add member functions here
+       //}}AFX_MSG
+       DECLARE_MESSAGE_MAP()
+};
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_EDITACTIONDLG_H__C1450122_B42F_452B_9F7C_E7D46C630564__INCLUDED_)
index da3d9fb..005fbf3 100644 (file)
@@ -6,6 +6,7 @@
 #include "EventPolicyEditor.h"
 #include "RuleSeverityDlg.h"
 #include "RuleAlarmDlg.h"
+#include "ActionSelDlg.h"
 
 #ifdef _DEBUG
 #define new DEBUG_NEW
@@ -483,12 +484,15 @@ void CEventPolicyEditor::OnPolicyAdd()
 {
    switch(m_wndRuleList.GetCurrentColumn())
    {
-      case COL_SOURCE:  // Source
+      case COL_SOURCE:
          AddSource();
          break;
-      case COL_EVENT:  // Event
+      case COL_EVENT:
          AddEvent();
          break;
+      case COL_ACTION:
+         AddAction();
+         break;
    }
 }
 
@@ -666,7 +670,23 @@ void CEventPolicyEditor::OnPolicyDelete(void)
                }
             }
             break;
-         case COL_SEVERITY:     // Severity
+         case COL_ACTION:
+            if (m_pEventPolicy->pRuleList[iRow].dwNumActions > 0)
+            {
+               m_pEventPolicy->pRuleList[iRow].dwNumActions--;
+               memmove(&m_pEventPolicy->pRuleList[iRow].pdwActionList[iItem],
+                       &m_pEventPolicy->pRuleList[iRow].pdwActionList[iItem + 1],
+                       sizeof(DWORD) * (m_pEventPolicy->pRuleList[iRow].dwNumActions - iItem));
+               if (m_pEventPolicy->pRuleList[iRow].dwNumActions == 0)
+               {
+                  m_wndRuleList.ReplaceItem(iRow, iCol, 0, "Any", m_iImageAny);
+                  m_wndRuleList.EnableCellSelection(iRow, iCol, FALSE);
+               }
+               else
+               {
+                  m_wndRuleList.DeleteItem(iRow, iCol, iItem);
+               }
+            }
             break;
       }
    }
@@ -819,3 +839,37 @@ void CEventPolicyEditor::EditComment(int iRow)
       UpdateRow(iRow);
    }
 }
+
+
+//
+// Add new action to rule
+//
+
+void CEventPolicyEditor::AddAction()
+{
+   CActionSelDlg dlg;
+   DWORD i, j;
+   int iRow;
+
+   if (dlg.DoModal() == IDOK)
+   {
+      iRow = m_wndRuleList.GetCurrentRow();
+      for(i = 0; i < dlg.m_dwNumActions; i++)
+      {
+         // Check if object already in the list
+         for(j = 0; j < m_pEventPolicy->pRuleList[iRow].dwNumActions; j++)
+            if (m_pEventPolicy->pRuleList[iRow].pdwActionList[j] == dlg.m_pdwActionList[i])
+               break;
+         if (j == m_pEventPolicy->pRuleList[iRow].dwNumActions)
+         {
+            // New object, add it to source list
+            m_pEventPolicy->pRuleList[iRow].dwNumActions++;
+            m_pEventPolicy->pRuleList[iRow].pdwActionList = 
+               (DWORD *)realloc(m_pEventPolicy->pRuleList[iRow].pdwActionList,
+                  sizeof(DWORD) * m_pEventPolicy->pRuleList[iRow].dwNumActions);
+            m_pEventPolicy->pRuleList[iRow].pdwActionList[j] = dlg.m_pdwActionList[i];
+         }
+      }
+      UpdateRow(iRow);
+   }
+}
index 824347e..c692c03 100644 (file)
@@ -37,6 +37,7 @@ public:
 
 // Implementation
 protected:
+       void AddAction(void);
        int m_iImageAny;
        CImageList *m_pImageList;
        void AddEvent(void);
index eaac2ce..d1b80bd 100644 (file)
@@ -19,6 +19,7 @@ CEventSelDlg::CEventSelDlg(CWnd* pParent /*=NULL*/)
        : CDialog(CEventSelDlg::IDD, pParent)
 {
    m_pImageList = NULL;
+   m_pdwEventList = NULL;
 
        //{{AFX_DATA_INIT(CEventSelDlg)
                // NOTE: the ClassWizard will add member initialization here
@@ -28,6 +29,7 @@ CEventSelDlg::CEventSelDlg(CWnd* pParent /*=NULL*/)
 CEventSelDlg::~CEventSelDlg()
 {
    delete m_pImageList;
+   safe_free(m_pdwEventList);
 }
 
 void CEventSelDlg::DoDataExchange(CDataExchange* pDX)
@@ -113,7 +115,7 @@ void CEventSelDlg::OnOK()
    }
    else
    {
-      MessageBox("You should select at least one object", "Warning", MB_OK | MB_ICONEXCLAMATION);
+      MessageBox("You should select at least one event", "Warning", MB_OK | MB_ICONEXCLAMATION);
    }
 }
 
diff --git a/src/console/win32/NewActionDlg.cpp b/src/console/win32/NewActionDlg.cpp
new file mode 100644 (file)
index 0000000..f986183
--- /dev/null
@@ -0,0 +1,44 @@
+// NewActionDlg.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "nxcon.h"
+#include "NewActionDlg.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CNewActionDlg dialog
+
+
+CNewActionDlg::CNewActionDlg(CWnd* pParent /*=NULL*/)
+       : CDialog(CNewActionDlg::IDD, pParent)
+{
+       //{{AFX_DATA_INIT(CNewActionDlg)
+       m_strName = _T("");
+       //}}AFX_DATA_INIT
+}
+
+
+void CNewActionDlg::DoDataExchange(CDataExchange* pDX)
+{
+       CDialog::DoDataExchange(pDX);
+       //{{AFX_DATA_MAP(CNewActionDlg)
+       DDX_Text(pDX, IDC_EDIT_NAME, m_strName);
+       DDV_MaxChars(pDX, m_strName, 63);
+       //}}AFX_DATA_MAP
+}
+
+
+BEGIN_MESSAGE_MAP(CNewActionDlg, CDialog)
+       //{{AFX_MSG_MAP(CNewActionDlg)
+               // NOTE: the ClassWizard will add message map macros here
+       //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CNewActionDlg message handlers
diff --git a/src/console/win32/NewActionDlg.h b/src/console/win32/NewActionDlg.h
new file mode 100644 (file)
index 0000000..255bfbc
--- /dev/null
@@ -0,0 +1,46 @@
+#if !defined(AFX_NEWACTIONDLG_H__C445DD8E_1569_4F71_9A97_FEC8D909D952__INCLUDED_)
+#define AFX_NEWACTIONDLG_H__C445DD8E_1569_4F71_9A97_FEC8D909D952__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+// NewActionDlg.h : header file
+//
+
+/////////////////////////////////////////////////////////////////////////////
+// CNewActionDlg dialog
+
+class CNewActionDlg : public CDialog
+{
+// Construction
+public:
+       CNewActionDlg(CWnd* pParent = NULL);   // standard constructor
+
+// Dialog Data
+       //{{AFX_DATA(CNewActionDlg)
+       enum { IDD = IDD_NEW_ACTION };
+       CString m_strName;
+       //}}AFX_DATA
+
+
+// Overrides
+       // ClassWizard generated virtual function overrides
+       //{{AFX_VIRTUAL(CNewActionDlg)
+       protected:
+       virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
+       //}}AFX_VIRTUAL
+
+// Implementation
+protected:
+
+       // Generated message map functions
+       //{{AFX_MSG(CNewActionDlg)
+               // NOTE: the ClassWizard will add member functions here
+       //}}AFX_MSG
+       DECLARE_MESSAGE_MAP()
+};
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_NEWACTIONDLG_H__C445DD8E_1569_4F71_9A97_FEC8D909D952__INCLUDED_)
index b03682b..6fc604d 100644 (file)
@@ -33,6 +33,7 @@
 char g_szServer[MAX_SERVER_NAME_LEN] = "localhost";
 char g_szLogin[MAX_LOGIN_NAME_LEN] = "";
 char g_szPassword[MAX_PASSWORD_LEN] = "";
+DWORD g_dwEncryptionMethod = CSCP_ENCRYPTION_NONE;
 
 
 //
@@ -65,6 +66,7 @@ CImageList *g_pObjectNormalImageList = NULL;
 char *g_szStatusText[] = { "NORMAL", "WARNING", "MINOR", "MAJOR", "CRITICAL", "UNKNOWN", "UNMANAGED", "DISABLED", "TESTING" };
 char *g_szStatusTextSmall[] = { "Normal", "Warning", "Minor", "Major", "Critical", "Unknown", "Unmanaged", "Disabled", "Testing" };
 char *g_szObjectClass[] = { "Generic", "Subnet", "Node", "Interface", "Network", "Container", "Zone", "ServiceRoot" };
+char *g_szActionType[] = { "Execute", "Remote", "E-Mail", "SMS" };
 char *g_szInterfaceTypes[] = {
    "Unknown",
    "Other",
index 35e292a..866b5dc 100644 (file)
@@ -170,6 +170,7 @@ char *BuildSymbolicOIDString(struct tree *pNode);
 //
 
 NXC_ACTION *FindActionById(DWORD dwActionId);
+void UpdateActions(DWORD dwCode, NXC_ACTION *pAction);
 
 
 //
@@ -180,9 +181,11 @@ extern DWORD g_dwOptions;
 extern char g_szServer[];
 extern char g_szLogin[];
 extern char g_szPassword[];
+extern DWORD g_dwEncryptionMethod;
 extern char g_szWorkDir[];
 extern char *g_szStatusText[];
 extern char *g_szStatusTextSmall[];
+extern char *g_szActionType[];
 extern COLORREF g_statusColorTable[];
 extern char *g_szObjectClass[];
 extern char *g_szInterfaceTypes[];
index a9905d0..3f0ecae 100644 (file)
@@ -2,35 +2,35 @@
 
 [General Info]
 Version=1
-LastClass=CActionEditor
-LastTemplate=CMDIChildWnd
+LastClass=CActionSelDlg
+LastTemplate=CDialog
 NewFileInclude1=#include "stdafx.h"
 NewFileInclude2=#include "nxcon.h"
 LastPage=0
 
-ClassCount=56
+ClassCount=59
 Class1=CConsoleApp
 Class3=CMainFrame
 Class4=CChildFrame
 Class7=CEventBrowser
 Class9=CMapView
 
-ResourceCount=69
+ResourceCount=73
 Resource1=IDD_NEW_USER (English (U.S.))
-Resource2=IDA_MDI_DEFAULT
+Resource2=IDD_USER_PROPERTIES
 Resource3=IDD_ABOUTBOX (English (U.S.))
-Resource4=IDD_DCI_THRESHOLDS
-Resource5=IDD_DCI_COLLECTION
+Resource4=IDM_CONTEXT
+Resource5=IDA_OBJECT_BROWSER
 Class2=CChildView
 Class5=CAboutDlg
 Class6=CControlPanel
 Class8=CMapFrame
 Class10=CLoginDialog
-Resource6=IDD_OBJECT_SECURITY
+Resource6=IDD_EDIT_RULE_ALARM
 Class11=CProgressDialog
-Resource7=IDD_MIB_BROWSER
+Resource7=IDD_LOGIN
 Class12=CObjectBrowser
-Resource8=IDD_SET_PASSWORD
+Resource8=IDA_MDI_DEFAULT
 Class13=CObjectPropDlg
 Resource9=IDA_MDI_DEFAULT (English (U.S.))
 Resource10=IDD_OBJECT_PRESENTATION (English (U.S.))
@@ -46,7 +46,7 @@ Resource17=IDD_EDIT_RULE_SEVERITY (English (U.S.))
 Class16=CDebugFrame
 Resource18=IDD_SELECT_OBJECT (English (U.S.))
 Resource19=IDD_OBJECT_PROPERTIES (English (U.S.))
-Resource20=IDD_ABOUTBOX
+Resource20=IDD_THRESHOLD
 Class17=CObjectPreview
 Resource21=IDD_OBJECT_GENERAL (English (U.S.))
 Class18=CToolBox
@@ -59,32 +59,32 @@ Class23=CNodePropsGeneral
 Resource23=IDD_EDIT_RULE_ALARM (English (U.S.))
 Class24=CObjectPropCaps
 Class25=CObjectPropSheet
-Resource24=IDA_EPP
+Resource24=IDD_DCI_COLLECTION
 Class26=CRequestProcessingDlg
 Resource25=IDM_CONTEXT (English (U.S.))
 Resource26=IDD_PROGRESS (English (U.S.))
-Resource27=IDD_EDIT_RULE_COMMENT
+Resource27=IDD_OBJECT_NODE_GENERAL
 Resource28=IDD_DCI_THRESHOLDS (English (U.S.))
 Class27=CObjectPropsGeneral
 Resource29=IDD_OBJECT_NODE_GENERAL (English (U.S.))
 Class28=CObjectPropsSecurity
 Resource30=IDA_ALARM_BROWSER (English (U.S.))
-Resource31=IDD_USER_PROPERTIES
-Resource32=IDD_SELECT_OBJECT
+Resource31=IDD_ACTION_PROPERTIES
+Resource32=IDD_EDIT_EVENT
 Class29=CUserSelectDlg
-Resource33=IDD_OBJECT_GENERAL
+Resource33=IDD_EDIT_RULE_SEVERITY
 Class30=CUserEditor
 Resource34=IDD_DCI_PROPERTIES
 Class31=CNewUserDlg
-Resource35=IDD_REQUEST_PROCESSING
-Resource36=IDA_ALARM_BROWSER
+Resource35=IDD_OBJECT_PRESENTATION
+Resource36=IDD_DCI_THRESHOLDS
 Class32=CUserPropDlg
 Resource37=IDD_OBJECT_SECURITY (English (U.S.))
-Resource38=IDR_MAINFRAME
+Resource38=IDD_NEW_USER
 Class33=CGroupPropDlg
-Resource39=IDD_THRESHOLD
-Resource40=IDA_OBJECT_BROWSER
-Resource41=IDM_VIEW_SPECIFIC
+Resource39=IDD_ABOUTBOX
+Resource40=IDD_GROUP_PROPERTIES
+Resource41=IDD_OBJECT_GENERAL
 Resource42=IDD_SET_PASSWORD (English (U.S.))
 Class34=CPasswordChangeDlg
 Class35=CNodeSummary
@@ -99,43 +99,50 @@ Class40=CGraph
 Class41=CGraphFrame
 Class42=CDCIThresholdsPage
 Resource46=IDD_EDIT_EVENT (English (U.S.))
-Resource47=IDD_LOGIN
-Resource48=IDD_OBJECT_NODE_GENERAL
+Resource47=IDD_CP_GENERAL (English (U.S.))
+Resource48=IDD_EDIT_RULE_COMMENT
 Class43=CThresholdDlg
 Resource49=IDD_THRESHOLD (English (U.S.))
-Resource50=IDD_SELECT_USER
+Resource50=IDD_CP_GENERAL
 Class44=CMIBBrowserDlg
 Class45=CEventPolicyEditor
 Class46=CRuleList
 Class47=CRuleHeader
 Resource51=IDD_LOGIN (English (U.S.))
-Resource52=IDM_CONTEXT
+Resource52=IDM_VIEW_SPECIFIC
 Class48=CObjectSelDlg
-Resource53=IDD_EDIT_RULE_SEVERITY
-Resource54=IDD_SELECT_EVENT
+Resource53=IDD_OBJECT_SECURITY
+Resource54=IDD_OBJECT_CAPS
 Class49=CRuleCommentDlg
-Resource55=IDD_OBJECT_CAPS
+Resource55=IDD_SELECT_EVENT
 Class50=CEventSelDlg
-Resource56=IDD_NEW_USER
+Resource56=IDD_NEW_ACTION
 Resource57=IDM_VIEW_SPECIFIC (English (U.S.))
 Resource58=IDD_OBJECT_CAPS (English (U.S.))
 Resource59=IDA_EPP (English (U.S.))
 Resource60=IDD_SELECT_USER (English (U.S.))
 Class51=CObjectPropsPresentation
 Resource61=IDD_USER_PROPERTIES (English (U.S.))
-Resource62=IDD_EDIT_EVENT
+Resource62=IDD_SELECT_OBJECT
 Class52=CRuleSeverityDlg
-Resource63=IDD_OBJECT_PRESENTATION
+Resource63=IDA_ALARM_BROWSER
 Class53=CRuleAlarmDlg
 Class54=CAlarmBrowser
-Resource64=IDD_GROUP_PROPERTIES
-Resource65=IDD_EDIT_RULE_ALARM
+Resource64=IDR_MAINFRAME
+Resource65=IDD_SELECT_USER
 Resource66=IDD_MIB_BROWSER (English (U.S.))
 Resource67=IDD_GROUP_PROPERTIES (English (U.S.))
 Resource68=IDD_REQUEST_PROCESSING (English (U.S.))
 Class55=CConsolePropsGeneral
 Class56=CActionEditor
-Resource69=IDD_CP_GENERAL (English (U.S.))
+Resource69=IDD_MIB_BROWSER
+Resource70=IDD_REQUEST_PROCESSING
+Class57=CNewActionDlg
+Resource71=IDA_EPP
+Class58=CEditActionDlg
+Resource72=IDD_SET_PASSWORD
+Class59=CActionSelDlg
+Resource73=IDD_SELECT_ACTION
 
 [CLS:CConsoleApp]
 Type=0
@@ -200,13 +207,10 @@ Command12=ID_VIEW_DEBUG
 Command13=ID_VIEW_TOOLBAR
 Command14=ID_VIEW_STATUS_BAR
 Command15=ID_VIEW_REFRESH
-Command16=ID_CONTROLPANEL_EVENTS
-Command17=ID_CONTROLPANEL_EVENTPOLICY
-Command18=ID_CONTROLPANEL_USERS
-Command19=ID_TOOLS_MIBBROWSER
-Command20=ID_TOOLS_ADDNODE
-Command21=ID_APP_ABOUT
-CommandCount=21
+Command16=ID_TOOLS_MIBBROWSER
+Command17=ID_TOOLS_ADDNODE
+Command18=ID_APP_ABOUT
+CommandCount=18
 
 [TB:IDR_MAINFRAME]
 Type=1
@@ -228,21 +232,22 @@ Command3=ID_EDIT_PASTE
 Command4=ID_EDIT_UNDO
 Command5=ID_EDIT_CUT
 Command6=ID_TOOLS_ADDNODE
-Command7=ID_VIEW_MAP
-Command8=ID_VIEW_OBJECTBROWSER
-Command9=ID_CONTROLPANEL_EVENTPOLICY
-Command10=ID_VIEW_REFRESH
-Command11=ID_NEXT_PANE
-Command12=ID_PREV_PANE
-Command13=ID_VIEW_NETWORKSUMMARY
-Command14=ID_VIEW_ALARMS
-Command15=ID_VIEW_EVENTS
-Command16=ID_VIEW_CONTROLPANEL
-Command17=ID_EDIT_COPY
-Command18=ID_EDIT_PASTE
-Command19=ID_EDIT_CUT
-Command20=ID_EDIT_UNDO
-CommandCount=20
+Command7=ID_VIEW_DEBUG
+Command8=ID_VIEW_MAP
+Command9=ID_VIEW_OBJECTBROWSER
+Command10=ID_CONTROLPANEL_EVENTPOLICY
+Command11=ID_VIEW_REFRESH
+Command12=ID_NEXT_PANE
+Command13=ID_PREV_PANE
+Command14=ID_VIEW_NETWORKSUMMARY
+Command15=ID_VIEW_ALARMS
+Command16=ID_VIEW_EVENTS
+Command17=ID_VIEW_CONTROLPANEL
+Command18=ID_EDIT_COPY
+Command19=ID_EDIT_PASTE
+Command20=ID_EDIT_CUT
+Command21=ID_EDIT_UNDO
+CommandCount=21
 
 [CLS:CControlPanel]
 Type=0
@@ -600,7 +605,11 @@ Command43=ID_ALARM_ACKNOWLEGE
 Command44=ID_ALARM_DELETE
 Command45=ID_ALARM_GOTOSOURCE
 Command46=ID_UPDATE_EVENT_LIST
-CommandCount=46
+Command47=ID_CONTROLPANEL_ACTIONS
+Command48=ID_CONTROLPANEL_EVENTS
+Command49=ID_CONTROLPANEL_EVENTPOLICY
+Command50=ID_CONTROLPANEL_USERS
+CommandCount=50
 
 [ACL:IDA_MDI_DEFAULT]
 Type=1
@@ -1196,7 +1205,11 @@ Command47=ID_POLICY_DISABLERULE
 Command48=ID_ALARM_ACKNOWLEGE
 Command49=ID_ALARM_DELETE
 Command50=ID_ALARM_GOTOSOURCE
-CommandCount=50
+Command51=ID_ACTION_NEW
+Command52=ID_ACTION_RENAME
+Command53=ID_ACTION_DELETE
+Command54=ID_ACTION_PROPERTIES
+CommandCount=54
 
 [MNU:IDM_CONTEXT (English (U.S.))]
 Type=1
@@ -1810,3 +1823,74 @@ BaseClass=CMDIChildWnd
 Filter=M
 VirtualFilter=mfWC
 
+[DLG:IDD_CP_GENERAL]
+Type=1
+Class=CConsolePropsGeneral
+ControlCount=3
+Control1=IDC_STATIC,button,1342177287
+Control2=IDC_CHECK_EXPAND,button,1342242819
+Control3=IDC_CHECK_GRID,button,1342242819
+
+[DLG:IDD_NEW_ACTION]
+Type=1
+Class=CNewActionDlg
+ControlCount=4
+Control1=IDC_EDIT_NAME,edit,1350631552
+Control2=IDOK,button,1342242817
+Control3=IDCANCEL,button,1342242816
+Control4=IDC_STATIC,static,1342308352
+
+[CLS:CNewActionDlg]
+Type=0
+HeaderFile=NewActionDlg.h
+ImplementationFile=NewActionDlg.cpp
+BaseClass=CDialog
+Filter=D
+VirtualFilter=dWC
+LastObject=CNewActionDlg
+
+[DLG:IDD_ACTION_PROPERTIES]
+Type=1
+Class=CEditActionDlg
+ControlCount=15
+Control1=IDC_EDIT_NAME,edit,1350631552
+Control2=IDC_RADIO_EXEC,button,1342308361
+Control3=IDC_RADIO_REXEC,button,1342177289
+Control4=IDC_RADIO_EMAIL,button,1342177289
+Control5=IDC_RADIO4,button,1342177289
+Control6=IDC_EDIT_RCPT,edit,1350631552
+Control7=IDC_EDIT_SUBJECT,edit,1350631552
+Control8=IDC_EDIT_DATA,edit,1350631552
+Control9=IDOK,button,1342242817
+Control10=IDCANCEL,button,1342242816
+Control11=IDC_STATIC,static,1342308352
+Control12=IDC_STATIC,button,1342177287
+Control13=IDC_STATIC,static,1342308352
+Control14=IDC_STATIC,static,1342308352
+Control15=IDC_STATIC,static,1342308352
+
+[CLS:CEditActionDlg]
+Type=0
+HeaderFile=EditActionDlg.h
+ImplementationFile=EditActionDlg.cpp
+BaseClass=CDialog
+Filter=D
+VirtualFilter=dWC
+LastObject=CEditActionDlg
+
+[DLG:IDD_SELECT_ACTION]
+Type=1
+Class=CActionSelDlg
+ControlCount=3
+Control1=IDOK,button,1342242817
+Control2=IDCANCEL,button,1342242816
+Control3=IDC_LIST_ACTIONS,SysListView32,1342275609
+
+[CLS:CActionSelDlg]
+Type=0
+HeaderFile=ActionSelDlg.h
+ImplementationFile=ActionSelDlg.cpp
+BaseClass=CDialog
+Filter=D
+VirtualFilter=dWC
+
index 5dd7856..3355842 100644 (file)
@@ -203,6 +203,7 @@ BOOL CConsoleApp::InitInstance()
    g_dwOptions = GetProfileInt(_T("General"), _T("Options"), 0);
    strcpy(g_szServer, (LPCTSTR)GetProfileString(_T("Connection"), _T("Server"), _T("localhost")));
    strcpy(g_szLogin, (LPCTSTR)GetProfileString(_T("Connection"), _T("Login"), NULL));
+   g_dwEncryptionMethod = GetProfileInt(_T("Connection"), _T("Encryption"), CSCP_ENCRYPTION_NONE);
 
    // Create mutex for action list access
    g_mutexActionListAccess = CreateMutex(NULL, FALSE, NULL);
@@ -550,6 +551,7 @@ void CConsoleApp::OnConnectToServer()
 
    dlgLogin.m_szServer = g_szServer;
    dlgLogin.m_szLogin = g_szLogin;
+   dlgLogin.m_iEncryption = g_dwEncryptionMethod;
    do
    {
       if (dlgLogin.DoModal() != IDOK)
@@ -560,10 +562,12 @@ void CConsoleApp::OnConnectToServer()
       strcpy(g_szServer, (LPCTSTR)dlgLogin.m_szServer);
       strcpy(g_szLogin, (LPCTSTR)dlgLogin.m_szLogin);
       strcpy(g_szPassword, (LPCTSTR)dlgLogin.m_szPassword);
+      g_dwEncryptionMethod = dlgLogin.m_iEncryption;
 
       // Save last connection parameters
       WriteProfileString(_T("Connection"), _T("Server"), g_szServer);
       WriteProfileString(_T("Connection"), _T("Login"), g_szLogin);
+      WriteProfileInt(_T("Connection"), _T("Encryption"), g_dwEncryptionMethod);
 
       // Initiate connection
       dwResult = DoLogin();
@@ -632,6 +636,11 @@ void CConsoleApp::EventHandler(DWORD dwEvent, DWORD dwCode, void *pArg)
                m_pMainWnd->PostMessage(WM_ALARM_UPDATE, dwCode, 
                                        (LPARAM)nx_memdup(pArg, sizeof(NXC_ALARM)));
                break;
+            case NX_NOTIFY_ACTION_CREATED:
+            case NX_NOTIFY_ACTION_MODIFIED:
+            case NX_NOTIFY_ACTION_DELETED:
+               UpdateActions(dwCode, (NXC_ACTION *)pArg);
+               break;
             default:
                break;
          }
index 805df05..fee2ec5 100644 (file)
@@ -105,6 +105,10 @@ SOURCE=.\ActionEditor.cpp
 # End Source File
 # Begin Source File
 
+SOURCE=.\ActionSelDlg.cpp
+# End Source File
+# Begin Source File
+
 SOURCE=.\AlarmBrowser.cpp
 # End Source File
 # Begin Source File
@@ -145,6 +149,10 @@ SOURCE=.\draw.cpp
 # End Source File
 # Begin Source File
 
+SOURCE=.\EditActionDlg.cpp
+# End Source File
+# Begin Source File
+
 SOURCE=.\EditBox.cpp
 # End Source File
 # Begin Source File
@@ -209,6 +217,10 @@ SOURCE=.\NetSummaryFrame.cpp
 # End Source File
 # Begin Source File
 
+SOURCE=.\NewActionDlg.cpp
+# End Source File
+# Begin Source File
+
 SOURCE=.\NewUserDlg.cpp
 # End Source File
 # Begin Source File
@@ -334,6 +346,10 @@ SOURCE=.\ActionEditor.h
 # End Source File
 # Begin Source File
 
+SOURCE=.\ActionSelDlg.h
+# End Source File
+# Begin Source File
+
 SOURCE=.\AlarmBrowser.h
 # End Source File
 # Begin Source File
@@ -366,6 +382,10 @@ SOURCE=.\DebugFrame.h
 # End Source File
 # Begin Source File
 
+SOURCE=.\EditActionDlg.h
+# End Source File
+# Begin Source File
+
 SOURCE=.\EditBox.h
 # End Source File
 # Begin Source File
@@ -430,6 +450,10 @@ SOURCE=.\NetSummaryFrame.h
 # End Source File
 # Begin Source File
 
+SOURCE=.\NewActionDlg.h
+# End Source File
+# Begin Source File
+
 SOURCE=.\NewUserDlg.h
 # End Source File
 # Begin Source File
index ff7aea8..3b46fe8 100644 (file)
@@ -388,6 +388,14 @@ BEGIN
         MENUITEM "&Delete",                     ID_ALARM_DELETE
         MENUITEM "&Go to source",               ID_ALARM_GOTOSOURCE
     END
+    POPUP "Action"
+    BEGIN
+        MENUITEM "&New...",                     ID_ACTION_NEW
+        MENUITEM "&Rename",                     ID_ACTION_RENAME
+        MENUITEM "&Delete",                     ID_ACTION_DELETE
+        MENUITEM SEPARATOR
+        MENUITEM "&Properties...",              ID_ACTION_PROPERTIES
+    END
 END
 
 
@@ -498,8 +506,8 @@ BEGIN
     CONTROL         "",IDC_STATIC,"Static",SS_ETCHEDHORZ,44,141,163,1
     CONTROL         "&No encryption",IDC_RADIO_CLEAR,"Button",
                     BS_AUTORADIOBUTTON | WS_GROUP,7,150,60,10
-    CONTROL         "Encrypt connection using &Blowfish algorithm",
-                    IDC_RADIO_BLOWFISH,"Button",BS_AUTORADIOBUTTON,7,164,154,
+    CONTROL         "Encrypt connection using &Blowfish + SHA1",
+                    IDC_RADIO_BLOWFISH,"Button",BS_AUTORADIOBUTTON,7,164,151,
                     10
 END
 
@@ -962,6 +970,56 @@ BEGIN
                     BS_AUTOCHECKBOX | WS_TABSTOP,13,28,85,10
 END
 
+IDD_NEW_ACTION DIALOG DISCARDABLE  0, 0, 174, 60
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Create Action"
+FONT 8, "MS Sans Serif"
+BEGIN
+    EDITTEXT        IDC_EDIT_NAME,7,18,160,14,ES_AUTOHSCROLL
+    DEFPUSHBUTTON   "OK",IDOK,63,39,50,14
+    PUSHBUTTON      "Cancel",IDCANCEL,117,39,50,14
+    LTEXT           "Action name",IDC_STATIC,7,7,40,8
+END
+
+IDD_ACTION_PROPERTIES DIALOG DISCARDABLE  0, 0, 235, 188
+STYLE DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_POPUP | WS_CAPTION | 
+    WS_SYSMENU
+CAPTION "Action Properties"
+FONT 8, "MS Sans Serif"
+BEGIN
+    EDITTEXT        IDC_EDIT_NAME,7,17,161,14,ES_AUTOHSCROLL
+    CONTROL         "&Execute command on management server",IDC_RADIO_EXEC,
+                    "Button",BS_AUTORADIOBUTTON | WS_GROUP,13,45,149,10
+    CONTROL         "Execute action on remote &agent",IDC_RADIO_REXEC,"Button",
+                    BS_AUTORADIOBUTTON,13,56,117,10
+    CONTROL         "Send e-&mail",IDC_RADIO_EMAIL,"Button",
+                    BS_AUTORADIOBUTTON,13,67,53,10
+    CONTROL         "Send &SMS message to mobile phone",IDC_RADIO4,"Button",
+                    BS_AUTORADIOBUTTON,13,78,132,10
+    EDITTEXT        IDC_EDIT_RCPT,7,107,161,14,ES_AUTOHSCROLL
+    EDITTEXT        IDC_EDIT_SUBJECT,7,137,161,14,ES_AUTOHSCROLL
+    EDITTEXT        IDC_EDIT_DATA,7,167,161,14,ES_AUTOHSCROLL
+    DEFPUSHBUTTON   "OK",IDOK,178,7,50,14
+    PUSHBUTTON      "Cancel",IDCANCEL,178,24,50,14
+    LTEXT           "Name",IDC_STATIC,7,7,20,8
+    GROUPBOX        "Type",IDC_STATIC,7,34,161,58
+    LTEXT           "Recipent address",IDC_STATIC,7,96,56,8
+    LTEXT           "E-mail subject",IDC_STATIC,7,126,44,8
+    LTEXT           "Command / message text",IDC_STATIC,7,156,81,8
+END
+
+IDD_SELECT_ACTION DIALOGEX 0, 0, 259, 146
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Select Action"
+FONT 8, "MS Sans Serif"
+BEGIN
+    DEFPUSHBUTTON   "OK",IDOK,202,7,50,14
+    PUSHBUTTON      "Cancel",IDCANCEL,202,25,50,14
+    CONTROL         "List1",IDC_LIST_ACTIONS,"SysListView32",LVS_REPORT | 
+                    LVS_SHOWSELALWAYS | LVS_SORTASCENDING | LVS_NOSORTHEADER | 
+                    WS_TABSTOP,7,7,189,132,WS_EX_CLIENTEDGE
+END
+
 
 #ifndef _MAC
 /////////////////////////////////////////////////////////////////////////////
@@ -1205,6 +1263,30 @@ BEGIN
         TOPMARGIN, 7
         BOTTOMMARGIN, 110
     END
+
+    IDD_NEW_ACTION, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 167
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 53
+    END
+
+    IDD_ACTION_PROPERTIES, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 228
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 181
+    END
+
+    IDD_SELECT_ACTION, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 252
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 139
+    END
 END
 #endif    // APSTUDIO_INVOKED
 
index e911a58..2ce1e39 100644 (file)
 #define IDI_EXEC                        214
 #define IDI_REXEC                       215
 #define IDD_CP_GENERAL                  216
+#define IDD_NEW_ACTION                  217
+#define IDD_ACTION_PROPERTIES           218
+#define IDD_SELECT_ACTION               219
 #define IDC_EDIT_SERVER                 1000
 #define IDC_EDIT_LOGIN                  1001
 #define IDC_EDIT_PASSWORD               1002
 #define IDC_TREE_VIEW                   1006
 #define IDC_EDIT_NAME                   1007
 #define IDC_EDIT_ID                     1008
+#define IDC_EDIT_RCPT                   1008
 #define IDC_EDIT_MESSAGE                1009
+#define IDC_EDIT_SUBJECT                1009
 #define IDC_EDIT_DESCRIPTION            1010
+#define IDC_EDIT_DATA                   1010
 #define IDC_COMBO_SEVERITY              1011
 #define IDC_CHECK_LOG                   1012
 #define IDC_EDIT_PRIMARY_IP             1015
 #define IDC_CHECK_MANAGE_ACTIONS        1142
 #define IDC_CHECK_EXPAND                1143
 #define IDC_CHECK_GRID                  1144
+#define IDC_RADIO_EXEC                  1147
+#define IDC_RADIO_REXEC                 1148
+#define IDC_RADIO_EMAIL                 1149
+#define IDC_RADIO4                      1150
+#define IDC_LIST_ACTIONS                1152
 #define ID_VIEW_CONTROLPANEL            32771
 #define ID_VIEW_EVENTS                  32774
 #define ID_VIEW_MAP                     32776
 #define ID_ALARM_DELETE                 32866
 #define ID_ALARM_GOTOSOURCE             32867
 #define ID_CONTROLPANEL_ACTIONS         32871
+#define ID_ACTION_NEW                   32872
+#define ID_ACTION_RENAME                32873
+#define ID_ACTION_DELETE                32874
+#define ID_ACTION_PROPERTIES            32875
 #define IDS_GETFOLDERPATH_FAILED        61216
 #define IDS_WORKDIR_CREATION_FAILED     61217
 
 #ifdef APSTUDIO_INVOKED
 #ifndef APSTUDIO_READONLY_SYMBOLS
 #define _APS_3D_CONTROLS                     1
-#define _APS_NEXT_RESOURCE_VALUE        217
-#define _APS_NEXT_COMMAND_VALUE         32872
-#define _APS_NEXT_CONTROL_VALUE         1145
+#define _APS_NEXT_RESOURCE_VALUE        220
+#define _APS_NEXT_COMMAND_VALUE         32876
+#define _APS_NEXT_CONTROL_VALUE         1153
 #define _APS_NEXT_SYMED_VALUE           119
 #endif
 #endif
index 69b0f13..ed7052d 100644 (file)
@@ -340,3 +340,58 @@ NXC_ACTION *FindActionById(DWORD dwActionId)
          return &g_pActionList[i];
    return NULL;
 }
+
+
+//
+// Update action list with information received from server
+//
+
+void UpdateActions(DWORD dwCode, NXC_ACTION *pAction)
+{
+   DWORD i;
+   NXC_ACTION *pCurrAction;
+
+   LockActions();
+
+   // Find action with given ID
+   pCurrAction = FindActionById(pAction->dwId);
+
+   // Update action list depending on notification code
+   switch(dwCode)
+   {
+      case NX_NOTIFY_ACTION_CREATED:
+      case NX_NOTIFY_ACTION_MODIFIED:
+         if (pCurrAction == NULL)
+         {
+            i = g_dwNumActions;
+            g_dwNumActions++;
+            g_pActionList = (NXC_ACTION *)realloc(g_pActionList, sizeof(NXC_ACTION) * g_dwNumActions);
+            memcpy(&g_pActionList[i], pAction, sizeof(NXC_ACTION));
+            g_pActionList[i].pszData = strdup(pAction->pszData);
+         }
+         else
+         {
+            // Action with given id already exist, just update it
+            safe_free(pCurrAction->pszData);
+            memcpy(pCurrAction, pAction, sizeof(NXC_ACTION));
+            pCurrAction->pszData = strdup(pAction->pszData);
+         }
+         break;
+      case NX_NOTIFY_ACTION_DELETED:
+         if (pCurrAction != NULL)
+         {
+            for(i = 0; i < g_dwNumActions; i++)
+               if (g_pActionList[i].dwId == pAction->dwId)
+               {
+                  g_dwNumActions--;
+                  safe_free(g_pActionList[i].pszData);
+                  memmove(&g_pActionList[i], &g_pActionList[i + 1], 
+                          sizeof(NXC_ACTION) * (g_dwNumActions - i));
+                  break;
+               }
+         }
+         break;
+   }
+
+   UnlockActions();
+}