"Fossies" - the Fresh Open Source Software Archive

Member "netxms-3.8.166/src/server/hdlink/jira/jira.h" (23 Feb 2021, 2489 Bytes) of package /linux/misc/netxms-3.8.166.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "jira.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2 ** NetXMS - Network Management System
    3 ** Helpdesk link module for Jira
    4 ** Copyright (C) 2014 Raden Solutions
    5 **
    6 ** This program is free software; you can redistribute it and/or modify
    7 ** it under the terms of the GNU General Public License as published by
    8 ** the Free Software Foundation; either version 2 of the License, or
    9 ** (at your option) any later version.
   10 **
   11 ** This program is distributed in the hope that it will be useful,
   12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
   13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   14 ** GNU General Public License for more details.
   15 **
   16 ** You should have received a copy of the GNU General Public License
   17 ** along with this program; if not, write to the Free Software
   18 ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
   19 **
   20 ** File: jira.h
   21 **
   22 **/
   23 
   24 #ifndef _jira_h_
   25 #define _jira_h_
   26 
   27 #include <nms_core.h>
   28 #include <hdlink.h>
   29 #include <curl/curl.h>
   30 
   31 #define JIRA_MAX_LOGIN_LEN          64
   32 #define JIRA_MAX_PASSWORD_LEN       64
   33 #define JIRA_MAX_PROJECT_CODE_LEN   32
   34 #define JIRA_MAX_ISSUE_TYPE_LEN     32
   35 #define JIRA_MAX_COMPONENT_NAME_LEN 128
   36 
   37 /**
   38  * Request data for cURL call
   39  */
   40 struct RequestData
   41 {
   42    size_t size;
   43    size_t allocated;
   44    char *data;
   45 };
   46 
   47 /**
   48  * Jira project's component
   49  */
   50 class ProjectComponent
   51 {
   52 public:
   53    INT64 m_id;
   54    TCHAR *m_name;
   55 
   56    ProjectComponent(INT64 id, const char *name)
   57    {
   58       m_id = id;
   59 #ifdef UNICODE
   60       m_name = WideStringFromUTF8String(CHECK_NULL_EX_A(name));
   61 #else
   62       m_name = strdup(CHECK_NULL_EX(name));
   63 #endif
   64    }
   65 
   66    ~ProjectComponent()
   67    {
   68       free(m_name);
   69    }
   70 };
   71 
   72 /**
   73  * Module class
   74  */
   75 class JiraLink : public HelpDeskLink
   76 {
   77 private:
   78    MUTEX m_mutex;
   79    char m_serverUrl[MAX_PATH];
   80    char m_login[JIRA_MAX_LOGIN_LEN];
   81    char m_password[JIRA_MAX_PASSWORD_LEN];
   82    CURL *m_curl;
   83    char m_errorBuffer[CURL_ERROR_SIZE];
   84 
   85    void lock() { MutexLock(m_mutex); }
   86    void unlock() { MutexUnlock(m_mutex); }
   87    UINT32 connect();
   88    void disconnect();
   89    ObjectArray<ProjectComponent> *getProjectComponents(const char *project);
   90 
   91 public:
   92    JiraLink();
   93    virtual ~JiraLink();
   94 
   95     virtual const TCHAR *getName();
   96     virtual const TCHAR *getVersion();
   97 
   98    virtual bool init();
   99    virtual bool checkConnection();
  100    virtual UINT32 openIssue(const TCHAR *description, TCHAR *hdref);
  101    virtual UINT32 addComment(const TCHAR *hdref, const TCHAR *comment);
  102    virtual bool getIssueUrl(const TCHAR *hdref, TCHAR *url, size_t size);
  103 };
  104 
  105 #endif