Search in sources :

Example 1 with PgpDecryptionService

use of de.pixart.messenger.crypto.PgpDecryptionService in project Pix-Art-Messenger by kriztan.

the class Account method initAccountServices.

public void initAccountServices(final XmppConnectionService context) {
    this.mOtrService = new OtrService(context, this);
    this.axolotlService = new AxolotlService(this, context);
    this.pgpDecryptionService = new PgpDecryptionService(context);
    if (xmppConnection != null) {
        xmppConnection.addOnAdvancedStreamFeaturesAvailableListener(axolotlService);
    }
}
Also used : AxolotlService(de.pixart.messenger.crypto.axolotl.AxolotlService) OtrService(de.pixart.messenger.crypto.OtrService) PgpDecryptionService(de.pixart.messenger.crypto.PgpDecryptionService)

Example 2 with PgpDecryptionService

use of de.pixart.messenger.crypto.PgpDecryptionService in project Pix-Art-Messenger by kriztan.

the class Conversation method trim.

public void trim() {
    synchronized (this.messages) {
        final int size = messages.size();
        final int maxsize = Config.PAGE_SIZE * Config.MAX_NUM_PAGES;
        if (size > maxsize) {
            List<Message> discards = this.messages.subList(0, size - maxsize);
            final PgpDecryptionService pgpDecryptionService = account.getPgpDecryptionService();
            if (pgpDecryptionService != null) {
                pgpDecryptionService.discard(discards);
            }
            discards.clear();
            untieMessages();
        }
    }
}
Also used : PgpDecryptionService(de.pixart.messenger.crypto.PgpDecryptionService)

Example 3 with PgpDecryptionService

use of de.pixart.messenger.crypto.PgpDecryptionService in project Pix-Art-Messenger by kriztan.

the class XmppConnectionService method onCreate.

@SuppressLint("TrulyRandom")
@Override
public void onCreate() {
    ExceptionHelper.init(getApplicationContext());
    PRNGFixes.apply();
    Resolver.init(this);
    this.mRandom = new SecureRandom();
    updateMemorizingTrustmanager();
    final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);
    final int cacheSize = maxMemory / 8;
    this.mBitmapCache = new LruCache<String, Bitmap>(cacheSize) {

        @Override
        protected int sizeOf(final String key, final Bitmap bitmap) {
            return bitmap.getByteCount() / 1024;
        }
    };
    Log.d(Config.LOGTAG, "initializing database...");
    this.databaseBackend = DatabaseBackend.getInstance(getApplicationContext());
    Log.d(Config.LOGTAG, "restoring accounts...");
    this.accounts = databaseBackend.getAccounts();
    final SharedPreferences.Editor editor = getPreferences().edit();
    if (this.accounts.size() == 0 && Arrays.asList("Sony", "Sony Ericsson").contains(Build.MANUFACTURER)) {
        editor.putBoolean(SettingsActivity.SHOW_FOREGROUND_SERVICE, true);
        Log.d(Config.LOGTAG, Build.MANUFACTURER + " is on blacklist. enabling foreground service");
    }
    editor.putBoolean(EventReceiver.SETTING_ENABLED_ACCOUNTS, hasEnabledAccounts()).apply();
    editor.apply();
    restoreFromDatabase();
    getContentResolver().registerContentObserver(ContactsContract.Contacts.CONTENT_URI, true, contactObserver);
    new Thread(new Runnable() {

        @Override
        public void run() {
            fileObserver.startWatching();
        }
    }).start();
    if (Config.supportOpenPgp()) {
        this.pgpServiceConnection = new OpenPgpServiceConnection(this, "org.sufficientlysecure.keychain", new OpenPgpServiceConnection.OnBound() {

            @Override
            public void onBound(IOpenPgpService2 service) {
                for (Account account : accounts) {
                    final PgpDecryptionService pgp = account.getPgpDecryptionService();
                    if (pgp != null) {
                        pgp.continueDecryption(true);
                    }
                }
            }

            @Override
            public void onError(Exception e) {
            }
        });
        this.pgpServiceConnection.bindToService();
    }
    this.pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    this.wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "XmppConnectionService");
    toggleForegroundService();
    updateUnreadCountBadge();
    toggleScreenEventReceiver();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        scheduleNextIdlePing();
    }
    // start export log service every day at given time
    ScheduleAutomaticExport();
    // cancel scheduled exporter
    CancelAutomaticExport(false);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        registerReceiver(this.mEventReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
    }
}
Also used : Account(de.pixart.messenger.entities.Account) IntentFilter(android.content.IntentFilter) IOpenPgpService2(org.openintents.openpgp.IOpenPgpService2) SharedPreferences(android.content.SharedPreferences) SecureRandom(java.security.SecureRandom) OpenPgpServiceConnection(org.openintents.openpgp.util.OpenPgpServiceConnection) PgpDecryptionService(de.pixart.messenger.crypto.PgpDecryptionService) SuppressLint(android.annotation.SuppressLint) OtrException(net.java.otr4j.OtrException) InvalidJidException(de.pixart.messenger.xmpp.jid.InvalidJidException) CertificateException(java.security.cert.CertificateException) Bitmap(android.graphics.Bitmap) SuppressLint(android.annotation.SuppressLint)

Aggregations

PgpDecryptionService (de.pixart.messenger.crypto.PgpDecryptionService)3 SuppressLint (android.annotation.SuppressLint)1 IntentFilter (android.content.IntentFilter)1 SharedPreferences (android.content.SharedPreferences)1 Bitmap (android.graphics.Bitmap)1 OtrService (de.pixart.messenger.crypto.OtrService)1 AxolotlService (de.pixart.messenger.crypto.axolotl.AxolotlService)1 Account (de.pixart.messenger.entities.Account)1 InvalidJidException (de.pixart.messenger.xmpp.jid.InvalidJidException)1 SecureRandom (java.security.SecureRandom)1 CertificateException (java.security.cert.CertificateException)1 OtrException (net.java.otr4j.OtrException)1 IOpenPgpService2 (org.openintents.openpgp.IOpenPgpService2)1 OpenPgpServiceConnection (org.openintents.openpgp.util.OpenPgpServiceConnection)1