当前位置: 首页>>代码示例>>Java>>正文


Java SipUri.getCanonicalSipContact方法代码示例

本文整理汇总了Java中com.csipsimple.api.SipUri.getCanonicalSipContact方法的典型用法代码示例。如果您正苦于以下问题:Java SipUri.getCanonicalSipContact方法的具体用法?Java SipUri.getCanonicalSipContact怎么用?Java SipUri.getCanonicalSipContact使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.csipsimple.api.SipUri的用法示例。


在下文中一共展示了SipUri.getCanonicalSipContact方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCallRemoteAtPostion

import com.csipsimple.api.SipUri; //导入方法依赖的package包/类
/**
 * Retrieve the remote sip uri for a call log at the given position
 * @param position  the position to look at
 * @return the sip uri
 */
public String getCallRemoteAtPostion(int position) {
    Cursor item = (Cursor) getItem(position);
    if(item != null) {
        String number = item.getString(item.getColumnIndex(CallLog.Calls.NUMBER));
        return SipUri.getCanonicalSipContact(number, false);
    }
    return "";
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:14,代码来源:CallLogAdapter.java

示例2: on_pager

import com.csipsimple.api.SipUri; //导入方法依赖的package包/类
@Override
public void on_pager(int callId, pj_str_t from, pj_str_t to, pj_str_t contact,
        pj_str_t mime_type, pj_str_t body) {
    lockCpu();

    long date = System.currentTimeMillis();
    String fromStr = PjSipService.pjStrToString(from);
    String canonicFromStr = SipUri.getCanonicalSipContact(fromStr);
    String contactStr = PjSipService.pjStrToString(contact);
    String toStr = PjSipService.pjStrToString(to);
    String bodyStr = PjSipService.pjStrToString(body);
    String mimeStr = PjSipService.pjStrToString(mime_type);

    // Sanitize from sip uri
    int slashIndex = fromStr.indexOf("/");
    if (slashIndex != -1){
        fromStr = fromStr.substring(0, slashIndex);
    }
    
    SipMessage msg = new SipMessage(canonicFromStr, toStr, contactStr, bodyStr, mimeStr,
            date, SipMessage.MESSAGE_TYPE_INBOX, fromStr);

    // Insert the message to the DB
    ContentResolver cr = pjService.service.getContentResolver();
    cr.insert(SipMessage.MESSAGE_URI, msg.getContentValues());

    // Broadcast the message
    Intent intent = new Intent(SipManager.ACTION_SIP_MESSAGE_RECEIVED);
    // TODO : could be parcelable !
    intent.putExtra(SipMessage.FIELD_FROM, msg.getFrom());
    intent.putExtra(SipMessage.FIELD_BODY, msg.getBody());
    pjService.service.sendBroadcast(intent, SipManager.PERMISSION_USE_SIP);

    // Notify android os of the new message
    notificationManager.showNotificationForMessage(msg);
    unlockCpu();
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:38,代码来源:UAStateReceiver.java

示例3: on_pager_status

import com.csipsimple.api.SipUri; //导入方法依赖的package包/类
@Override
public void on_pager_status(int callId, pj_str_t to, pj_str_t body, pjsip_status_code status,
        pj_str_t reason) {
    lockCpu();
    // TODO : treat error / acknowledge of messages
    int messageType = (status.equals(pjsip_status_code.PJSIP_SC_OK)
            || status.equals(pjsip_status_code.PJSIP_SC_ACCEPTED)) ? SipMessage.MESSAGE_TYPE_SENT
            : SipMessage.MESSAGE_TYPE_FAILED;
    String toStr = SipUri.getCanonicalSipContact(PjSipService.pjStrToString(to));
    String reasonStr = PjSipService.pjStrToString(reason);
    String bodyStr = PjSipService.pjStrToString(body);
    int statusInt = status.swigValue();
    Log.d(THIS_FILE, "SipMessage in on pager status " + status.toString() + " / " + reasonStr);

    // Update the db
    ContentResolver cr = pjService.service.getContentResolver();
    ContentValues args = new ContentValues();
    args.put(SipMessage.FIELD_TYPE, messageType);
    args.put(SipMessage.FIELD_STATUS, statusInt);
    if (statusInt != StatusCode.OK
            && statusInt != StatusCode.ACCEPTED) {
        args.put(SipMessage.FIELD_BODY, bodyStr + " // " + reasonStr);
    }
    cr.update(SipMessage.MESSAGE_URI, args,
            SipMessage.FIELD_TO + "=? AND " +
                    SipMessage.FIELD_BODY + "=? AND " +
                    SipMessage.FIELD_TYPE + "=" + SipMessage.MESSAGE_TYPE_QUEUED,
            new String[] {
                    toStr, bodyStr
            });

    // Broadcast the information
    Intent intent = new Intent(SipManager.ACTION_SIP_MESSAGE_RECEIVED);
    intent.putExtra(SipMessage.FIELD_FROM, toStr);
    pjService.service.sendBroadcast(intent, SipManager.PERMISSION_USE_SIP);
    unlockCpu();
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:38,代码来源:UAStateReceiver.java

示例4: insertOrUpdateCSipUri

import com.csipsimple.api.SipUri; //导入方法依赖的package包/类
@Override
public boolean insertOrUpdateCSipUri(Context ctxt, long contactId, String uri) {

    ContentResolver cr = ctxt.getContentResolver();
    long rawContactId = -1;
    Cursor c = cr.query(RawContacts.CONTENT_URI,
            new String[]{RawContacts._ID},
            RawContacts.CONTACT_ID + "=?",
            new String[]{String.valueOf(contactId)}, null);
    try {
        if(c.moveToNext()) {
            rawContactId = c.getLong(c.getColumnIndex(RawContacts._ID));
        }
    } catch (Exception e) {
        Log.e(THIS_FILE, "Error while looping on contacts", e);
    } finally {
        c.close();
    }
    
    if(rawContactId != -1) {
        String csipUri = SipUri.getCanonicalSipContact(uri, false);
        // First try update
        ContentValues cv = new ContentValues();
        cv.put(CommonDataKinds.Im.DATA, csipUri);
        Cursor cs = cr.query(Data.CONTENT_URI, new String[] {CommonDataKinds.Im._ID},
                CommonDataKinds.Im.MIMETYPE + "=?"
                + " AND " + CommonDataKinds.Im.PROTOCOL + "=?" 
                + " AND " + CommonDataKinds.Im.CUSTOM_PROTOCOL + "=?" 
                + " AND " + CommonDataKinds.Im.RAW_CONTACT_ID + "=?", new String [] {
            CommonDataKinds.Im.CONTENT_ITEM_TYPE,
            Integer.toString(CommonDataKinds.Im.PROTOCOL_CUSTOM),
            SipManager.PROTOCOL_CSIP,
            Long.toString(rawContactId)
        }, null);
        if(cs != null) {
            int count = cs.getCount();
            cs.close();
            
            
            if(count > 0) {
                int updated = cr.update(Data.CONTENT_URI, cv, 
                    CommonDataKinds.Im.MIMETYPE + "=?"
                    + " AND " + CommonDataKinds.Im.PROTOCOL + "=?" 
                    + " AND " + CommonDataKinds.Im.CUSTOM_PROTOCOL + "=?" 
                    + " AND " + CommonDataKinds.Im.RAW_CONTACT_ID + "=?", new String [] {
                CommonDataKinds.Im.CONTENT_ITEM_TYPE,
                Integer.toString(CommonDataKinds.Im.PROTOCOL_CUSTOM),
                SipManager.PROTOCOL_CSIP,
                Long.toString(rawContactId)
                });
                Log.d(THIS_FILE, "Updated : " + updated);
            }else {
                cv.put(CommonDataKinds.Im.MIMETYPE, CommonDataKinds.Im.CONTENT_ITEM_TYPE);
                cv.put(CommonDataKinds.Im.PROTOCOL, CommonDataKinds.Im.PROTOCOL_CUSTOM);
                cv.put(CommonDataKinds.Im.CUSTOM_PROTOCOL, SipManager.PROTOCOL_CSIP);
                cv.put(CommonDataKinds.Im.RAW_CONTACT_ID, rawContactId);
                Uri insertedUri = cr.insert(Data.CONTENT_URI, cv);
                if(insertedUri == null) {
                    return false;
                }
                Log.d(THIS_FILE, "Inserted : " + insertedUri.toString());
            }
            
            return true;
        }
    }
    return false;
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:69,代码来源:ContactsUtils5.java

示例5: bindView

import com.csipsimple.api.SipUri; //导入方法依赖的package包/类
/**
 * Binds the views in the entry to the data in the call log.
 * 
 * @param view the view corresponding to this entry
 * @param c the cursor pointing to the entry in the call log
 * @param count the number of entries in the current item, greater than 1 if
 *            it is a group
 */
private void bindView(int position, View view, Cursor c, int count) {
    final CallLogListItemViews views = (CallLogListItemViews) view.getTag();

    // Default case: an item in the call log.
    views.primaryActionView.setVisibility(View.VISIBLE);
    views.bottomDivider.setVisibility(isLastOfSection(c) ? View.GONE : View.VISIBLE);

    int numberColIndex = c.getColumnIndex(CallLog.Calls.NUMBER);
    int dateColIndex = c.getColumnIndex(CallLog.Calls.DATE);
    int durationColIndex = c.getColumnIndex(CallLog.Calls.DURATION);
    int accIdIndex = c.getColumnIndex(SipManager.CALLLOG_PROFILE_ID_FIELD);
    // int typeColIndex = c.getColumnIndex(CallLog.Calls.TYPE);

    String number = c.getString(numberColIndex);
    final long date = c.getLong(dateColIndex);
    final long duration = c.getLong(durationColIndex);
    final Long accId = c.getLong(accIdIndex);
    // final int callType = c.getInt(typeColIndex);

    // final CallerInfo cachedContactInfo = getContactInfoFromCallLog(c);

    CallRowInfos cri = new CallRowInfos();
    cri.callIds = getCallIds(c, count);
    cri.position = position;
    cri.number = number;
    cri.accId = accId;
    views.primaryActionView.setTag(cri);
    views.secondaryActionView.setTag(cri);
    views.secondaryActionView.setVisibility(TextUtils.isEmpty(number) ? View.GONE
            : View.VISIBLE);

    String cachedNumber = (String) view.getTag(R.id.number);
    if (cachedNumber != null && cachedNumber.equals(number)) {
        // No need to go set details about the contact again this has
        // already been done
        return;
    }
    CallerInfo info = CallerInfo.getCallerInfoFromSipUri(mContext, number);

    final Uri lookupUri = info.contactContentUri;
    final String name = info.name;
    final int ntype = info.numberType;
    final String label = info.phoneLabel;
    CharSequence formattedNumber = SipUri.getCanonicalSipContact(number, false);
    final int[] callTypes = getCallTypes(c, count);
    PhoneCallDetails details;
    if (TextUtils.isEmpty(name)) {
        details = new PhoneCallDetails(number, formattedNumber,
                callTypes, date, duration);
    } else {
        // We do not pass a photo id since we do not need the high-res
        // picture.
        details = new PhoneCallDetails(number, formattedNumber,
                callTypes, date, duration, name, ntype, label, lookupUri, null);
    }

    mCallLogViewsHelper.setPhoneCallDetails(views, details);
    setPhoto(views, info);
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:68,代码来源:CallLogAdapter.java


注:本文中的com.csipsimple.api.SipUri.getCanonicalSipContact方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。