コード例 #1
0
ファイル: RubyEngine.java プロジェクト: HEGALLIS/Ruby
  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++;
    }
  }
コード例 #2
0
ファイル: RubyEngine.java プロジェクト: HEGALLIS/Ruby
  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++;
    }
  }
コード例 #3
0
ファイル: Jukebox.java プロジェクト: ejgarcia/isabel
  /** Costructs a new Jukebox. */
  public Jukebox(SipProvider sip_provider, UserAgentProfile user_profile) {
    log = sip_provider.getLog();
    this.user_profile = user_profile;
    this.sip_provider = sip_provider;

    if (user_profile.contact_url == null)
      user_profile.contact_url =
          user_profile.username + "@" + sip_provider.getViaAddress() + ":" + sip_provider.getPort();

    if (!user_profile.no_prompt) stdout = System.out;

    if (user_profile.do_register) {
      RegisterAgent ra =
          new RegisterAgent(
              sip_provider,
              user_profile.from_url,
              user_profile.contact_url,
              user_profile.username,
              user_profile.username,
              user_profile.realm,
              user_profile.passwd,
              this);
      ra.loopRegister(user_profile.expires, user_profile.expires / 2);
    }

    UserAgent ua = new UserAgent(sip_provider, user_profile, this);
    ua.listen();
  }
コード例 #4
0
ファイル: RubyEngine.java プロジェクト: HEGALLIS/Ruby
 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();
 }
コード例 #5
0
ファイル: RubyEngine.java プロジェクト: HEGALLIS/Ruby
  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);
  }
コード例 #6
0
ファイル: RubyEngine.java プロジェクト: HEGALLIS/Ruby
 /** 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();
 }
コード例 #7
0
ファイル: RubyEngine.java プロジェクト: HEGALLIS/Ruby
 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();
   }
 }
コード例 #8
0
ファイル: RubyEngine.java プロジェクト: HEGALLIS/Ruby
 public boolean isRegistered() {
   for (RegisterAgent ra : ras) if (ra != null && ra.isRegistered()) return true;
   return false;
 }