PEP 55 Update license on source files to current license text and date
[tpot/pegasus/.git] / src / Providers / ManagedSystem / NTPService / NTPService.h
1 //%2003////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (c) 2000, 2001, 2002  BMC Software, Hewlett-Packard Development
4 // Company, L. P., IBM Corp., The Open Group, Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.;
6 // IBM Corp.; EMC Corporation, The Open Group.
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to
10 // deal in the Software without restriction, including without limitation the
11 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 // sell copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 // 
15 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
16 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
17 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
18 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
19 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 //
24 //==============================================================================
25 //
26 // Author: Paulo F. Borges (pfborges@wowmail.com)
27 //
28 // Modified By: Jair Francisco T. dos Santos (t.dos.santos.francisco@non.hp.com)
29 //==============================================================================
30 // Based on DNSService.h file
31 //%/////////////////////////////////////////////////////////////////////////////
32 #ifndef _NTP_H
33 #define _NTP_H
34
35 //------------------------------------------------------------------------------
36 // INCLUDES
37 //------------------------------------------------------------------------------
38 //Pegasus includes
39 #include <Pegasus/Common/Config.h>
40 #include <Pegasus/Common/String.h>
41 #include <Pegasus/Common/CIMDateTime.h>
42 #include <Pegasus/Common/OperationContext.h>
43 #include <Pegasus/Common/CIMName.h>
44
45
46 //------------------------------------------------------------------------------
47 PEGASUS_USING_PEGASUS;
48 PEGASUS_USING_STD;
49
50 // Role definitions
51 static const String NTP_ROLE_CLIENT("server");
52
53 // Defines
54 #define CLASS_NAME CIMName ("PG_NTPService")
55 #define SYSTEM_CREATION_CLASS_NAME CIMName ("CIM_UnitaryComputerSystem")
56 #define CREATION_CLASS_NAME CIMName ("PG_NTPService")
57 static const String NTP_CAPTION("NTP daemon");
58 static const String NTP_DESCRIPTION("Describes the Network Time Protocol (NTP) daemon");
59
60 // Insert MOF property definitions
61 static const int MAX_KEYS = 4;
62 static const String PROPERTY_SYSTEM_CREATION_CLASS_NAME("SystemCreationClassName");
63 static const String PROPERTY_SYSTEM_NAME("SystemName");
64 static const String PROPERTY_CREATION_CLASS_NAME("CreationClassName");
65 static const String PROPERTY_NAME("Name");
66 static const String PROPERTY_CAPTION("Caption");
67 static const String PROPERTY_DESCRIPTION("Description");
68 static const String PROPERTY_SERVER_ADDRESS("ServerAddress");
69     
70 //------------------------------------------------------------------------------
71 // Class [NTPService] Definition
72 //------------------------------------------------------------------------------
73 class NTPService
74 {
75     public:
76         //Constructor/Destructor
77         NTPService(void);
78         ~NTPService(void);
79         
80     public:  
81         //
82         // Public Functions - Interface
83         //
84
85         // This function retrieve TRUE, if user have permissions, otherwise FALSE
86         Boolean AccessOk(const OperationContext & context);
87
88         // This function retrieves the system name
89         Boolean getSystemName(String & hostName);
90   
91         // This function retrieves the local host name
92         Boolean getLocalHostName(String & hostName);
93
94         // This function returns TRUE if the Service Name is valid
95         // returns the Name property on the 'strValue' argument
96         Boolean getNTPName(String & strValue);
97
98         // This function returns TRUE if the Caption is valid
99         // returns the Caption property on the 'strValue' argument
100         Boolean getCaption(String & strValue);
101
102         // This function returns TRUE if the Description is valid
103         // returns the Description property on the 'strValue' argument
104         Boolean getDescription(String & strValue);
105
106         // This function returns TRUE if the ServerAddress is valid
107         // returns the ServerAddress property on the 'strValue' argument
108         Boolean getServerAddress(Array<String> & strValue);
109
110     private:
111
112         //
113         // Private Functions
114         //
115
116         // This function retrieves the NTP information from "/etc/ntp.conf" file
117         Boolean getNTPInfo(void);
118
119         // This function resolves host name servers
120         Boolean getHostName(String serverAddress, String & nameServer);
121
122         // This function verify if host is address
123         Boolean isHostAddress(String host);
124
125         // This function resolves address servers
126         Boolean getHostAddress(String nameServer, String & serverAddress);
127
128         // This function retrieves the key value from line buffer
129         Boolean getKeyValue(String strLine, String & strValue);
130
131         //
132         // Class Variables
133         //
134         String ntpName;
135         Array<String> ntpServerAddress;         
136 };
137 #endif