Search in sources :

Example 6 with SendReq

use of com.google.android.mms.pdu.SendReq in project android-aosp-mms by slvn.

the class WorkingMessage method saveAsMms.

/**
 * Force the message to be saved as MMS and return the Uri of the message.
 * Typically used when handing a message off to another activity.
 */
public Uri saveAsMms(boolean notify) {
    if (DEBUG)
        LogTag.debug("saveAsMms mConversation=%s", mConversation);
    // If we have discarded the message, just bail out.
    if (mDiscarded) {
        LogTag.warn("saveAsMms mDiscarded: true mConversation: " + mConversation + " returning NULL uri and bailing");
        return null;
    }
    // FORCE_MMS behaves as sort of an "invisible attachment", making
    // the message seem non-empty (and thus not discarded).  This bit
    // is sticky until the last other MMS bit is removed, at which
    // point the message will fall back to SMS.
    updateState(FORCE_MMS, true, notify);
    // Collect our state to be written to disk.
    prepareForSave(true);
    try {
        // Make sure we are saving to the correct thread ID.
        DraftCache.getInstance().setSavingDraft(true);
        if (!mConversation.getRecipients().isEmpty()) {
            mConversation.ensureThreadId();
        }
        mConversation.setDraftState(true);
        PduPersister persister = PduPersister.getPduPersister(mActivity);
        SendReq sendReq = makeSendReq(mConversation, mSubject);
        // have one already, make sure it is synced to disk.
        if (mMessageUri == null) {
            mMessageUri = createDraftMmsMessage(persister, sendReq, mSlideshow, null, mActivity, null);
        } else {
            updateDraftMmsMessage(mMessageUri, persister, mSlideshow, sendReq, null);
        }
        mHasMmsDraft = true;
    } finally {
        DraftCache.getInstance().setSavingDraft(false);
    }
    return mMessageUri;
}
Also used : PduPersister(com.google.android.mms.pdu.PduPersister) SendReq(com.google.android.mms.pdu.SendReq)

Example 7 with SendReq

use of com.google.android.mms.pdu.SendReq in project android-aosp-mms by slvn.

the class WorkingMessage method makeSendReq.

/**
 * makeSendReq should always return a non-null SendReq, whether the dest addresses are
 * valid or not.
 */
private static SendReq makeSendReq(Conversation conv, CharSequence subject) {
    String[] dests = conv.getRecipients().getNumbers(true);
    SendReq req = new SendReq();
    EncodedStringValue[] encodedNumbers = EncodedStringValue.encodeStrings(dests);
    if (encodedNumbers != null) {
        req.setTo(encodedNumbers);
    }
    if (!TextUtils.isEmpty(subject)) {
        req.setSubject(new EncodedStringValue(subject.toString()));
    }
    req.setDate(System.currentTimeMillis() / 1000L);
    return req;
}
Also used : EncodedStringValue(com.google.android.mms.pdu.EncodedStringValue) SendReq(com.google.android.mms.pdu.SendReq)

Example 8 with SendReq

use of com.google.android.mms.pdu.SendReq in project android-aosp-mms by slvn.

the class WorkingMessage method asyncUpdateDraftMmsMessage.

private void asyncUpdateDraftMmsMessage(final Conversation conv, final boolean isStopping) {
    if (Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
        LogTag.debug("asyncUpdateDraftMmsMessage conv=%s mMessageUri=%s", conv, mMessageUri);
    }
    final HashMap<Uri, InputStream> preOpenedFiles = mSlideshow.openPartFiles(mContentResolver);
    new Thread(new Runnable() {

        @Override
        public void run() {
            try {
                DraftCache.getInstance().setSavingDraft(true);
                final PduPersister persister = PduPersister.getPduPersister(mActivity);
                final SendReq sendReq = makeSendReq(conv, mSubject);
                if (mMessageUri == null) {
                    mMessageUri = createDraftMmsMessage(persister, sendReq, mSlideshow, null, mActivity, preOpenedFiles);
                } else {
                    updateDraftMmsMessage(mMessageUri, persister, mSlideshow, sendReq, preOpenedFiles);
                }
                ensureThreadIdIfNeeded(conv, isStopping);
                conv.setDraftState(true);
                if (Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
                    LogTag.debug("asyncUpdateDraftMmsMessage conv: " + conv + " uri: " + mMessageUri);
                }
                // Be paranoid and delete any SMS drafts that might be lying around. Must do
                // this after ensureThreadId so conv has the correct thread id.
                asyncDeleteDraftSmsMessage(conv);
            } finally {
                DraftCache.getInstance().setSavingDraft(false);
                closePreOpenedFiles(preOpenedFiles);
            }
        }
    }, "WorkingMessage.asyncUpdateDraftMmsMessage").start();
}
Also used : PduPersister(com.google.android.mms.pdu.PduPersister) InputStream(java.io.InputStream) Uri(android.net.Uri) SendReq(com.google.android.mms.pdu.SendReq)

Aggregations

SendReq (com.google.android.mms.pdu.SendReq)8 PduPersister (com.google.android.mms.pdu.PduPersister)6 Uri (android.net.Uri)4 EncodedStringValue (com.google.android.mms.pdu.EncodedStringValue)4 MmsException (com.google.android.mms.MmsException)3 ContentValues (android.content.ContentValues)2 Intent (android.content.Intent)2 Resources (android.content.res.Resources)1 SpannableString (android.text.SpannableString)1 SlideshowModel (com.android.mms.model.SlideshowModel)1 RateController (com.android.mms.util.RateController)1 GenericPdu (com.google.android.mms.pdu.GenericPdu)1 MultimediaMessagePdu (com.google.android.mms.pdu.MultimediaMessagePdu)1 PduComposer (com.google.android.mms.pdu.PduComposer)1 PduParser (com.google.android.mms.pdu.PduParser)1 RetrieveConf (com.google.android.mms.pdu.RetrieveConf)1 SendConf (com.google.android.mms.pdu.SendConf)1 InputStream (java.io.InputStream)1