private void initServiceDiscovery() {
    ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(extXMPPConnection);
    try {
      if (capsCacheDir == null) {
        capsCacheDir = new File(service.getCacheDir(), "entity-caps-cache");
        capsCacheDir.mkdirs();
        EntityCapsManager.setPersistentCache(new SimpleDirectoryPersistentCache(capsCacheDir));
      }
    } catch (java.io.IOException e) {
      Log.e(TAG, "Could not init : " + e.getLocalizedMessage());
    }

    PingManager.getInstanceFor(extXMPPConnection).setPingMinimumInterval(10 * 1000);
    String app_name = service.getString(R.string.app_name);
    String build_revision = service.getString(R.string.build_revision);
    Version.Manager.getInstanceFor(extXMPPConnection)
        .setVersion(new Version(app_name, build_revision, Constant.ANDROID));

    DeliveryReceiptManager dm = DeliveryReceiptManager.getInstanceFor(extXMPPConnection);
    dm.enableAutoReceipts();
    dm.addReceiptReceivedListener(
        new ReceiptReceivedListener() { // DOES NOT WORK IN CARBONS
          public void onReceiptReceived(String fromJid, String toJid, String receiptId) {

            changeMessageDeliveryStatus(receiptId, ChatConstants.DS_ACKED);
          }
        });
  }
Beispiel #2
0
  private void initServiceDiscovery() {
    // register connection features
    ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(mXMPPConnection);

    // init Entity Caps manager with storage in app's cache dir
    try {
      if (capsCacheDir == null) {
        capsCacheDir = new File(mService.getCacheDir(), "entity-caps-cache");
        capsCacheDir.mkdirs();
        EntityCapsManager.setPersistentCache(new SimpleDirectoryPersistentCache(capsCacheDir));
      }
    } catch (java.io.IOException e) {
      Log.e(TAG, "Could not init Entity Caps cache: " + e.getLocalizedMessage());
    }

    // reference PingManager, set ping flood protection to 10s
    PingManager.getInstanceFor(mXMPPConnection).setPingMinimumInterval(10 * 1000);

    // set Version for replies
    String app_name = mService.getString(org.yaxim.androidclient.R.string.app_name);
    String build_revision = mService.getString(org.yaxim.androidclient.R.string.build_revision);
    Version.Manager.getInstanceFor(mXMPPConnection)
        .setVersion(new Version(app_name, build_revision, "Android"));

    // reference DeliveryReceiptManager, add listener
    DeliveryReceiptManager dm = DeliveryReceiptManager.getInstanceFor(mXMPPConnection);
    dm.enableAutoReceipts();
    dm.addReceiptReceivedListener(
        new ReceiptReceivedListener() { // DOES NOT WORK IN CARBONS
          public void onReceiptReceived(String fromJid, String toJid, String receiptId) {
            Log.d(TAG, "got delivery receipt for " + receiptId);
            changeMessageDeliveryStatus(receiptId, ChatConstants.DS_ACKED);
          }
        });
  }