Qtopia Home - Classes - Annotated - Functions - Qt Embedded |
|
This is the verbatim text of the phone.h include file. It is provided only for illustration; the copyright remains with Trolltech.
/**********************************************************************
** Copyright (C) 2000-2003 Trolltech AS. All rights reserved.
**
** This file is part of the Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#ifndef PHONE_H
#define PHONE_H
#include <qobject.h>
#include <qstring.h>
#include <qvaluelist.h>
#include <qdatetime.h>
class PhoneCall;
class PhoneCallPrivate;
class PhoneLine;
class PhoneLinePrivate;
class PhoneBook;
class SMSRequest;
class SimToolkit;
class QStringList;
class PhoneCall
{
friend class PhoneLine;
friend class PhoneCallPrivate;
friend bool operator==( const PhoneCall& call1,
const PhoneCall& call2 );
friend bool operator!=( const PhoneCall& call1,
const PhoneCall& call2 );
public:
PhoneCall();
PhoneCall( const PhoneCall& call );
~PhoneCall();
// Call states.
enum State
{
Idle, // New outgoing call, not dialed yet.
Incoming, // Incoming connection from remote party.
Dialing, // Dialing, but not yet connected.
Connected, // Connected to the other party.
Hold, // Connected, but currently on hold.
HangupLocal, // Local side hung up the call.
HangupRemote, // Remote side hung up the call, or call lost.
Missed, // Incoming call that was missed.
NetworkFailure, // Network has failed in some way.
OtherFailure // Something else went wrong.
};
// Scope of an operation.
enum Scope
{
CallOnly, // Only the referenced call.
Group // All calls in the same active/held group.
};
// Request types, for reporting failures.
enum Request
{
HoldFailed,
JoinFailed
};
// Types of calls.
enum CallType
{
Voice,
Data,
Fax
};
int id() const;
PhoneCall& operator=( const PhoneCall& call );
PhoneLine& line() const;
QString fullNumber() const;
QString number() const;
State state() const;
CallType callType() const;
QDateTime startTime() const;
QDateTime endTime() const;
bool hasBeenConnected() const;
// Convenience functions for detecting interesting states.
bool idle() const { return ( state() == Idle ); }
bool incoming() const { return ( state() == Incoming ); }
bool dialing() const { return ( state() == Dialing ); }
bool connected() const
{ return ( state() == Connected || state() == Hold ); }
bool onHold() const { return ( state() == Hold ); }
bool dropped() const { return ( state() >= HangupLocal ); }
bool missed() const { return ( state() == Missed ); }
bool dialed() const;
QString pendingTones() const;
void dial( const QString& number, bool callerid );
void accept();
void hangup( Scope scope = Group );
void hold();
void activate( Scope scope = Group );
void join( bool detachSubscriber = FALSE );
void tone( const QString& tones );
void transfer( const QString& number );
void connectPendingTonesChanged( QObject *, const char * );
void connectStateChanged( QObject *, const char * );
void disconnectStateChanged( QObject *, const char * );
void connectRequestFailed( QObject *, const char * );
void disconnectRequestFailed( QObject *, const char * );
// The "null" call, which is always in the "idle" state,
// and upon which it is impossible to perform a dial request.
QT_STATIC_CONST PhoneCall null;
private:
PhoneCallPrivate *d;
};
inline bool operator==( const PhoneCall& call1,
const PhoneCall& call2 )
{
return (call1.d == call2.d);
}
inline bool operator!=( const PhoneCall& call1,
const PhoneCall& call2 )
{
return (call1.d != call2.d);
}
class PhoneLine : public QObject
{
Q_OBJECT
friend class PhoneLinePrivate;
public:
PhoneLine( const QString& name = QString::null, QObject* parent=0 );
~PhoneLine();
QString name() const;
QValueList<PhoneCall> calls() const;
PhoneCall createCall();
PhoneCall active() const;
// Information query types. Format of return values as per GSM 07.07.
enum QueryType
{
Number,
Manufacturer,
Model,
Revision,
Serial,
BatteryCharge,
SignalQuality,
CharacterSet, // Modifiable
SupportedCharacterSets,
AdviceOfCharge,
Registration, // Query and notification.
Operator, // Modifiable
AvailableOperators,
PricePerUnit,
SIMIdentity,
VibrateOnRing, // Modifiable
SilentMode, // Modifiable
ServiceCenter, // Modifiable
CallerIdRestriction, // Modifiable
LockControlSurface, // Modifiable (+CLCK=CS)
LockPhoneToSimCard, // Modifiable (+CLCK=PS)
LockSimCard, // Modifiable (+CLCK=SC)
BarrAllOutgoing, // Modifiable (+CLCK=AO)
BarrAllOutgoingIntl, // Modifiable (+CLCK=OI)
BarrOutgoingIntlExceptHome, // Modifiable (+CLCK=OX)
BarrAllIncoming, // Modifiable (+CLCK=AI)
BarrIncomingWhenRoaming, // Modifiable (+CLCK=IR)
BarrIncomingNotTA, // Modifiable (+CLCK=NT)
BarrIncomingNotME, // Modifiable (+CLCK=NM)
BarrIncomingNotSim, // Modifiable (+CLCK=NS)
BarrIncomingNotAny, // Modifiable (+CLCK=NA)
AllBarringServices, // Modifiable (+CLCK=AB)
AllOutgoingBarringServices, // Modifiable (+CLCK=AG)
AllIncomingBarringServices, // Modifiable (+CLCK=AC)
SimFixedDialingMemory, // Modifiable (+CLCK=FD)
ChangeLockControlSurfacePassword, // Modifiable (+CPWD=CS)
ChangeLockPhoneToSimCardPassword, // Modifiable (+CPWD=PS)
ChangeLockSimCardPassword, // Modifiable (+CPWD=SC)
ChangeBarrAllOutgoingPassword, // Modifiable (+CPWD=AO)
ChangeBarrAllOutgoingIntlPassword, // Modifiable (+CPWD=OI)
ChangeBarrOutgoingIntlExceptHomePassword, // Modifiable (+CPWD=OX)
ChangeBarrAllIncomingPassword, // Modifiable (+CPWD=AI)
ChangeBarrIncomingWhenRoamingPassword, // Modifiable (+CPWD=IR)
ChangeBarrIncomingNotTAPassword, // Modifiable (+CPWD=NT)
ChangeBarrIncomingNotMEPassword, // Modifiable (+CPWD=NM)
ChangeBarrIncomingNotSimPassword, // Modifiable (+CPWD=NS)
ChangeBarrIncomingNotAnyPassword, // Modifiable (+CPWD=NA)
ChangeAllBarringServicesPassword, // Modifiable (+CPWD=AB)
ChangeAllOutgoingBarringServicesPassword, // Modifiable (+CPWD=AG)
ChangeAllIncomingBarringServicesPassword, // Modifiable (+CPWD=AC)
ChangeSimFixedDialingMemoryPassword, // Modifiable (+CPWD=FD)
ClosedUserGroup, // Modifiable
ForwardingUnconditional, // Modifiable (+CCFC=0)
ForwardingMobileBusy, // Modifiable (+CCFC=1)
ForwardingNoReply, // Modifiable (+CCFC=2)
ForwardingNotReachable, // Modifiable (+CCFC=3)
ForwardingAll, // Modifiable (+CCFC=4)
ForwardingAllConditional, // Modifiable (+CCFC=5)
CallWaiting, // Modifiable
Channels, // Modifiable
SimFieldLimits,
Functionality, // Modifiable
RequiredPin,
SendPin, // Modifiable, but no query support.
ChangePin, // Modifiable, but no query support.
SimInserted, // Notification
SimRemoved, // Notification
VibrateNow, // Modifiable, but no query support.
InitializationDone, // Query and notification
AccessoryStatus, // Query and notification
};
void query( QueryType type ) const;
void modify( QueryType type, const QString& value );
// Query result parsers:
struct OperatorInfo {
enum Status { Unknown, Available, Current, Forbidden } status;
QString name;
QString id;
};
static OperatorInfo parseOperator(const QString&, bool *automatic);
static QString formatOperator(bool automatic, const QString& opid=QString::null);
static QValueList<OperatorInfo> parseAvailableOperators(const QString&);
static QString parseServiceCenter(const QString&);
static bool parseCallerIdRestriction(const QString&, bool *modifiable=0);
static QString formatCallerIdRestriction(bool on);
static QString formatChannels( QValueList<int> channels );
static QString formatBarring( bool enable, const QString& password=QString::null );
enum ClassX { Voice=1, Data=2, Fax=4, Sms=8 };
struct ForwardRec { bool enabled; int classx; QString number; };
static QValueList<ForwardRec> parseForwarding(const QString&);
static QString formatForwarding(bool enable, int classx, const QString& number);
static int parseCallWaiting(const QString&);
static QString formatCallWaiting(bool enable, int classx);
static QString formatChangePassword(const QString& op, const QString &np);
SMSRequest *sms();
PhoneBook *phoneBook();
SimToolkit *simToolkit();
void startData( const QString& number, const QStringList& initCmds, const QStringList& moduleArgs, bool persist );
void stopData();
signals:
// Notification of a new call being added to the "calls()" list.
void newCall( const PhoneCall& call );
// Notification of a value that was being queried for.
void queryResult( PhoneLine::QueryType type, const QString& value );
// Asynchronous notification of an interesting value that wasn't
// explicitly requested by a query call.
void notification( PhoneLine::QueryType type, const QString& value );
private:
PhoneLinePrivate *d;
void emitNewCall( PhoneCallPrivate *d );
void emitQueryResult( QueryType type, const QString& value );
void emitNotification( QueryType type, const QString& value );
};
class PhoneUtils
{
private:
PhoneUtils() {}
public:
static QString stripNumber( const QString& number );
static int matchNumbers( const QString& num1, const QString& num2 );
static bool matchPrefix( const QString& num, const QString& prefix );
static QString resolveLetters( const QString& number );
// Rule information for international prefixes.
typedef struct
{
const char *country; // Country the rules apply to.
int internationalCode; // International prefix for country.
char areaCodeLength; // Length of local area codes.
char areaCodeLengthAlt; // Alternative length, or zero.
signed char areaCodePrefix; // Local area code prefix, or -1 if none.
char areaCodePrefixLength; // Length of the area code prefix.
} IDDRule;
static IDDRule const rules[];
static int const numRules;
};
#endif // PHONE_H
| Copyright © 2001-2004 Trolltech | Trademarks | Qtopia version 2.0.1
|