Android client and agent adapted to 2.0-M3 API
authorVictor Kirhenshtein <victor@netxms.org>
Wed, 8 Apr 2015 17:04:27 +0000 (20:04 +0300)
committerVictor Kirhenshtein <victor@netxms.org>
Wed, 8 Apr 2015 17:04:27 +0000 (20:04 +0300)
android/src/agent/.classpath
android/src/console/.classpath
android/src/console/src/org/netxms/ui/android/main/activities/NodeBrowser.java
android/src/console/src/org/netxms/ui/android/main/activities/NodePollerActivity.java
android/src/console/src/org/netxms/ui/android/main/adapters/InterfaceDetailsAdapter.java
android/src/console/src/org/netxms/ui/android/main/adapters/OverviewAdapter.java

index 643379c..9729440 100644 (file)
@@ -7,7 +7,7 @@
        <classpathentry kind="src" path="src"/>
        <classpathentry kind="src" path="gen"/>
        <classpathentry kind="lib" path="libs/android-support-v4.jar"/>
-       <classpathentry kind="lib" path="libs/netxms-base-2.0-M2.jar"/>
-       <classpathentry kind="lib" path="libs/netxms-mobile-agent-2.0-M2.jar"/>
+       <classpathentry kind="lib" path="libs/netxms-base-2.0-M3.jar"/>
+       <classpathentry kind="lib" path="libs/netxms-mobile-agent-2.0-M3.jar"/>
        <classpathentry kind="output" path="bin/classes"/>
 </classpath>
index 9ec5171..77ebf78 100644 (file)
@@ -9,8 +9,8 @@
        <classpathentry kind="lib" path="libs/acra-4.4.0.jar"/>
        <classpathentry kind="src" path="src"/>
        <classpathentry kind="src" path="gen"/>
-       <classpathentry kind="lib" path="libs/netxms-base-2.0-M2.jar"/>
-       <classpathentry kind="lib" path="libs/netxms-client-2.0-M2.jar"/>
-       <classpathentry kind="lib" path="libs/netxms-client-api-2.0-M2.jar"/>
+       <classpathentry kind="lib" path="libs/netxms-base-2.0-M3.jar"/>
+       <classpathentry kind="lib" path="libs/netxms-client-2.0-M3.jar"/>
+       <classpathentry kind="lib" path="libs/netxms-client-api-2.0-M3.jar"/>
        <classpathentry kind="output" path="bin/classes"/>
 </classpath>
index ba14afe..3516191 100644 (file)
@@ -10,7 +10,7 @@ import java.util.Stack;
 
 import org.netxms.base.GeoLocation;
 import org.netxms.client.NXCSession;
-import org.netxms.client.constants.NodePoller;
+import org.netxms.client.constants.NodePollType;
 import org.netxms.client.objects.AbstractObject;
 import org.netxms.client.objects.GenericObject;
 import org.netxms.client.objects.Node;
@@ -255,25 +255,25 @@ public class NodeBrowser extends AbstractClientActivity
                        case R.id.poll_status:
                                Intent psIntent = new Intent(this, NodePollerActivity.class);
                                psIntent.putExtra("nodeId", (int)selectedObject.getObjectId());
-                               psIntent.putExtra("pollType", NodePoller.STATUS_POLL);
+                               psIntent.putExtra("pollType", NodePollType.STATUS);
                                startActivity(psIntent);
                                break;
                        case R.id.poll_configuration:
                                Intent pcIntent = new Intent(this, NodePollerActivity.class);
                                pcIntent.putExtra("nodeId", (int)selectedObject.getObjectId());
-                               pcIntent.putExtra("pollType", NodePoller.CONFIGURATION_POLL);
+                               pcIntent.putExtra("pollType", NodePollType.CONFIGURATION_NORMAL);
                                startActivity(pcIntent);
                                break;
                        case R.id.poll_topology:
                                Intent ptIntent = new Intent(this, NodePollerActivity.class);
                                ptIntent.putExtra("nodeId", (int)selectedObject.getObjectId());
-                               ptIntent.putExtra("pollType", NodePoller.TOPOLOGY_POLL);
+                               ptIntent.putExtra("pollType", NodePollType.TOPOLOGY);
                                startActivity(ptIntent);
                                break;
                        case R.id.poll_interfaces:
                                Intent piIntent = new Intent(this, NodePollerActivity.class);
                                piIntent.putExtra("nodeId", (int)selectedObject.getObjectId());
-                               piIntent.putExtra("pollType", NodePoller.INTERFACE_POLL);
+                               piIntent.putExtra("pollType", NodePollType.INTERFACES);
                                startActivity(piIntent);
                                break;
                        case R.id.navigate_to:
@@ -303,7 +303,7 @@ public class NodeBrowser extends AbstractClientActivity
                                                        {
                                                                String message = tool.getConfirmationText()
                                                                                .replaceAll("%OBJECT_NAME%", selectedObject.getObjectName())
-                                                                               .replaceAll("%OBJECT_IP_ADDR%", selectedObject.getPrimaryIP().getHostAddress());
+                                                                               .replaceAll("%OBJECT_IP_ADDR%", ((Node)selectedObject).getPrimaryIP().getHostAddress());
                                                                new AlertDialog.Builder(this)
                                                                                .setIcon(android.R.drawable.ic_dialog_alert)
                                                                                .setTitle(R.string.confirm_tool_execution)
index d221b83..721d3df 100644 (file)
@@ -16,6 +16,7 @@ import android.text.style.ForegroundColorSpan;
 import android.util.Log;
 import android.widget.TextView;
 import org.netxms.client.TextOutputListener;
+import org.netxms.client.constants.NodePollType;
 import org.netxms.client.objects.AbstractObject;
 import org.netxms.ui.android.R;
 
@@ -25,10 +26,10 @@ import org.netxms.ui.android.R;
 public class NodePollerActivity extends AbstractClientActivity
 {
        private static final String TAG = "nxclient/NodePoller";
-       private static final String[] POLL_NAME = { "", "Status", "Configuration", "Interface", "Topology" };
+       private static final String[] POLL_NAME = { "", "Status", "Configuration (full)", "Interface", "Topology", "Configuration", "Instance" };
        
        private long nodeId;
-       private int pollType;
+       private NodePollType pollType;
        private boolean pollInProgress = false;
        private TextView textView;
        
@@ -39,7 +40,7 @@ public class NodePollerActivity extends AbstractClientActivity
        protected void onCreateStep2(Bundle savedInstanceState)
        {
                nodeId = getIntent().getIntExtra("nodeId", 0);
-               pollType = getIntent().getIntExtra("pollType", 0);
+               pollType = (NodePollType)getIntent().getSerializableExtra("pollType");
                
                setContentView(R.layout.node_poller);
                
@@ -58,7 +59,7 @@ public class NodePollerActivity extends AbstractClientActivity
                super.onServiceConnected(name, binder);
                AbstractObject object = service.findObjectById(nodeId);
                TextView title = (TextView)findViewById(R.id.ScreenTitlePrimary);
-               title.setText(POLL_NAME[pollType] + " poll: " + ((object != null) ? object.getObjectName() : ("[" + Long.toString(nodeId) + "]")));
+               title.setText(POLL_NAME[pollType.getValue()] + " poll: " + ((object != null) ? object.getObjectName() : ("[" + Long.toString(nodeId) + "]")));
                restart();
        }
 
index 41f79d9..83bea93 100644 (file)
@@ -3,9 +3,11 @@
  */
 package org.netxms.ui.android.main.adapters;
 
+import java.net.InetAddress;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.netxms.base.InetAddressEx;
 import org.netxms.client.constants.ObjectStatus;
 import org.netxms.client.objects.Interface;
 import org.netxms.ui.android.R;
@@ -58,7 +60,8 @@ public class InterfaceDetailsAdapter extends BaseAdapter
                addRow(r.getString(R.string.if_port), Integer.toString(i.getPort()));
                addRow(r.getString(R.string.if_description), i.getDescription());
                addRow(r.getString(R.string.if_mac_address), i.getMacAddress().toString());
-               addRow(r.getString(R.string.if_ip_address), i.getPrimaryIP().getHostAddress());
+               for(InetAddressEx a : i.getIpAddressList())
+                       addRow(r.getString(R.string.if_ip_address), a.toString());
                addRow(r.getString(R.string.if_admin_state), i.getAdminStateAsText(), getAdminStateColor(i.getAdminState()));
                addRow(r.getString(R.string.if_oper_state), i.getOperStateAsText(), getOperStateColor(i.getOperState()));
                addRow(r.getString(R.string.if_exp_state), getExpStateText(i.getExpectedState()));
index b248d4c..8b1ce10 100644 (file)
@@ -62,10 +62,10 @@ public class OverviewAdapter extends BaseAdapter
                        addPair(r.getString(R.string.overview_guid), toString(obj.getGuid()));
                        addPair(r.getString(R.string.overview_class), obj.getClass().getSimpleName());
                        addPair(r.getString(R.string.overview_status), getNodeStatus(obj.getStatus()));
-                       addPair(r.getString(R.string.overview_primary_ip), obj.getPrimaryIP().getHostAddress());
                        switch (obj.getObjectClass())
                        {
                                case AbstractObject.OBJECT_NODE:
+                                       addPair(r.getString(R.string.overview_primary_ip), ((Node)obj).getPrimaryIP().getHostAddress());
                                        addPair(r.getString(R.string.overview_zone_id), Long.toString(((Node)obj).getZoneId()));
                                        addPair(r.getString(R.string.overview_primary_hostname), ((Node)obj).getPrimaryName());
                                        if (((Node)obj).hasAgent())