Add filetransfer file size restriction. Fix a problem in gui when adding new jmenu components from plugins. Fix right button menu send file.

cusax-fix
Damian Minkov 17 years ago
parent 1cb5ff2ceb
commit a9846ca1ad

File diff suppressed because it is too large Load Diff

@ -946,6 +946,24 @@ public void sendFile( final File file,
public Object construct()
throws Exception
{
if(file.length() > sendFileTransport.getMaximumFileLength())
{
addMessage(
chatSession.getCurrentChatTransport().getName(),
System.currentTimeMillis(),
Constants.ERROR_MESSAGE,
GuiActivator.getResources()
.getI18NString("service.gui.FILE_TOO_BIG",
new String[]{
sendFileTransport.getMaximumFileLength()/1024/1024
+ " MB"}),
"",
"text");
fileComponent.setFailed();
return "";
}
final FileTransfer fileTransfer
= sendFileTransport.sendFile(file);

@ -126,6 +126,12 @@ public void sendSmsMessage(String phoneNumber, String message)
public FileTransfer sendFile(File file)
throws Exception;
/**
* Returns the maximum file length supported by the protocol in bytes.
* @return the file length that is supported.
*/
public long getMaximumFileLength();
/**
* Invites a contact to join this chat.
*

@ -715,7 +715,7 @@ protected void close(boolean isEscaped)
WritePanelRightButtonMenu writePanelRightMenu =
chatWritePanel.getRightButtonMenu();
SIPCommMenu selectedMenu = menuBar.getSelectedMenu();
JMenu selectedMenu = menuBar.getSelectedMenu();
// SIPCommMenu contactMenu = getCurrentChatPanel()
// .getProtoContactSelectorBox().getMenu();

@ -312,6 +312,19 @@ public FileTransfer sendFile(File file)
return ftOpSet.sendFile(contact, file);
}
/**
* Returns the maximum file length supported by the protocol in bytes.
* @return the file length that is supported.
*/
public long getMaximumFileLength()
{
OperationSetFileTransfer ftOpSet
= (OperationSetFileTransfer) contact.getProtocolProvider()
.getOperationSet(OperationSetFileTransfer.class);
return ftOpSet.getMaximumFileLength();
}
public void inviteChatContact(String contactAddress, String reason)
{
}

@ -132,16 +132,8 @@ public void statusChanged(FileTransferStatusChangeEvent event)
}
else if (status == FileTransferStatusChangeEvent.FAILED)
{
hideProgressRelatedComponents();
titleLabel.setText(
dateString
+ resources.getI18NString(
"service.gui.FILE_UNABLE_TO_SEND",
new String[]{toContactName}));
cancelButton.setVisible(false);
setFailed();
retryButton.setVisible(true);
setWarningStyle(true);
}
else if (status == FileTransferStatusChangeEvent.IN_PROGRESS)
{
@ -200,6 +192,22 @@ else if (status == FileTransferStatusChangeEvent.REFUSED)
}
}
/**
* Change the style of the component to be failed.
*/
public void setFailed()
{
hideProgressRelatedComponents();
titleLabel.setText(
dateString
+ resources.getI18NString(
"service.gui.FILE_UNABLE_TO_SEND",
new String[]{toContactName}));
cancelButton.setVisible(false);
setWarningStyle(true);
}
/**
* Returns the date of the component event.
*

@ -121,13 +121,13 @@ private void init()
/**
* Returns the currently selected menu.
*/
public SIPCommMenu getSelectedMenu()
public JMenu getSelectedMenu()
{
int menuCount = this.getMenuCount();
for (int i = 0; i < menuCount; i++)
{
SIPCommMenu menu = (SIPCommMenu) this.getMenu(i);
JMenu menu = this.getMenu(i);
if (menu.isSelected())
{

@ -9,6 +9,7 @@
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.io.*;
import javax.swing.*;
@ -514,7 +515,35 @@ else if (itemName.equalsIgnoreCase("call"))
}
else if (itemName.equalsIgnoreCase("sendFile"))
{
// disabled
ContactListPane clistPanel = mainFrame.getContactListPanel();
SwingUtilities.invokeLater(
clistPanel.new RunMessageWindow(
contactItem)
{
public void run()
{
super.run();
JFileChooser fileChooser = new JFileChooser(
ConfigurationManager.getSendFileLastDir());
int result = fileChooser.showOpenDialog(
GuiActivator.getUIService().
getChatWindowManager().getSelectedChat().
getChatWindow());
if (result == JFileChooser.APPROVE_OPTION)
{
File selectedFile = fileChooser.getSelectedFile();
ConfigurationManager
.setSendFileLastDir(selectedFile.getParent());
GuiActivator.getUIService().
getChatWindowManager().getSelectedChat().
sendFile(selectedFile);
}
} });
}
else if (itemName.equalsIgnoreCase("renameContact"))
{

@ -80,6 +80,10 @@ public FileTransfer sendFile( Contact toContact,
{
assertConnected();
if(file.length() > getMaximumFileLength())
throw new IllegalArgumentException(
"File length exceeds the allowed one for this protocol");
// Get the aim connection
AimConnection aimConnection = icqProvider.getAimConnection();
@ -358,6 +362,17 @@ void fireFileTransferCreated(FileTransferCreatedEvent event)
}
}
/**
* Returns the maximum file length supported by the protocol in bytes.
* Supports up to 2GB.
*
* @return the file length that is supported.
*/
public long getMaximumFileLength()
{
return 2147483648l;// = 2048*1024*1024;
}
/**
* Our listener that will tell us when we're registered to
*/

@ -100,6 +100,10 @@ public FileTransfer sendFile( Contact toContact,
{
assertConnected();
if(file.length() > getMaximumFileLength())
throw new IllegalArgumentException(
"File length exceeds the allowed one for this protocol");
String fullJid = jabberProvider.getFullJid(toContact);
// First we check if file transfer is at all supported for this
@ -216,6 +220,17 @@ else if (!jabberProvider.isRegistered())
+"being able to send a file.");
}
/**
* Returns the maximum file length supported by the protocol in bytes.
* Supports up to 2GB.
*
* @return the file length that is supported.
*/
public long getMaximumFileLength()
{
return 2147483648l;// = 2048*1024*1024;
}
/**
* Our listener that will tell us when we're registered to
*/

@ -79,6 +79,10 @@ public FileTransfer sendFile( Contact toContact,
{
assertConnected();
if(file.length() > getMaximumFileLength())
throw new IllegalArgumentException(
"File length exceeds the allowed one for this protocol");
if( !(toContact instanceof ContactMsnImpl) )
throw new IllegalArgumentException(
"The specified contact is not an msn contact." + toContact);
@ -283,6 +287,17 @@ void fireFileTransferCreated(FileTransferCreatedEvent event)
}
}
/**
* Returns the maximum file length supported by the protocol in bytes.
* Supports up to 2GB.
*
* @return the file length that is supported.
*/
public long getMaximumFileLength()
{
return 2147483648l;// = 2048*1024*1024;
}
/**
* Our listener that will tell us when we're registered to
*/

@ -84,6 +84,10 @@ public FileTransfer sendFile( Contact toContact,
{
assertConnected();
if(file.length() > getMaximumFileLength())
throw new IllegalArgumentException(
"File length exceeds the allowed one for this protocol");
ArrayList<String> filesToSend = new ArrayList<String>();
filesToSend.add(file.getCanonicalPath());
Date sentDate = new Date();
@ -404,6 +408,17 @@ public void statusChanged(SessionFileTransferEvent ev)
ft.fireStatusChangeEvent(getStateMapping(newState));
}
/**
* Returns the maximum file length supported by the protocol in bytes.
* Supports up to 256MB.
*
* @return the file length that is supported.
*/
public long getMaximumFileLength()
{
return 268435456l;// = 256*1024*1024;
}
/**
* Our listener that will tell us when we're registered to
*/

@ -87,4 +87,10 @@ public void addFileTransferListener(
*/
public void removeFileTransferListener(
FileTransferListener listener);
/**
* Returns the maximum file length supported by the protocol in bytes.
* @return the file length that is supported.
*/
public long getMaximumFileLength();
}

Loading…
Cancel
Save