本文整理汇总了Java中com.csipsimple.api.SipProfileState类的典型用法代码示例。如果您正苦于以下问题:Java SipProfileState类的具体用法?Java SipProfileState怎么用?Java SipProfileState使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SipProfileState类属于com.csipsimple.api包,在下文中一共展示了SipProfileState类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addAccountInfos
import com.csipsimple.api.SipProfileState; //导入依赖的package包/类
/**
* Apply account information to remote view
*
* @param context application context for resources retrieval
* @param activeAccountsInfos List of sip profile state to show in this
* notification view
*/
public void addAccountInfos(Context context, ArrayList<SipProfileState> activeAccountsInfos) {
int i = 0;
for (SipProfileState accountInfo : activeAccountsInfos) {
// Clamp to max possible notifications in remote view
if (i < cells.length) {
setViewVisibility(cells[i], View.VISIBLE);
WizardInfo wizardInfos = WizardUtils.getWizardClass(accountInfo.getWizard());
if (wizardInfos != null) {
CharSequence dName = accountInfo.getDisplayName();
setImageViewResource(icons[i], wizardInfos.icon);
if (!TextUtils.isEmpty(dName)) {
setTextViewText(texts[i], dName);
// setCharSequence(icons[i], "setContentDescription",
// dName);
}
}
i++;
}
}
}
示例2: getProfileState
import com.csipsimple.api.SipProfileState; //导入依赖的package包/类
/**
* Get the dynamic state of the profile
*
* @param account the sip profile from database. Important field is id.
* @return the dynamic sip profile state
*/
public SipProfileState getProfileState(SipProfile account) {
if (!created || account == null) {
return null;
}
if (account.id == SipProfile.INVALID_ID) {
return null;
}
SipProfileState accountInfo = new SipProfileState(account);
Cursor c = service.getContentResolver().query(
ContentUris.withAppendedId(SipProfile.ACCOUNT_STATUS_ID_URI_BASE, account.id),
null, null, null, null);
if (c != null) {
try {
if (c.getCount() > 0) {
c.moveToFirst();
accountInfo.createFromDb(c);
}
} catch (Exception e) {
Log.e(THIS_FILE, "Error on looping over sip profiles states", e);
} finally {
c.close();
}
}
return accountInfo;
}
示例3: setPresence
import com.csipsimple.api.SipProfileState; //导入依赖的package包/类
/**
* Set self presence
*
* @param presence the SipManager.SipPresence
* @param statusText the text of the presence
* @throws SameThreadException
*/
public void setPresence(PresenceStatus presence, String statusText, long accountId)
throws SameThreadException {
if (!created) {
Log.e(THIS_FILE, "PJSIP is not started here, nothing can be done");
return;
}
SipProfile account = new SipProfile();
account.id = accountId;
SipProfileState profileState = getProfileState(account);
// In case of already added, we have to act finely
// If it's local we can just consider that we have to re-add account
// since it will actually just touch the account with a modify
if (profileState != null && profileState.isAddedToStack()) {
// The account is already there in accounts list
pjsua.acc_set_online_status(profileState.getPjsuaId(), getOnlineForStatus(presence));
}
}
示例4: getAccountIdForPjsipId
import com.csipsimple.api.SipProfileState; //导入依赖的package包/类
public static long getAccountIdForPjsipId(Context ctxt, int pjId) {
long accId = SipProfile.INVALID_ID;
Cursor c = ctxt.getContentResolver().query(SipProfile.ACCOUNT_STATUS_URI, null, null,
null, null);
if (c != null) {
try {
c.moveToFirst();
do {
int pjsuaId = c.getInt(c.getColumnIndex(SipProfileState.PJSUA_ID));
Log.d(THIS_FILE, "Found pjsua " + pjsuaId + " searching " + pjId);
if (pjsuaId == pjId) {
accId = c.getInt(c.getColumnIndex(SipProfileState.ACCOUNT_ID));
break;
}
} while (c.moveToNext());
} catch (Exception e) {
Log.e(THIS_FILE, "Error on looping over sip profiles", e);
} finally {
c.close();
}
}
return accId;
}
示例5: getSipProfileState
import com.csipsimple.api.SipProfileState; //导入依赖的package包/类
public SipProfileState getSipProfileState(int accountDbId) {
final SipProfile acc = getAccount(accountDbId);
if(pjService != null && acc != null) {
return pjService.getProfileState(acc);
}
return null;
}
示例6: updateProfileStateFromService
import com.csipsimple.api.SipProfileState; //导入依赖的package包/类
/**
* Synchronize content provider backend from pjsip stack
*
* @param pjsuaId the pjsua id of the account to synchronize
* @throws SameThreadException
*/
public void updateProfileStateFromService(int pjsuaId) throws SameThreadException {
if (!created) {
return;
}
long accId = getAccountIdForPjsipId(service, pjsuaId);
Log.d(THIS_FILE, "Update profile from service for " + pjsuaId + " aka in db " + accId);
if (accId != SipProfile.INVALID_ID) {
int success = pjsuaConstants.PJ_FALSE;
pjsua_acc_info pjAccountInfo;
pjAccountInfo = new pjsua_acc_info();
success = pjsua.acc_get_info(pjsuaId, pjAccountInfo);
if (success == pjsuaConstants.PJ_SUCCESS && pjAccountInfo != null) {
ContentValues cv = new ContentValues();
try {
// Should be fine : status code are coherent with RFC
// status codes
cv.put(SipProfileState.STATUS_CODE, pjAccountInfo.getStatus().swigValue());
} catch (IllegalArgumentException e) {
cv.put(SipProfileState.STATUS_CODE,
SipCallSession.StatusCode.INTERNAL_SERVER_ERROR);
}
cv.put(SipProfileState.STATUS_TEXT, pjStrToString(pjAccountInfo.getStatus_text()));
cv.put(SipProfileState.EXPIRES, pjAccountInfo.getExpires());
service.getContentResolver().update(
ContentUris.withAppendedId(SipProfile.ACCOUNT_STATUS_ID_URI_BASE, accId),
cv, null, null);
Log.d(THIS_FILE, "Profile state UP : " + cv);
}
} else {
Log.e(THIS_FILE, "Trying to update not added account " + pjsuaId);
}
}
示例7: updateRegistrationsState
import com.csipsimple.api.SipProfileState; //导入依赖的package包/类
public void updateRegistrationsState() {
Log.d(THIS_FILE, "Update registration state");
ArrayList<SipProfileState> activeProfilesState = new ArrayList<SipProfileState>();
Cursor c = getContentResolver().query(SipProfile.ACCOUNT_STATUS_URI, null, null, null, null);
if (c != null) {
try {
if(c.getCount() > 0) {
c.moveToFirst();
do {
SipProfileState ps = new SipProfileState(c);
if(ps.isValidForCall()) {
activeProfilesState.add(ps);
}
} while ( c.moveToNext() );
}
} catch (Exception e) {
Log.e(THIS_FILE, "Error on looping over sip profiles", e);
} finally {
c.close();
}
}
Collections.sort(activeProfilesState, SipProfileState.getComparator());
// Handle status bar notification
if (activeProfilesState.size() > 0 &&
prefsWrapper.getPreferenceBooleanValue(SipConfigManager.ICON_IN_STATUS_BAR, true)) {
// Testing memory / CPU leak as per issue 676
// for(int i=0; i < 10; i++) {
// Log.d(THIS_FILE, "Notify ...");
notificationManager.notifyRegisteredAccounts(activeProfilesState, prefsWrapper.getPreferenceBooleanValue(SipConfigManager.ICON_IN_STATUS_BAR_NBR));
// try {
// Thread.sleep(6000);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// }
} else {
notificationManager.cancelRegisters();
}
if(hasSomeActiveAccount) {
acquireResources();
}else {
releaseResources();
}
}
示例8: notifyRegisteredAccounts
import com.csipsimple.api.SipProfileState; //导入依赖的package包/类
public synchronized void notifyRegisteredAccounts(ArrayList<SipProfileState> activeAccountsInfos, boolean showNumbers) {
if (!isServiceWrapper) {
Log.e(THIS_FILE, "Trying to create a service notification from outside the service");
return;
}
int icon = R.drawable.ic_stat_sipok;
CharSequence tickerText = context.getString(R.string.service_ticker_registered_text);
long when = System.currentTimeMillis();
Builder nb = new Builder(context);
nb.setSmallIcon(icon);
nb.setTicker(tickerText);
nb.setWhen(when);
Intent notificationIntent = new Intent(SipManager.ACTION_SIP_DIALER);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
RegistrationNotification contentView = new RegistrationNotification(context.getPackageName());
contentView.clearRegistrations();
if(!Compatibility.isCompatible(9)) {
contentView.setTextsColor(notificationPrimaryTextColor);
}
contentView.addAccountInfos(context, activeAccountsInfos);
// notification.setLatestEventInfo(context, contentTitle,
// contentText, contentIntent);
nb.setOngoing(true);
nb.setOnlyAlertOnce(true);
nb.setContentIntent(contentIntent);
nb.setContent(contentView);
Notification notification = nb.build();
notification.flags |= Notification.FLAG_NO_CLEAR;
// We have to re-write content view because getNotification setLatestEventInfo implicitly
notification.contentView = contentView;
if (showNumbers) {
// This only affects android 2.3 and lower
notification.number = activeAccountsInfos.size();
}
startForegroundCompat(REGISTER_NOTIF_ID, notification);
}
示例9: setAccountRegistration
import com.csipsimple.api.SipProfileState; //导入依赖的package包/类
/**
* Change account registration / adding state
*
* @param account The account to modify registration
* @param renew if 0 we ask for deletion of this account; if 1 we ask for
* registration of this account (and add if necessary)
* @param forceReAdd if true, we will first remove the account and then
* re-add it
* @return true if the operation get completed without problem
* @throws SameThreadException
*/
public boolean setAccountRegistration(SipProfile account, int renew, boolean forceReAdd)
throws SameThreadException {
int status = -1;
if (!created || account == null) {
Log.e(THIS_FILE, "PJSIP is not started here, nothing can be done");
return false;
}
if (account.id == SipProfile.INVALID_ID) {
Log.w(THIS_FILE, "Trying to set registration on a deleted account");
return false;
}
SipProfileState profileState = getProfileState(account);
// If local account -- Ensure we are not deleting, because this would be
// invalid
if (profileState.getWizard().equalsIgnoreCase(WizardUtils.LOCAL_WIZARD_TAG)) {
if (renew == 0) {
return false;
}
}
// In case of already added, we have to act finely
// If it's local we can just consider that we have to re-add account
// since it will actually just touch the account with a modify
if (profileState != null && profileState.isAddedToStack()
&& !profileState.getWizard().equalsIgnoreCase(WizardUtils.LOCAL_WIZARD_TAG)) {
// The account is already there in accounts list
service.getContentResolver().delete(
ContentUris.withAppendedId(SipProfile.ACCOUNT_STATUS_URI, account.id), null,
null);
Log.d(THIS_FILE, "Account already added to stack, remove and re-load or delete");
if (renew == 1) {
if (forceReAdd) {
status = pjsua.acc_del(profileState.getPjsuaId());
addAccount(account);
} else {
pjsua.acc_set_online_status(profileState.getPjsuaId(),
getOnlineForStatus(service.getPresence()));
status = pjsua.acc_set_registration(profileState.getPjsuaId(), renew);
}
} else {
// if(status == pjsuaConstants.PJ_SUCCESS && renew == 0) {
Log.d(THIS_FILE, "Delete account !!");
status = pjsua.acc_del(profileState.getPjsuaId());
}
} else {
if (renew == 1) {
addAccount(account);
} else {
Log.w(THIS_FILE, "Ask to unregister an unexisting account !!" + account.id);
}
}
// PJ_SUCCESS = 0
return status == 0;
}