preferences.h 12.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
/*
 *  Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc.
 *  Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
 *
 *  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 3 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.
 *
 *  Additional permission under GNU GPL version 3 section 7:
 *
 *  If you modify this program, or any covered work, by linking or
 *  combining it with the OpenSSL project's OpenSSL library (or a
 *  modified version of that library), containing parts covered by the
 *  terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
 *  grants you additional permission to convey the resulting work.
 *  Corresponding Source for a non-source form of such a combination
 *  shall include the source code for the parts of OpenSSL used as well
 *  as that of the covered work.
 */

#ifndef __PREFERENCE_H__
#define __PREFERENCE_H__

#include "config/serializable.h"

36
// general preferences
37 38 39 40 41 42 43 44 45 46 47 48
const Conf::Key orderKey("order");                          // :	1234/2345/
const Conf::Key audioApiKey("audioApi");                    // :	0
const Conf::Key historyLimitKey("historyLimit");            // :	30
const Conf::Key historyMaxCallsKey("historyMaxCalls");      // :	20
const Conf::Key notifyMailsKey("notifyMails");              // :	false
const Conf::Key zoneToneChoiceKey("zoneToneChoice");        // :	North America
const Conf::Key registrationExpireKey("registrationExpire");// :	180
const Conf::Key portNumKey("portNum");                      // :	5060
const Conf::Key searchBarDisplayKey("searchBarDisplay");    // :	true
const Conf::Key zeroConfenableKey("zeroConfenable");        // :	false
const Conf::Key md5HashKey("md5Hash");                      // :	false

49
// voip preferences
Alexandre Savard's avatar
Alexandre Savard committed
50 51 52 53 54 55 56
const Conf::Key playDtmfKey("playDtmf"); // true                    true
const Conf::Key playTonesKey("playTones");  // true
const Conf::Key pulseLengthKey("pulseLength"); //=250
const Conf::Key sendDtmfAsKey("sendDtmfAs");// =0
const Conf::Key symmetricRtpKey("symmetric");// =true
const Conf::Key zidFileKey("zidFile");// =sfl.zid

57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
// addressbook preferences
const Conf::Key photoKey("photo");//		false
const Conf::Key enabledKey("enabled");//		true
const Conf::Key listKey("list");//		1243608768.30329.0@emilou-desktop/1243456917.15690.23@emilou-desktop/
const Conf::Key maxResultsKey("maxResults");//		25
const Conf::Key businessKey("business");//		true
const Conf::Key homeKey("home");//		false
const Conf::Key mobileKey("mobile");//		false

// hooks preferences
const Conf::Key iax2EnabledKey("iax2Enabled");// :		false
const Conf::Key numberAddPrefixKey("numberAddPrefix");//:	false
const Conf::Key numberEnabledKey("numberEnabled"); //:	false
const Conf::Key sipEnabledKey("sipEnabled"); //:		false
const Conf::Key urlCommandKey("urlCommand"); //:		x-www-browser
const Conf::Key urlSipFieldKey("urlSipField"); //:		X-sflphone-url

74
// audio preferences
75 76 77 78 79 80 81 82 83 84
const Conf::Key alsamapKey("alsa");
const Conf::Key pulsemapKey("pulse");
const Conf::Key cardinKey("cardin");// : 0
const Conf::Key cardoutKey("cardout");// 0
const Conf::Key cardringKey("cardring");// : 0
const Conf::Key framesizeKey("framesize");// : 20
const Conf::Key pluginKey("plugin"); //: default
const Conf::Key smplrateKey("smplrate");//: 44100
const Conf::Key devicePlaybackKey("devicePlayback");//:
const Conf::Key deviceRecordKey("deviceRecord");// :
85
const Conf::Key deviceRingtoneKey("deviceRingtone");// :
86 87 88
const Conf::Key recordpathKey("recordpath");//: /home/msavard/Bureau
const Conf::Key volumemicKey("volumemic");//:  100
const Conf::Key volumespkrKey("volumespkr");//: 100
Alexandre Savard's avatar
Alexandre Savard committed
89

90 91 92 93 94 95 96
// shortcut preferences
const Conf::Key hangupShortKey("hangUp");
const Conf::Key pickupShortKey("pickUp");
const Conf::Key popupShortKey("popupWindow");
const Conf::Key toggleHoldShortKey("toggleHold");
const Conf::Key togglePickupHangupShortKey("togglePickupHangup");

Alexandre Savard's avatar
Alexandre Savard committed
97

98 99 100 101 102 103 104 105
class Preferences : public Serializable {

 public:

  Preferences();

  ~Preferences();

106
  virtual void serialize(Conf::YamlEmitter *emitter);
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161

  virtual void unserialize(Conf::MappingNode *map);


  std::string getAccountOrder(void) { return _accountOrder; }
  void setAccountOrder(std::string ord) { _accountOrder = ord; }

  int getAudioApi(void) { return _audioApi; }
  void setAudioApi(int api) { _audioApi = api; }

  int getHistoryLimit(void) { return _historyLimit; }
  void setHistoryLimit(int lim) { _historyLimit = lim; }

  int getHistoryMaxCalls(void) { return _historyMaxCalls; }
  void setHistoryMaxCalls(int max) { _historyMaxCalls = max; }

  bool getNotifyMails(void) { return _notifyMails; }
  void setNotifyMails(bool mails) { _notifyMails = mails; }

  std::string getZoneToneChoice(void) { return _zoneToneChoice; }
  void setZoneToneChoice(std::string str) { _zoneToneChoice = str; }

  int getRegistrationExpire(void) { return _registrationExpire; }
  void setRegistrationExpire(int exp) { _registrationExpire = exp; }

  int getPortNum(void) { return _portNum; }
  void setPortNum(int port) { _portNum = port; }

  bool getSearchBarDisplay(void) { return _searchBarDisplay; }
  void setSearchBarDisplay(bool search) { _searchBarDisplay = search; }

  bool getZeroConfenable(void) { return _zeroConfenable; }
  void setZeroConfenable(bool enable) { _zeroConfenable = enable; }

  bool getMd5Hash(void) { return _md5Hash; }
  void setMd5Hash(bool md5) { _md5Hash = md5; }

 private:

  // account order
  std::string _accountOrder;

  int _audioApi;
  int _historyLimit;
  int _historyMaxCalls;
  bool _notifyMails;
  std::string _zoneToneChoice;
  int _registrationExpire;
  int _portNum;
  bool _searchBarDisplay;
  bool _zeroConfenable;
  bool _md5Hash;

};

Alexandre Savard's avatar
Alexandre Savard committed
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203

class VoipPreference : public Serializable {

 public:

  VoipPreference();

  ~VoipPreference();

  virtual void serialize(Conf::YamlEmitter *emitter);

  virtual void unserialize(Conf::MappingNode *map);

  bool getPlayDtmf(void) { return _playDtmf; }
  void setPlayDtmf(bool dtmf) { _playDtmf = dtmf; }

  bool getPlayTones(void) { return _playTones; }
  void setPlayTones(bool tone) { _playTones = tone; }

  int getPulseLength(void) { return _pulseLength; }
  void setPulseLength(int length) { _pulseLength = length; }

  int getSendDtmfAs(void) { return _sendDtmfAs; }
  void setSendDtmfAs(int dtmf) { _sendDtmfAs = dtmf; }

  bool getSymmetricRtp(void) { return _symmetricRtp; }
  void setSymmetricRtp(bool sym) { _symmetricRtp = sym; }

  std::string getZidFile(void) { return _zidFile; }
  void setZidFile(std::string file) { _zidFile = file; }

 private:

  bool _playDtmf;
  bool _playTones;
  int _pulseLength;
  int _sendDtmfAs;
  bool _symmetricRtp;
  std::string _zidFile;

};

204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264
class AddressbookPreference : public Serializable {

 public:

  AddressbookPreference();

  ~AddressbookPreference();

  virtual void serialize(Conf::YamlEmitter *emitter);

  virtual void unserialize(Conf::MappingNode *map);

  bool getPhoto(void) { return _photo;}
  void setPhoto(bool p) { _photo = p; }

  bool getEnabled(void) { return _enabled; }
  void setEnabled(bool e) { _enabled = e; }

  std::string getList(void) { return _list; }
  void setList(std::string l) { _list = l; }

  int getMaxResults(void) { return _maxResults; }
  void setMaxResults(int r) { _maxResults = r; }

  bool getBusiness(void) { return _business; }
  void setBusiness(bool b) { _business = b; }

  bool getHome(void) { return _home; }
  void setHone(bool h) { _home = h; }

  bool getMobile(void) { return _mobile; }
  void setMobile(bool m) { _mobile = m; }

 private:

  bool _photo;
  bool _enabled;
  std::string _list;
  int _maxResults;
  bool _business;
  bool _home;
  bool _mobile;

};


class HookPreference : public Serializable {

 public:

  HookPreference();

  ~HookPreference();

  virtual void serialize(Conf::YamlEmitter *emitter);

  virtual void unserialize(Conf::MappingNode *map);

  bool getIax2Enabled(void) { return _iax2Enabled; }
  void setIax2Enabled( bool i) { _iax2Enabled = i; }

265 266
  std::string getNumberAddPrefix(void) { return _numberAddPrefix; }
  void setNumberAddPrefix(std::string n) { _numberAddPrefix = n; }
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282

  bool getNumberEnabled(void) { return _numberEnabled; }
  void setNumberEnabled(bool n) { _numberEnabled = n; }

  bool getSipEnabled(void) { return _sipEnabled; }
  void setSipEnabled(bool s) { _sipEnabled = s; }

  std::string getUrlCommand(void) { return _urlCommand; }
  void setUrlCommand(std::string u) { _urlCommand = u; }

  std::string getUrlSipField(void) { return _urlSipField; }
  void setUrlSipField(std::string u) { _urlSipField = u; }

 private:

  bool _iax2Enabled;// :		false
283
  std::string _numberAddPrefix;//:	false
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327
  bool _numberEnabled; //:	false
  bool _sipEnabled; //:		false
  std::string _urlCommand; //:		x-www-browser
  std::string _urlSipField; //:		X-sflphone-url

};


class AudioPreference : public Serializable {

 public:

  AudioPreference();

  ~AudioPreference();

  virtual void serialize(Conf::YamlEmitter *emitter);

  virtual void unserialize(Conf::MappingNode *map);

  // alsa preference
  int getCardin(void) { return _cardin; }
  void setCardin(int c) { _cardin = c; }

  int getCardout(void) { return _cardout; }
  void setCardout(int c) { _cardout = c; }

  int getCardring(void) { return _cardring; }
  void setCardring(int c) { _cardring = c; }

  int getFramesize(void) { return _framesize; }
  void setFramesize(int f) { _framesize = f; }
  
  std::string getPlugin(void) { return _plugin; }
  void setPlugin(std::string p) { _plugin = p; }
  
  int getSmplrate(void) { return _smplrate; }
  void setSmplrate(int r) { _smplrate = r; }
   
  //pulseaudio preference
  std::string getDevicePlayback(void) { return _devicePlayback; }
  void setDevicePlayback(std::string p) { _devicePlayback = p; }
  
  std::string getDeviceRecord(void) { return _deviceRecord; }
328
  void setDeviceRecord(std::string r) { _deviceRecord = r; }
329 330

  std::string getDeviceRingtone(void) { return _deviceRingtone; }
331
  void setDeviceRingtone(std::string r) { _deviceRingtone = r; }
332 333 334

  // general preference
  std::string getRecordpath(void) { return _recordpath; }
335
  void setRecordpath(std::string r) { _recordpath = r; }
336 337

  int getVolumemic(void) { return _volumemic; }
338
  void setVolumemic(int m) { _volumemic = m; }
339 340

  int getVolumespkr(void) { return _volumespkr; }
341
  void setVolumespkr(int s) { _volumespkr = s; }
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364

 private:
   
  // alsa preference
  int _cardin; // 0
  int _cardout; // 0
  int _cardring;// 0
  int _framesize; // 20
  std::string _plugin; // default
  int _smplrate;// 44100
   
  //pulseaudio preference
  std::string _devicePlayback;//:
  std::string _deviceRecord; //:
  std::string _deviceRingtone; //:

  // general preference
  std::string _recordpath; //: /home/msavard/Bureau
  int _volumemic; //:  100
  int _volumespkr; //: 100
  
};

365 366 367 368 369 370 371 372 373 374 375 376 377

class ShortcutPreferences : public Serializable {

 public:

  ShortcutPreferences();

  ~ShortcutPreferences();

  virtual void serialize(Conf::YamlEmitter *emitter);

  virtual void unserialize(Conf::MappingNode *map);

Alexandre Savard's avatar
Alexandre Savard committed
378
  void setShortcuts(std::map<std::string, std::string> shortcut);
379
  std::map<std::string, std::string> getShortcuts(void);
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405

  std::string getHangup(void) { return _hangup; }
  void setHangup(std::string hangup) { _hangup = hangup; }

  std::string getPickup(void) { return _pickup; }
  void setPickup(std::string pickup) { _pickup = pickup; }

  std::string getPopup(void) { return _popup; }
  void setPopup(std::string popup) { _popup = popup; }

  std::string getToggleHold(void) { return _toggleHold; }
  void setToggleHold(std::string hold) { _toggleHold = hold; }

  std::string getTogglePickupHangup(void) { return _togglePickupHangup; }
  void setTogglePickupHangup(std::string toggle) { _togglePickupHangup = toggle; }

 private:

  std::string _hangup;
  std::string _pickup;
  std::string _popup;
  std::string _toggleHold;
  std::string _togglePickupHangup;

};

406
#endif