telephonyserverplugins/attestltsy/config/modifycommdb.pl
author Tom Pritchard <tomp@symbian.org>
Wed, 24 Feb 2010 13:44:01 +0000
branchAT_Test_LTSY
changeset 6 9b3b5a50db11
child 10 4d82aaca4452
permissions -rw-r--r--
Updating the config script to setup commdb dynamically
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
     1
#!perl -w
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
     2
# Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies).
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
     3
# All rights reserved.
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
     4
# This component and the accompanying materials are made available
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
     5
# under the terms of "Eclipse Public License v1.0"
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
     6
# which accompanies this distribution, and is available
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
     7
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
     8
#
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
     9
# Initial Contributors:
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    10
# Symbian Foundation - initial contribution.
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    11
#
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    12
# Contributors:
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    13
#
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    14
# Description:
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    15
# This simple script shows how to modify the content of a feature manager
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    16
# data file.
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    17
# 
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    18
#
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    19
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    20
use strict;
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    21
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    22
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    23
# Ask for the COM port and Baud
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    24
my $com;
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    25
my $baud;
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    26
print "What COMM port is the modem on?\n(Note: Symbian COMM ports are 1 less than windows)\n\tCOMM::";
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    27
chomp ($com = <>);
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    28
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    29
print "What is the baud rate of the modem?\n(Wavecomm default is 9600, Telit default is 152000)\n\tBaud=";
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    30
chomp ($baud = <>);
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    31
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    32
print "\nComm::$com Baud=$baud\n";
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    33
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    34
# Open the config files
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    35
my $defaultcomdb = "<./AT-LTSY(default).cfg";
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    36
my $commdb = ">>../../../../../../epoc32/winscw/c/AT-LTSY.cfg";
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    37
#my $commdb = ">./AT-LTSY.cfg";
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    38
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    39
open(COMMDBOUT, $commdb);
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    40
open(COMMDBREAD, $defaultcomdb);
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    41
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    42
# Read in the default commdb and write it out to the new file, changing the com port and baud where necessary
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    43
my $modembearertable = 0;
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    44
my $modementry = 0;
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    45
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    46
while(<COMMDBREAD>)
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    47
{
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    48
my($line)=$_;
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    49
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    50
# first wait till we've found the $modembearertable line.
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    51
if ($line =~ m/^\[ModemBearer\]/) 
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    52
	{
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    53
	print "Found the modem bearer table\n";
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    54
	$modembearertable = 1;
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    55
	}
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    56
# Or if we've got the end of the table unset the boolean
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    57
elsif ($modembearertable && $line =~ m/^\[/) 
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    58
	{
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    59
	print "Found the end fo the modem bearer table\n";
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    60
	$modembearertable = 0;	
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    61
	}
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    62
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    63
# If we're in the modem table then check for a few things
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    64
if ($modembearertable)
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    65
	{
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    66
	# Now wait till we've got to an entry for our modem
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    67
	if ($line =~ m/^\sName=CommModem/) 
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    68
		{
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    69
		print "Found the modem entry\n";
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    70
		$modementry = 1;
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    71
		}
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    72
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    73
	# Or if we've reached the end of the modem entry unset the boolean
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    74
	if ($modementry && $line =~ m/^END_ADD/) 
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    75
		{
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    76
		print "Found the end of the modem entry\n";
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    77
		$modementry = 0;
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    78
		}
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    79
	}
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    80
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    81
# If we're in the entry for our modem then potentially modify the line
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    82
if ($modementry)
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    83
	{
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    84
	# If it's the comm port number set that up
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    85
	if ($line =~ m/^\sPortName=COMM::/) 
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    86
		{
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    87
		print "Changing COMM port\n";
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    88
		$line = "\tPortName=COMM::$com\n"
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    89
		}
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    90
	
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    91
	# If it's the rate then set that up
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    92
	if ($line =~ m/^\sRate=/) 
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    93
		{
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    94
		print "Changing Baud rate\n";
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    95
		$line = "\tRate=$baud\n"
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    96
		}
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    97
	}
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    98
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
    99
# Write out the (modified) line to the new commdb
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   100
print COMMDBOUT $line;
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   101
}
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   102
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   103
# Close the files
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   104
close(COMMDBOUT);
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   105
close(COMMDBREAD);
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   106
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   107
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   108
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   109
# Open the .cfg file and read each line
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   110
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   111
#rename($datfile, $datfileback) or die "Couldn't backup feature data file '$datfile'\n";
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   112
#rename($datfile2, $datfile) or die "Couldn't copy feature data file '$datfile2'\n";
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   113
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   114
#printf ("\tFeature Database setup\n");
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   115
#
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   116
# Example code to remove a feature flag.
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   117
#
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   118
#$fmc->RemoveFeatureFlagByUID($ffuid) or die "Couldn't remove feature flag\n";
9b3b5a50db11 Updating the config script to setup commdb dynamically
Tom Pritchard <tomp@symbian.org>
parents:
diff changeset
   119