public void halt() { // modified long time = SystemClock.elapsedRealtime(); int i = 0; for (RegisterAgent ra : ras) { unregister(i); while (ra != null && ra.CurrentState != RegisterAgent.UNREGISTERED && SystemClock.elapsedRealtime() - time < 2000) try { Thread.sleep(100); } catch (InterruptedException e1) { } if (wl[i].isHeld()) { wl[i].release(); if (pwl[i] != null && pwl[i].isHeld()) pwl[i].release(); } if (kas[i] != null) { Receiver.alarm(0, LoopAlarm.class); kas[i].halt(); } Receiver.onText(Receiver.REGISTER_NOTIFICATION + i, null, 0, 0); if (ra != null) ra.halt(); if (uas[i] != null) uas[i].hangup(); if (sip_providers[i] != null) sip_providers[i].halt(); i++; } }
public void registerUdp() { IpAddress.setLocalIpAddress(); int i = 0; for (RegisterAgent ra : ras) { try { if (user_profiles[i] == null || user_profiles[i].username.equals("") || user_profiles[i].realm.equals("") || sip_providers[i] == null || sip_providers[i].getDefaultTransport() == null || sip_providers[i].getDefaultTransport().equals("tcp")) { i++; continue; } user_profiles[i].contact_url = getContactURL(user_profiles[i].from_url, sip_providers[i]); if (!Receiver.isFast(i)) { unregister(i); } else { if (ra != null && ra.register()) { Receiver.onText( Receiver.REGISTER_NOTIFICATION + i, getUIContext().getString(R.string.reg), R.drawable.sym_presence_idle, 0); wl[i].acquire(); } } } catch (Exception ex) { } i++; } }
public void togglemute() { if (ua.muteMediaApplication()) Receiver.onText( Receiver.CALL_NOTIFICATION, getUIContext().getString(R.string.menu_mute), android.R.drawable.stat_notify_call_mute, Receiver.ccCall.base); else Receiver.progress(); }
public void unregister(int i) { if (user_profiles[i] == null || user_profiles[i].username.equals("") || user_profiles[i].realm.equals("")) return; RegisterAgent ra = ras[i]; if (ra != null && ra.unregister()) { Receiver.alarm(0, LoopAlarm.class); Receiver.onText( Receiver.REGISTER_NOTIFICATION + i, getUIContext().getString(R.string.reg), R.drawable.sym_presence_idle, 0); wl[i].acquire(); } else Receiver.onText(Receiver.REGISTER_NOTIFICATION + i, null, 0, 0); }
/** Makes a new call */ public boolean call(String target_url, boolean force) { int p = pref; boolean found = false; if (isRegistered(p) && Receiver.isFast(p)) found = true; else { for (p = 0; p < LINES; p++) if (isRegistered(p) && Receiver.isFast(p)) { found = true; break; } if (!found && force) { p = pref; if (Receiver.isFast(p)) found = true; else for (p = 0; p < LINES; p++) if (Receiver.isFast(p)) { found = true; break; } } } if (!found || (ua = uas[p]) == null) { if (PreferenceManager.getDefaultSharedPreferences(getUIContext()) .getBoolean(Settings.PREF_CALLBACK, Settings.DEFAULT_CALLBACK) && PreferenceManager.getDefaultSharedPreferences(getUIContext()) .getString(Settings.PREF_POSURL, Settings.DEFAULT_POSURL) .length() > 0) { Receiver.url("n=" + Uri.decode(target_url)); return true; } return false; } ua.printLog("UAC: CALLING " + target_url); if (!ua.user_profile.audio && !ua.user_profile.video) { ua.printLog("ONLY SIGNALING, NO MEDIA"); } return ua.call(target_url, false); }
/** When a UA failed on (un)registering. */ public void onUaRegistrationFailure( RegisterAgent reg_ra, NameAddress target, NameAddress contact, String result) { boolean retry = false; int i = 0; for (RegisterAgent ra : ras) { if (ra == reg_ra) break; i++; } if (isRegistered(i)) { reg_ra.CurrentState = RegisterAgent.UNREGISTERED; Receiver.onText(Receiver.REGISTER_NOTIFICATION + i, null, 0, 0); } else { retry = true; Receiver.onText( Receiver.REGISTER_NOTIFICATION + i, getUIContext().getString(R.string.regfailed) + " (" + result + ")", R.drawable.sym_presence_away, 0); } if (retry && SystemClock.uptimeMillis() > lastpwl + 45000 && pwl[i] != null && !pwl[i].isHeld() && Receiver.on_wlan) { lastpwl = SystemClock.uptimeMillis(); if (wl[i].isHeld()) wl[i].release(); pwl[i].acquire(); register(); if (!wl[i].isHeld() && pwl[i].isHeld()) pwl[i].release(); } else if (wl[i].isHeld()) { wl[i].release(); if (pwl[i] != null && pwl[i].isHeld()) pwl[i].release(); } if (SystemClock.uptimeMillis() > lasthalt + 45000) { lasthalt = SystemClock.uptimeMillis(); sip_providers[i].haltConnections(); } updateDNS(); reg_ra.stopMWI(); WifiManager wm = (WifiManager) Receiver.mContext.getSystemService(Context.WIFI_SERVICE); wm.startScan(); }
public void expire() { Receiver.expire_time = 0; int i = 0; for (RegisterAgent ra : ras) { if (ra != null && ra.CurrentState == RegisterAgent.REGISTERED) { ra.CurrentState = RegisterAgent.UNREGISTERED; Receiver.onText(Receiver.REGISTER_NOTIFICATION + i, null, 0, 0); } i++; } register(); }
public void keepAlive() { int i = 0; for (KeepAliveSip ka : kas) { if (ka != null && Receiver.on_wlan && isRegistered(i)) try { ka.sendToken(); Receiver.alarm(60, LoopAlarm.class); } catch (IOException e) { if (!Ruby.release) e.printStackTrace(); } i++; } }
public void onMWIUpdate(RegisterAgent mwi_ra, boolean voicemail, int number, String vmacc) { int i = 0; for (RegisterAgent ra : ras) { if (ra == mwi_ra) break; i++; } if (i != pref) return; if (voicemail) { String msgs = getUIContext().getString(R.string.voicemail); if (number != 0) { msgs = msgs + ": " + number; } Receiver.MWI_account = vmacc; if (lastmsgs[i] == null || !msgs.equals(lastmsgs[i])) { Receiver.onText( Receiver.MWI_NOTIFICATION, msgs, android.R.drawable.stat_notify_voicemail, 0); lastmsgs[i] = msgs; } } else { Receiver.onText(Receiver.MWI_NOTIFICATION, null, 0, 0); lastmsgs[i] = null; } }
public void onUaRegistrationSuccess( RegisterAgent reg_ra, NameAddress target, NameAddress contact, String result) { int i = 0; for (RegisterAgent ra : ras) { if (ra == reg_ra) break; i++; } if (isRegistered(i)) { if (Receiver.on_wlan) Receiver.alarm(60, LoopAlarm.class); Receiver.onText( Receiver.REGISTER_NOTIFICATION + i, getUIContext().getString(i == pref ? R.string.regpref : R.string.regclick), R.drawable.sym_presence_available, 0); reg_ra.subattempts = 0; reg_ra.startMWI(); Receiver.registered(); } else Receiver.onText(Receiver.REGISTER_NOTIFICATION + i, null, 0, 0); if (wl[i].isHeld()) { wl[i].release(); if (pwl[i] != null && pwl[i].isHeld()) pwl[i].release(); } }
public int speaker(int mode) { int ret = ua.speakerMediaApplication(mode); Receiver.progress(); return ret; }
public void togglebluetooth() { ua.bluetoothMediaApplication(); Receiver.progress(); }
public void answercall() { Receiver.stopRingtone(); ua.accept(); }