Hello guys, i have problem with my aSmack file transfer, my Sending Works Brilliantly , but interesting part is my Receiving part, works Ocassionly ! some times it feels sorry for me and transfers file and then its ok untill i restart the emulator and tada , bye hopes. it seems after receiving the requests the Negotiator Seems lost his cookie and no time to answer it,and returns NullPointer at Negotiating, here is my my providers shiits i have added:
ProviderManager.addIQProvider("vCard", "vcard-temp", new VCardProvider());
ProviderManager.addIQProvider("query", "jabber:iq:private",new PrivateDataManager.PrivateDataIQProvider());
ProviderManager.addExtensionProvider("x", "jabber:x:event",new MessageEventProvider());
// Group Chat Invitations
ProviderManager.addExtensionProvider("x", "jabber:x:conference",new GroupChatInvitation.Provider());
// Service Discovery # Items
ProviderManager.addIQProvider("query","http://jabber.org/protocol/disco#items", new DiscoverItemsProvider());
// Service Discovery # Info
ProviderManager.addIQProvider("query","http://jabber.org/protocol/disco#info", new DiscoverInfoProvider());
// Data Forms
ProviderManager.addExtensionProvider("x", "jabber:x:data", new DataFormProvider());
// Delayed Delivery
ProviderManager.addExtensionProvider("x", "jabber:x:delay", new DelayInformationProvider());
// Version
try {
ProviderManager.addIQProvider("query", "jabber:iq:version",Class.forName("org.jivesoftware.smackx.packet.Version"));
} catch (ClassNotFoundException e) { }
// Offline Message Requests
ProviderManager.addIQProvider("offline", "http://jabber.org/protocol/offline",new OfflineMessageRequest.Provider());
// Offline Message Indicator
ProviderManager.addExtensionProvider("offline","http://jabber.org/protocol/offline",new OfflineMessageInfo.Provider());
// Last Activity
ProviderManager.addIQProvider("query", "jabber:iq:last", new LastActivity.Provider());
// User Search
ProviderManager.addIQProvider("query", "jabber:iq:search", new UserSearch.Provider());
// SharedGroupsInfo
ProviderManager.addIQProvider("sharedgroup","http://www.jivesoftware.org/protocol/sharedgroup", new SharedGroupsInfo.Provider());
// JEP-33: Extended Stanza Addressing
ProviderManager.addExtensionProvider("addresses","http://jabber.org/protocol/address",new MultipleAddressesProvider());
// FileTransfer
ProviderManager.addIQProvider("si","http://jabber.org/protocol/si", new StreamInitiationProvider());
ProviderManager.addIQProvider("query","http://jabber.org/protocol/bytestreams", new BytestreamsProvider());
ProviderManager.addIQProvider("open","http://jabber.org/protocol/ibb", new OpenIQProvider());
ProviderManager.addIQProvider("close","http://jabber.org/protocol/ibb", new CloseIQProvider());
ProviderManager.addExtensionProvider("data","http://jabber.org/protocol/ibb", new DataPacketProvider());
// Privacy
ProviderManager.addIQProvider("query", "jabber:iq:privacy", new PrivacyProvider());
ProviderManager.addIQProvider("command", "http://jabber.org/protocol/commands",new AdHocCommandDataProvider());
ProviderManager.addExtensionProvider("malformed-action","http://jabber.org/protocol/commands",new AdHocCommandDataProvider.MalformedActionError());
ProviderManager.addExtensionProvider("bad-locale","http://jabber.org/protocol/commands",new AdHocCommandDataProvider.BadLocaleError());
ProviderManager.addExtensionProvider("bad-payload","http://jabber.org/protocol/commands",new AdHocCommandDataProvider.BadPayloadError());
ProviderManager.addExtensionProvider("bad-sessionid","http://jabber.org/protocol/commands",new AdHocCommandDataProvider.BadSessionIDError());
ProviderManager.addExtensionProvider("session-expired","http://jabber.org/protocol/commands",new AdHocCommandDataProvider.SessionExpiredError());
// Attention
ProviderManager.addExtensionProvider("attention", "urn:xmpp:attention:0",
new AttentionExtension.Provider());
// XEP-184 Message Delivery Receipts
ProviderManager.addExtensionProvider("received", "urn:xmpp:receipts",
new DeliveryReceipt.Provider());
ProviderManager.addExtensionProvider("request", "urn:xmpp:receipts",
new DeliveryReceipt.Provider());
ProviderManager.addIQProvider("query", "http://jabber.org/protocol/bytestreams",
new BytestreamsProvider());
ProviderManager.addIQProvider("query", "http://jabber.org/protocol/disco#items",
new DiscoverItemsProvider());
ProviderManager.addIQProvider("query", "http://jabber.org/protocol/disco#info",
new DiscoverInfoProvider());
System.out.println("Providers Set");
ServiceDiscoveryManager.getInstanceFor(connection).addFeature("http://jabber.org/protocol/disco#info");
ServiceDiscoveryManager.getInstanceFor(connection).addFeature("jabber:iq:privac y");
ServiceDiscoveryManager.getInstanceFor(connection).addFeature("http://jabber.org/protocol/si");
and here is my code:
public void listenforFiles(){
connection.addPacketListener(new PacketListener() {
@Override
public void processPacket(Packet packet) throws NotConnectedException {
System.out.println("new packet");
System.out.println(packet.getPacketID());
// if( packet.getXmlns()!=null){
// if( packet.getXmlns().equals("http://jabber.org/protocol/disco#info")){
// System.out.println("its a"+"http://jabber.org/protocol/disco#info");
// }
// }
MyService.packetid=packet.getPacketID();
}
}, null);
SmackAndroid.init(this);
final FileTransferManager manager = new FileTransferManager(connection);
manager.addFileTransferListener(new FileTransferListener() {
public void fileTransferRequest(final FileTransferRequest request) {
new Thread(){
@Override
public void run() {
System.out.println(request.getStreamID());
// IncomingFileTransfer transfer = request.accept();
// System.out.println("New file Arrived: "+request+"status: "+transfer.getStatus()+"type: "+request.getMimeType());
// File file = new File("storage/sdcard/LifeMatePrivate/"+transfer.getFileName());
FileTransferNegotiator.setServiceEnabled(connection,true);
IncomingFileTransfer transfer = request.accept();
try{
transfer.recieveFile(new File("/storage/sdcard/"+transfer.getFileName()));
System.out.println("after receive file here");
while(!transfer.isDone()) {
try{
Thread.sleep(1000L);
}catch (Exception e) {
Log.e("", e.getMessage());
}
if(transfer.getStatus().equals(Status.error)) {
Log.e("ERROR!!! ", transfer.getError() + "");
}
if(transfer.getException() != null) {
transfer.getException().printStackTrace();
}
}
}catch (Exception e) {
Log.e("", e.getMessage());
}
};
}.start();
}
});
}
and here is the IQ Received:
07-03 13:41:49.622: D/SMACK(1395): RCV (0):
<iq id="2V7d4-18" to="admin@reza-hp/Smack" type="set" from="reza@reza-hp/Smack"><si xmlns="http://jabber.org/protocol/si" id="jsi_4434623838427379011" mime-type="image/jpeg" profile="http://jabber.org/protocol/si/profile/file-transfer"><file xmlns="http://jabber.org/protocol/si/profile/file-transfer" name="autumn-desktop-wallpaper.jpg" size="1011871"><desc>autumn-desktop-wallpaper.jpg</desc></file><feature xmlns="http://jabber.org/protocol/feature-neg"><x xmlns="jabber:x:data" type="form"><field var="stream-method" type="list-single"><option><value>http://jabber.org/protocol/bytestreams</value></option><option><value>http://jabber.org /protocol/ibb</value></option></field></x></feature></si></iq>
its all fine in the packet, Please my Beloved Developers, help me so i can sleep after being awake working on this for 3 days beg you , love u thanks alot