solution: bps netstatus_interface_list_t as QVariantList

I was looking for an easy way to know the name of the interface for WIFI, cell PHONE...

These names are different for Z10, Z30, Q10,... you can't find names

First aid, I found was Cascades Sample App "MyDevice".

Congratulations to Martin Woolley @mdwrim providing this app to wander on Github

Now I could get the names of WIFI connections, but lacked a way to get the names for cell PHONES

discussed with @mdwrim on twitter and got to come an interface more names for cell PHONES, but this could be broken easy to new devices.

next congratulations to @dkonigs who joined the discussion on twitter mentioning Netstatus API to inspect the Interface Types

OK - I wanted to use the netstatus and discovered that I have a loop through a list of interfaces netstatus and tried this code.

thought it would be easy because I already used Netstatus events to know if the user is on WIFI, cell PHONE etc.

But I have to give up - as a former Developer Java and C++ now / Qt developer such things bps C does not for me.

next Bravo to strobejb help with the code in this thread here. Based on his code I solved it and now it's easy to know all the Netstatus Interfaces.

Here is a method that you give bps bps netstatus_interface_list_t as QVariantList, so you can use for data models, storing as JSON or almost.

QVariantList YourClass::netStatusInterfaceList() {
    QVariantList interfaceList;
    netstatus_interface_list_t iflist;
    netstatus_get_interfaces(&iflist);

    for (int i = 0; i < iflist.num_interfaces; i++) {
        netstatus_interface_details_t *details = 0;
        netstatus_get_interface_details(iflist.interfaces[i], &details);
        if (details) {
            QVariantMap interfaceDetailsMap;
            const char *name = netstatus_interface_get_name(details);
            qDebug() << "DETAILS FOR Interface: " << name;
            interfaceDetailsMap.insert("name", name);
            netstatus_interface_type_t type = netstatus_interface_get_type(
                    details);
            bool connected = netstatus_interface_is_connected(details);
            interfaceDetailsMap.insert("connected", connected);
            bool up = netstatus_interface_is_up(details);
            interfaceDetailsMap.insert("up", up);
            interfaceDetailsMap.insert("hasType", type ? "true" : "false");
            if (type) {
                interfaceDetailsMap.insert("type", type);
                switch (type) {
                case NETSTATUS_INTERFACE_TYPE_WIRED:
                    interfaceDetailsMap.insert("typeName", "WIRED");
                    break;
                case NETSTATUS_INTERFACE_TYPE_WIFI:
                    interfaceDetailsMap.insert("typeName", "WIFI");
                    break;
                case NETSTATUS_INTERFACE_TYPE_VPN:
                    interfaceDetailsMap.insert("typeName", "VPN");
                    break;
                case NETSTATUS_INTERFACE_TYPE_BB:
                    interfaceDetailsMap.insert("typeName", "BB");
                    break;
                case NETSTATUS_INTERFACE_TYPE_UNKNOWN:
                    interfaceDetailsMap.insert("typeName", "UNKNOWN");
                    break;
                case NETSTATUS_INTERFACE_TYPE_USB:;
                    interfaceDetailsMap.insert("typeName", "USB");
                    break;
                case NETSTATUS_INTERFACE_TYPE_BLUETOOTH_DUN:
                    interfaceDetailsMap.insert("typeName", "BLUETOOTH_DUN");
                    break;
                case NETSTATUS_INTERFACE_TYPE_CELLULAR:
                    interfaceDetailsMap.insert("typeName", "CELLULAR");
                    break;
                case NETSTATUS_INTERFACE_TYPE_P2P:
                    interfaceDetailsMap.insert("typeName", "P2P");
                    break;
                default:
                    interfaceDetailsMap.insert("typeName", "????");
                    break;
                }
            }
            if (connected) {
                // enumerate the ip addresses for this interface
                int numip = netstatus_interface_get_num_ip_addresses(details);
                QVariantList ipAddressList;
                for (int j = 0; j < numip; j++) {
                    QVariantMap ipAddressMap;
                    const char *ip = netstatus_interface_get_ip_address(details,
                            j);
                    const char *nm = netstatus_interface_get_ip_address_netmask(
                            details, j);
                    ipAddressMap.insert("ipAddress", ip);
                    ipAddressMap.insert("netmask", nm);
                    ipAddressList.append(ipAddressMap);
                }
                interfaceDetailsMap.insert("ipAddresses", ipAddressList);
                // enumerate gateways for this interface
                int numgw = netstatus_interface_get_num_ip_gateways(details);
                QVariantList ipGatewayList;
                for (int j = 0; j < numgw; j++) {
                    QVariantMap ipGatewayMap;
                    const char *ip = netstatus_interface_get_ip_gateway(details,
                            j);
                    ipGatewayMap.insert("gatewayIp",ip);
                    ipGatewayList.append(ipGatewayMap);
                }
                interfaceDetailsMap.insert("ipGateways",ipGatewayList);
            }
            interfaceList.append(interfaceDetailsMap);
        } // end if details
          // FREE Memory
        netstatus_free_interface_details(&details);
    }
    // FREE Memory
    netstatus_free_interfaces(&iflist);
    qDebug() << "List of Netstatus Interfaces: " << interfaceList.size();
    return interfaceList;
}

Thanks again to all the forum here and twitter. It's really nice to work with this great community

XXXX

and here is what you will get if the QVariantList was saved from the JsonDataAccess on a Z30:

[
   {
      "connected" : false,
      "hasType" : "false",
      "name" : "pflog0",
      "up" : false
   },
   {
      "connected" : false,
      "hasType" : "false",
      "name" : "lo0",
      "up" : true
   },
   {
      "connected" : false,
      "hasType" : "false",
      "name" : "rndis0",
      "up" : false
   },
   {
      "connected" : false,
      "hasType" : "false",
      "name" : "ecm0",
      "up" : false
   },
   {
      "connected" : false,
      "hasType" : "false",
      "name" : "bb0",
      "up" : false
   },
   {
      "connected" : false,
      "hasType" : "false",
      "name" : "ppp0",
      "up" : false
   },
   {
      "connected" : false,
      "hasType" : "false",
      "name" : "pan0",
      "up" : false
   },
   {
      "connected" : false,
      "hasType" : "false",
      "name" : "nap0",
      "up" : false
   },
   {
      "connected" : false,
      "hasType" : "true",
      "name" : "msm4",
      "type" : 7,
      "typeName" : "CELLULAR",
      "up" : false
   },
   {
      "connected" : false,
      "hasType" : "true",
      "name" : "msm3",
      "type" : 7,
      "typeName" : "CELLULAR",
      "up" : false
   },
   {
      "connected" : false,
      "hasType" : "true",
      "name" : "msm2",
      "type" : 7,
      "typeName" : "CELLULAR",
      "up" : false
   },
   {
      "connected" : true,
      "hasType" : "false",
      "ipAddresses" : [
         {
            "ipAddress" : "10.21.34.184",
            "netmask" : "255.255.255.252"
         },
         {
            "ipAddress" : "fe80::4242:24ff:4242:94d7%msm1",
            "netmask" : "ffff:ffff:ffff:ffff::"
         }
      ],
      "ipGateways" : [
         {
            "gatewayIp" : "10.21.34.184"
         }
      ],
      "name" : "msm1",
      "up" : true
   },
   {
      "connected" : true,
      "hasType" : "true",
      "ipAddresses" : [
         {
            "ipAddress" : "10.51.149.71",
            "netmask" : "255.255.255.240"
         },
         {
            "ipAddress" : "fe80::4242:24ff:4242:94d7%msm0",
            "netmask" : "ffff:ffff:ffff:ffff::"
         }
      ],
      "ipGateways" : [
         {
            "gatewayIp" : "10.51.149.71"
         }
      ],
      "name" : "msm0",
      "type" : 7,
      "typeName" : "CELLULAR",
      "up" : true
   },
   {
      "connected" : false,
      "hasType" : "true",
      "name" : "bcm1",
      "type" : 2,
      "typeName" : "WIFI",
      "up" : false
   },
   {
      "connected" : true,
      "hasType" : "true",
      "ipAddresses" : [
         {
            "ipAddress" : "192.168.42.42",
            "netmask" : "255.255.255.0"
         },
         {
            "ipAddress" : "fe80::4242:24ff:4242:94d7%bcm0",
            "netmask" : "ffff:ffff:ffff:ffff::"
         }
      ],
      "ipGateways" : [
         {
            "gatewayIp" : "192.168.42.1"
         }
      ],
      "name" : "bcm0",
      "type" : 2,
      "typeName" : "WIFI",
      "up" : true
   },
   {
      "connected" : false,
      "hasType" : "false",
      "name" : "smsc0",
      "up" : false
   },
   {
      "connected" : false,
      "hasType" : "false",
      "name" : "asix0",
      "up" : false
   },
   {
      "connected" : false,
      "hasType" : "false",
      "name" : "vlan0",
      "up" : false
   },
   {
      "connected" : false,
      "hasType" : "false",
      "name" : "vpn0",
      "up" : false
   },
   {
      "connected" : false,
      "hasType" : "false",
      "name" : "openvpn0",
      "up" : false
   },
   {
      "connected" : false,
      "hasType" : "false",
      "name" : "ipsec1",
      "up" : false
   },
   {
      "connected" : false,
      "hasType" : "false",
      "name" : "ipsec0",
      "up" : false
   },
   {
      "connected" : false,
      "hasType" : "false",
      "name" : "lo2",
      "up" : false
   },
   {
      "connected" : false,
      "hasType" : "true",
      "name" : "msm5",
      "type" : 7,
      "typeName" : "CELLULAR",
      "up" : false
   },
   {
      "connected" : false,
      "hasType" : "true",
      "name" : "msm6",
      "type" : 7,
      "typeName" : "CELLULAR",
      "up" : false
   },
   {
      "connected" : false,
      "hasType" : "true",
      "name" : "msm7",
      "type" : 7,
      "typeName" : "CELLULAR",
      "up" : false
   },
   {
      "connected" : true,
      "hasType" : "true",
      "ipAddresses" : [
         {
            "ipAddress" : "fd38:4242:4242:67b5:dacc:4242:f17e:6af7%59",
            "netmask" : "ff00::"
         },
         {
            "ipAddress" : "fe80::4242:24ff:4242:94d7%bptp0",
            "netmask" : "ffff:ffff:ffff:ffff::"
         }
      ],
      "ipGateways" : [],
      "name" : "bptp0",
      "type" : 8,
      "typeName" : "P2P",
      "up" : true
   }
]

the same linking Z10, Q10,... will report the names of different interfaces.

Martin Woolley also updates the sample MyDevice for use netstatus interface list with QNetworkInterface

Tags: BlackBerry Developers

Similar Questions

  • Any solution yet?

    Why is there a solution to this? My mac is so hot because of these applications. Yes, I had reformatthis.

  • Solution to stop and bufferin game of Air streaming on Apple TV 3rd gen. ?

    Even when im in the same room of 12 feet out. It's really frustrating.

    Streaming tube you 3rd generation is very frustrating on Air play on Apple TV. I have a Mac Book Pro with Mac OS El Capitan.

    any help will be appreciated.  Im trying using Roku, it might work better.

    Hi wilmernyc,

    I see your post that your antenna streaming is lagging and becomes interrupted when trying to stream content from your MacBook Pro to your Apple TV. I want to help you get a solution for this!

    Please follow the steps listed here to solve this problem:

    If your content is interrupted or your network is lagging

    If you have a weak Wi - Fi signal or interference from a device nearby, like a microwave or baby monitor, follow these steps:

    1. Make sure that you use the recommended settings of your Wi-Fi router.
    2. Move or disable other devices that may cause interference.
    3. If possible, connect your Apple TV directly to your router with an Ethernet cable instead of using Wi - Fi.

    Your AirPlay connection may if interrupt prematurely when you lock your device, put it to sleep, or switch to a different application.

    Get help with AirPlay and AirPlay Mirroring on your iPhone, iPad or iPod touch - Apple Support

    Although the article does not directly apply to OS X, I think that these steps will be useful for you.

    Take care!

  • Why always show that "there is a connection to the Apple store error."? It has been a month I am facing such a problem. How can I fix? Hope you have a solution to this...

    Why always show that "there is a connection to the Apple store error."? It has been a month I am facing such a problem. How can I fix? Hope you have a solution to this...

    I don't know if this is the problem, but it is something that must be correct establish a secure connection:

    Open Date and time preferences system, Date & time tab. Make sure that it is set to automatically set the time.

    Alternatively, make sure that your date/time is correctly set to the second.

    Another thing to try is to restart your modem and router.

  • Continuity and transfer works do not (Solution)

    I open this topic just to share my solution to the problem that some of you may face too.

    After upgrading to Mac OS Sierra, the characteristics of continuity has stopped working completely between my MacBook and iPhone, so I did all the procedures standards withoutsuccess:

    -Disconnect icloud on both devices and connect again

    -Reset the PRAM on Mac

    -Reset network settings

    -Turn on bluetooth works (all devices)

    -Creating a new user on mac to see if it was a problem with the specific user (without success)

    -Restart both devices again

    -Reset the router (just in case)

    And after a day trying to fix it, I gave up. But the next morning (today), I decided to try one last thing, and to my surprise, everything returned to normal instantly and magically.

    Here's what I did:

    On your mac,.

    1. disable the bluetooth

    2. finder-> go to folder...->/Library/Preferences /.

    3. delete the file com.apple.Bluetooth.plist

    4. turn on the bluetooth

    Boom. Everything returned to normal.

    I hope this helps someone who has the same problem I was. For any question, please check below.

    lucasvallim wrote:

    On your mac,.

    1. disable the bluetooth

    2. finder-> go to folder...->/Library/Preferences /.

    3. delete the file com.apple.Bluetooth.plist

    4. turn on the bluetooth

    You can check that the correct path is the one as written:

    / Library/Preferences /.

    and is not

    ~/Library/preferences/

  • By dictating the long notes, using Siri, Siri will stop as soon as I take a little break. Therefore, the note ends abruptly. Any solution for this?

    By dictating the long notes on Mac using Siri, Siri will stop as soon as I take a little break. Therefore, the note ends abruptly. Any solution for this?

    For long notes, you are better to use regular old dictation - under Mac OS for a few years now, Siri is not mandatory.

    To activate it, go to "System Preferences"-> keyboard-> dictation. Once enabled, you can press the "Fn" key twice to activate and dictate the long notes in any application.

    Siri is optimized for short, quick things. I don't think that you can change, you just use the method that is better to listen to what you want to do at the time (short notes, using Siri. Long notes, use dictation).

  • When I turn off my IPad wifi also turns off after the installation of IOS10. What is the solution?

    When I turn off my IPad wifi also turns off after the installation of IOS10. What is the solution?

    Hello. Do you mean "Turn off" or "sleep"? Your iPad there cell phones, or is it only WiFi?

  • When I include photos from a folder in the Photos app in the dock, and I have created an album for them, their changes. It is important for me to keep them in the same order that they were in the file. (It's a numerical order). Any solution?

    Recently, I switched from PC to Mac, and I transferred all my files photo. Now I am their integration in the Photos app in the dock (by dragging the file etc). But when I include photos from a folder in the Photos app in the dock, and then create an album for them, their order in the album change of what it is in the file. It is important for me to keep them in the same order that they were in the file. (In the file it is in numerical order). Any solution?

    You can drag and drop to any order in your albums.

  • Just upgraded to El Carlos Moreira of 10.6.8 on my imac. Using 1.5 photos, many are torn to pieces, especially the big raw files. Any solution?

    Just upgraded to El Carlos Moreira of 10.6.8 on my imac (2010). With the help of pictures 1.5, many are shredded, especially the big raw files. Any solution?

    Select one miniature pixelation and try, if reprocessing RAW format will help.  The last RAW support update that you have installed with the upgrade may have changed you the treatment for your camera RAW format.

    To reprocess the file open RAW image in edit mode and use the command "Image > reprocess RAW."  Does return correct thumbnail?

  • Given that I have updated to ios 10 my lock screen does nothing, I can not drag what anyone, cannot click on notifications, is there a solution?

    I've got the 6s and since I have updated to ios 10 my lock screen is totally unresponsive, I can't do anything, is there a solution?

    First, try a soft reset, press and hold the power button / stop and the "home" button until it goes off and you have the apple logo, then let go and let start up.

  • Solution of fast backup, photos of google or iCloud photo library?

    Hey there Apple community, im in a bit of a situation difficult and need a few thoughts. My iPhone more than 6 s is fully charged to 64 GB of photos and applications. My iMac is fully loaded with photos in iphoto, Yosemite. I have 10% left in my iMac HD. It won't let me save my iphone. I know I go through my iphoto library and organize and delete some photos and consolidate the events before migrating to the new application photos and then move it to icloud photo library, but I'm very limited on time in the next few months and won't be able to do. I wrestle on a quick temporary solution for backup, but don't want to spoil or lose my precious photos and other data.

    But this is what im thinking, tell me if this would mess things up.

    I would like to either temporarily back up all my photos on Google photos for now from my iphone, and then when I'm ready, I'm going to migrate my iphoto library all on my imac to the photo library to icloud and then transfer my photo library from google to the photo library icloud (but not sure. If it works Someone at - it experience with google pictures and Mac?).

    Or I simply activate the iCloud library of photos on my phone while it backs up my current pictures on my phone last year and then optimize my storage on my phone. Then a few months starting now to migrate my iphoto library 268 GB of Photos app on my iMac running Yosemite and then migrate the library of Photos in this same icloud photos library that I opened a few months back from my phone (I understand I will pay $10 per month for the size of the library). I feel like the latest one is the best option, but I'm not sure if I do it my icloud library won't sync and consolidate properly because I started with my current pictures on my phone and then brought in my library of photos together for the last 5 years at a later date. How do you think any community?

    Why not get an external drive and move the photo library of the computer to the outside. If successful, you can then remove the library on the computer, or just keep it as a backup.

    The article is for iPhoto, but the basics are the same.

    iPhoto: move your iPhoto library to a new location

  • Need solution for Mac Mail Backup... !!

    Hello

    I will start by telling you all that I am new to the mac world. As time has passed, I put the hand on a lot of my mac os x. But there are many things that I'm unable to perform or understand. One of the main things are mac mail backup. I connected with my Gmail in mac mail, as a frequent user of e-mail client, my gmail is nearly full and now I want to make a backup of all emails and folders available on gmail or the mac mail to give a cleaner more watch and save emails per year. Please help me to get the solutions as soon as possible. Thank you.

    Export your mailboxes. You can import them later if you want to access messages

    https://www.CNET.com/how-to/a-better-way-to-archive-email-in-Apple-Mail/

  • Is the time capsule the best solution for me?

    Dear Apple Support,

    I'm looking for a good solution for the following:

    -economy of mey Macbook Air 13 "wireless backup

    -Storage of files from various media (videos, basically)

    -Playback of multimedia files (iphoto library and mkv videos) on my Smart TV (wifi capable, and endowed with a multimedia player)

    I think a Time Capsule and Apple TV, but before buying it, I want to be sure those will satisfy the above requirements.

    Thank you for your answer!

    Kind regards

    Tamas

    If you format a drive for mac to use as a Time Machine backup format there is a chance your smart TV will be able to read this disc.

  • Please I have iPhone 6 more stopped working all of a sudden shows apple logo then black screen I can solution?

    Please I have iPhone 6 more stopped working all of a sudden shows apple logo then black screen I can solution?

    Have you tried to restart the iPhone by pressing and maintaining the sleep/wake and home buttons?

  • My phone, when I try to call, the volume seem to be so slow than normal, what happens after I have updated my phone, whenever I wear my scarf that I barely hear anything... Any solution? Thanks in advance

    My phone, when I try to call, I could barely hear the voice of the speaker, even turning on the Mono Audio, I rebooted the phone but nothing, this problem occurs after I updated the ios 9.3.5 aka the recent, so any solution pls response asap thx in advance

    Hello, dzharun!

    Thank you for joining the communities Support from Apple! It seems that you encounter to the appellants the hearing in question on your iPhone. I know how important it is, you are able to hear callers. Restart the phone and adjusting the audio are very advanced! Read this article If you hear not a person on an appeal or a voice messageor if the sound is not clear on your iPhone. Since you have tried reboot, find out exactly as follows:

    Turn off the receiver

    The receiver of the iPhone will not work properly if it is blocked or dirty.

    Follow these steps, after each:

    • Make sure that nothing is blocking the receiver, such as a case or a movie.
      If you have a new iPhone, remove the plastic on the front and the rear of the unit.
    • Check the receiver opening to see if it is blocked or dirty. If necessary, clean the receiver opening with a clean brush, dry, soft.
    • While you're online, turn on the speaker. If you still do not hear, then your network or the reception might be the issue. Try calling again later or somewhere else.

    Also, check out this article with links to learn more: get help with hardware on your iPhone, iPad, and iPod touch features. It has links to articles for several steps to help with issues with the receiver and the speaker.

    See you soon!

Maybe you are looking for