本文整理汇总了Java中org.jivesoftware.smackx.filetransfer.FileTransferManager类的典型用法代码示例。如果您正苦于以下问题:Java FileTransferManager类的具体用法?Java FileTransferManager怎么用?Java FileTransferManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FileTransferManager类属于org.jivesoftware.smackx.filetransfer包,在下文中一共展示了FileTransferManager类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: FileDownloadListener
import org.jivesoftware.smackx.filetransfer.FileTransferManager; //导入依赖的package包/类
public FileDownloadListener(Context context, Connection connection) {
this.mConnection = connection;
this.mContext = context;
recieveFilePath = YiFileUtils.getStorePath() + "yiim/"
+ UserInfo.getUserInfo(context).getUserName() + "/file_recv/";
// ServiceDiscoveryManager sdm = ServiceDiscoveryManager
// .getInstanceFor(connection);
// if (sdm == null)
// sdm = new ServiceDiscoveryManager(connection);
// sdm.addFeature("http://jabber.org/protocol/disco#info");
// sdm.addFeature("jabber:iq:privacy");
FileTransferManager transfer = new FileTransferManager(connection);
FileTransferNegotiator.setServiceEnabled(connection, true);
transfer.addFileTransferListener(new RecFileTransferListener());
}
示例2: sendFile
import org.jivesoftware.smackx.filetransfer.FileTransferManager; //导入依赖的package包/类
private void sendFile(String to,String file){
/*
* This sends a file to someone
* @param to the xmmp-account who receives the file, the destination
* @param file the path from the file
*/
File f=new File(file);
FileTransferManager manager = new FileTransferManager(conn);
OutgoingFileTransfer transfer =
manager.createOutgoingFileTransfer(to);
// Send the file
try {
transfer.sendFile(f,"I have a file for you?");
} catch (XMPPException e) {
// TODO Auto-generated catch block
e.printStackTrace();
sendMessage(logAccount,"Sorry,couldn't deliver the file");
}
}
示例3: output
import org.jivesoftware.smackx.filetransfer.FileTransferManager; //导入依赖的package包/类
public void output(String jid) throws XMPPException{
FileTransferManager manager = new FileTransferManager(connection);
// Create the outgoing file transfer
OutgoingFileTransfer transfer = manager.createOutgoingFileTransfer(jid); //����û�ҪΪ �����jid��[email protected]/resource
// Send the file
InputStream inputStream;
try {
inputStream = context.getResources().getAssets().open("xmpp.txt");
transfer.sendStream(inputStream, "xmpp.txt", inputStream.available(), "aa");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例4: sendFileToUser
import org.jivesoftware.smackx.filetransfer.FileTransferManager; //导入依赖的package包/类
/**
* 向其他用户发送文件
* @param xmppConnection
* @param toUser 接受文件的用户名
* @param fileName 文件路径
* @param remark 备注
* @return
*/
public static boolean sendFileToUser(XMPPConnection xmppConnection,String toUser,String fileName,String remark){
// 创建文件传输管理器
FileTransferManager manager = new FileTransferManager(xmppConnection);
// 创建输出的文件传输
OutgoingFileTransfer transfer = manager.createOutgoingFileTransfer(toUser);
// 发送文件
try {
transfer.sendFile(new File(fileName), remark);
return true;
} catch (XMPPException e) {
e.printStackTrace();
return false;
}
}
示例5: FileShareSystem
import org.jivesoftware.smackx.filetransfer.FileTransferManager; //导入依赖的package包/类
/**
* Instantiates a new file share system.
*
* @param deviceID
* the device id
* @param localCacheDirectory
* the local cache directory
*/
public FileShareSystem(String deviceID, File localCacheDirectory)
{
this.deviceID = deviceID;
fileShareDelegatesByContentID = new HashMap<MD5Hash, FileShareSystemContentRegistrationDelegate>();
this.localFileCache = new LocalFileCache(localCacheDirectory);
FileTransferNegotiator.IBB_ONLY = true;
fileReceiver = new FileReceiver(this, this.localFileCache);
fileTransferManager = new FileTransferManager(SynergyNetCluster.get().getXMPPConnection());
log.fine("Registering fileReceiver with file transfer manager");
fileTransferManager.addFileTransferListener(fileReceiver);
messagingManager = SynergyNetCluster.get().getMessagingManager();
messagingManager.registerMessageListener(this, FileDistributionMessage.class);
}
示例6: newConnection
import org.jivesoftware.smackx.filetransfer.FileTransferManager; //导入依赖的package包/类
@Override
public void newConnection(XMPPConnection connection) {
// disable streamhost prioritization
Socks5BytestreamManager s5bsm = Socks5BytestreamManager.getBytestreamManager(connection);
s5bsm.setProxyPrioritizationEnabled(false);
sFileTransferManager = FileTransferManager.getInstanceFor(connection);
sFileTransferManager.addFileTransferListener(this);
}
示例7: OutgoingTransfersManager
import org.jivesoftware.smackx.filetransfer.FileTransferManager; //导入依赖的package包/类
/**
* Default constructor. Initialize fields and sets the default detection
* time of an outgoing file transfer.
*
* @param maxOut maximum number of simultaneous outgoing file transfers
*/
public OutgoingTransfersManager( FileTransferManager manager, int maxOut, int responseTimeout, ReentrantLock transfersLock) {
this.maxOut = maxOut;
transfers = new ConcurrentHashMap<TransferHandle,OutgoingTransfer>();
this.transfersLock = transfersLock;
queuedTransfers = new LinkedList<OutgoingTransfer>();
// Setting negotiation timeout
OutgoingFileTransfer.setResponseTimeout( responseTimeout );
this.manager = manager;
transferStateMonitor = new TransferStateMonitorThread();
}
示例8: IncomingTransfersManager
import org.jivesoftware.smackx.filetransfer.FileTransferManager; //导入依赖的package包/类
public IncomingTransfersManager(Module module, FileTransferManager manager, ReentrantLock transfersLock) {
this.module = module;
receiverListeners = new HashMap<DeploymentID,TransferReceiver>();
handlersRequestMap = new HashMap<IncomingTransferHandle,FileTransferRequest>();
transfers = new ConcurrentHashMap<TransferHandle,IncomingTransfer>();
this.manager = manager;
transferStateMonitor = new TransferStateMonitorThread();
this.transfersLock = transfersLock;
}
示例9: start
import org.jivesoftware.smackx.filetransfer.FileTransferManager; //导入依赖的package包/类
public void start(Module module, XMPPConnection connection) {
ReentrantLock lock = new ReentrantLock();
FileTransferManager manager = new FileTransferManager(connection);
incomingManager = new IncomingTransfersManager(module, manager, lock);
int responseTimeout = context.parseIntegerProperty(TransferProperties.PROP_FILE_TRANSFER_TIMEOUT) * 1000;
outgoingManager = new OutgoingTransfersManager(manager, maxOut, responseTimeout, lock);
incomingManager.start(connection);
outgoingManager.start();
}
示例10: sendFile
import org.jivesoftware.smackx.filetransfer.FileTransferManager; //导入依赖的package包/类
/**
* 发送文件
*
* @param connection
* @param user
* @param toUserName
* @param file
*/
public static void sendFile(final Context context,
final Connection connection, final String toUser, final Uri uri,
final String filePath, final MsgType msgType) {
new Thread() {
public void run() {
XMPPConnection.DEBUG_ENABLED = true;
// AccountManager accountManager;
try {
// accountManager = connection.getAccountManager();
Presence pre = connection.getRoster().getPresence(toUser);
if (pre.getType() != Presence.Type.unavailable) {
if (connection.isConnected()) {
Log.d(TAG, "connection con");
}
// 创建文件传输管理器
// ServiceDiscoveryManager sdm = ServiceDiscoveryManager
// .getInstanceFor(connection);
// if (sdm == null)
// sdm = new ServiceDiscoveryManager(connection);
FileTransferManager manager = new FileTransferManager(
connection);
// 创建输出的文件传输
OutgoingFileTransfer transfer = manager
.createOutgoingFileTransfer(pre.getFrom());
// 发送文件
transfer.sendFile(new File(filePath),
msgType.toString());
while (!transfer.isDone()) {
if (transfer.getStatus() == FileTransfer.Status.in_progress) {
// 可以调用transfer.getProgress();获得传输的进度
// Log.d(TAG,
// "send status:" + transfer.getStatus());
// Log.d(TAG,
// "send progress:"
// + transfer.getProgress());
if (mFileUploadListener != null) {
mFileUploadListener.transProgress(context,
uri, filePath,
transfer.getProgress());
}
}
}
// YiLog.getInstance().i("send file error: %s",
// transfer.);
Log.d(TAG, "send status 1 " + transfer.getStatus());
if (transfer.isDone()) {
if (mFileUploadListener != null) {
mFileUploadListener.transDone(context, toUser,
uri, msgType, filePath,
transfer.getStatus());
}
}
}
} catch (Exception e) {
Log.d(TAG, "send exception");
if (mFileUploadListener != null) {
mFileUploadListener.transDone(context, toUser, uri,
msgType, filePath, Status.error);
}
}
}
}.start();
}
示例11: getFileTransferManager
import org.jivesoftware.smackx.filetransfer.FileTransferManager; //导入依赖的package包/类
/**
* @return the mFileTransferManager
*/
public FileTransferManager getFileTransferManager() {
return mFileTransferManager;
}
示例12: setFileTransferManager
import org.jivesoftware.smackx.filetransfer.FileTransferManager; //导入依赖的package包/类
/**
* @param mFileTransferManager the mFileTransferManager to set
*/
public void setFileTransferManager(FileTransferManager mFileTransferManager) {
this.mFileTransferManager = mFileTransferManager;
}
示例13: FileSenderWorker
import org.jivesoftware.smackx.filetransfer.FileTransferManager; //导入依赖的package包/类
/**
* Instantiates a new file sender worker.
*
* @param localFileCache
* the local file cache
* @param fileTransferManager
* the file transfer manager
* @param deviceToSendToJID
* the device to send to jid
* @param identityOfFileToSend
* the identity of file to send
*/
public FileSenderWorker(LocalFileCache localFileCache, FileTransferManager fileTransferManager, String deviceToSendToJID, MD5Hash identityOfFileToSend)
{
this.localFileCache = localFileCache;
this.fileTransferManager = fileTransferManager;
this.destinationDevice = deviceToSendToJID;
this.identifyOfFile = identityOfFileToSend;
}