Home | History | Annotate | Download | only in sms
      1 /*
      2  * Copyright (C) 2015 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License
     15  */
     16 package com.android.phone.vvm.omtp.sms;
     17 
     18 import android.telecom.Log;
     19 
     20 import com.android.phone.vvm.omtp.OmtpConstants;
     21 
     22 /**
     23  * Structured data representation of OMTP STATUS message.
     24  *
     25  * The getters will return null if the field was not set in the message body or it could not be
     26  * parsed.
     27  */
     28 public class StatusMessage {
     29     // NOTE: Following Status SMS fields are not yet parsed, as they do not seem
     30     // to be useful for initial omtp source implementation.
     31     // lang, g_len, vs_len, pw_len, pm, gm, vtc, vt
     32 
     33     private final String mProvisioningStatus;
     34     private final String mStatusReturnCode;
     35     private final String mSubscriptionUrl;
     36     private final String mServerAddress;
     37     private final String mTuiAccessNumber;
     38     private final String mClientSmsDestinationNumber;
     39     private final String mImapPort;
     40     private final String mImapUserName;
     41     private final String mImapPassword;
     42     private final String mSmtpPort;
     43     private final String mSmtpUserName;
     44     private final String mSmtpPassword;
     45 
     46     @Override
     47     public String toString() {
     48         return "StatusMessage [mProvisioningStatus=" + mProvisioningStatus
     49                 + ", mStatusReturnCode=" + mStatusReturnCode
     50                 + ", mSubscriptionUrl=" + mSubscriptionUrl
     51                 + ", mServerAddress=" + mServerAddress
     52                 + ", mTuiAccessNumber=" + mTuiAccessNumber
     53                 + ", mClientSmsDestinationNumber=" + mClientSmsDestinationNumber
     54                 + ", mImapPort=" + mImapPort
     55                 + ", mImapUserName=" + mImapUserName
     56                 + ", mImapPassword=" + Log.pii(mImapPassword)
     57                 + ", mSmtpPort=" + mSmtpPort
     58                 + ", mSmtpUserName=" + mSmtpUserName
     59                 + ", mSmtpPassword=" + Log.pii(mSmtpPassword) + "]";
     60     }
     61 
     62     public StatusMessage(WrappedMessageData wrappedData) {
     63         mProvisioningStatus = wrappedData.extractString(OmtpConstants.PROVISIONING_STATUS);
     64         mStatusReturnCode = wrappedData.extractString(OmtpConstants.RETURN_CODE);
     65         mSubscriptionUrl = wrappedData.extractString(OmtpConstants.SUBSCRIPTION_URL);
     66         mServerAddress = wrappedData.extractString(OmtpConstants.SERVER_ADDRESS);
     67         mTuiAccessNumber = wrappedData.extractString(OmtpConstants.TUI_ACCESS_NUMBER);
     68         mClientSmsDestinationNumber = wrappedData.extractString(
     69                 OmtpConstants.CLIENT_SMS_DESTINATION_NUMBER);
     70         mImapPort = wrappedData.extractString(OmtpConstants.IMAP_PORT);
     71         mImapUserName = wrappedData.extractString(OmtpConstants.IMAP_USER_NAME);
     72         mImapPassword = wrappedData.extractString(OmtpConstants.IMAP_PASSWORD);
     73         mSmtpPort = wrappedData.extractString(OmtpConstants.SMTP_PORT);
     74         mSmtpUserName = wrappedData.extractString(OmtpConstants.SMTP_USER_NAME);
     75         mSmtpPassword = wrappedData.extractString(OmtpConstants.SMTP_PASSWORD);
     76     }
     77 
     78     /**
     79      * @return the subscriber's VVM provisioning status.
     80      */
     81     public String getProvisioningStatus() {
     82         return mProvisioningStatus;
     83     }
     84 
     85     /**
     86      * @return the return-code of the status SMS.
     87      */
     88     public String getReturnCode() {
     89         return mStatusReturnCode;
     90     }
     91 
     92     /**
     93      * @return the URL of the voicemail server. This is the URL to send the users to for subscribing
     94      * to the visual voicemail service.
     95      */
     96     public String getSubscriptionUrl() {
     97         return mSubscriptionUrl;
     98     }
     99 
    100     /**
    101      * @return the voicemail server address. Either server IP address or fully qualified domain
    102      * name.
    103      */
    104     public String getServerAddress() {
    105         return mServerAddress;
    106     }
    107 
    108     /**
    109      * @return the Telephony User Interface number to call to access voicemails directly from the
    110      * IVR.
    111      */
    112     public String getTuiAccessNumber() {
    113         return mTuiAccessNumber;
    114     }
    115 
    116     /**
    117      * @return the number to which client originated SMSes should be sent to.
    118      */
    119     public String getClientSmsDestinationNumber() {
    120         return mClientSmsDestinationNumber;
    121     }
    122 
    123     /**
    124      * @return the IMAP server port to talk to.
    125      */
    126     public String getImapPort() {
    127         return mImapPort;
    128     }
    129 
    130     /**
    131      * @return the IMAP user name to be used for authentication.
    132      */
    133     public String getImapUserName() {
    134         return mImapUserName;
    135     }
    136 
    137     /**
    138      * @return the IMAP password to be used for authentication.
    139      */
    140     public String getImapPassword() {
    141         return mImapPassword;
    142     }
    143 
    144     /**
    145      * @return the SMTP server port to talk to.
    146      */
    147     public String getSmtpPort() {
    148         return mSmtpPort;
    149     }
    150 
    151     /**
    152      * @return the SMTP user name to be used for SMTP authentication.
    153      */
    154     public String getSmtpUserName() {
    155         return mSmtpUserName;
    156     }
    157 
    158     /**
    159      * @return the SMTP password to be used for SMTP authentication.
    160      */
    161     public String getSmtpPassword() {
    162         return mSmtpPassword;
    163     }
    164 }