Connection Types Supported by libgnokii

The ./configure script automatically enables those connection types for which it can find the needed libraries and/or include files, but up to version 0.6.14 the config file parse routines wouldn't know which connection types were actually compiled.

These are all the connection types known to libgnokii (all names must be lowercase in gnokiirc):

  • bluetooth *
  • dau9p
  • dku2
  • dku2libusb *
  • dku5
  • dlr3p
  • infrared *
  • irda *
  • m2bus
  • serial
  • tcp **
  • tekram

* automatically enabled at configure time if all dependencies are satisfied
** not available on WIN32 builds

If you have written a program using libgnokii and you wish to know if a given connection is available you can use gn_get_connectiontype(), or you can use gn_lib_get_supported_connection() to get all supported connection types.
Note: this works with libgnokii version 0.6.15 or later.

I've written a small program to be used in scripts to check if a given connection is available.

Example:

conn=bluetooth; get_supported_connection $conn || echo "Sorry $conn is not compiled in your libgnokii"

C source follows:

/*

  $Id:$

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

  Copyright (c) 2006 by Daniele Forsi

  This prints a list of all connections supported by the currently installed libgnokii
  or checks if a given connection is supported (libgnokii later than 0.6.14).

  Compile and test:
  gcc get_supported_connection.c -o get_supported_connection $(pkg-config --libs gnokii)
  conn=bluetooth; get_supported_connection $conn || echo "Sorry $conn is not compiled in your libgnokii"

*/

#include 

#include "gnokii.h"

int main(int argc, char *argv[]) {
	int i;
	const char *conn;

	if (argc == 2) {
		if (!strcmp(argv[1], "-l")) {
			for (i = 0; ; i++) {
				conn = gn_lib_get_supported_connection(i);
				if (!conn) break;
				printf("%s\n", conn);
			}
		} else {
			if (gn_get_connectiontype(argv[1]) == GN_CT_NONE) return 1;
		}
	} else {
		printf("Usage: %s -l|conn\n  -l    list all supported connection types\n  conn  connection type to search\n", argv[0]);
		return 1;
	}

	return 0;
}

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Current CVS code allows to

Current CVS code allows to disable libusb support. Perhaps it would be wise to allow that also for bluetooth and irda (well, it doesn't require any additional libraries). It may be useful when you compile on the system that has more capabilities than the system you will use it on.

pkot
PS. Perhaps create a module in CVS for such short snipplets of code?

Yes, explicitly disabling

Yes, explicitly disabling them would be useful and "more orthogonal" and a CVS module would make it easier to download this code and possibly keep it in sync with libgnokii.
Since CVS is not good at moving files, we just need to think in advance if it makes sense to have a directory structure inspired by the splitting of gnokii.c (such as sms, phonebook, etc.).

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
more