Search in sources :

Example 1 with PrivateDataManager

use of org.jivesoftware.smackx.iqprivate.PrivateDataManager in project Spark by igniterealtime.

the class PrivateNotes method savePrivateNotes.

public static void savePrivateNotes(PrivateNotes notes) {
    PrivateDataManager manager = PrivateDataManager.getInstanceFor(SparkManager.getConnection());
    PrivateDataManager.addPrivateDataProvider("scratchpad", "scratchpad:notes", new PrivateNotes.Provider());
    try {
        manager.setPrivateData(notes);
    } catch (XMPPException | SmackException e) {
        Log.error(e);
    }
}
Also used : SmackException(org.jivesoftware.smack.SmackException) PrivateDataManager(org.jivesoftware.smackx.iqprivate.PrivateDataManager) XMPPException(org.jivesoftware.smack.XMPPException)

Example 2 with PrivateDataManager

use of org.jivesoftware.smackx.iqprivate.PrivateDataManager in project Spark by igniterealtime.

the class Tasks method saveTasks.

public static void saveTasks(Tasks tasks, XMPPConnection con) {
    PrivateDataManager manager = PrivateDataManager.getInstanceFor(con);
    PrivateDataManager.addPrivateDataProvider("scratchpad", "scratchpad:tasks", new Tasks.Provider());
    try {
        manager.setPrivateData(tasks);
    } catch (XMPPException | SmackException e) {
        Log.error(e);
    }
}
Also used : SmackException(org.jivesoftware.smack.SmackException) PrivateDataManager(org.jivesoftware.smackx.iqprivate.PrivateDataManager) XMPPException(org.jivesoftware.smack.XMPPException)

Example 3 with PrivateDataManager

use of org.jivesoftware.smackx.iqprivate.PrivateDataManager in project xabber-android by redsolution.

the class PrivateStorageManager method setPrivateData.

private void setPrivateData(AccountJid accountJid, PrivateData privateData) {
    AccountItem accountItem = AccountManager.getInstance().getAccount(accountJid);
    if (accountItem == null || !accountItem.isEnabled())
        return;
    XMPPTCPConnection connection = accountItem.getConnection();
    PrivateDataManager privateDataManager = PrivateDataManager.getInstanceFor(connection);
    try {
        if (!privateDataManager.isSupported())
            return;
        privateDataManager.setPrivateData(privateData);
    } catch (SmackException.NoResponseException | XMPPException.XMPPErrorException | SmackException.NotConnectedException | InterruptedException | IllegalArgumentException e) {
        e.printStackTrace();
    }
}
Also used : XMPPTCPConnection(com.xabber.xmpp.smack.XMPPTCPConnection) AccountItem(com.xabber.android.data.account.AccountItem) PrivateDataManager(org.jivesoftware.smackx.iqprivate.PrivateDataManager)

Example 4 with PrivateDataManager

use of org.jivesoftware.smackx.iqprivate.PrivateDataManager in project Spark by igniterealtime.

the class PrivateNotes method getPrivateNotes.

public static PrivateNotes getPrivateNotes() {
    PrivateDataManager manager = PrivateDataManager.getInstanceFor(SparkManager.getConnection());
    PrivateDataManager.addPrivateDataProvider("scratchpad", "scratchpad:notes", new PrivateNotes.Provider());
    PrivateNotes notes = null;
    try {
        notes = (PrivateNotes) manager.getPrivateData("scratchpad", "scratchpad:notes");
    } catch (XMPPException | SmackException e) {
        Log.error(e);
    }
    if (notes.getNotes() != null) {
        String note = notes.getNotes().replaceAll("&", "&");
        notes.setMyNotes(note);
    }
    return notes;
}
Also used : SmackException(org.jivesoftware.smack.SmackException) PrivateDataManager(org.jivesoftware.smackx.iqprivate.PrivateDataManager) XMPPException(org.jivesoftware.smack.XMPPException)

Example 5 with PrivateDataManager

use of org.jivesoftware.smackx.iqprivate.PrivateDataManager in project Spark by igniterealtime.

the class Tasks method getTaskList.

public static Tasks getTaskList(XMPPConnection con) {
    PrivateDataManager manager = PrivateDataManager.getInstanceFor(con);
    PrivateDataManager.addPrivateDataProvider("scratchpad", "scratchpad:tasks", new Tasks.Provider());
    Tasks tasks = null;
    try {
        tasks = (Tasks) manager.getPrivateData("scratchpad", "scratchpad:tasks");
    } catch (XMPPException | SmackException e) {
        Log.error(e);
    }
    return tasks;
}
Also used : SmackException(org.jivesoftware.smack.SmackException) PrivateDataManager(org.jivesoftware.smackx.iqprivate.PrivateDataManager) XMPPException(org.jivesoftware.smack.XMPPException)

Aggregations

PrivateDataManager (org.jivesoftware.smackx.iqprivate.PrivateDataManager)7 SmackException (org.jivesoftware.smack.SmackException)4 XMPPException (org.jivesoftware.smack.XMPPException)4 AccountItem (com.xabber.android.data.account.AccountItem)2 XMPPTCPConnection (com.xabber.xmpp.smack.XMPPTCPConnection)2 Nullable (androidx.annotation.Nullable)1