本文整理汇总了Java中com.csipsimple.api.SipMessage类的典型用法代码示例。如果您正苦于以下问题:Java SipMessage类的具体用法?Java SipMessage怎么用?Java SipMessage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SipMessage类属于com.csipsimple.api包,在下文中一共展示了SipMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: confirmDeleteThread
import com.csipsimple.api.SipMessage; //导入依赖的package包/类
private void confirmDeleteThread(final String from) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(R.string.confirm_dialog_title)
.setIcon(android.R.drawable.ic_dialog_alert)
.setCancelable(true)
.setPositiveButton(R.string.delete, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if(TextUtils.isEmpty(from)) {
getActivity().getContentResolver().delete(SipMessage.MESSAGE_URI, null, null);
}else {
Builder threadUriBuilder = SipMessage.THREAD_ID_URI_BASE.buildUpon();
threadUriBuilder.appendEncodedPath(from);
getActivity().getContentResolver().delete(threadUriBuilder.build(), null, null);
}
}
})
.setNegativeButton(R.string.no, null)
.setMessage(TextUtils.isEmpty(from)
? R.string.confirm_delete_all_conversations
: R.string.confirm_delete_conversation)
.show();
}
示例2: onViewCreated
import com.csipsimple.api.SipMessage; //导入依赖的package包/类
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
getListView().setDivider(null);
fromText.setOnClickListener(this);
sendButton.setOnClickListener(this);
mAdapter = new MessageAdapter(getActivity(), null);
getListView().setAdapter(mAdapter);
// Setup from args
String from = getArguments().getString(SipMessage.FIELD_FROM);
String fullFrom = getArguments().getString(SipMessage.FIELD_FROM_FULL);
if (fullFrom == null) {
fullFrom = from;
}
setupFrom(from, fullFrom);
if (remoteFrom == null) {
chooseSipUri();
}
}
示例3: onContextItemSelected
import com.csipsimple.api.SipMessage; //导入依赖的package包/类
@Override
public boolean onContextItemSelected(android.view.MenuItem item) {
AdapterView.AdapterContextMenuInfo info =
(AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
Cursor c = (Cursor) mAdapter.getItem(info.position);
if (c != null) {
SipMessage msg = new SipMessage(c);
switch (item.getItemId()) {
case MENU_COPY: {
clipboardManager.setText(msg.getDisplayName(), msg.getBody());
break;
}
default:
break;
}
}
return super.onContextItemSelected(item);
}
示例4: sendMessage
import com.csipsimple.api.SipMessage; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void sendMessage(final String message, final String callee, final long accountId) throws RemoteException {
SipService.this.enforceCallingOrSelfPermission(SipManager.PERMISSION_USE_SIP, null);
//We have to ensure service is properly started and not just binded
SipService.this.startService(new Intent(SipService.this, SipService.class));
getExecutor().execute(new SipRunnable() {
@Override
protected void doRun() throws SameThreadException {
Log.d(THIS_FILE, "will sms " + callee);
if(pjService != null) {
ToCall called = pjService.sendMessage(callee, message, accountId);
if(called!=null) {
SipMessage msg = new SipMessage(SipMessage.SELF,
SipUri.getCanonicalSipContact(callee), SipUri.getCanonicalSipContact(called.getCallee()),
message, "text/plain", System.currentTimeMillis(),
SipMessage.MESSAGE_TYPE_QUEUED, called.getCallee());
msg.setRead(true);
getContentResolver().insert(SipMessage.MESSAGE_URI, msg.getContentValues());
Log.d(THIS_FILE, "Inserted "+msg.getTo());
}else {
SipService.this.notifyUserOfMessage( getString(R.string.invalid_sip_uri)+ " : "+callee );
}
}else {
SipService.this.notifyUserOfMessage( getString(R.string.connection_not_valid) );
}
}
});
}
示例5: ConversationsAdapter
import com.csipsimple.api.SipMessage; //导入依赖的package包/类
public ConversationsAdapter(Context context, Cursor c) {
super(context, R.layout.conversation_list_item, c, new String[] {
SipMessage.FIELD_BODY
},
new int[] {
R.id.subject
}, 0);
mContext = context;
}
示例6: getRemoteNumber
import com.csipsimple.api.SipMessage; //导入依赖的package包/类
String getRemoteNumber() {
String number = from;
if (SipMessage.SELF.equals(number)) {
number = to;
}
return number;
}
示例7: formatMessage
import com.csipsimple.api.SipMessage; //导入依赖的package包/类
private CharSequence formatMessage(Cursor cursor) {
SpannableStringBuilder buf = new SpannableStringBuilder();
/*
String remoteContact = cursor.getString(cursor.getColumnIndex(SipMessage.FIELD_FROM));
if (remoteContact.equals("SELF")) {
remoteContact = cursor.getString(cursor.getColumnIndex(SipMessage.FIELD_TO));
buf.append("To: ");
}
*/
String remoteContactFull = cursor.getString(cursor.getColumnIndex(SipMessage.FIELD_FROM_FULL));
CallerInfo callerInfo = CallerInfo.getCallerInfoFromSipUri(mContext, remoteContactFull);
if (callerInfo != null && callerInfo.contactExists) {
buf.append(callerInfo.name);
buf.append(" / ");
buf.append(SipUri.getDisplayedSimpleContact(remoteContactFull));
} else {
buf.append(SipUri.getDisplayedSimpleContact(remoteContactFull));
}
int counter = cursor.getInt(cursor.getColumnIndex("counter"));
if (counter > 1) {
buf.append(" (" + counter + ") ");
}
int read = cursor.getInt(cursor.getColumnIndex(SipMessage.FIELD_READ));
// Unread messages are shown in bold
if (read == 0) {
buf.setSpan(STYLE_BOLD, 0, buf.length(),
Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
}
return buf;
}
示例8: loadMessageContent
import com.csipsimple.api.SipMessage; //导入依赖的package包/类
private void loadMessageContent() {
getLoaderManager().restartLoader(0, getArguments(), this);
String from = getArguments().getString(SipMessage.FIELD_FROM);
if (!TextUtils.isEmpty(from)) {
ContentValues args = new ContentValues();
args.put(SipMessage.FIELD_READ, true);
getActivity().getContentResolver().update(SipMessage.MESSAGE_URI, args,
SipMessage.FIELD_FROM + "=?", new String[] {
from
});
}
}
示例9: getArguments
import com.csipsimple.api.SipMessage; //导入依赖的package包/类
public static Bundle getArguments(String from, String fromFull) {
Bundle bundle = new Bundle();
if (from != null) {
bundle.putString(SipMessage.FIELD_FROM, from);
bundle.putString(SipMessage.FIELD_FROM_FULL, fromFull);
}
return bundle;
}
示例10: getType
import com.csipsimple.api.SipMessage; //导入依赖的package包/类
@Override
public String getType(Uri uri) {
switch (URI_MATCHER.match(uri)) {
case ACCOUNTS:
return SipProfile.ACCOUNT_CONTENT_TYPE;
case ACCOUNTS_ID:
return SipProfile.ACCOUNT_CONTENT_ITEM_TYPE;
case ACCOUNTS_STATUS:
return SipProfile.ACCOUNT_STATUS_CONTENT_TYPE;
case ACCOUNTS_STATUS_ID:
return SipProfile.ACCOUNT_STATUS_CONTENT_ITEM_TYPE;
case CALLLOGS :
return SipManager.CALLLOG_CONTENT_TYPE;
case CALLLOGS_ID :
return SipManager.CALLLOG_CONTENT_ITEM_TYPE;
case FILTERS:
return SipManager.FILTER_CONTENT_TYPE;
case FILTERS_ID:
return SipManager.FILTER_CONTENT_ITEM_TYPE;
case MESSAGES:
return SipMessage.MESSAGE_CONTENT_TYPE;
case MESSAGES_ID:
return SipMessage.MESSAGE_CONTENT_ITEM_TYPE;
case THREADS:
return SipMessage.MESSAGE_CONTENT_TYPE;
case THREADS_ID:
return SipMessage.MESSAGE_CONTENT_ITEM_TYPE;
default:
throw new IllegalArgumentException(UNKNOWN_URI_LOG + uri);
}
}
示例11: on_pager
import com.csipsimple.api.SipMessage; //导入依赖的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();
}
示例12: on_pager_status
import com.csipsimple.api.SipMessage; //导入依赖的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();
}
示例13: onCreateLoader
import com.csipsimple.api.SipMessage; //导入依赖的package包/类
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
return new CursorLoader(getActivity(), SipMessage.THREAD_URI, null, null, null, null);
}
示例14: onVisibilityChanged
import com.csipsimple.api.SipMessage; //导入依赖的package包/类
@Override
public void onVisibilityChanged(boolean visible) {
if(visible) {
attachAdapter();
// Start loading
if(!alreadyLoaded) {
getLoaderManager().initLoader(0, null, this);
alreadyLoaded = true;
}
}
if (visible && isResumed()) {
ListView lv = getListView();
if (lv != null && mAdapter != null) {
final int checkedPos = lv.getCheckedItemPosition();
if (checkedPos >= 0) {
// TODO post instead
Thread t = new Thread() {
public void run() {
Cursor c = (Cursor) mAdapter.getItem(checkedPos - getListView().getHeaderViewsCount());
if(c != null) {
String from = c.getString(c.getColumnIndex(SipMessage.FIELD_FROM));
String to = c.getString(c.getColumnIndex(SipMessage.FIELD_TO));
final String fromFull = c.getString(c.getColumnIndex(SipMessage.FIELD_FROM_FULL));
String number = from;
if (SipMessage.SELF.equals(number)) {
number = to;
}
final String nbr = number;
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
viewDetails(checkedPos, nbr, fromFull);
}
});
}
};
};
t.start();
}
}
}
}
示例15: bindView
import com.csipsimple.api.SipMessage; //导入依赖的package包/类
@Override
public void bindView(View view, Context context, Cursor cursor) {
super.bindView(view, context, cursor);
final ConversationListItemViews tagView = (ConversationListItemViews) view.getTag();
String nbr = cursor.getString(cursor.getColumnIndex(SipMessage.FIELD_FROM));
String fromFull = cursor.getString(cursor.getColumnIndex(SipMessage.FIELD_FROM_FULL));
String to_number = cursor.getString(cursor.getColumnIndex(SipMessage.FIELD_TO));
//int read = cursor.getInt(cursor.getColumnIndex(SipMessage.FIELD_READ));
long date = cursor.getLong(cursor.getColumnIndex(SipMessage.FIELD_DATE));
tagView.fromFull = fromFull;
tagView.to = to_number;
tagView.from = nbr;
tagView.position = cursor.getPosition();
/*
Drawable background = (read == 0)?
context.getResources().getDrawable(R.drawable.conversation_item_background_unread) :
context.getResources().getDrawable(R.drawable.conversation_item_background_read);
view.setBackgroundDrawable(background);
*/
String number = cursor.getString(cursor.getColumnIndex(SipMessage.FIELD_FROM_FULL));
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);
*/
// Photo
tagView.quickContactView.assignContactUri(info.contactContentUri);
ContactsAsyncHelper.updateImageViewWithContactPhotoAsync(mContext,
tagView.quickContactView.getImageView(),
info,
R.drawable.ic_contact_picture_holo_dark);
// From
tagView.fromView.setText(formatMessage(cursor));
//Date
// Set the date/time field by mixing relative and absolute times.
int flags = DateUtils.FORMAT_ABBREV_RELATIVE;
tagView.dateView.setText(DateUtils.getRelativeTimeSpanString(date, System.currentTimeMillis(), DateUtils.MINUTE_IN_MILLIS, flags));
}