use of org.jivesoftware.spark.preference.Preference in project Spark by igniterealtime.
the class ReceiveFileTransfer method acceptFileTransfer.
public void acceptFileTransfer(final FileTransferRequest request) {
String fileName = request.getFileName();
long fileSize = request.getFileSize();
String requestor = request.getRequestor();
String bareJID = XmppStringUtils.parseBareJid(requestor);
// SPARK-1869
FileTransferNegotiator.getInstanceFor(SparkManager.getConnection());
FileTransferNegotiator.IBB_ONLY = SettingsManager.getLocalPreferences().isFileTransferIbbOnly();
ByteFormat format = new ByteFormat();
String text = format.format(fileSize);
fileLabel.setText(fileName + " (" + text + ")");
ContactList contactList = SparkManager.getWorkspace().getContactList();
ContactItem contactItem = contactList.getContactItemByJID(bareJID);
titleLabel.setText(Res.getString("message.user.is.sending.you.a.file", contactItem.getDisplayName()));
File tempFile = new File(Spark.getSparkUserHome(), "/tmp");
try {
tempFile.mkdirs();
File file = new File(tempFile, fileName);
file.delete();
BufferedWriter out = new BufferedWriter(new FileWriter(file));
out.write("a");
out.close();
imageLabel.setIcon(GraphicUtils.getIcon(file));
// Delete temp file when program exits.
file.delete();
} catch (IOException e) {
imageLabel.setIcon(SparkRes.getImageIcon(SparkRes.DOCUMENT_INFO_32x32));
Log.error(e);
}
acceptButton.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
try {
Downloads.checkDownloadDirectory();
acceptRequest(request);
} catch (Exception ex) {
// this means there is a problem with the download directory
try {
request.reject();
} catch (SmackException.NotConnectedException e1) {
Log.warning("Unable to reject the request.", ex);
}
setBackground(new Color(239, 245, 250));
acceptButton.setVisible(false);
declineButton.setVisible(false);
if (Downloads.getDownloadDirectory() == null) {
fileLabel.setText("");
} else {
ResourceUtils.resLabel(fileLabel, null, Res.getString("label.transfer.download.directory") + " " + Downloads.getDownloadDirectory().getAbsolutePath());
}
// option to set a new path for the file-download
pathButton.setVisible(true);
pathButton.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
Preference p = SparkManager.getPreferenceManager().getPreference(new FileTransferPreference().getNamespace());
// retrieve the filetransfer preferences and show the preference menu
// to the user
SparkManager.getPreferenceManager().showPreferences(p);
}
});
titleLabel.setText(ex.getMessage());
titleLabel.setForeground(new Color(65, 139, 179));
invalidate();
validate();
repaint();
}
}
});
declineButton.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
rejectRequest(request);
}
});
}
use of org.jivesoftware.spark.preference.Preference in project Spark by igniterealtime.
the class PreferencesPanel method selectionChanged.
private synchronized void selectionChanged() {
PreferenceUI o = (PreferenceUI) list.getSelectedValue();
Preference pref = o.getPreference();
pref.load();
JComponent comp = pref.getGUI();
flowPanel.removeAll();
// Create the title panel for this dialog
TitlePanel titlePanel = new TitlePanel(pref.getTitle(), pref.getTooltip(), pref.getIcon(), false);
flowPanel.add(comp, BorderLayout.CENTER);
flowPanel.add(titlePanel, BorderLayout.NORTH);
flowPanel.invalidate();
flowPanel.validate();
flowPanel.repaint();
currentPreference = pref;
}
use of org.jivesoftware.spark.preference.Preference in project Spark by igniterealtime.
the class OTRPlugin method initialize.
@Override
public void initialize() {
// Create OTRManager singleton
_manager = OTRManager.getInstance();
// The following will add an Entry into the Spark Preferences Window
Preference mypreference = new OTRPreferences();
SparkManager.getPreferenceManager().addPreference(mypreference);
}
Aggregations