Exemplo n.º 1
0
 public boolean sendMessage(Message message, boolean encrypt) {
   if (!Network.hasNetwork(this.mContext)) {
     return false;
   }
   Intent intent = createServiceIntent();
   String perfData = MessageProfiling.getPrefString();
   if (!TextUtils.isEmpty(perfData)) {
     CommonPacketExtension perfExt =
         new CommonPacketExtension("pf", null, (String[]) null, (String[]) null);
     CommonPacketExtension sentPerfExt =
         new CommonPacketExtension(
             PushServiceConstants.SEND_MSG_EVENT_TYPE_SENT,
             null,
             (String[]) null,
             (String[]) null);
     sentPerfExt.setText(perfData);
     perfExt.appendChild(sentPerfExt);
     message.addExtension(perfExt);
   }
   Bundle messageBundle = message.toBundle();
   if (messageBundle == null) {
     return false;
   }
   MyLog.v("SEND:" + message.toXML());
   intent.setAction(PushConstants.ACTION_SEND_MESSAGE);
   intent.putExtra(PushConstants.EXTRA_SESSION, sSession);
   intent.putExtra(PushConstants.EXTRA_PACKET, messageBundle);
   intent.putExtra(PushConstants.EXTRA_ENCYPT, encrypt);
   this.mContext.startService(intent);
   return true;
 }
Exemplo n.º 2
0
 public boolean batchSendMessage(Message[] messages, boolean encrypt) {
   if (!Network.hasNetwork(this.mContext)) {
     return false;
   }
   Intent intent = createServiceIntent();
   Bundle[] messageBundles = new Bundle[messages.length];
   for (int i = 0; i < messages.length; i++) {
     String perfData = MessageProfiling.getPrefString();
     if (!TextUtils.isEmpty(perfData)) {
       CommonPacketExtension perfExt =
           new CommonPacketExtension("pf", null, (String[]) null, (String[]) null);
       CommonPacketExtension sentPerfExt =
           new CommonPacketExtension(
               PushServiceConstants.SEND_MSG_EVENT_TYPE_SENT,
               null,
               (String[]) null,
               (String[]) null);
       sentPerfExt.setText(perfData);
       perfExt.appendChild(sentPerfExt);
       messages[i].addExtension(perfExt);
     }
     MyLog.v("SEND:" + messages[i].toXML());
     messageBundles[i] = messages[i].toBundle();
   }
   if (messageBundles.length <= 0) {
     return false;
   }
   intent.setAction(PushConstants.ACTION_BATCH_SEND_MESSAGE);
   intent.putExtra(PushConstants.EXTRA_SESSION, sSession);
   intent.putExtra(PushConstants.EXTRA_PACKETS, messageBundles);
   intent.putExtra(PushConstants.EXTRA_ENCYPT, encrypt);
   this.mContext.startService(intent);
   return true;
 }
Exemplo n.º 3
0
 private ServiceClient(Context context) {
   this.mIsMiuiPushServiceEnabled = false;
   this.mProvisioned = 0;
   this.mContext = context.getApplicationContext();
   if (serviceInstalled()) {
     MyLog.v("use miui push service");
     this.mIsMiuiPushServiceEnabled = true;
   }
 }
Exemplo n.º 4
0
 public boolean sendPresence(Presence presence) {
   if (!Network.hasNetwork(this.mContext)) {
     return false;
   }
   Intent intent = createServiceIntent();
   Bundle presBundle = presence.toBundle();
   if (presBundle == null) {
     return false;
   }
   MyLog.v("SEND:" + presence.toXML());
   intent.setAction(PushConstants.ACTION_SEND_PRESENCE);
   intent.putExtra(PushConstants.EXTRA_SESSION, sSession);
   intent.putExtra(PushConstants.EXTRA_PACKET, presBundle);
   this.mContext.startService(intent);
   return true;
 }
Exemplo n.º 5
0
 public boolean sendIQ(IQ iq) {
   if (!Network.hasNetwork(this.mContext)) {
     return false;
   }
   Intent intent = createServiceIntent();
   Bundle iqBundle = iq.toBundle();
   if (iqBundle == null) {
     return false;
   }
   MyLog.v("SEND:" + iq.toXML());
   intent.setAction(PushConstants.ACTION_SEND_IQ);
   intent.putExtra(PushConstants.EXTRA_SESSION, sSession);
   intent.putExtra(PushConstants.EXTRA_PACKET, iqBundle);
   this.mContext.startService(intent);
   return true;
 }