Пример #1
0
  private boolean isAtleastOneBuddyOnPhone() {

    IBuddy[] buddies = this.myVoip.getAccount().getBuddies();
    for (IBuddy buddy : buddies) {
      if (buddy.getState() == BuddyState.ON_LINE) return true;
    }

    return false;
  }
Пример #2
0
  private void updateBuddyStateInfo(IBuddy buddy) {
    Log.d(TAG, "Called updateBuddyStateInfo on buddy");
    if (buddy == null) {
      Log.e(TAG, "Called updateBuddyStateInfo on NULL buddy");
      return;
    }

    Log.d(TAG, "Called updateBuddyStateInfo on buddy:" + buddy.getUri());

    int buddyPosition = this.buddyArrayAdapter.getPosition(buddy);
    if (buddyPosition < 0) {
      Log.d(TAG, "Adding buddy to listView!");
      this.buddiesArray.add(buddy);

    } else {
      Log.d(TAG, "Replacing buddy into the listView!");
      this.buddiesArray.set(buddyPosition, buddy);
    }
    this.buddyArrayAdapter.notifyDataSetChanged();
  }
Пример #3
0
    @Override
    public void handleMessage(Message voipMessage) {

      if (voipMessage.what == -1) {
        Log.d(TAG, "App exiting request");
        myVoip.destroyLib();
        finish();
        Runtime.getRuntime().gc();
        android.os.Process.killProcess(android.os.Process.myPid());
        return;
      }

      VoipEventBundle myEventBundle = getEventBundle(voipMessage);
      Log.d(
          TAG,
          "HANDLE MESSAGE TYPE:"
              + myEventBundle.getEventType()
              + " EVENT:"
              + myEventBundle.getEvent());

      updateCallStateInfo();
      updateServerStateInfo();

      if (myEventBundle.getEventType() == VoipEventType.BUDDY_EVENT) {
        Log.d(TAG, "In handle Message for BUDDY STATE");
        IBuddy myBuddy = (IBuddy) myEventBundle.getData();
        this.app.addInfoLine("Buddy (" + myBuddy.getUri() + ") ->" + myBuddy.getStatusText());
        updateBuddyStateInfo(myBuddy);
      }
      // Register the account after the Lib Initialization
      if (myEventBundle.getEvent() == VoipEvent.LIB_INITIALIZED) {
        myVoip.registerAccount();
      } else if (myEventBundle.getEvent() == VoipEvent.ACCOUNT_REGISTERED) {
        this.app.addInfoLine("Ready to accept calls (adding buddy...)");
        // add a buddy so that we can receive presence notifications from it
        subscribeBuddies();
      } else if (myEventBundle.getEvent() == VoipEvent.CALL_INCOMING) handleIncomingCall();
      // else if  (myState.getState()==VoipState.CALL_ACTIVE)    {}

      // Unregister the account
      else if (myEventBundle.getEvent() == VoipEvent.CALL_HANGUP) {
        setupButtons(false);
        ICall callInfo = (ICall) myEventBundle.getData();
        Log.d(TAG, "Hangup from uri:" + callInfo.getRemoteUri());
        IBuddy myBuddy = myVoip.getAccount().getBuddy(callInfo.getRemoteUri());
        Log.d(TAG, "Current Buddy Status Text:" + myBuddy.getStatusText());
        updateBuddyStateInfo(myBuddy);
        // myVoip.unregisterAccount();
      }
      // Deinitialize the Voip Lib and release all allocated resources
      else if (myEventBundle.getEvent() == VoipEvent.LIB_DEINITIALIZED
          || myEventBundle.getEvent() == VoipEvent.LIB_DEINITIALIZATION_FAILED) {
        Log.d(TAG, "Setting to null MyVoipLib");
        this.app.myVoip = null;

        if (this.reinitRequest) {
          this.reinitRequest = false;
          this.app.runExample();
        }
      }
    } // end of handleMessage()