Exemplo n.º 1
0
  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++;
    }
  }
Exemplo n.º 2
0
  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++;
    }
  }
Exemplo n.º 3
0
 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();
 }
Exemplo n.º 4
0
  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);
  }
Exemplo n.º 5
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);
  }
Exemplo n.º 6
0
 /** 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();
 }
Exemplo n.º 7
0
 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();
 }
Exemplo n.º 8
0
 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++;
   }
 }
Exemplo n.º 9
0
 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;
   }
 }
Exemplo n.º 10
0
 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();
   }
 }
Exemplo n.º 11
0
 public int speaker(int mode) {
   int ret = ua.speakerMediaApplication(mode);
   Receiver.progress();
   return ret;
 }
Exemplo n.º 12
0
 public void togglebluetooth() {
   ua.bluetoothMediaApplication();
   Receiver.progress();
 }
Exemplo n.º 13
0
 public void answercall() {
   Receiver.stopRingtone();
   ua.accept();
 }