[Zerofile-svn] SF.net SVN: zerofile: [69] trunk/src
Status: Pre-Alpha
Brought to you by:
karl-bengtsson
|
From: <kar...@us...> - 2007-12-04 14:50:01
|
Revision: 69
http://zerofile.svn.sourceforge.net/zerofile/?rev=69&view=rev
Author: karl-bengtsson
Date: 2007-12-04 06:50:04 -0800 (Tue, 04 Dec 2007)
Log Message:
-----------
Test av file sending stanza grejjer
Modified Paths:
--------------
trunk/src/XMPPLinkLocalChatSession.java
trunk/src/ZeroFileChatWindow.java
Modified: trunk/src/XMPPLinkLocalChatSession.java
===================================================================
--- trunk/src/XMPPLinkLocalChatSession.java 2007-12-04 14:31:19 UTC (rev 68)
+++ trunk/src/XMPPLinkLocalChatSession.java 2007-12-04 14:50:04 UTC (rev 69)
@@ -49,6 +49,25 @@
}
}
+ public void offerFileTransfer(String localFileNameAndPath)
+ {
+ int lastSlashIndex = localFileNameAndPath.lastIndexOf('/');
+ if (!(lastSlashIndex >= 0 && lastSlashIndex < localFileNameAndPath.length() - 1))
+ {
+ System.out.println("blaaargh, felaktigt filnamn");
+ }
+ else
+ {
+ File filen = new File(localFileNameAndPath);
+ long sizeOfFile = filen.length();
+ String filnamn = localFileNameAndPath.substring(lastSlashIndex + 1);
+ String fileTransferStanza = "<message to=\""+_chatPartner.getServiceName()+"\" from=\""+ZeroconfRegistration.getMyServiceName()+"\"><body></body></message>";
+ fileTransferStanza += "<x xmlns=\"jabber:x:oob\">";
+ fileTransferStanza += "<url type=\"file\" size=\""+String.valueOf(sizeOfFile)+"\">";
+ fileTransferStanza += "http://10.100.46.243:5297/25E8656B83FBA3A2/"+localFileNameAndPath+"</url></x></message>";
+ }
+ }
+
public XMPPLinkLocalChatSession(XMPPLinkLocalHost hostToChatWith)
{
_chatPartner = hostToChatWith;
Modified: trunk/src/ZeroFileChatWindow.java
===================================================================
--- trunk/src/ZeroFileChatWindow.java 2007-12-04 14:31:19 UTC (rev 68)
+++ trunk/src/ZeroFileChatWindow.java 2007-12-04 14:50:04 UTC (rev 69)
@@ -13,6 +13,7 @@
private JPanel _bottomPanel;
private JTextField _entryTextField;
private JButton _sendButton;
+ private JButton _sendFileButton;
private XMPPLinkLocalChatSession _session;
public ZeroFileChatWindow(XMPPLinkLocalChatSession sess)
@@ -53,6 +54,7 @@
_bottomPanel.setLayout(new GridLayout(1,0,1,1));
_entryTextField = new JTextField();
_sendButton = new JButton("Send");
+ _sendFileButton = new JButton("Send file...");
_bottomPanel.add(_entryTextField);
_entryTextField.addKeyListener(
new KeyListener()
@@ -72,6 +74,17 @@
}
});
_bottomPanel.add(_sendButton);
+ _bottomPanel.add(_sendFileButton);
+ _sendFileButton.addActionListener(
+ new ActionListener(){
+ public void actionPerformed(ActionEvent sendButtonPress){
+ JFileChooser _fileChooser= new JFileChooser();
+ _fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
+ _fileChooser.showOpenDialog(null);
+ _session.offerFileTransfer(_fileChooser.getSelectedFile().toString());
+ }
+ }
+ );
_chatWindowFrame.setVisible(true);
_sendButton.addActionListener(
new ActionListener(){
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|