examples/QtQuick/telephonysuppleservices/supservices_symbian.cpp

00001 /****************************************************************************
00002 **
00003 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
00004 ** All rights reserved.
00005 ** Contact: Nokia Corporation
00006 **
00007 **
00008 ** $QT_BEGIN_LICENSE:BSD$
00009 ** You may use this file under the terms of the BSD license as follows:
00010 **
00011 ** "Redistribution and use in source and binary forms, with or without
00012 ** modification, are permitted provided that the following conditions are
00013 ** met:
00014 **   * Redistributions of source code must retain the above copyright
00015 **     notice, this list of conditions and the following disclaimer.
00016 **   * Redistributions in binary form must reproduce the above copyright
00017 **     notice, this list of conditions and the following disclaimer in
00018 **     the documentation and/or other materials provided with the
00019 **     distribution.
00020 **   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
00021 **     the names of its contributors may be used to endorse or promote
00022 **     products derived from this software without specific prior written
00023 **     permission.
00024 **
00025 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00026 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00027 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00028 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00029 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00030 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00031 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00032 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00033 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00034 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00035 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
00036 ** $QT_END_LICENSE$
00037 **
00038 ****************************************************************************/
00039 
00040 #include <supservices_symbian.h>
00041 #include <etel3rdparty.h>
00042 #include <supservices.h>
00043 
00047 SupServicesPrivate* SupServicesPrivate::NewL(SupServices *aPublicInterface)
00048 {
00049     SupServicesPrivate* self = new (ELeave) SupServicesPrivate(aPublicInterface);
00050     CleanupStack::PushL(self);
00051     self->ConstructL();
00052     CleanupStack::Pop(self);
00053     return self;
00054 }
00055 
00059 void SupServicesPrivate::ConstructL()
00060 {
00061     iTelephony = CTelephony::NewL();
00062 }
00063 
00064 // Private constructor - initialise the pointer to the public API class
00065 // and make this standard priority for scheduling.
00066 SupServicesPrivate::SupServicesPrivate(SupServices *aPublicInterface)
00067     : iPublic(aPublicInterface), CActive(CActive::EPriorityStandard),
00068       iCallBarringSupplServicesV1Pckg(iCallBarringSupplServicesV1),
00069       iCallForwardingSupplServicesV1Pckg(iCallForwardingSupplServicesV1),
00070       iCallWaitingSupplServicesV1Pckg(iCallWaitingSupplServicesV1),
00071       iTIdentityServiceV1Pckg(iTIdentityServiceV1)
00072 {
00073     // Adding this Active object
00074     // to an Active scheduler.
00075     CActiveScheduler::Add(this);
00076 }
00077 
00081 SupServicesPrivate::~SupServicesPrivate()
00082 {
00083     // Cancel any outstanding async request before this object is destroyed
00084     // in order to avoid stray signals.
00085     // This destructor cannot leave.
00086     Cancel(); //  Calls DoCancel()
00087     if( iTelephony )
00088     {
00089         delete iTelephony;
00090         iTelephony = NULL;
00091     }
00092 
00093 }
00094 
00099 void SupServicesPrivate::GetCallBarringStatus()
00100 {
00101 
00102     CTelephony::TCallBarringCondition condition = CTelephony::EBarAllOutgoing;
00103 
00104     // Obtains the call barring status for "Outgoing Calls".
00105     // Depending upon the phone settings, the call barring status could be active,
00106     // inactive or not avilable. The status can also be not provisioned on GSM/WCDMA networks.
00107 
00108     iTelephony->GetCallBarringStatus(iStatus, condition, iCallBarringSupplServicesV1Pckg);
00109     iSupServiceType = ECallBarred;
00110     SetActive();
00111 
00112 }
00113 
00117 void SupServicesPrivate::GetCallForwardingStatus()
00118 {
00119     CTelephony::TCallForwardingCondition condition = CTelephony::ECallForwardingNoReply;
00120 
00121     // Obtains the call forwarding status on "No Reply".
00122     // Depending upon the phone settings, the call forwarding status could be active,
00123     // inactive, not avilable or not provisioned.
00124 
00125     iTelephony->GetCallForwardingStatus(iStatus, condition, iCallForwardingSupplServicesV1Pckg);
00126     iSupServiceType = ECallForwarded;
00127     SetActive();
00128 
00129 }
00130 
00134 void SupServicesPrivate::GetCallWaitingStatus()
00135 {
00136     // Obtains the call waiting status .
00137     // Depending upon the phone settings, the call waiting status could be active,
00138     // inactive or not avilable. The status can also be not provisioned on GSM/WCDMA networks.
00139 
00140     iTelephony->GetCallWaitingStatus(iStatus, iCallWaitingSupplServicesV1Pckg);
00141     iSupServiceType = ECallWaiting;
00142     SetActive();
00143 }
00144 
00148 void SupServicesPrivate::GetCallerIdentityStatus()
00149 {
00150     CTelephony::TIdentityService condition = CTelephony::EIdServiceCallerPresentation;
00151 
00152     // Obtains the status for Calling Line Identification Presentation. This condition
00153     // enables the phone to display the number of remote party that calls your phone.
00154     // The status information can be active, restricted, allowed, not provisioned or unknown,
00155     // depending upon the phone settings.
00156 
00157     iTelephony->GetIdentityServiceStatus(iStatus, condition, iTIdentityServiceV1Pckg);
00158     iSupServiceType = ECallerIdentification;
00159     SetActive();
00160 }
00161 
00166 void SupServicesPrivate::RunL()
00167 {
00168     if( iStatus == KErrNone )
00169     {
00170         switch( iSupServiceType )
00171         {
00172         case ECallBarred:
00173             {
00174                 if( iCallBarringSupplServicesV1.iCallBarringCondition == CTelephony::EBarAllOutgoing)
00175                 {
00176                     _LIT(KCallBarMessage,"Bar Outgoing calls");
00177                     // Buffer for outgoing call bar status information.
00178                     TBuf<64> message(KCallBarMessage);
00179 
00180                     // Appends the call bar status to the buffer.
00181                     message.Append(GetSupServiceStatus(iCallBarringSupplServicesV1.iCallBarring));
00182                     iPublic->getMessage(message);
00183                 }
00184                 else
00185                 {
00186                     _LIT(KNoCallBarMessage,"Outgoing calls not barred");
00187 
00188                     // Buffer providing information that outgoing calls are not barred.
00189                     TBuf<64> message(KNoCallBarMessage);
00190                     iPublic->getMessage(message);
00191                 }
00192                 break;
00193             }
00194 
00195         case ECallForwarded:
00196             {
00197                 if( iCallForwardingSupplServicesV1.iCallForwardingCondition == CTelephony::ECallForwardingNoReply )
00198                 {
00199                     _LIT(KCallForwardMessage,"Call forward on noReply");
00200                     // Buffer for call forward status information
00201                     TBuf<64> message(KCallForwardMessage);
00202 
00203                     // Appends the call forward status to the buffer .
00204                     message.Append(GetSupServiceStatus(iCallForwardingSupplServicesV1.iCallForwarding));
00205                     iPublic->getMessage(message);
00206                 }
00207 
00208                 else
00209                 {
00210                     _LIT(KNoCallForwardMessage,"Call forward on noReply not set");
00211                     // Buffer providing information that call forwarding on no reply is not set.
00212                     TBuf<64> message(KNoCallForwardMessage);
00213                     iPublic->getMessage(message);
00214                 }
00215                 break;
00216             }
00217 
00218         case ECallWaiting:
00219             {
00220             _LIT(KCallWaitMessage,"Call waiting");
00221             // Buffer to hold the call waiting status information.
00222             TBuf<64> message(KCallWaitMessage);
00223 
00224             // Appends the call waiting status returned to the buffer.
00225             message.Append(GetSupServiceStatus(iCallWaitingSupplServicesV1.iCallWaiting));
00226             iPublic->getMessage(message);
00227             break;
00228             }
00229 
00230         case ECallerIdentification:
00231             {
00232             // Buffer holding the CLIP status information.
00233             TBuf<64> message;
00234             // Returns the "Calling Line Identification Presentation" status.
00235             switch(iTIdentityServiceV1.iIdentityStatus)
00236             {
00237             case CTelephony::EIdServiceActivePermanent:
00238                 {
00239                 _LIT(KCLIPActiveMessage,"CLIP is permanently active");
00240                 message.Append(KCLIPActiveMessage);
00241                 break;
00242                 }
00243             case CTelephony::EIdServiceActiveDefaultRestricted:
00244                 {
00245                 _LIT(KCLIPRestrictedMessage,"CLIP is restricted");
00246                 message.Append(KCLIPRestrictedMessage);
00247                 break;
00248                 }
00249             case CTelephony::EIdServiceActiveDefaultAllowed:
00250                 {
00251                 _LIT(KCLIPAllowedMessage,"CLIP is Allowed");
00252                 message.Append(KCLIPAllowedMessage);
00253                 break;
00254                 }
00255             case CTelephony::EIdServiceNotProvisioned:
00256                 {
00257                 _LIT(KCLIPNotProvisionedMessage,"CLIP is NotProvisioned");
00258                 message.Append(KCLIPNotProvisionedMessage);
00259                 break;
00260                 }
00261             case CTelephony::EIdServiceUnknown:
00262             default:
00263                 {
00264                 _LIT(KCLIPUnknownMessage,"CLIP service is Unknown");
00265                 message.Append(KCLIPUnknownMessage);
00266                 break;
00267                 }
00268 
00269             }
00270             iPublic->getMessage(message);
00271             break;
00272         }
00273 
00274         default:
00275             break;
00276         }
00277 
00278     }
00279 
00280     // emits a signal to print the supplementary service status.
00281     emit iPublic->printMessage();
00282 }
00283 
00289 TDes& SupServicesPrivate::GetSupServiceStatus(CTelephony::TSupplServiceStatus aStatus)
00290 {
00291     imessage.Delete(0,imessage.Length());
00292     switch( aStatus )
00293     {
00294     case CTelephony::EStatusActive:
00295             _LIT(KActiveMessage," active.");
00296             imessage.Append(KActiveMessage);
00297             break;
00298     case CTelephony::ENotActive:
00299             _LIT(KNotActiveMessage," not active.");
00300             imessage.Append(KNotActiveMessage);
00301             break;
00302     case CTelephony::ENotProvisioned:
00303             _LIT(KNotProvisionedMessage," not provisioned.");
00304             imessage.Append(KNotProvisionedMessage);
00305             break;
00306     case CTelephony::ENotAvailable:
00307             _LIT(KNotAvailableMessage," not available.");
00308             imessage.Append(KNotAvailableMessage);
00309             break;
00310     case CTelephony::EUnknown:
00311     default:
00312             _LIT(KUnknownMessage," unknown.");
00313             imessage.Append(KUnknownMessage);
00314             break;
00315     }
00316     return imessage;
00317 
00318 }
00319 
00323 void SupServicesPrivate::DoCancel()
00324 {
00325     // Cancels the call barring status request.
00326     iTelephony->CancelAsync(CTelephony::EGetCallBarringStatusCancel);
00327 
00328     // Cancels the call forwarding status request.
00329     iTelephony->CancelAsync(CTelephony::EGetCallForwardingStatusCancel);
00330 
00331     // Cancels the call waiting status request.
00332     iTelephony->CancelAsync(CTelephony::EGetCallWaitingStatusCancel);
00333 
00334     // Cancels the Identity service status request.
00335     iTelephony->CancelAsync(CTelephony::EGetIdentityServiceStatusCancel);
00336 
00337 }
00338 

Generated by  doxygen 1.6.2