~ubuntu-branches/ubuntu/intrepid/gsmlib/intrepid

« back to all changes in this revision

Viewing changes to gsmlib/gsm_cb.h

  • Committer: Bazaar Package Importer
  • Author(s): Mikael Hedin
  • Date: 2002-01-24 12:59:07 UTC
  • Revision ID: james.westby@ubuntu.com-20020124125907-b7qkpokx5283jdpu
Tags: upstream-1.8
ImportĀ upstreamĀ versionĀ 1.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// *************************************************************************
 
2
// * GSM TA/ME library
 
3
// *
 
4
// * File:    gsm_cb.h
 
5
// *
 
6
// * Purpose: Cell Broadcast Message Implementation
 
7
// *
 
8
// * Author:  Peter Hofmann (software@pxh.de)
 
9
// *
 
10
// * Created: 4.8.2001
 
11
// *************************************************************************
 
12
 
 
13
#ifndef GSM_CB_H
 
14
#define GSM_CB_H
 
15
 
 
16
#include <gsmlib/gsm_sms_codec.h>
 
17
#include <gsmlib/gsm_util.h>
 
18
#include <string>
 
19
 
 
20
using namespace std;
 
21
 
 
22
namespace gsmlib
 
23
{
 
24
  // representation of DataCodingScheme
 
25
  // The data coding scheme is described in detail in ETSI GSM 03.38, section 5
 
26
  // This class reuses the DCS_* constants from DataCodingScheme in 
 
27
  // gsm_sms_codec
 
28
 
 
29
  class CBDataCodingScheme
 
30
  {
 
31
  public:
 
32
    enum Language {German = 0, English = 1, Italian = 2, French = 3,
 
33
                   Spanish = 4, Dutch = 5, Swedish = 6, Danish = 7,
 
34
                   Portuguese = 8, Finnish = 9, Norwegian = 10, Greek = 11,
 
35
                   Turkish = 12, Unknown = 1000};
 
36
 
 
37
  private:
 
38
    unsigned char _dcs;
 
39
    Language _language;
 
40
 
 
41
  public:
 
42
    // initialize with data coding scheme octet
 
43
    CBDataCodingScheme(unsigned char dcs);
 
44
    
 
45
    // default constructor
 
46
    CBDataCodingScheme() : _dcs(DCS_DEFAULT_ALPHABET), _language(English) {}
 
47
 
 
48
    // return language of CBM
 
49
    Language getLanguage() const {return _language;}
 
50
 
 
51
    // return compression level (if language == Unknown)
 
52
    bool compressed() const {return (_dcs & DCS_COMPRESSED) == DCS_COMPRESSED;}
 
53
 
 
54
    // return type of alphabet used
 
55
    // (DCS_DEFAULT_ALPHABET, DCS_EIGHT_BIT_ALPHABET, DCS_SIXTEEN_BIT_ALPHABET,
 
56
    // DCS_RESERVED_ALPHABET)
 
57
    unsigned char getAlphabet() const
 
58
      {return _language == Unknown ? _dcs & (3 << 2) : DCS_DEFAULT_ALPHABET;}
 
59
 
 
60
    // create textual representation of CB data coding scheme
 
61
    string toString() const;
 
62
  };
 
63
 
 
64
  // representation of Cell Broadcast message (CBM)
 
65
  // The CBM format is described in detail in ETSI GSM 03.41, section 9.3
 
66
  
 
67
  class CBMessage : public RefBase
 
68
  {
 
69
  public:
 
70
    enum GeographicalScope {CellWide, PLMNWide, LocationAreaWide,
 
71
                            CellWide2};
 
72
 
 
73
  private:
 
74
    // fields parsed from the CB TPDU
 
75
    GeographicalScope _geographicalScope;
 
76
    int _messageCode;
 
77
    int _updateNumber;
 
78
    int _messageIdentifier;
 
79
    CBDataCodingScheme _dataCodingScheme;
 
80
    int _totalPageNumber;
 
81
    int _currentPageNumber;
 
82
    string _data;
 
83
 
 
84
  public:
 
85
    // constructor with given pdu
 
86
    CBMessage(string pdu) throw(GsmException);
 
87
 
 
88
    // accessor functions
 
89
    GeographicalScope getGeographicalScope() const {return _geographicalScope;}
 
90
    int getMessageCode() const {return _messageCode;}
 
91
    int getUpdateNumber() const {return _updateNumber;}
 
92
    int getMessageIdentifier() const {return _messageIdentifier;}
 
93
    CBDataCodingScheme getDataCodingScheme() const {return _dataCodingScheme;}
 
94
    int getTotalPageNumber() const {return _totalPageNumber;}
 
95
    int getCurrentPageNumber() const {return _currentPageNumber;}
 
96
    string getData() const {return _data;}
 
97
 
 
98
    // create textual representation of CBM
 
99
    string toString() const;
 
100
  };
 
101
 
 
102
  // some useful typdefs
 
103
  typedef Ref<CBMessage> CBMessageRef;
 
104
};
 
105
 
 
106
#endif // GSM_CB_H