1 /*****************************************************************************/ 2 /* */ 3 /* ICSHORT.H */ 4 /* */ 5 /* (C) 1996-97 Ullrich von Bassewitz */ 6 /* Wacholderweg 14 */ 7 /* D-70597 Stuttgart */ 8 /* EMail: uz@ibb.schwaben.com */ 9 /* */ 10 /*****************************************************************************/ 11 12 13 14 // $Id$ 15 // 16 // $Log$ 17 // 18 // 19 20 21 22 // Handle the short dial numbers 23 24 25 26 #ifndef _ICSHORT_H 27 #define _ICSHORT_H 28 29 30 31 #include "coll.h" 32 33 #include "istecmsg.h" 34 35 36 37 /*****************************************************************************/ 38 /* Data */ 39 /*****************************************************************************/ 40 41 42 43 // Values for the "Usage" field in class ShortNumberInfo 44 const unsigned usUnused = 0; 45 const unsigned usShortcut = 1; 46 const unsigned usAutoDial = 2; 47 const unsigned usLock = 3; 48 49 50 51 /*****************************************************************************/ 52 /* class ShortNumberInfo */ 53 /*****************************************************************************/ 54 55 56 57 class ShortNumberInfo: public Streamable { 58 59 friend class ShortNumberColl; 60 61 u16 Memory; // Memory location of this number 62 u16 Usage; // Usage 63 String Number; // Stored number 64 unsigned char AutoDial; // "Babyruf" 65 unsigned char Devices; // Valid for which device? 66 unsigned char Signaling; // Ring attribute 67 unsigned char Locked; 68 69 70 public: 71 ShortNumberInfo (unsigned aMemory); 72 // Create a ShortNumberInfo 73 74 ShortNumberInfo (const IstecMsg& Msg); 75 // Create a ShortNumberInfo from an istec message 76 77 ShortNumberInfo (StreamableInit); 78 // Build constructor 79 80 virtual void Load (Stream& S); 81 // Load the object from a stream 82 83 virtual void Store (Stream& S) const; 84 // Store the object into a stream 85 86 virtual u16 StreamableID () const; 87 // Return the stream ID 88 89 static Streamable* Build (); 90 // Return a new instance 91 92 void Unpack (const IstecMsg& Msg); 93 // Unpack the contents of a message into the struct 94 95 void Pack (IstecMsg& Msg) const; 96 // Pack the data into a message ready for download to the istec 97 98 unsigned GetMemory () const; 99 // Return the memory setting 100 101 unsigned GetUsage () const; 102 // Get the usage info 103 104 void SetUsage (unsigned NewUsage); 105 // Set the usage info 106 107 const String& GetNumber () const; 108 // Get the number info 109 110 void SetNumber (const String& NewNumber); 111 // Set a new number 112 113 unsigned GetSignaling () const; 114 // Return the signaling info 115 116 void SetSignaling (unsigned NewSignaling); 117 // Set the signaling info 118 119 String GetAlias () const; 120 // Get the alias for the given number 121 122 unsigned GetDeviceMap () const; 123 // Return a bitmap of devices that are valid for the current usage 124 125 void SetDeviceMap (unsigned NewMap); 126 // Set a new device map 127 128 String DeviceList (); 129 // Return a list of devices (e.g. "-2--567-") 130 131 const String& SignalName (); 132 // Return the name for a specific signaling type 133 134 const String& UsageName (); 135 // Return the name for a usage 136 }; 137 138 139 GetMemory()140inline unsigned ShortNumberInfo::GetMemory () const 141 // Return the memory setting 142 { 143 return Memory; 144 } 145 146 147 SetUsage(unsigned NewUsage)148inline void ShortNumberInfo::SetUsage (unsigned NewUsage) 149 // Set the usage info 150 { 151 Usage = NewUsage; 152 } 153 154 155 GetNumber()156inline const String& ShortNumberInfo::GetNumber () const 157 // Get the number info 158 { 159 return Number; 160 } 161 162 163 SetSignaling(unsigned NewSignaling)164inline void ShortNumberInfo::SetSignaling (unsigned NewSignaling) 165 // Set the signaling info 166 { 167 Signaling = NewSignaling; 168 } 169 170 171 172 /*****************************************************************************/ 173 /* class ShortNumberColl */ 174 /*****************************************************************************/ 175 176 177 178 class ShortNumberColl: public SortedCollection<ShortNumberInfo, u16> { 179 180 protected: 181 virtual int Compare (const u16* Key1, const u16* Key2); 182 virtual const u16* KeyOf (const ShortNumberInfo* Item); 183 // Helpers for managing sort order 184 185 public: 186 ShortNumberColl (); 187 // Construct a collection 188 189 ShortNumberColl (StreamableInit); 190 // Construct an empty collection 191 192 ShortNumberInfo& NewShortNumber (u16 aMemory); 193 // Create and insert a new short number 194 195 ShortNumberInfo& NewShortNumber (const IstecMsg& Msg); 196 // Create and insert a new short number 197 198 ShortNumberInfo& GetShortNumber (u16 aMemory); 199 // Get the entry in the specified memory. If it does not exist, it is created. 200 }; 201 202 203 204 /*****************************************************************************/ 205 /* Code */ 206 /*****************************************************************************/ 207 208 209 210 void ShortNumberList (ShortNumberColl& ShortNumbers, int& Changed); 211 // List all short numbers. Allow editing. 212 213 String FileSaveShort (const String& Filename, const ShortNumberColl& Numbers); 214 // Save short numbers to a file. The function returns an error message or 215 // the empty string if all is well. 216 217 String FileLoadShort (const String& Filename, ShortNumberColl& Numbers); 218 // Load a configuration from a file. The function returns an error message or 219 // the empty string if all is well. 220 221 222 223 // End of ICSHORT.H 224 225 #endif 226