正在查看: bbinstant v6.24.0 应用的 KapchatUploadService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: bbinstant v6.24.0 应用的 KapchatUploadService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.adjetter.kapchatsdk;
import android.annotation.SuppressLint;
import android.app.Service;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Binder;
import android.os.IBinder;
import com.adjetter.kapchatsdk.attachments.KapchatAttachmentStructure;
import com.adjetter.kapchatsdk.helper.KapchatReadAllMesages;
import com.adjetter.kapchatsdk.helper.KapchatUpdateattachmentStatus;
import com.adjetter.kapchatsdk.interfaces.IUpdatenotify;
import com.adjetter.kapchatsdk.interfaces.IkapchatMessages;
import com.adjetter.kapchatsdk.structure.KapchatUpdateAttachmentMessageStatus;
import com.adjetter.kapchatsdk.structure.KapchatUpdateAttachments;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.mobileconnectors.remoteconfiguration.Attributes;
import com.amazonaws.services.s3.AmazonS3Client;
import com.amazonaws.services.s3.model.CannedAccessControlList;
import com.amazonaws.services.s3.model.InstructionFileId;
import com.amazonaws.services.s3.model.ObjectMetadata;
import com.amazonaws.services.s3.model.PutObjectRequest;
import com.google.gson.Gson;
import java.io.File;
import java.io.FileInputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.Random;
import java.util.concurrent.Executor;
import org.jivesoftware.smack.chat.Chat;
import org.jivesoftware.smack.chat.ChatManager;
import org.jivesoftware.smack.chat.ChatMessageListener;
import org.jivesoftware.smack.packet.Message;
import org.jxmpp.jid.impl.JidCreate;
public class KapchatUploadService extends Service implements IkapchatMessages, IUpdatenotify {
Chat newchat;
IUpdatenotify notify;
private final IBinder mbinder = new Localbinder();
ArrayList<KapchatMessageList> offlinelist = new ArrayList<>();
public class Localbinder extends Binder {
public Localbinder() {
}
public KapchatUploadService getService() {
return KapchatUploadService.this;
}
}
@SuppressLint({"StaticFieldLeak"})
public class upload extends AsyncTask<KapchatAttachmentStructure, Void, String> {
ArrayList<KapchatAttachmentStructure> attachlist = new ArrayList<>();
public upload() {
}
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
public String doInBackground(KapchatAttachmentStructure... kapchatAttachmentStructureArr) {
this.attachlist.add(kapchatAttachmentStructureArr[0]);
for (int i = 0; i < this.attachlist.size(); i++) {
StringBuilder sb = new StringBuilder();
sb.append("message list body ");
sb.append(this.attachlist.get(i).getBody());
}
for (int i2 = 0; i2 < this.attachlist.size(); i2++) {
try {
if (this.attachlist.get(i2).getBody() == null) {
this.attachlist.get(i2).setBody("attachment");
}
File file = new File(this.attachlist.get(i2).getFilepath());
ObjectMetadata objectMetadata = new ObjectMetadata();
StringBuilder sb2 = new StringBuilder();
sb2.append("file length is ");
sb2.append(file.length());
objectMetadata.setContentLength(file.length());
String str = "" + Calendar.getInstance().getTimeInMillis();
String str2 = file.getName().split("\\.")[r6.length - 1];
String str3 = "kapchatattach".replaceAll(" ", Attributes.PREDEFINED_ATTRIBUTE_PREFIX) + "_1_" + str + InstructionFileId.DOT + str2;
file.isFile();
String string = KapchatUploadService.this.getSharedPreferences("kapchatpreference", 0).getString("uploadSecretKey", "");
AmazonS3Client amazonS3Client = new AmazonS3Client(new BasicAWSCredentials("" + KapchatUploadService.this.getSharedPreferences("kapchatpreference", 0).getString("uploadAccessKey", ""), "" + string));
amazonS3Client.putObject(new PutObjectRequest("chat-file-attachments", str3, new FileInputStream(file), objectMetadata));
amazonS3Client.setObjectAcl("chat-file-attachments", str3, CannedAccessControlList.PublicRead);
this.attachlist.get(i2).setMimeurl("https://chat-file-attachments.s3.amazonaws.com/" + str3);
StringBuilder sb3 = new StringBuilder();
sb3.append("keyname is ");
sb3.append(str3);
} catch (Exception e) {
e.printStackTrace();
return "no";
}
}
return "yes";
}
@Override
public void onPostExecute(String str) {
String str2;
int i;
int i2;
Message message;
Message.Type type;
KapchatSendMessageStructure kapchatSendMessageStructure;
long currentTimeMillis;
StringBuilder sb;
int i3 = 0;
String str3 = "0";
super.onPostExecute((upload) str);
StringBuilder sb2 = new StringBuilder();
sb2.append("attachlistsize on post ");
sb2.append(this.attachlist.size());
if (this.attachlist.size() != 0) {
int i4 = 0;
while (i4 < this.attachlist.size()) {
if (str.equalsIgnoreCase("yes")) {
try {
KapchatUploadService.this.newchat = ChatManager.getInstanceFor(KapchatConnection.mConnection).createChat(JidCreate.entityBareFrom(this.attachlist.get(i4).getTojid()), new ChatMessageListener() {
public void processMessage(Chat chat, Message message2) {
try {
KapchatUploadService.this.newchat.sendMessage(message2);
} catch (Exception e) {
System.out.println("######### crzsh here1 : " + e.getMessage());
}
}
});
org.jxmpp.jid.a bareFrom = JidCreate.bareFrom(this.attachlist.get(i4).getTojid());
type = Message.Type.chat;
message = new Message(bareFrom, type);
kapchatSendMessageStructure = new KapchatSendMessageStructure();
kapchatSendMessageStructure.enquiryId = str3;
kapchatSendMessageStructure.fromJid = "" + KapchatUploadService.this.getSharedPreferences("kapchatpreference", i3).getString("userName", "");
kapchatSendMessageStructure.leadId = Integer.parseInt(KapchatUploadService.this.getSharedPreferences("kapchatpreference", i3).getString("leadId", str3));
String str4 = "/attachment" + this.attachlist.get(i4).getFilepath();
kapchatSendMessageStructure.message = "" + str4.substring(str4.lastIndexOf("/") + 1);
kapchatSendMessageStructure.messageId = null;
kapchatSendMessageStructure.receiverName = null;
currentTimeMillis = System.currentTimeMillis();
kapchatSendMessageStructure.sentDate = currentTimeMillis;
sb = new StringBuilder();
sb.append("");
str2 = str3;
} catch (Exception e) {
e = e;
str2 = str3;
}
try {
sb.append(KapchatUploadService.this.getSharedPreferences("kapchatpreference", i3).getString("contactName", ""));
kapchatSendMessageStructure.senderName = sb.toString();
kapchatSendMessageStructure.supportId = "" + KapchatUploadService.this.getSharedPreferences("kapchatpreference", 0).getString("supportId", "");
kapchatSendMessageStructure.taskId = 0;
kapchatSendMessageStructure.toJid = null;
kapchatSendMessageStructure.fromResource = KapchatUploadService.this.getSharedPreferences("kapchatpreference", 0).getString("kapchatresource", "");
kapchatSendMessageStructure.mime = "" + this.attachlist.get(i4).getMime();
kapchatSendMessageStructure.label = "" + this.attachlist.get(i4).getBody();
kapchatSendMessageStructure.url = "" + this.attachlist.get(i4).getMimeurl().toString();
if (KapchatUploadService.this.getSharedPreferences("kapchatpreference", 0).getString("guestsession", "").equalsIgnoreCase("true")) {
kapchatSendMessageStructure.taskId = Integer.parseInt(KapchatUploadService.this.getSharedPreferences("kapchatpreference", 0).getString("taskId", ""));
kapchatSendMessageStructure.ticketId = KapchatUploadService.this.getSharedPreferences("kapchatpreference", 0).getString("ticketId", "");
}
message.setBody("" + ("{\"key\":\"" + KapchatHelper.supportmessagekey + "\",\"supportChatMessage\":" + new Gson().toJson(kapchatSendMessageStructure) + ",\"type\":\"" + KapchatHelper.supporttype + "\"}"));
message.setType(type);
message.setStanzaId(message.getStanzaId() + (new Random().nextInt(900000) + 100000));
StringBuilder sb3 = new StringBuilder();
sb3.append("sending xml ");
sb3.append(message.toXML());
KapchatUploadService.this.newchat.sendMessage(message);
ArrayList arrayList = new ArrayList();
arrayList.clear();
KapchatMessageList kapchatMessageList = new KapchatMessageList();
kapchatMessageList.setConversationId(this.attachlist.get(i4).getConversationid());
kapchatMessageList.setStanzaId(message.getStanzaId());
kapchatMessageList.setMessageStatus("1");
kapchatMessageList.setSendDate("" + currentTimeMillis);
arrayList.add(kapchatMessageList);
KapchatUpdateAttachmentMessageStatus kapchatUpdateAttachmentMessageStatus = new KapchatUpdateAttachmentMessageStatus(KapchatUploadService.this.getApplicationContext(), null);
Executor executor = AsyncTask.THREAD_POOL_EXECUTOR;
kapchatUpdateAttachmentMessageStatus.executeOnExecutor(executor, arrayList);
ArrayList arrayList2 = new ArrayList();
KapchatUpdateAttachments kapchatUpdateAttachments = new KapchatUpdateAttachments();
kapchatUpdateAttachments.setConversationid(this.attachlist.get(i4).getConversationid());
kapchatUpdateAttachments.setMimeurl(this.attachlist.get(i4).getMimeurl());
kapchatUpdateAttachments.setMessagestatus("1");
arrayList2.add(kapchatUpdateAttachments);
StringBuilder sb4 = new StringBuilder();
sb4.append("updating sendlist size ");
sb4.append(arrayList2.size());
new KapchatUpdateattachmentStatus(KapchatUploadService.this.getApplicationContext(), KapchatUploadService.this.notify, Boolean.TRUE).executeOnExecutor(executor, arrayList2);
SharedPreferences.Editor edit = KapchatUploadService.this.getSharedPreferences("kapchatpreference", 0).edit();
edit.putString("lastLogout", "" + new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(new Date()));
edit.apply();
} catch (Exception e2) {
e = e2;
e.printStackTrace();
ArrayList arrayList3 = new ArrayList();
KapchatUpdateAttachments kapchatUpdateAttachments2 = new KapchatUpdateAttachments();
kapchatUpdateAttachments2.setConversationid(this.attachlist.get(i4).getConversationid());
kapchatUpdateAttachments2.setMimeurl(this.attachlist.get(i4).getMimeurl());
if (str.equalsIgnoreCase("yes")) {
kapchatUpdateAttachments2.setMessagestatus("10");
} else {
kapchatUpdateAttachments2.setMessagestatus("7");
}
arrayList3.add(kapchatUpdateAttachments2);
new KapchatUpdateattachmentStatus(KapchatUploadService.this.getApplicationContext(), KapchatUploadService.this.notify, Boolean.TRUE).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, arrayList3);
i = 1;
i2 = 0;
i4 += i;
i3 = i2;
str3 = str2;
}
i = 1;
i2 = 0;
} else {
str2 = str3;
ArrayList arrayList4 = new ArrayList();
KapchatUpdateAttachments kapchatUpdateAttachments3 = new KapchatUpdateAttachments();
kapchatUpdateAttachments3.setConversationid(this.attachlist.get(i4).getConversationid());
kapchatUpdateAttachments3.setMimeurl(this.attachlist.get(i4).getMimeurl());
kapchatUpdateAttachments3.setMessagestatus("7");
arrayList4.add(kapchatUpdateAttachments3);
i = 1;
i2 = 0;
new KapchatUpdateattachmentStatus(KapchatUploadService.this.getApplicationContext(), KapchatUploadService.this.notify, Boolean.TRUE).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, arrayList4);
}
i4 += i;
i3 = i2;
str3 = str2;
}
}
}
}
@Override
public void clearMessages(Boolean bool) {
}
@Override
public void clearMultiple(Boolean bool, ArrayList<String> arrayList) {
}
@Override
public void getMessageList(ArrayList<KapchatMessageList> arrayList) {
this.offlinelist.clear();
for (int i = 0; i < arrayList.size(); i++) {
if (arrayList.get(i).getMessageStatus().equalsIgnoreCase("5")) {
this.offlinelist.add(arrayList.get(i));
}
}
for (int i2 = 0; i2 < this.offlinelist.size(); i2++) {
ArrayList arrayList2 = new ArrayList();
KapchatUpdateAttachments kapchatUpdateAttachments = new KapchatUpdateAttachments();
kapchatUpdateAttachments.setConversationid(this.offlinelist.get(i2).getConversationId());
kapchatUpdateAttachments.setMimeurl(this.offlinelist.get(i2).getMimeurl());
kapchatUpdateAttachments.setMessagestatus("6");
arrayList2.add(kapchatUpdateAttachments);
new KapchatUpdateattachmentStatus(getApplicationContext(), this.notify, Boolean.TRUE).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, arrayList2);
}
uploadimage();
}
@Override
public void getPaginationList(ArrayList<KapchatMessageList> arrayList) {
}
@Override
public IBinder onBind(Intent intent) {
return this.mbinder;
}
@Override
public void onDestroy() {
super.onDestroy();
}
@Override
public int onStartCommand(Intent intent, int i, int i2) {
return super.onStartCommand(intent, i, i2);
}
public void readAllMessages() {
new KapchatReadAllMesages(getApplicationContext(), this, 0).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new Void[0]);
}
@Override
public void readMessageList(int i) {
}
@Override
public void update(Boolean bool) {
if (bool.booleanValue()) {
sendBroadcast(new Intent("com.adjetter.kapchatupdate"));
}
}
@Override
public void updateMessageList(Boolean bool, ArrayList<KapchatMessageList> arrayList) {
}
public void uploadimage() {
this.notify = this;
if (this.offlinelist.size() != 0) {
for (int i = 0; i < this.offlinelist.size(); i++) {
KapchatAttachmentStructure kapchatAttachmentStructure = new KapchatAttachmentStructure();
kapchatAttachmentStructure.setBody(this.offlinelist.get(i).getMessage());
kapchatAttachmentStructure.setDownload(this.offlinelist.get(i).getDownload());
kapchatAttachmentStructure.setDownloadpath(this.offlinelist.get(i).getDownloadPath());
kapchatAttachmentStructure.setFilepath(this.offlinelist.get(i).getDownloadPath());
kapchatAttachmentStructure.setFromjid(this.offlinelist.get(i).getFromJid());
kapchatAttachmentStructure.setMessagestatus(this.offlinelist.get(i).getMessageStatus());
kapchatAttachmentStructure.setMime(this.offlinelist.get(i).getMime());
kapchatAttachmentStructure.setMimeurl(this.offlinelist.get(i).getMimeurl());
kapchatAttachmentStructure.setSenddate(this.offlinelist.get(i).getSendDate());
kapchatAttachmentStructure.setTojid(this.offlinelist.get(i).getToJid());
kapchatAttachmentStructure.setType(this.offlinelist.get(i).getMessageType());
kapchatAttachmentStructure.setConversationid(this.offlinelist.get(i).getConversationId());
StringBuilder sb = new StringBuilder();
sb.append("executing id ");
sb.append(this.offlinelist.get(i).getConversationId());
new upload().execute(kapchatAttachmentStructure);
}
}
}
}