本文整理汇总了Java中com.csipsimple.api.SipProfile类的典型用法代码示例。如果您正苦于以下问题:Java SipProfile类的具体用法?Java SipProfile怎么用?Java SipProfile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SipProfile类属于com.csipsimple.api包,在下文中一共展示了SipProfile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRequest
import com.csipsimple.api.SipProfile; //导入依赖的package包/类
@Override
public HttpRequestBase getRequest(SipProfile acc) throws IOException {
String requestURL = "http://200.152.124.172/billing/webservice/Server.php";
HttpPost httpPost = new HttpPost(requestURL);
httpPost.addHeader("SOAPAction", "\"mostra_creditos\"");
httpPost.addHeader("Content-Type", "text/xml");
// prepare POST body
String body = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><SOAP-ENV:Envelope " +
"SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" " +
"xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" " +
"xmlns:xsi=\"http://www.w3.org/1999/XMLSchema-instance\" " +
"xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/1999/XMLSchema\"" +
"><SOAP-ENV:Body><mostra_creditos SOAP-ENC:root=\"1\">" +
"<chave xsi:type=\"xsd:string\">" +
acc.data +
"</chave><username xsi:type=\"xsd:string\">" +
acc.username.replaceAll("^12", "") +
"</username></mostra_creditos></SOAP-ENV:Body></SOAP-ENV:Envelope>";
Log.d(THIS_FILE, "Sending request for user " + acc.username.replaceAll("^12", ""));
// set POST body
HttpEntity entity = new StringEntity(body);
httpPost.setEntity(entity);
return httpPost;
}
示例2: getAccountIdForCallHandler
import com.csipsimple.api.SipProfile; //导入依赖的package包/类
/**
* Retrieve internal id of call handler as saved in databases It should be
* some negative < SipProfile.INVALID_ID number
*
* @param ctxt Application context
* @param packageName name of the call handler package
* @return the id of this call handler in databases
*/
public static Long getAccountIdForCallHandler(Context ctxt, String packageName) {
SharedPreferences prefs = ctxt.getSharedPreferences("handlerCache", Context.MODE_PRIVATE);
long accountId = SipProfile.INVALID_ID;
try {
accountId = prefs.getLong(VIRTUAL_ACC_PREFIX + packageName, SipProfile.INVALID_ID);
} catch (Exception e) {
Log.e(THIS_FILE, "Can't retrieve call handler cache id - reset");
}
if (accountId == SipProfile.INVALID_ID) {
// We never seen this one, add a new entry for account id
int maxAcc = prefs.getInt(VIRTUAL_ACC_MAX_ENTRIES, 0x0);
int currentEntry = maxAcc + 1;
accountId = SipProfile.INVALID_ID - (long) currentEntry;
Editor edt = prefs.edit();
edt.putLong(VIRTUAL_ACC_PREFIX + packageName, accountId);
edt.putInt(VIRTUAL_ACC_MAX_ENTRIES, currentEntry);
edt.commit();
}
return accountId;
}
示例3: addBuddiesForAccount
import com.csipsimple.api.SipProfile; //导入依赖的package包/类
/**
* Add buddies for a given account
* @param acc
*/
private synchronized void addBuddiesForAccount(SipProfile acc) {
// Get buddies uris for this account
final List<String> toAdd = getBuddiesForAccount(acc);
if (toAdd.size() > 0 && service != null) {
service.getExecutor().execute(new SipRunnable() {
@Override
protected void doRun() throws SameThreadException {
for (String csipUri : toAdd) {
service.addBuddy("sip:" + csipUri);
}
}
});
}
addedAccounts.add(acc);
}
示例4: fillLayout
import com.csipsimple.api.SipProfile; //导入依赖的package包/类
public void fillLayout(final SipProfile account) {
bindFields();
if(!TextUtils.isEmpty(account.display_name)) {
accountDisplayName.setText(account.display_name);
}else {
accountDisplayName.setText(getDefaultName());
}
if(accountUsername != null) {
accountUsername.setText(account.getSipUserName());
}
if(accountServer != null) {
accountServer.setText(account.getSipDomain());
}
accountPassword.setText(account.data);
if(accountAuthorization != null) {
accountAuthorization.setText(account.username);
}
}
示例5: onActivityResult
import com.csipsimple.api.SipProfile; //导入依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode == CREATE_ACCOUNT) {
if(resultCode == Activity.RESULT_OK) {
String uname = data.getStringExtra(SipProfile.FIELD_USERNAME);
String pwd = data.getStringExtra(SipProfile.FIELD_DATA);
if(!TextUtils.isEmpty(uname) && !TextUtils.isEmpty(pwd)) {
setUsername(uname);
setPassword(pwd);
if(canSave()) {
parent.saveAndFinish();
}
}
}
}
}
示例6: buildAccount
import com.csipsimple.api.SipProfile; //导入依赖的package包/类
public SipProfile buildAccount(SipProfile account) {
account = super.buildAccount(account);
account.transport = SipProfile.TRANSPORT_UDP;
account.reg_timeout = 180;
// Use port 80 for blocked countries
String currentCountry = Locale.getDefault().getCountry();
if(!TextUtils.isEmpty(currentCountry)) {
if ("AE".equalsIgnoreCase(currentCountry) ||
"CN".equalsIgnoreCase(currentCountry) ||
"PK".equalsIgnoreCase(currentCountry)) {
account.proxies = new String[] {
"sip99.mondotalk.com:80"
};
}
}
return account;
}
示例7: fillLayout
import com.csipsimple.api.SipProfile; //导入依赖的package包/类
@Override
public void fillLayout(final SipProfile account) {
super.fillLayout(account);
//Override titles so they are consistent with the how our support docs refer to them
accountUsername.setTitle(R.string.w_onsip_username);
accountUsername.setDialogTitle(R.string.w_onsip_username_desc);
accountAuthorization.setTitle(R.string.w_onsip_authentication_name);
accountAuthorization.setDialogTitle(R.string.w_onsip_authentication_name_desc);
accountPassword.setTitle(R.string.w_onsip_password);
accountPassword.setDialogTitle(R.string.w_onsip_password_desc);
accountServer.setTitle(R.string.w_onsip_server);
accountServer.setDialogTitle(R.string.w_onsip_server_desc);
}
示例8: profileFromContextMenuInfo
import com.csipsimple.api.SipProfile; //导入依赖的package包/类
/**
* Retrieve sip account from a given context menu info pressed
* @param cmi The context menu info to retrieve infos from
* @return corresponding sip profile if everything goes well, null if not able to retrieve profile
*/
private SipProfile profileFromContextMenuInfo(ContextMenuInfo cmi) {
AdapterView.AdapterContextMenuInfo info;
try {
info = (AdapterView.AdapterContextMenuInfo) cmi;
} catch (ClassCastException e) {
Log.e(THIS_FILE, "bad menuInfo", e);
return null;
}
Cursor c = (Cursor) getListAdapter().getItem(info.position - getListView().getHeaderViewsCount());
if (c == null) {
// For some reason the requested item isn't available, do nothing
return null;
}
return new SipProfile(c);
}
示例9: onCreateContextMenu
import com.csipsimple.api.SipProfile; //导入依赖的package包/类
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
final SipProfile account = profileFromContextMenuInfo(menuInfo);
if(account == null) {
return;
}
WizardInfo wizardInfos = WizardUtils.getWizardClass(account.wizard);
// Setup the menu header
menu.setHeaderTitle(account.display_name);
if(wizardInfos != null) {
menu.setHeaderIcon(wizardInfos.icon);
}
menu.add(0, MENU_ITEM_ACTIVATE, 0, account.active ? R.string.deactivate_account
: R.string.activate_account);
menu.add(0, MENU_ITEM_MODIFY, 0, R.string.modify_account);
menu.add(0, MENU_ITEM_DELETE, 0, R.string.delete_account);
menu.add(0, MENU_ITEM_WIZARD, 0, R.string.choose_wizard);
}
示例10: onItemSelected
import com.csipsimple.api.SipProfile; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void onItemSelected(AdapterView<?> adapter, View v, int position, long id) {
if(profileId != SipProfile.INVALID_ID) {
if(hasPresenceRegistration && isValid) {
if(position < PRESENCES_ITEMS_LENGTH) {
if(service != null) {
try {
service.setPresence(getSelectedPresence().ordinal(), "Test", profileId);
} catch (RemoteException e) {
Log.e(THIS_FILE, "Error while trying to set presence through service", e);
}
}
}
}
}
}
示例11: updateRegistration
import com.csipsimple.api.SipProfile; //导入依赖的package包/类
/**
* Update user interface when registration of account has changed
* This include change selected account if we are in canChangeIfValid mode
*/
private void updateRegistration() {
if(profileId < 0) {
return;
}
SipProfile acc = SipProfile.getProfileFromDbId(getContext(), profileId, ACC_PROJECTION);
isValid = false;
hasPresenceRegistration = false;
if(acc != null) {
AccountStatusDisplay accountStatusDisplay = AccountListUtils
.getAccountDisplay(getContext(), acc.id);
if(accountStatusDisplay.availableForCalls) {
isValid = true;
}
hasPresenceRegistration = (acc.publish_enabled == 1);
}
setEnabled(isValid);
setVisibility(hasPresenceRegistration ? View.VISIBLE : View.GONE);
}
示例12: buildAccount
import com.csipsimple.api.SipProfile; //导入依赖的package包/类
public SipProfile buildAccount(SipProfile account) {
account.display_name = accountDisplayName.getText();
account.acc_id = "<sip:" + SipUri.encodeUser(accountUsername.getText().trim()) + "@" + getDomain() + ">";
String regUri = "sip:" + getDomain();
account.reg_uri = regUri;
account.proxies = new String[] { "sip:"+accountProxy.getText() } ;
account.realm = "*";
account.username = getText(accountAuthorization).trim();
account.data = getText(accountPassword);
account.scheme = SipProfile.CRED_SCHEME_DIGEST;
account.datatype = SipProfile.CRED_DATA_PLAIN_PASSWD;
account.reg_timeout = 1800;
account.transport = SipProfile.TRANSPORT_UDP;
return account;
}
示例13: setAccount
import com.csipsimple.api.SipProfile; //导入依赖的package包/类
/**
* Set the currently selected account for this widget
* It will change internal state,
* Change icon and label of the account
* @param aAccount
*/
public void setAccount(SipProfile aAccount) {
account = aAccount;
if (account == null) {
if(isInEditMode() || Compatibility.canMakeGSMCall(getContext())) {
textView.setText(getResources().getString(R.string.gsm));
imageView.setImageResource(R.drawable.ic_wizard_gsm);
}else {
textView.setText(getResources().getString(R.string.acct_inactive));
imageView.setImageResource(android.R.drawable.ic_dialog_alert);
}
} else {
textView.setText(account.display_name);
imageView.setImageDrawable(new BitmapDrawable(getResources(), WizardUtils.getWizardBitmap(getContext(),
account)));
}
if (onAccountChange != null) {
onAccountChange.onChooseAccount(account);
}
}
示例14: getProfileState
import com.csipsimple.api.SipProfile; //导入依赖的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;
}
示例15: getDefaultFilters
import com.csipsimple.api.SipProfile; //导入依赖的package包/类
@Override
public List<Filter> getDefaultFilters(SipProfile acc) {
// For US and Canada resident, auto add 10 digits => prefix with 1 rewriting rule
String country = Locale.getDefault().getCountry();
if (Locale.CANADA.getCountry().equals(country) || Locale.US.getCountry().equals(country)) {
ArrayList<Filter> filters = new ArrayList<Filter>();
Filter f = new Filter();
f.account = (int) acc.id;
f.action = Filter.ACTION_REPLACE;
f.matchPattern = "^(\\d{10})$";
f.replacePattern = "1$0";
f.matchType = Filter.MATCHER_HAS_N_DIGIT;
filters.add(f);
return filters;
}
return null;
}