From 49dd905279a8e62936e3713510ab0fd738e20ecb Mon Sep 17 00:00:00 2001 From: short <> Date: Wed, 3 Apr 2002 00:08:34 +0000 Subject: [PATCH] Found in "gnokii-working" directory, some November-patches version --- .exrc | 2 + COPYING | 356 +- Docs/CREDITS | 58 +- Docs/FAQ | 9 - Docs/Makefile | 86 +- Docs/README-AT | 58 + Docs/README-CIMD | 20 + Docs/gettext-howto | 22 - Docs/man/gnokii.1 | 10 +- Docs/man/todologo.1 | 5 +- Docs/man/xgnokii.1x | 2 +- Docs/protocol/nk6110.txt | 6 +- Docs/protocol/nk7110.txt | 8 +- Docs/sample/cimd-connect | 6 + Docs/sample/gnokiirc | 47 +- INSTALL | 10 +- Makefile | 49 +- Makefile.global.in | 6 +- VERSION | 2 +- common/Makefile | 89 +- common/at-hw.c | 2659 +++++++++ common/cfgreader.c | 58 +- common/cimd.c | 1636 ++++++ common/data/at-emulator.c | 34 +- common/data/datapump.c | 13 + common/data/rlp-common.c | 22 + common/data/rlp-crc24.c | 10 + common/data/virtmodem.c | 49 +- common/devices/tekram.c | 52 +- common/devices/unixirda.c | 137 +- common/devices/unixserial.c | 355 +- common/fbus-6110.c | 350 +- common/gsm-api.c | 1240 ++-- common/gsm-bitmaps.c | 369 +- common/gsm-common.c | 590 +- common/gsm-encoding.c | 14 +- common/gsm-error.c | 9 +- common/gsm-networks.c | 87 +- common/gsm-ringtones.c | 1415 ++--- common/gsm-sms.c | 1529 ++--- common/gsm-statemachine.c | 157 +- common/links/Makefile | 4 +- common/links/atbus.c | 31 +- common/links/atbus.c-REMOVE | 0 common/links/fbus-phonet.c | 14 +- common/links/fbus.c | 51 +- common/mbus-2110.c | 5 +- common/mbus-6160.c | 5 +- common/mbus-640.c | 5 +- common/misc.c | 277 +- common/phones/Makefile | 11 +- common/phones/atgen.c | 469 +- common/phones/atgen.c-REMOVE | 0 common/phones/dc2711.c | 5 +- common/phones/dc2711.c-REMOVE | 0 common/phones/nk2110.c | 130 +- common/phones/nk3110.c | 82 +- common/phones/nk6100.c | 225 +- common/phones/nk7110.c | 501 +- common/phones/nokia.c | 9 +- configure.in | 14 +- do | 13 + getopt/Makefile | 2 +- gnokii/Makefile | 31 +- gnokii/gnokii.c | 10917 +++++++++--------------------------- gnokiid/Makefile | 24 +- gnokiid/gnokiid.c | 146 +- include/cfgreader.h | 12 +- include/config.h.in.in | 16 +- include/data/at-emulator.h | 14 + include/data/datapump.h | 10 + include/data/rlp-common.h | 16 + include/data/rlp-crc24.h | 12 + include/data/virtmodem.h | 22 +- include/devices/tekram.h | 13 + include/devices/unixirda.h | 32 +- include/devices/unixserial.h | 15 +- include/fbus-3810.h | 205 + include/fbus-6110.h | 7 +- include/gnokii.h | 9 +- include/gsm-api.h | 535 +- include/gsm-bitmaps.h | 68 +- include/gsm-common.h | 1082 +++- include/gsm-networks.h | 38 +- include/gsm-ringtones.h | 112 +- include/gsm-sms.h | 513 +- include/links/atbus.h | 9 +- include/links/atbus.h-REMOVE | 0 include/links/fbus.h | 10 +- include/mbus-6160.h | 7 +- include/mbus-640.h | 7 +- include/misc.h | 141 +- include/phones/nk6100.h | 12 +- include/phones/nk7110.h | 49 +- include/phones/nokia.h | 10 +- packaging/Debian/README.debian | 3 +- packaging/Debian/control | 13 +- packaging/Debian/copyright | 42 +- packaging/Debian/docs | 7 - packaging/Debian/menu | 2 +- packaging/Debian/postinst | 7 +- packaging/Debian/preinst | 9 +- packaging/Debian/rules | 44 +- packaging/RedHat/gnokii.spec.in | 22 +- packaging/Slackware/SlackBuild.in | 29 +- po/Makefile.in.in | 11 +- po/POTFILES.in | 34 +- po/et.po | 2897 +++++----- smsd/ChangeLog | 6 +- smsd/Makefile | 38 +- smsd/db.c | 197 +- smsd/lowlevel.c | 88 +- smsd/lowlevel.h | 7 +- smsd/sms-sendsms | 100 + smsd/sms.tables.sql | 11 +- smsd/smsd.c | 23 +- smsd/smsd.h | 1 + utils/Makefile | 25 +- utils/mgnokiidev.c | 18 +- xgnokii/Makefile | 148 +- xgnokii/VERSION | 2 +- xgnokii/xgnokii.c | 283 +- xgnokii/xgnokii.h | 11 +- xgnokii/xgnokii_calendar.c | 15 +- xgnokii/xgnokii_calendar.h | 5 + xgnokii/xgnokii_cfg.c | 5 + xgnokii/xgnokii_cfg.h | 5 + xgnokii/xgnokii_common.c | 8 +- xgnokii/xgnokii_common.h | 21 +- xgnokii/xgnokii_contacts.c | 84 +- xgnokii/xgnokii_contacts.h | 10 + xgnokii/xgnokii_data.c | 19 +- xgnokii/xgnokii_data.h | 5 + xgnokii/xgnokii_dtmf.c | 8 +- xgnokii/xgnokii_dtmf.h | 5 + xgnokii/xgnokii_logos.c | 828 +-- xgnokii/xgnokii_lowlevel.c | 482 +- xgnokii/xgnokii_lowlevel.h | 40 +- xgnokii/xgnokii_netmon.c | 8 +- xgnokii/xgnokii_netmon.h | 5 + xgnokii/xgnokii_sms.c | 394 +- xgnokii/xgnokii_sms.h | 5 + xgnokii/xgnokii_speed.c | 8 +- xgnokii/xgnokii_speed.h | 5 + xgnokii/xgnokii_xkeyb.c | 135 +- xgnokii/xgnokii_xkeyb.h | 5 + 146 files changed, 16634 insertions(+), 17132 deletions(-) create mode 100644 .exrc create mode 100644 Docs/README-AT create mode 100644 Docs/README-CIMD create mode 100755 Docs/sample/cimd-connect create mode 100644 common/at-hw.c create mode 100644 common/cimd.c create mode 100644 common/links/atbus.c-REMOVE create mode 100644 common/phones/atgen.c-REMOVE create mode 100644 common/phones/dc2711.c-REMOVE create mode 100755 do create mode 100644 include/fbus-3810.h create mode 100644 include/links/atbus.h-REMOVE create mode 100755 smsd/sms-sendsms diff --git a/.exrc b/.exrc new file mode 100644 index 0000000..f3c07bf --- /dev/null +++ b/.exrc @@ -0,0 +1,2 @@ +set tabstop=8 +set shiftwidth=8 diff --git a/COPYING b/COPYING index 60549be..99a8ab6 100644 --- a/COPYING +++ b/COPYING @@ -1,340 +1,30 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 +GNOKII - A Linux/Unix toolset and driver for the Nokia 3x10/8110/51x0/61x0 + Copyright (C) 1999 Hugh Blemings & Pavel Janík ml. - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. +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. - Preamble +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. - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA. - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. +You can contact authors by mail at - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. +hugh@blemings.org Pavel.Janik@suse.cz +Hugh Blemings Mgr. Pavel Janík, SuSE CR, s.r.o. +PO Box 234 Pod Pekárnami 338/12 +Belconnen ACT 2616 190 00 Praha 9 +Australia Czech Republic - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. +We would be delighted to receive a postcard from you if you use gnokii but +this is not a requirement of these licence terms! :) - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) 19yy - - 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; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) 19yy name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. +Any trademarks in this or other gnokii documents/files are the property of +their respective owners. diff --git a/Docs/CREDITS b/Docs/CREDITS index 7193775..820c4af 100644 --- a/Docs/CREDITS +++ b/Docs/CREDITS @@ -56,7 +56,7 @@ Thank you to, in no particular order... * Goran Dokic, Samuli Sorvakko and anonymous for gettext files for Dutch, Finnish and German translations. -* Marcel Holtmann for RLP FCS code and misc stuff. +* Marcel Holtmann for RLP FCS code, the irda code and other misc stuff. * Chris Kemp for logo stuff and a big part of the RLP code. @@ -73,38 +73,54 @@ Thank you to, in no particular order... * Alessandro Zummo for reset and getopts code. +* Manfred Jonsson for his manufacturer and windows patch, and AT command + support. + * Mark Looi for Cell Broadcast code - based on protocol decoded by - Colin Paton + Colin Paton. -* Sebastian Zagrodzki and Jacek Fiok for Polish .po file +* Sebastian Zagrodzki and Jacek Fiok for Polish .po file. -* Lucy for making pizza and putting up with Hugh disappearing to - work on this. Rachael for new parent induced insomnia... +* Marcin Wi±cek for all his work and tons of patches. -* Last not least: Mirka for allowing Pavel to work on gnokii - and for _great_ gnokii operator logos... +* Gabriele Zappi for testing, general help and bug fixes. -* Hendrik Spohr for getting 7110 functions and DLR-3 to work (one small step - for Hendrik, big step for (my)gnokii :-)) - -* Balazs Nagy for frames list and long hacker's work... +* Erik Rossen for help with documentation and debian packaging support. + +* Marian Jancar for patches on 7110 series. + +* Tamar Bondar for updates on SMS handling on 3810 series. -* Ladislav Michl & Manfred Jonsson for support for various AT phones... +* Marek Rogoziñski for help in tracing some nasty bugs. -* Manfred Jonsson for idea of programming, which looks for me good +* Pavel Machek for developing 2110 and Duncall support and many clever + hints. -* Michael Hund for many improvements and progress in 7110/6210 source... +* Bo¹tjan Müller for Slovenian translation and other things. -* Ralf Thelen for very required by many, many people patch and getting - infrared sockets to work -> small changes, few days of hard searching :-). - Also sms stuff is OK now +* Hans Motshärg for Estonian translation. -* Gabriele Zappi for many 6210 improvements and big calendar source +* Marcin P³awiñski for preview logos. -* Andrea Scopece for 61xx source for netmonitor and other improvements +* Martin Lucina for any kind of help he is providing ;-) -* ....and other people, who reported me bugs or want(ed) to use mygnokii - and help me in making it the best ! +* Gabriele Stella for Italian translation. + +* Andrea Scopece for bug reports and other help. + +* Panagiotis Astithas, Daniel O'Connor, Sheldon Hearn for help with FreeBSD. + +* Artur Kubiak for help with Solaris. + +* Markus Plail for work on 7110 support. + +* Simon Huggins for help with 6210 and IrDA. + +* Lucy for making pizza and putting up with Hugh disappearing to + work on this. Rachael for new parent induced insomnia... + +* Last not least: Mirka for allowing Pavel to work on gnokii + and for _great_ gnokii operator logos... We tried to mentioned everyone who contributed to gnokii project but we might to forgot someone. If anyone does feel that we missed him and his diff --git a/Docs/FAQ b/Docs/FAQ index f140e5d..f8d32c5 100644 --- a/Docs/FAQ +++ b/Docs/FAQ @@ -103,12 +103,3 @@ Q. Does gnokii work under Sun's Solaris ? A. Generally yes, but in fact it depends on hardware -- your serial port must support at least 115200 baud rate. Sun Enterprise 250 machine is known to work with gnokii. - -------------------------------------------------------------------------------- -Q. I get "Sorry, phone has not yet been converted to new style. - Phone.Functions == NULL!" message. What's wrong? - -A. Don't worry. Nothing's wrong with your phone. Gnokii internal structure is - changing to be more flexible. It is quite complex process so it may take - some time to get everything to work. You may help us to do it -- you'll get - more functionality sooner. diff --git a/Docs/Makefile b/Docs/Makefile index 8dd1724..d5666ac 100644 --- a/Docs/Makefile +++ b/Docs/Makefile @@ -1,63 +1,47 @@ # -# Makefile for the xGNOKII tool suite. +# Makefile for the GNOKII tool suite's documentation directory +# +# Copyright (C) 1999 Hugh Blemings & Pavel Janík ml. +# 2000 Karel Zak # -TOPDIR=.. -include $(TOPDIR)/Makefile.global - -HELP1_DIR = en_US -HELP11_DIR = pl_PL -HELP2_DIR = examples -HELP3_DIR = default +TOPDIR=../ +include ${TOPDIR}/Makefile.global -GNOKII1_MAN1 = "man/gnokii.1" -GNOKII1_MAN2 = "man/todologo.1" -GNOKII8_MAN1 = "man/gnokiid.8" -GNOKII8_MAN2 = "man/mgnokiidev.8" -XGNOKII_MAN = "man/xgnokii.1x" +# +# Documentation for gnokii (xgnokii install documentation files itself). +# -all: +INSTALL_DOCS = README \ + README-3810 \ + README-6110 \ + CREDITS \ + DataCalls-QuickStart \ + README-WIN32 \ + gettext-howto \ + gnokii.nol \ + gnokii-ir-howto \ + packaging-howto \ + sample.gnokiirc + +GNOKII1_MAN = "man/gnokii.1 man/todologo.1" +GNOKII8_MAN = "man/gnokiid.8 man/mgnokiidev.8" +XGNOKII_MAN = man/xgnokii.1x + +all: @echo -makelib: - @echo - install: $(INSTALL) -d $(docdir) - - ( cd $(HELP1_DIR); \ - $(FIND) . -type d \! -path "*CVS*" \ - -exec $(INSTALL) -d $(docdir)/en_US/{} \; ; \ - $(FIND) . -type f \! -path "*CVS*" \ - -exec $(INSTALL) -m 0444 {} $(docdir)/en_US/{} \; \ - ) - ( cd $(HELP11_DIR); \ - $(FIND) . -type d \! -path "*CVS*" \ - -exec $(INSTALL) -d $(docdir)/pl_PL/{} \; ; \ - $(FIND) . -type f \! -path "*CVS*" \ - -exec $(INSTALL) -m 0444 {} $(docdir)/pl_PL/{} \; \ - ) - - ( cd $(HELP2_DIR); \ - $(FIND) . -type d \! -path "*CVS*" \ - -exec $(INSTALL) -d $(docdir)/examples/{} \; ; \ - $(FIND) . -type f \! -path "*CVS*" \ - -exec $(INSTALL) -m 0444 {} $(docdir)/examples/{} \; \ - ) - ( cd $(HELP3_DIR); \ - $(FIND) . -type d \! -path "*CVS*" \ - -exec $(INSTALL) -d $(docdir)/default/{} \; ; \ - $(FIND) . -type f \! -path "*CVS*" \ - -exec $(INSTALL) -m 0444 {} $(docdir)/default/{} \; \ - ) - $(INSTALL) -m 0444 CREDITS $(docdir) - $(INSTALL) -m 0444 ../COPYING $(docdir) - $(INSTALL) $(GNOKII1_MAN1) $(man1dir) - $(INSTALL) $(GNOKII1_MAN2) $(man1dir) - $(INSTALL) $(GNOKII8_MAN1) $(man8dir) - $(INSTALL) $(GNOKII8_MAN2) $(man8dir) - if [ "x$(HAVE_XGNOKII)" = xyes ]; then \ - ($(INSTALL) $(XGNOKII_MAN) $(xmandir)) \ + @for xxx in $(INSTALL_DOCS); do \ + if [ -e $$xxx ]; then \ + $(INSTALL) -m 0444 $$xxx $(docdir)/$$xxx; \ + fi; \ + done + $(INSTALL) $(GNOKII1_MAN) $(man1dir) + $(INSTALL) $(GNOKII8_MAN) $(man8dir) + if [ "x$HAVE_XGNOKII" = xyes ]; then \ + $(INSTALL) $(XGNOKII_MAN) $(xmandir) \ fi @echo "done" diff --git a/Docs/README-AT b/Docs/README-AT new file mode 100644 index 0000000..4f906bd --- /dev/null +++ b/Docs/README-AT @@ -0,0 +1,58 @@ +-- README-AT -- +-- Notes, bugs and a todo list for AT command compatible modems -- + +* Notes * + +General PDU documentation can be found on: + http://www.siemens-mobile.de/pages/wm/downloads/m20_sms.pdf +General AT commands documentation can be found on: + http://www.siemens-mobile.de/pages/wm/downloads/tc35_at_e.pdf + +Although this documentation is for Siemens devices, your modem will probably +support some subset (or superset?) of it. Official standard document could be +probably also found in www.etsi.org library. + + +Successfuly tested: + +Siemens M20 + (provided by the courtesy of Lubor Otta) + ATI1 --> SIEMENS M20 Revision: 5.4, 13.12.00 13:15 + + gnokiirc argument "serial_write_usleep" MUST be >=1 otherwise + the device communication is very unreliable. + +Nokia Communicator 9000i + ATI2 --> SW6.36 : HW0320 + + Only +CMGF==1 mode capable so no logo/ring send/receive. + No +CNMI new SMS reporting so their detection is slow (+CMGL). + Unable to receive SMSes to SIM so no Gnokii SMS receive possible. + No +COPS/+CREG so no network code detection, set it manually. + +Nokia Communicator 9110 + (provided by the courtesy of Karel Zatloukal) + ATI2 --> SW 4.05: HW 3600 + + Only +CMGF==1 mode capable so no logo/ring receive but it can send! + No PhoneBook commands supported so no contacts access available. + Unable to receive SMSes to SIM so no Gnokii SMS receive possible. + No +COPS/+CREG so no network code detection, set it manually. + +Nokia Communicator 9210 + ATI2 --> SW03.54 + + No PhoneBook commands supported so no contacts access available. + Unable to receive SMSes to SIM so no Gnokii SMS receive possible. + No +COPS/+CREG so no network code detection, set it manually. + +Nokia CardPhone + (provided by the courtesy of Tim Boudreau) + ATI2 --> SW4.23 + + No known disadvantages. + + +* Known Bugs * + +* To-do * diff --git a/Docs/README-CIMD b/Docs/README-CIMD new file mode 100644 index 0000000..65b640c --- /dev/null +++ b/Docs/README-CIMD @@ -0,0 +1,20 @@ +-- README-CIMD -- +-- Notes, bugs and a todo list for SMS center protocol support -- + +* Notes * + +Currently it has been tested only on "EOTEL BMG" BIP (=Business messaging +gateway Interface Protocol) if using BMG (=Bussiness Messaging Gateway) <-> +<-> SMSC (SMS Center) protocol CIMD. This service is provided +by Eurotel CZ (230 02) operator, service description (not technical and +just in Czech language!): + http://www.eurotel.cz/eurotel/Site/sluzby/slsms_webbmg.htm + +BIP is probably predecessor to the very similiar to Nokia CIMD2 protocol, +its description for Artus SMS center can be found on: + http://forum.nokia.com/download/cimdspec.pdf + + +* Known Bugs * + +* To-do * diff --git a/Docs/gettext-howto b/Docs/gettext-howto index 1c78ab1..c24e67d 100644 --- a/Docs/gettext-howto +++ b/Docs/gettext-howto @@ -100,25 +100,3 @@ SnowWhite:/tmp/gnokii$ The second line is in czech language :-) There are some problems - for example with "Mar" which is substitute by the C preprocessor. -6. How to use locale in the gnokii code - -It's simple. Instead uf using: -"some string" -use: -_("some string") - -In some cases _() cannot be used but the text still needs to be localized. -In such cases use: -N_("some string") -For more detailes refer to gettext info pages. - -When sending us the patches and writing code for gnokii follow the rules: - - do NOT translate DEBUG output (usually done by dprintf()), - - translate all other output - - do not output to stdout, unless you are in the application level code - (gnokii/*.c, gnokiid/*.c, xgnokii/*.c, smsd/*.c) - --- -$Id$ -Pavel Janik -Pawel Kot diff --git a/Docs/man/gnokii.1 b/Docs/man/gnokii.1 index 214d696..1c9e4a2 100644 --- a/Docs/man/gnokii.1 +++ b/Docs/man/gnokii.1 @@ -61,16 +61,16 @@ resets the phone. .SS CALENDAR .TP -.BR "\-\-getcalendarnote \fIindex\fP [\-v]" -get the note with number \fIindex\fR from calendar. +.BR "\-\-getcalendarnote \fIstart\fP [\fIsend\fP] [\-v]" +get the note with numbers from \fIstart\fR to \fIend\fR from calendar. .PP [\-v] \- output in vCalendar 1.0 format .TP .BR "\-\-writecalendarnote" write the note to calendar. .TP -.BR "\-\-deletecalendarnote \fIindex\fP" -delete the note with number [\fIindex\fR] from calendar. +.BR "\-\-deletecalendarnote \fIstart\fP [\fIend\fP]" +delete the note with numbers from \fIstart\fR to \fIend\fR from calendar. .SS SMS .TP @@ -193,4 +193,4 @@ See also Docs/CREDITS from Gnokii sources. This program is distributed under the GNU Public License. .SH "SEE ALSO" -gnokiid, xgnokii, xlogos +gnokiid, xgnokii diff --git a/Docs/man/todologo.1 b/Docs/man/todologo.1 index c66955b..db9b969 100644 --- a/Docs/man/todologo.1 +++ b/Docs/man/todologo.1 @@ -33,7 +33,7 @@ from \fIgnokii.nol\fR that is distributed with mobile phone. Use .B gnokii or -.B xlogos +.B xgnokii to do the uploading. .SH EXAMPLES @@ -52,6 +52,5 @@ Tomi Ollila This program is distributed under the GNU Public License. .SH SEE ALSO -.BR gnokii(1), -xlogos +.BR gnokii(1), xgnokii(1x) diff --git a/Docs/man/xgnokii.1x b/Docs/man/xgnokii.1x index 5fad541..16f1037 100644 --- a/Docs/man/xgnokii.1x +++ b/Docs/man/xgnokii.1x @@ -36,4 +36,4 @@ See also Docs/CREDITS from the Gnokii sources. This program is distributed under the GNU Public License. .SH "SEE ALSO" -gnokii, gnokiid, xlogos +gnokii, gnokiid diff --git a/Docs/protocol/nk6110.txt b/Docs/protocol/nk6110.txt index baac106..a4f35ed 100644 --- a/Docs/protocol/nk6110.txt +++ b/Docs/protocol/nk6110.txt @@ -298,9 +298,9 @@ Correct format is FBUS version 2/Direct IRDA/MBUS version 2 0x05: 5 second 0x0a: 10 second 0x0f: 15 second - 0x14: 20 second - 0x19: 25 second - 0x1e: 30 second + 0x1e: 20 second + 0x14: 25 second + 0x19: 30 second where divtype: 0x02: all diverts for all call types ? Found only, when deactivate all diverts for all call types (with call type 0x00) diff --git a/Docs/protocol/nk7110.txt b/Docs/protocol/nk7110.txt index c95d9b9..525bf61 100644 --- a/Docs/protocol/nk7110.txt +++ b/Docs/protocol/nk7110.txt @@ -215,11 +215,11 @@ Correct format is FBUS version 2/Infrared/MBUS version 2 where location: 0x21 (always ?) r Set Picture Image { 0x0051, location, number[2 bytes], 0x07 } where location: 0x21 (always ?) - - s List Picture Images { 0x0096, FolderID, 0x0f, 0x07 } - where: FolderID - see 0x14/0x017B + s List Picture Images { 0x0096, location, 0x0f, 0x07 } + where location: + LM tries with 0x09, 0x11, 0x19, 0x21, 0x29, 0x31, 0x39, 0x41, 0x49 + Returned value with 0x21 r List Picture Images { 0x0097, number of pictures[2 bytes], number1[2 bytes], number2[2 bytes], ..., } - s Get SMS from folder { 0x0107, folderID, 0x00, location, 0x01, 0x65, 0x01} where: folderID - see 0x14/0x017B r Get SMS from folder { 0x0108, status, folderID, 0x00, location, type, sender number,...} diff --git a/Docs/sample/cimd-connect b/Docs/sample/cimd-connect new file mode 100755 index 0000000..320c4e9 --- /dev/null +++ b/Docs/sample/cimd-connect @@ -0,0 +1,6 @@ +#! /usr/sbin/chat -vEf +# ^^^ all options MUST be given as ONE word only (all are passed as ARGV[1]) +TIMEOUT 3 "" "ATZ" "OK-ATZ-OK" "" ABORT "BUSY" ABORT "NO CARRIER" ABORT "NO DIAL TONE" ABORT "ERROR" ABORT "VOICE" "" +ATL2 OK +ATD$TELEPHONE +TIMEOUT 90 CONNECT \c ^M \c diff --git a/Docs/sample/gnokiirc b/Docs/sample/gnokiirc index 845aca8..bbecf77 100644 --- a/Docs/sample/gnokiirc +++ b/Docs/sample/gnokiirc @@ -21,10 +21,7 @@ model = 6110 # to understand what this changes if you're curious. initlength = default -# The type of the connection, for IR set this to infrared or irda. -# If you have 6210/6250/7110 phone and dau9p cable (the one you can -# use with 6100 series and cannot use hardware modem from the phone) -# you may want to use 'dau9p' value to get faster initialization. +# The type of the connection, for IR set this to infrared connection = serial # Set bindir to point to the location of the various gnokii binaries. @@ -32,3 +29,45 @@ connection = serial # permissions 4750, owned by root, group gnokii. Ensure you # are in the gnokii group and that the group exists... bindir = /usr/local/sbin/ + +# Baudrate to use on serial port connections. +# Currently used only by models AT and BIP/CIMD. Defaults to 19200. +serial_baudrate = 19200 + +# Force waiting after each send character the specified usec time. +# Value -1 forces the fastest 'block' writing, +# value 0 writes each character separately without any explicite waiting, +# other positive values specify the appropriate 1/1000000 sec delaying. +# Siemens M20 requires at least "1"! FIXME: Autodetect +#serial_write_usleep = 10000 + +# Force serial port handshaking mode, useful primarily for "AT" model. +# Gnokii "AT" model uses software handshake by default. +# Possible values: hardware (RTS/CTS - 7 wires) or software (XON/XOFF - 3 wires) +#handshake = software + +# If defined (not commented out by '#') it will quit Gnokii anytime +# when DCD line will drop. +require_dcd = 1 + +# Run the specified script(s) right after opening and initializing the device +# and before any communucation (right before closing for disconnect_script). +# You may find handy to use it to connect your modem to SMS Center +# when using BIP or CIMD protocols +connect_script = echo x +disconnect_script = echo y + +# Any entries in the following two sections will be set as environment +# variables when running the scripts. +# Handy for use for $VAR substitutions in your chat(8) script. +[connect_script] +TELEPHONE = 01234567 +[disconnect_script] + + +[CIMD] + +# This section is used only if "model" is set to BIP or CIMD. +# Set here your authorization pair given you by the operator. +name = USERNAME +password = PASSWORD diff --git a/INSTALL b/INSTALL index 7d5654f..3551ce2 100644 --- a/INSTALL +++ b/INSTALL @@ -16,7 +16,7 @@ Install path prefix. Default /usr/local/ --without-x - Compile without GTK (X11) programs + Compile without GTK (Xwin) programs --disable-nls Set if you don't have/want GNU gettext support @@ -34,17 +34,15 @@ Good default (example): ./configure --prefix=/usr \ - --enable-security + --enable-gettext 2/ compilation: - make (or make gnokii-debug to create staticlly linked binary - -- mainly for debugging) + make groupadd gnokii - it is really needed (make dep - if you want/need) - make install or make install-suid or make install-strip or - make install-ss (suid + strip) + make install make install-docs clean source: diff --git a/Makefile b/Makefile index 1feaf9c..f43d66d 100644 --- a/Makefile +++ b/Makefile @@ -17,27 +17,20 @@ include ${TOPDIR}/Makefile.global BIN_DIRS = gnokii +BIN_DIRS += smsd + ifndef WIN32 -BIN_DIRS += gnokiid -BIN_DIRS += mgnetd -BIN_DIRS += mgnetd/mg_demo_client +#BIN_DIRS += gnokiid utils endif -DIRS = common \ - Docs \ +DIRS = common/phones \ + common/links \ + common/devices \ + common \ $(BIN_DIRS) +# common/data \ -# -# For now gnokiid and utils only make sense on Unix like systems. -# Some other stuff that makes only sense on Win32 platform. -# - -ifndef WIN32 -DIRS += utils -endif - -GTK_DIRS = xgnokii \ - xlogos +GTK_DIRS = xgnokii PO_DIR = po DOCS_DIR = Docs @@ -56,25 +49,6 @@ all: $(DIRS) fi @echo "done" -makelib: - @for dir in $(DIRS); do \ - if [ -e $$dir/Makefile ]; then \ - $(MAKE) -C $$dir makelib; \ - fi; \ - done - @if [ "x$(USE_NLS)" = xyes ]; then \ - $(MAKE) -C $(PO_DIR) makelib; \ - fi - - @if [ "$(GTK_LIBS)" ]; then \ - for dir in $(GTK_DIRS); do \ - if [ -e $$dir/Makefile ]; then \ - $(MAKE) -C $$dir makelib; \ - fi; \ - done \ - fi - @echo "done" - dummy: $(DIRS): dummy @@ -115,9 +89,10 @@ distclean: clean include/config.h \ include/config.h.in \ packaging/RedHat/gnokii.spec \ - packaging/Slackware/SlackBuild \ po/Makefile.in \ debian + $(RM) `$(FIND) . -name "*~"` + @echo "done" dep: @for dir in $(DIRS); do \ @@ -135,7 +110,7 @@ dep: fi @echo "done" -install: +install: all @for dir in $(DIRS); do \ if [ -e $$dir/Makefile ]; then \ $(MAKE) -C $$dir install; \ diff --git a/Makefile.global.in b/Makefile.global.in index 23fa672..b06e08c 100644 --- a/Makefile.global.in +++ b/Makefile.global.in @@ -23,11 +23,11 @@ exec_prefix = @exec_prefix@ bindir = @bindir@ sbindir = @sbindir@ xbindir = ${prefix}/X11R6/bin/ -libdir = @libdir@ +libdir = @libdir@/${PACKAGE} xgnokii_libdir = @XGNOKIIDIR@/@XPACKAGE@ man1dir = @mandir@/man1/ man8dir = @mandir@/man8/ -xmandir = @mandir@/man1/ +xmandir = ${prefix}/X11R6/man/man1/ docdir = ${prefix}/doc/${PACKAGE} locdir = @datadir@/locale @@ -73,5 +73,5 @@ endif CFLAGS += -I$(GNOKII_INCLUDE) -LDFLAGS = $(LIBS) -Wl,--rpath -Wl,$(libdir) +LDFLAGS = $(LIBS) diff --git a/VERSION b/VERSION index 2a8e926..4a22caa 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.3_pre8-gold_2002_03_10 +0.4.0pre1_ats diff --git a/common/Makefile b/common/Makefile index 2dad729..c63a8a7 100644 --- a/common/Makefile +++ b/common/Makefile @@ -1,7 +1,12 @@ # +# $Id$ +# # Makefile for the GNOKII tool suite. # +# Copyright (C) 1999 Hugh Blemings & Pavel Janík ml. +# 2000 Karel Zak +# # # For this common directory is used "subsystem.o" .o files concept. @@ -12,75 +17,48 @@ TOPDIR=.. include $(TOPDIR)/Makefile.global -CFLAGS += $(PTHREAD_CFLAGS) - -DIRS = protocol \ - oldmodules \ - newmodules - -OBJS = devices/device.o \ - data/rlp-common.o \ - data/rlp-crc24.o \ - files/midifile.o \ +OBJS = cfgreader.o \ + device.o \ gsm-ringtones.o \ - gsm-coding.o \ - gsm-datetime.o \ - gsm-wap.o \ + at-hw.o \ + cimd.o \ gsm-api.o \ - gsm-phonebook.o \ - gsm-calendar.o \ gsm-networks.o \ - gsm-bitmaps.o \ - gsm-sms.o \ - files/cfgreader.o \ + vcal.o \ misc.o \ - protocol/fbus.o \ - protocol/fbus3110.o \ - protocol/fbusirda.o \ - protocol/mbus.o \ - protocol/at.o \ - newmodules/sniff/sniff.o \ - newmodules/newat.o \ - newmodules/n6110.o \ - newmodules/n3110.o \ - newmodules/n7110.o - -DATA_OBJS = data/virtmodem.o \ - data/at-emulator.o \ - data/datapump.o - -ifdef WIN32 - OBJS += $(TOPDIR)/win32/winserial.o -else - OBJS += devices/unixserial.o \ - devices/unixirda.o \ - devices/tekram.o -endif + gsm-bitmaps.o \ + gsm-common.o \ + gsm-encoding.o \ + gsm-statemachine.o +# gsm-sms.o \ -ifdef XPM_CFLAGS - CFLAGS += $(XPM_CFLAGS) -endif +all: libgnokii.a gsm-filetypes.o + +phones/PHONES.o: + $(MAKE) -C phones PHONES.o -all: COMMON.o DATA.o gsm-filetypes.o +links/LINKS.o: + $(MAKE) -C links LINKS.o -COMMON.o: $(OBJS) - $(LD) $(LDREL) $(LDOUT) COMMON.o $(OBJS) +devices/DEVICES.o: + $(MAKE) -C devices DEVICES.o -DATA.o: $(DATA_OBJS) - $(LD) $(LDREL) $(LDOUT) DATA.o $(DATA_OBJS) +libgnokii.a: $(OBJS) phones/PHONES.o links/LINKS.o devices/DEVICES.o + ar rcs $@ $^ +# $(CC) -shared -o libgnokii.so $(OBJS) phones/PHONES.o links/LINKS.o devices/DEVICES.o -gsm-filetypes.o: files/gsm-filetypes.c - $(CC) $(CFLAGS) -c files/gsm-filetypes.c +gsm-filetypes.o: gsm-filetypes.c + $(CC) $(CFLAGS) $(CPPFLAGS) $(XPM_CFLAGS) -c gsm-filetypes.c -makelib: $(OBJS) DATA.o gsm-filetypes.o - $(CC) -shared -o libmygnokii.so $(OBJS) DATA.o gsm-filetypes.o +vcal.c: vcal.lx + $(LEX) -ovcal.c vcal.lx clean: - $(RM) $(OBJS) $(DATA_OBJS) *~ depend libmygnokii.so COMMON.o gsm-filetypes.o DATA.o - + $(RM) $(OBJS) *~ depend COMMON.o gsm-filetypes.o vcal.c phones/PHONES.o links/LINKS.o devices/DEVICES.o *.a + install: $(INSTALL) -d $(libdir) - $(INSTALL) libmygnokii.so $(libdir) + $(INSTALL) libgnokii.so $(libdir) @echo depend dep: @@ -92,3 +70,4 @@ endif .PHONY: all install clean dep depend + diff --git a/common/at-hw.c b/common/at-hw.c new file mode 100644 index 0000000..74b9f91 --- /dev/null +++ b/common/at-hw.c @@ -0,0 +1,2659 @@ +/* + + $Id$ + + G N O K I I + + A Linux/Unix toolset and driver for Nokia mobile phones. + + Copyright (C) 2001 Jan Kratochvil, + based on code by Hugh Blemings & Pavel Janík ml. + + Released under the terms of the GNU GPL, see file COPYING for more details. + + This file provides an API for accessing functions on AT (Hayes) command + compatible hardware modems such as Siemens M20. + See README-AT for more details on supported mobile phones and GSM modems. + + The various routines are called ATHW (whatever) as a concatenation of AT + and HardWare communication type. + + $Log$ + Revision 1.1.1.1 2002/04/03 00:08:02 short + Found in "gnokii-working" directory, some November-patches version + + +*/ + +#define ATHW_DEBUG 1 +/* #define DISABLE_CMGF0 1 */ /* Force AT+CMGF=1 on phones capable +CMGF=0 */ + +/* System header files */ + +#include +#include +#include +#include +#include + + +#ifdef WIN32 + +#include +#include "win32/winserial.h" + +#undef IN +#undef OUT + +#define WRITEPHONE(a, b, c) WriteCommBlock(b, c) +#define sleep(x) Sleep((x) * 1000) +#define usleep(x) Sleep(((x) < 1000) ? 1 : ((x) / 1000)) +extern HANDLE hPhone; + +#else + +#define WRITEPHONE(a, b, c) device_write(b, c) +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "device.h" +#include "devices/unixserial.h" + +#endif + +/* Various header file */ + +#include "config.h" +#include "misc.h" +#include "gsm-common.h" + +/* Global variables used by code in gsm-api.c to expose the functions + supported by this model of phone. */ + + +#if __unices__ +/* fd opened in device.c */ +extern int device_portfd; +#endif + +/* Our private defines */ + +#define ATHW_CME_NOT_FOUND (22) /* +CME ERROR: 22 */ +#define ATHW_CMS_INVALID_MEMORY_INDEX (321) /* +CMS ERROR: 321 */ + +/* When now catchbuffer was provided and must have some space to decode + * OK/ERROR/... result codes. + */ +#define ATHW_CATCHBUFFER_LENGTH 0x400 + +/* Default message reference, filled-in by GSM modem + */ +#define ATHW_PDU_MR_DEFAULT (0x00) + +/* Maximum PDU size in bytes + */ +#define GNOKII_MAX_PDU_LENGTH (64+GSM_MAX_DESTINATION_LENGTH/2+(GSM_MAX_SMS_LENGTH*7)/8) + +/* Local variables */ + + +#ifndef WIN32 +static char PortDevice[GSM_MAX_DEVICE_NAME_LENGTH]; +#endif +static bool RequestTerminate; +static GSM_MemoryType ATHW_CurrentMemoryType=GMT_XX; +static int ATHW_CurrentCMGF=-1; +static bool ATHW_CMGS_CMGF1_8bit_HaveBinHex; /* AT+CMGS in +CMGF==1 and 8bit mode accepts hexstring */ +static bool ATHW_HaveCNMI=false; +static bool ATHW_HaveSiemensMGR=false; /* "AT^SMGR" supported? */ +static bool ATHW_HaveSiemensMGL=false; /* "AT^SMGL" supported? */ +static int ATHW_CNMI_count=-1; /* value (-1) means it is not yet known */ + +/* We don't know whether we should place SMSC in the front of +CMGS PDU + * so we will try both methods. + * When we will at least once successfuly send a message, we will *_force-it + * as the probability of wrong settings and successful message send is REALLY low. :-) + * (Maybe not so low when we will try to send prefix and no prefix is expected, + * this is also the reason why we will first try to NOT to send the prefix as we + * would have to successfuly hit some valid SMS center by the initial part of PDU.) + * Note: Applicable only if +CMGF==0 + */ +static bool ATHW_CurrentSMSCPrefix=false; +static bool ATHW_CurrentSMSCPrefix_force=false; +/* Always try 4 retries - w/o prefix, w/prefix, w/o prefix again, w/prefix again, fail + * This number should be probable even to give some 'stability' when all SMSes are failing + */ +#define ATHW_CURRENTSMSCPREFIX_RETRIES (4) + +/* Please see the comment above ATHW_SaveSMS_StatSupported_solve(). + * Number of retry sessions before giving up sending SMS during SaveSMS. + */ +#define ATHW_SAVESMS_STATSUPPORTED_RETRIES (2) + + +static char ATHW_CatchBuffer[ATHW_CATCHBUFFER_LENGTH]; +static char *ATHW_CatchBufferPtr=ATHW_CatchBuffer; /* current destination writing ptr */ +static char *ATHW_CatchBufferMarker; /* marks begin of currently catched stream */ +static GSM_Error *ATHW_CatchBufferErrorP; + +static long ATHW_RX_Patrol_CME_ERROR_code; +static long ATHW_RX_Patrol_CMS_ERROR_code; + +typedef char *(*ATHW_RX_PatrolFunc)(char *after); +typedef void (*ATHW_RX_PatrolReset)(void); + +struct ATHW_RX_Patrol { + const char *buoy; + ATHW_RX_PatrolFunc func; + ATHW_RX_PatrolReset reset; + }; + +static const struct ATHW_RX_Patrol *ATHW_RX_Patrol_Current; + +static void ATHW_CatchBufferReset(void); +static void ATHW_CatchBufferMarkStart(GSM_Error *errorcodep); + +#ifndef WIN32 + +static pthread_t Thread; +# if __unices__ +static pthread_t selThread; +# endif + +#endif + +/* Local variables used by get/set phonebook entry code. Buffer is used as a + source or destination for phonebook data and other functions... Error is + set to GE_NONE by calling function, set to GE_COMPLETE or an error code by + handler routines as appropriate. */ + +static GSM_MemoryStatus *CurrentMemoryStatus; +static GSM_Error CurrentMemoryStatusError; + +static GSM_PhonebookEntry *CurrentPhonebookEntry; +static GSM_Error CurrentPhonebookError; + +static GSM_SMSMessage *CurrentSMSMessage; +static char *CurrentSMSMessagePDU; /* hex string representation for +CMGF=0 patrol */ +static size_t CurrentSMSMessagePDU_size; /* used only if (+CMGF==0), size in bytes */ +static GSM_Error CurrentSMSMessageError; + +static GSM_SMSStatus *CurrentSMSStatus; +static GSM_Error CurrentSMSStatusError; + +static GSM_MessageCenter *CurrentMessageCenter; +static GSM_Error CurrentMessageCenterError; + +static float *CurrentRFLevel; /* AT+CSQ */ +static GSM_Error GetRFLevelError; + +static float *CurrentBatteryLevel; /* AT+CBC */ +static GSM_Error GetBatteryLevelError; + +static GSM_PowerSource *CurrentPowersource; /* AT+CBC */ +static GSM_Error GetPowersourceError; + +static GSM_Error DialVoiceError; + +static GSM_Error CancelCallError; + +static GSM_Error CurrentPhoneInfoError; + +static unsigned char Manufacturer[GSM_MAX_MANUFACTURER_LENGTH]; +static unsigned char Model[GSM_MAX_MODEL_LENGTH]; +static unsigned char Revision[GSM_MAX_REVISION_LENGTH]; +static unsigned char IMEI[GSM_MAX_IMEI_LENGTH]; + +static char CurrentIncomingCall[20] = " "; + +static GSM_NetworkInfo *CurrentNetworkInfo; +static GSM_Error CurrentNetworkInfoError; + + +/* Pointer to a callback function used to return changes to a calls status */ +/* This saves unreliable polling */ +static void (*CallPassup)(char c); + + +/* "catchbufer" can be provided as NULL: + * - sizeof() will be bogus but it will be ingored anyway + */ + +static void ATHW_TX_SendCommand(GSM_Error *errorcodep,const struct ATHW_RX_Patrol *patrol,const char *fmt,...) G_GNUC_PRINTF(3,4); +static void ATHW_TX_SendCommand(GSM_Error *errorcodep,const struct ATHW_RX_Patrol *patrol,const char *fmt,...) +{ +char *command; +size_t command_len; +va_list ap; +int writephone_got; + + if (errorcodep) + *errorcodep=GE_BUSY; + ATHW_RX_Patrol_Current=patrol; + + va_start(ap,fmt); + command_len=gvasprintf(&command,fmt,ap); + va_end(ap); + if (-1==command_len) { + if (errorcodep) + *errorcodep=GE_INTERNALERROR; + return; + } + + ATHW_CatchBufferMarkStart(errorcodep); + + writephone_got=WRITEPHONE(PortFD, command, command_len); + +#ifdef ATHW_DEBUG + write(1,"CMD:",4); + write(1,command,command_len); + write(1,"\n",1); +#endif + + free(command); + if (command_len!=writephone_got) { + if (errorcodep) + *errorcodep=GE_INTERNALERROR; + return; + } + + /* success but we don't wait for the result code */ +} + +/* This function is used to get storage status from the phone. It currently + supports two different memory areas - internal and SIM. */ + +static GSM_Error +wait_on(volatile GSM_Error *what, int timeout) +{ +GSM_Error r=GE_TIMEOUT; /* shut up GCC when (timeout==0) */ + + while (timeout && ((r=*what)==GE_BUSY)) { + if (!--timeout) { + r=GE_TIMEOUT; + break; + } + usleep(100000); + } + /* any specific patrollers are no longer valid */ + ATHW_RX_Patrol_Current=NULL; + +#ifdef ATHW_DEBUG + printf("wait_on finish, timeout=%d\n",(r==GE_TIMEOUT)); +#endif + + return(r); +} + +#define WAIT_ON(what, timeout) \ + do { \ + GSM_Error res = wait_on(what, timeout); \ + if (res != GE_NONE) \ + return res; \ + } while (0) + +/* I hope GCC gets this bunch optimized on the normal the normal errorcodep!=NULL case + */ +#define ATHW_TX_SENDCOMMAND_WAIT_ON(errorcodep,timeout,patrol,args...) \ + do { \ +GSM_Error _ATHW_TX_SENDCOMMAND_WAIT_ON_err,*_ATHW_TX_SENDCOMMAND_WAIT_ON_errp; \ + \ + if (!(_ATHW_TX_SENDCOMMAND_WAIT_ON_errp=(errorcodep))) \ + _ATHW_TX_SENDCOMMAND_WAIT_ON_errp=&_ATHW_TX_SENDCOMMAND_WAIT_ON_err; \ + ATHW_TX_SendCommand(_ATHW_TX_SENDCOMMAND_WAIT_ON_errp,(patrol),args); \ + WAIT_ON(_ATHW_TX_SENDCOMMAND_WAIT_ON_errp,(timeout)); \ + } while (0) + + +#define ATHW_ERR_WRAPPER(expr) \ + do { \ + GSM_Error err=(expr); \ + if (err!=GE_NONE) \ + return(err); \ + } while (0) + +/* Currently we use a heuristic for extraction as at least Nokia 9000i doesn't + * escape quote characters even if they are inside enquoted strings! + * When we find -- ", -- we assume it is the separator although it may be false! + * Hmm, Siemens M20 has the same broken behaviour. + */ +static void ATHW_ExtractString(char *dest,size_t destlen,char *src,int element_no) +{ +char *srcend,*start,*end; + + *dest='\0'; + if (!(srcend=strchr(src,'\n'))) + return; /* INTERNAL error! */ + do { + while (*src==' ') src++; + if (*src!='"') { + start=src; + while (srcd_buf && d[-1]==' ') + d--; + *d='\0'; +} + +#define ATHW_BUFFERTRIMCOPY_OFFSET(d,s,offset) (ATHW_BufferTrimCopy((d)+(offset),sizeof((d))-(offset),(s))) +#define ATHW_BUFFERTRIMCOPY(d,s) (ATHW_BUFFERTRIMCOPY_OFFSET((d),(s),0)) + +static GSM_Error ATHW_GetPhoneInfo(void) +{ +/* +CGMI=Request Manufacturer Identification + * +CGMM=Request Model Identification + * +CGMR=Request Revision Identification + * +CGSN=Request Product Serial Number Identification (IMEI) + */ + + ATHW_TX_SENDCOMMAND_WAIT_ON(&CurrentPhoneInfoError/*errorcodep*/,20/*timeout*/,NULL/*patrol*/,"/AT+CGMI\r"); + ATHW_BUFFERTRIMCOPY(Manufacturer,ATHW_CatchBufferMarker); + + ATHW_TX_SENDCOMMAND_WAIT_ON(&CurrentPhoneInfoError/*errorcodep*/,20/*timeout*/,NULL/*patrol*/,"/AT+CGMM\r"); + ATHW_BUFFERTRIMCOPY_OFFSET(Model,ATHW_CatchBufferMarker,3); + memcpy(Model,"AT-",3); + + ATHW_TX_SENDCOMMAND_WAIT_ON(&CurrentPhoneInfoError/*errorcodep*/,20/*timeout*/,NULL/*patrol*/,"/AT+CGMR\r"); + ATHW_BUFFERTRIMCOPY(Revision,ATHW_CatchBufferMarker); + + ATHW_TX_SENDCOMMAND_WAIT_ON(&CurrentPhoneInfoError/*errorcodep*/,20/*timeout*/,NULL/*patrol*/,"/AT+CGSN\r"); + ATHW_BUFFERTRIMCOPY(IMEI,ATHW_CatchBufferMarker); + + return(GE_NONE); +} + +static unsigned char ATHW_SMStoFO(GSM_SMSMessage *SMS) +{ + return(0 + |((SMS->Type==GST_MO)<<0) + |(2<<3) /*=integer*/ + |0 /* bit 5 is Status Report Request, not supported */ + |((!!SMS->UDHPresent)<<6) /*UDH set*/ + |((!!SMS->ReplyViaSameSMSC)<<7) /*ReplyPath*/ + ); +} + +static unsigned char ATHW_SMStoDCS(GSM_SMSMessage *SMS) +{ +int class=(SMS->Class==-1 ? 1 : SMS->Class); /* we default to class 1 (Mobile Equipment target) */ + + if (!SMS->EightBit && class==1) + return(0x00); + return(0xF0 | ((!!SMS->EightBit)<<2) | ((class&0x03)<<0)); +} + +/* Nokia 9000i: We need to temporarily turn on ECHO otherwise we wouldn't got the "\n> " prompt + * (At least Siemens M20 doesn't have this broken behaviour.) + */ +static GSM_Error ATHW_SMS_CMGF01_pre(void) +{ + if (ATHW_CurrentCMGF==1) { + /* We just cannot send UDH header in pure CMGF 1 mode */ + if (CurrentSMSMessage->UDHPresent && (!CurrentSMSMessage->EightBit || !ATHW_CMGS_CMGF1_8bit_HaveBinHex)) + return(GE_INTERNALERROR); + + /* AT+CSMP=,,, */ + ATHW_TX_SENDCOMMAND_WAIT_ON(&CurrentSMSMessageError/*errorcodep*/,10/*timeout*/,NULL/*patrol*/, + "AT+CSMP=%d,%d,%d,%d\r", + /* : */ ATHW_SMStoFO(CurrentSMSMessage), + /* : */ SMS_Validity_to_VP(CurrentSMSMessage->Validity), + + /* FIXME: Should we query current "MessageCenter.No" to get "Format" field? */ + /* : */ (unsigned char)CurrentSMSMessage->MessageCenter.Format, + + /* : */ ATHW_SMStoDCS(CurrentSMSMessage) + ); + } + + ATHW_TX_SENDCOMMAND_WAIT_ON(&CurrentSMSMessageError/*errorcodep*/,10/*timeout*/,NULL/*patrol*/, + "ATE1\r"); + + return(GE_NONE); +} + +static GSM_Error ATHW_SMS_CMGF01_post(void) +{ + ATHW_TX_SENDCOMMAND_WAIT_ON(&CurrentSMSMessageError/*errorcodep*/,10/*timeout*/,NULL/*patrol*/, + "ATE0\r"); + + return(GE_NONE); +} + +/* For now we just kick out all quotes in the source "string" as no escaping + * method was found on Nokia 9000i - what the other ones? + */ +static const char *ATHW_Enquote(const char *string) +{ + +#define ATHW_ENQUOTE_SLOTS (4) + +struct ATHW_Enquote_slot { + char *buf; + size_t len; + }; + +static struct ATHW_Enquote_slot slots[ATHW_ENQUOTE_SLOTS]; +static struct ATHW_Enquote_slot *slot=slots; +size_t stringl=strlen(string); +char *d; +const char *r,*s; + + if (slot->len<1+stringl+1+1) { /* "string"\0 */ +char *newbuf; +size_t newlen=(!slot->len ? 0x100 : slot->len*2); + + if (!(newbuf=realloc(slot->buf,newlen))) + return(NULL); + slot->buf=newbuf; + slot->len=newlen; + } + + d=slot->buf; + *d++='"'; + for (s=string;*s;s++) { + if (*s=='"') + continue; + *d++=*s; + } + *d++='"'; + *d++='\0'; + + r=slot->buf; + if (++slot>=slots+ARRAY_LEN(slots)) + slot=slots; + return(r); +} + +static char *ATHW_PhoneSetup_CMGF1_Detect_Patrol_9(char *after) +{ + /* We got at least echo of the initial "9" digit. + * Nokia 9000i/9110i/CardPhone will echo even "Q" followed by ERROR, + * but Nokia 9210 will give ERROR immediately (w/o echo of "Q"). + * When the feature is not supported we will get GE_TIMEOUT and + * ATHW_CMGS_CMGF1_8bit_HaveBinHex will be reset to "false" by the error check + * in ATHW_PhoneSetup_CMGF1_Detect_core(). + */ + ATHW_CMGS_CMGF1_8bit_HaveBinHex=true; + + WRITEPHONE(PortFD,"Q",1); + + /* We don't need to patrol for "Q", its detection would be cross-phone + * incompatible. + */ + + return(after); /* eat line - it will be just one character... */ +} + +static const struct ATHW_RX_Patrol ATHW_PhoneSetup_CMGF1_Detect_Patrol_9_struct= + { "9",ATHW_PhoneSetup_CMGF1_Detect_Patrol_9 }; + +static char *ATHW_PhoneSetup_CMGF1_Detect_Patrol_GT_SPACE(char *after) +{ + WRITEPHONE(PortFD,"9",1); + ATHW_RX_Patrol_Current=&ATHW_PhoneSetup_CMGF1_Detect_Patrol_9_struct; + return(after); /* eat line - it will be just one character... */ +} + +static const struct ATHW_RX_Patrol ATHW_PhoneSetup_CMGF1_Detect_Patrol_GT_SPACE_struct= + { "\n> ",ATHW_PhoneSetup_CMGF1_Detect_Patrol_GT_SPACE }; + +/* ATHW_CMGS_CMGF1_8bit_HaveBinHex feature is AFAIK present on Nokia 9000i/9110 + * and also on Nokia CardPhone (but CardPhone supports +CMGF==0 so it is useless there). + * On Nokia 9000i we will detect the feature as present although it cannot be used + * for logo/ring sending as it will later fail to set UDH bit in FO by AT+CSMP. + */ +static GSM_Error ATHW_PhoneSetup_CMGF1_Detect_core(void) +{ +GSM_SMSMessage sms; + + ATHW_CMGS_CMGF1_8bit_HaveBinHex=false; /* default */ + + /* We need to reset the catchbuffer as we would otherwise + * catch some completely bogus previous output. + * We are called only during phone setup so here is no risk in loosing + * some unsolicited result codes. + */ + ATHW_CatchBufferReset(); + + CurrentSMSMessage=&sms; + /* for ATHW_SMStoFO(): */ + CurrentSMSMessage->UDHPresent=false; + CurrentSMSMessage->Type=GST_MO; + CurrentSMSMessage->UDHPresent=false; /* warning: it would fail on Nokia 9000i or Siemens M20! */ + CurrentSMSMessage->ReplyViaSameSMSC=false; + /* for SMS_Validity_to_VP(): */ + CurrentSMSMessage->Validity=GSMV_72_Hours; /* default */ + /* for ATHW_SMS_CMGF01_pre(): */ + CurrentSMSMessage->MessageCenter.Format=GSMF_Text; + /* for ATHW_SMStoDCS(): */ + CurrentSMSMessage->EightBit=true; /* IMPORTANT!: The ONLY meaning of the whole procedure! */ + CurrentSMSMessage->Class=1; + /* Do proper AT+CSMP= and also ATE1 */ + ATHW_SMS_CMGF01_pre(); + + ATHW_TX_SendCommand(&CurrentSMSMessageError/*errorcodep*/,&ATHW_PhoneSetup_CMGF1_Detect_Patrol_GT_SPACE_struct/*patrol*/, + "AT+CMGS=%s\r",ATHW_Enquote("123456"/*just some test number*/)); + + /* Timeout 5 is too small for Nokia 9000i, give it a rest... + */ + if (GE_TIMEOUT==wait_on(&CurrentSMSMessageError,20/*timeout*/)) + ATHW_CMGS_CMGF1_8bit_HaveBinHex=false; + + return(GE_NONE); +} + +static GSM_Error ATHW_PhoneSetup_CMGS_Reset(void) +{ +GSM_Error err; +int retry; + + /* We try to escape AT+CMGS mode, at least Siemens M20 then needs to get some rest + */ + WRITEPHONE(PortFD,"\x1B\r",2); + usleep(500000); + + ATHW_CatchBufferReset(); /* output can be very bogus due to escaping */ + + for (retry=0;retry<3;retry++) { + ATHW_TX_SendCommand(&err/*errorcodep*/,NULL/*patrol*/, + "AT\r"); + if (wait_on(&err,10/*timeout*/)==GE_NONE) + return(err); /* success */ + } + /* Hmm, we've probably stucked the phone :-( + */ + return(err); /* failure */ +} + +static void ATHW_PhoneSetup_CMGF1_Detect(void) +{ + ATHW_PhoneSetup_CMGF1_Detect_core(); /* errors of the detection are ignored */ + ATHW_PhoneSetup_CMGS_Reset(); + ATHW_SMS_CMGF01_post(); /* turn off echo */ +#ifdef ATHW_DEBUG + printf("ATHW_PhoneSetup_CMGF1_Detect: ATHW_CMGS_CMGF1_8bit_HaveBinHex=%d\n",(int)ATHW_CMGS_CMGF1_8bit_HaveBinHex); +#endif +} + +static GSM_Error ATHW_PhoneSetup_CMGFSet(int CMGF) +{ + ATHW_CurrentCMGF=-1; + ATHW_TX_SENDCOMMAND_WAIT_ON(NULL/*errorcodep*/,10/*timeout*/,NULL/*patrol*/, + "AT+CMGF=%d\r",CMGF); + ATHW_CurrentCMGF=CMGF; + + if (CMGF==1) + ATHW_PhoneSetup_CMGF1_Detect(); + + return(GE_NONE); +} + +static GSM_Error ATHW_PhoneSetup(void) +{ +GSM_Error err; + + ATHW_CurrentMemoryType=GMT_XX; /* invalidate */ + + ATHW_PhoneSetup_CMGS_Reset(); + + ATHW_TX_SENDCOMMAND_WAIT_ON(NULL/*errorcodep*/,60/*timeout*/,NULL/*patrol*/, + "AT&F\r"); + + ATHW_TX_SENDCOMMAND_WAIT_ON(NULL/*errorcodep*/,10/*timeout*/,NULL/*patrol*/, + "ATE0\r"); + ATHW_TX_SENDCOMMAND_WAIT_ON(NULL/*errorcodep*/,10/*timeout*/,NULL/*patrol*/, + "AT+CSDH=1\r"); + ATHW_TX_SENDCOMMAND_WAIT_ON(NULL/*errorcodep*/,10/*timeout*/,NULL/*patrol*/, + "AT+CMEE=1\r"); + ATHW_TX_SENDCOMMAND_WAIT_ON(NULL/*errorcodep*/,10/*timeout*/,NULL/*patrol*/, + "AT+CRC=1\r"); /* request "+CRING: VOICE" reporting */ + + /* Try to detect Siemens M20 with M1 backward compatibility mode */ + ATHW_TX_SendCommand(&err/*errorcodep*/,NULL/*patrol*/, + "AT+CSMS=128\r"); + if (GE_NONE==wait_on(&err,10/*timeout*/)) { + ATHW_CurrentSMSCPrefix=true; /* it will be true ASAP +CMGS=0 is done */ + ATHW_CurrentSMSCPrefix_force=true; + } + ATHW_TX_SENDCOMMAND_WAIT_ON(NULL/*errorcodep*/,10/*timeout*/,NULL/*patrol*/, + "AT+CSMS=0\r"); /* turn on ATHW_CurrentSMSCPrefix, if possible */ + +#ifndef DISABLE_CMGF0 + if (GE_NONE!=ATHW_PhoneSetup_CMGFSet(0)) +#endif + ATHW_PhoneSetup_CMGFSet(1); + + ATHW_TX_SendCommand(&err/*errorcodep*/,NULL/*patrol*/, + "AT^SMGR=?\r"); /* it should just return "\nOK\n" */ + ATHW_HaveSiemensMGR=(GE_NONE==wait_on(&err,10/*timeout*/)); + ATHW_TX_SendCommand(&err/*errorcodep*/,NULL/*patrol*/, + "AT^SMGL=?\r"); /* it should just return "\nOK\n" */ + ATHW_HaveSiemensMGL=(GE_NONE==wait_on(&err,10/*timeout*/)); + + ATHW_HaveCNMI=true; + ATHW_TX_SendCommand(&err/*errorcodep*/,NULL/*patrol*/, + "AT+CNMI=2,1\r"); /* =2 (buffer when data active), =1 (+CMTI codes) */ + if (GE_NONE!=wait_on(&err,10/*timeout*/)) { + ATHW_TX_SendCommand(&err/*errorcodep*/,NULL/*patrol*/, + "AT+CNMI=1,1\r"); /* =1 (discard when data active), =1 (+CMTI codes) */ + if (GE_NONE!=wait_on(&err,10/*timeout*/)) + ATHW_HaveCNMI=false; + } + ATHW_CNMI_count=-1; /* unknown yet */ + + ATHW_TX_SendCommand(&err/*errorcodep*/,NULL/*patrol*/, + "AT+COPS=3,2\r"); /* =3 (just set ), =2 (numeric) */ + wait_on(&err,10/*timeout*/); /* error ignored, GetNetworkInfo will find the failure itself */ + + /* Enable LAC+CellID returns, it will also disable unsolicited changes reporting + * but we ignore it successfuly. + */ + ATHW_TX_SendCommand(&err/*errorcodep*/,NULL/*patrol*/, + "AT+CREG=2\r"); + wait_on(&err,10/*timeout*/); /* error ignored, GetNetworkInfo will find the failure itself */ + + ATHW_GetPhoneInfo(); + + return(GE_NONE); +} + + +static void ATHW_RX_Char(char rx_byte); +static void ATHW_SigHandler(int status); +static bool ATHW_OpenSerial(void); + +GSM_Phone phone_at_hw; /* forward declaration */ + +/* Initialise variables and state machine. */ + +static GSM_Error ATHW_Init(GSM_Data *data, GSM_Statemachine *state) +{ + RequestTerminate = false; + CallPassup = NULL; + + /* Create and start main thread. */ + +#ifdef WIN32 +{ +int rtn; + rtn = ! OpenConnection(State->Link.PortDevice,ATHW_RX_Char,ATHW_KeepAliveProc); + if (rtn != 0) { + return(GE_INTERNALERROR); +} +#else + SAFE_STRNCPY_SIZEOF(PortDevice,state->Link.PortDevice); + if (!ATHW_OpenSerial()) + return(GE_INTERNALERROR); +#endif + + ATHW_ERR_WRAPPER(ATHW_PhoneSetup()); + + return (GE_NONE); +} + +#if __unices__ +/* thread for handling incoming data */ +void ATHW_SelectLoop() +{ + int err; + fd_set readfds; + struct timeval timeout; + + FD_ZERO(&readfds); + FD_SET(device_portfd, &readfds); + /* set timeout to 15 seconds */ + timeout.tv_sec=15; + timeout.tv_usec=0; + while (!RequestTerminate) { + err = select(device_portfd + 1, &readfds, NULL, NULL, &timeout); + /* call singal handler to process incoming data */ + if ( err > 0 ) ATHW_SigHandler(0); + else if (err == -1) perror("Error in SelectLoop"); + } +} +#endif + +static GSM_Error ATHW_AnswerCall(GSM_Data *data, GSM_Statemachine *state) +{ + /* data->CallNo not present up to Nokia 9110i */ + ATHW_TX_SENDCOMMAND_WAIT_ON(&CurrentPhoneInfoError/*errorcodep*/,20/*timeout*/,NULL/*patrol*/,"ATA\r"); + return(GE_NONE); +} + +/* Applications should call ATHW_Terminate to shut down the ATHW thread and + close the serial port. */ + +static GSM_Error ATHW_Terminate(GSM_Data *data, GSM_Statemachine *state) +{ + /* Request termination of thread */ + RequestTerminate = true; + +#ifndef WIN32 + /* Now wait for thread to terminate. */ + pthread_join(Thread, NULL); + + /* Close serial port. */ + device_close(); + +#else + CloseConnection(); +#endif + + return(GE_NONE); +} + +/* +CSQ: Signal Quality + * CurrentRFLevel = 1st arg + */ +static char *ATHW_RX_Patrol_CSQ(char *after) +{ +long l; + + l=ATHW_ExtractNumber(after/*src*/,0/*element_no*/); + if (l>=0 && l<=31) + *CurrentRFLevel=l; + + return(after); /* eat line */ +} + +static const struct ATHW_RX_Patrol ATHW_RX_Patrol_CSQ_struct= + { "\n+CSQ:", ATHW_RX_Patrol_CSQ }; + +static GSM_Error ATHW_GetRFLevel(GSM_Data *data, GSM_Statemachine *state) +{ + CurrentRFLevel=data->RFLevel; + + ATHW_TX_SENDCOMMAND_WAIT_ON(&GetRFLevelError/*errorcodep*/,30/*timeout*/,&ATHW_RX_Patrol_CSQ_struct,"AT+CSQ\r"); + + if (*data->RFUnits!=GRF_CSQ) { + *data->RFUnits = GRF_Percentage; /* required by xgnokii_lowlevel.c */ + *data->RFLevel = (*data->RFLevel)*100/31; /* +CSQ */ + } + + return (GE_NONE); +} + +/* +CBC: Battery Charge + * CurrentPowersource = 1st arg + * CurrentBatteryLevel = 2nd arg + */ +static char *ATHW_RX_Patrol_CBC(char *after) +{ +long l; + + if (CurrentPowersource) { + l=ATHW_ExtractNumber(after/*src*/,0/*element_no*/); + if (l==0 || l==1) + *CurrentPowersource=(l==1 ? GPS_ACDC : GPS_BATTERY); + } + + if (CurrentBatteryLevel) { + l=ATHW_ExtractNumber(after/*src*/,1/*element_no*/); + if (l>=0 && l<=100) + *CurrentBatteryLevel=l; + } + + return(after); /* eat line */ +} + +static const struct ATHW_RX_Patrol ATHW_RX_Patrol_CBC_struct= + { "\n+CBC:", ATHW_RX_Patrol_CBC }; + +static GSM_Error ATHW_GetBatteryLevel(GSM_Data *data, GSM_Statemachine *state) +{ + CurrentBatteryLevel=data->BatteryLevel; + *data->BatteryUnits = GBU_Percentage; + + ATHW_TX_SendCommand(&GetBatteryLevelError/*errorcodep*/,&ATHW_RX_Patrol_CBC_struct,"AT+CBC\r"); + if (GE_NONE!=wait_on(&GetBatteryLevelError,30/*timeout*/)) { + /* We are probably on AC powered device such as Nokia CardPhone + */ + *CurrentBatteryLevel=100; + } + + + return (GE_NONE); +} + +static GSM_Error ATHW_GetPowersource(GSM_Data *data, GSM_Statemachine *state) +{ + CurrentPowersource=data->PowerSource; + + ATHW_TX_SendCommand(&GetPowersourceError/*errorcodep*/,&ATHW_RX_Patrol_CBC_struct,"AT+CBC\r"); + if (GE_NONE!=wait_on(&GetPowersourceError,30/*timeout*/)) { + /* We are probably on AC powered device such as Nokia CardPhone + */ + *CurrentPowersource=GPS_ACDC; + } + + return (GE_NONE); +} + +static GSM_Error ATHW_DialVoice(GSM_Data *data, GSM_Statemachine *state) +{ + /* "ATDnumber;" is notation supported at least on Nokia up to 9110i + * We need to wait for establishing a connection as other commands would otherwise break it! + */ + ATHW_TX_SENDCOMMAND_WAIT_ON(&DialVoiceError/*errorcodep*/,600/*timeout*/,NULL/*patrol*/,"ATD%s;\r",data->VoiceNumber); + + return(GE_NONE); +} + +/* Dial a data call - type specifies request to use: + type 0 should normally be used + type 1 should be used when calling a digital line - corresponds to ats35=0 + Maybe one day we'll know what they mean! + FIXME: ATHW currently ignores it - what value should be used for S35? +*/ + +static GSM_Error ATHW_DialData(GSM_Data *data, GSM_Statemachine *state) +{ + CallPassup=data->DataCallPassUp; + + switch (*data->DataType) { + case 0: /* FALLTHRU */ + case 1: /* FALLTHRU */ + default: + break; + break; + case -1: /* Just used to set the call passup */ + return GE_NONE; + break; + } + + ATHW_TX_SendCommand(NULL/*errorcodep*/,NULL/*patrol*/,"ATD%s\r",data->DataNumber); + return(GE_NONE); +} + +static GSM_Error ATHW_GetIncomingCallNr(GSM_Data *data, GSM_Statemachine *state) +{ + if (*CurrentIncomingCall != ' ') { + strcpy(data->IncomingCallNr, CurrentIncomingCall); + return GE_NONE; + } else return GE_BUSY; +} + +static GSM_Error ATHW_CancelCall(GSM_Data *data, GSM_Statemachine *state) +{ + ATHW_TX_SENDCOMMAND_WAIT_ON(&CancelCallError/*errorcodep*/,60/*timeout*/,NULL/*patrol*/,"ATH\r"); + + return(GE_NONE); +} + +/* messagecenter->No" is NOT set as it is input argument */ +static void ATHW_MessageCenterClear(GSM_MessageCenter *messagecenter) +{ + messagecenter->Name[0]='\0'; /* not present up to Nokia 9110i */ + messagecenter->Recipient[0]='\0'; /* not present up to Nokia 9110i */ + messagecenter->Number[0]='\0'; /* default */ + messagecenter->Format=GSMF_Text; /* default */ + messagecenter->Validity=GSMV_72_Hours; /* default */ +} + +/* +CSCA: + * MessageCenter->Number = 1st arg + */ +static char *ATHW_RX_Patrol_CSCA(char *after) +{ + ATHW_EXTRACTSTRING(CurrentMessageCenter->Number,after/*src*/,0/*element_no*/); + + return(after); /* eat line */ +} + +static const struct ATHW_RX_Patrol ATHW_RX_Patrol_CSCA_struct= + { "\n+CSCA:", ATHW_RX_Patrol_CSCA }; + +/* +CSMP: + * CurrentMessageCenter->Format = 3rd arg + * CurrentMessageCenter->Validity = 2nd arg + */ +static char *ATHW_RX_Patrol_CSMP(char *after) +{ +long l; + + l=ATHW_ExtractNumber(after/*src*/,2/*element_no*/); + if (l>=0 && l<0x100) + CurrentMessageCenter->Format=(GSM_SMSMessageFormat)l; + + l=ATHW_ExtractNumber(after/*src*/,1/*element_no*/); + if (l>=0 && l<0x100) + CurrentMessageCenter->Validity=(GSM_SMSMessageValidity)l; + + return(after); /* eat line */ +} + +static const struct ATHW_RX_Patrol ATHW_RX_Patrol_CSMP_struct= + { "\n+CSMP:", ATHW_RX_Patrol_CSMP }; + +/* This function sends to the mobile phone a request for the SMS Center */ + +static GSM_Error ATHW_GetSMSCenter(GSM_Data *data, GSM_Statemachine *state) +{ + CurrentMessageCenter = data->MessageCenter; + + if (CurrentMessageCenter->No!=1) /* "CurrentMessageCenter->No" not present up to Nokia 9110i */ + return(GE_INTERNALERROR); /* FIXME: some better code? */ + ATHW_MessageCenterClear(CurrentMessageCenter); + + ATHW_TX_SENDCOMMAND_WAIT_ON(&CurrentMessageCenterError/*errorcodep*/,10/*timeout*/,&ATHW_RX_Patrol_CSCA_struct,"AT+CSCA?\r"); + ATHW_TX_SENDCOMMAND_WAIT_ON(&CurrentMessageCenterError/*errorcodep*/,10/*timeout*/,&ATHW_RX_Patrol_CSMP_struct,"AT+CSMP?\r"); + + printf("message center OK: %s\n",CurrentMessageCenter->Number); + return(GE_NONE); +} + +/* This function set the SMS Center profile on the phone. */ + +static GSM_Error ATHW_SetSMSCenter(GSM_Data *data, GSM_Statemachine *state) +{ + CurrentMessageCenter = data->MessageCenter; + ATHW_TX_SENDCOMMAND_WAIT_ON(&CurrentMessageCenterError/*errorcodep*/,10/*timeout*/,NULL/*patrol*/, + "AT+CSCA=%s\r",ATHW_Enquote(CurrentMessageCenter->Number)); + return(GE_NONE); +} + +static int ATHW_RX_Patrol_SiemensMGL_count; + +static char *ATHW_RX_Patrol_SiemensMGL(char *after) +{ +char *s; + + /* There may be left string from AT+CMGL=? which would confuse us! + */ + for (s=after;isspace(*s);s++); + if (*s=='(') + return(after); /* eat line */ + + /* Lines with our wanted "REC UNREAD" should be already filtered by the request + */ + ATHW_RX_Patrol_SiemensMGL_count++; + + return(after); /* eat line */ +} + +static const struct ATHW_RX_Patrol ATHW_RX_Patrol_SiemensMGL_struct= + { "\n^SMGL:", ATHW_RX_Patrol_SiemensMGL }; + +static void ATHW_Update_CNMI_count(void) +{ +const char *state; + + if (!ATHW_HaveSiemensMGL) + return; + + switch (ATHW_CurrentCMGF) { + case 0: state="0"; break; + case 1: state=ATHW_Enquote("REC UNREAD"); break; + default: + return; /* not supported */ + } + + ATHW_RX_Patrol_SiemensMGL_count=0; + ATHW_TX_SendCommand(&CurrentSMSStatusError/*errorcodep*/,&ATHW_RX_Patrol_SiemensMGL_struct/*patrol*/, + "AT^SMGL=%s\r",state); + if (GE_NONE==wait_on(&CurrentSMSStatusError,600/*timeout*/)) + ATHW_CNMI_count=ATHW_RX_Patrol_SiemensMGL_count; /* otherwise not updated */ +} + +/* +CPMS: + * CurrentSMSStatus->Used = 2nd arg + * CurrentSMSStatus->Slots = 3nd arg + */ +static char *ATHW_RX_Patrol_CPMS(char *after) +{ +long l; + + l=ATHW_ExtractNumber(after/*src*/,1/*element_no*/); + if (l>=0 && lUsed=l; + + l=ATHW_ExtractNumber(after/*src*/,2/*element_no*/); + if (l>=0 && lSlots=l; + + return(after); /* eat line */ +} + +static const struct ATHW_RX_Patrol ATHW_RX_Patrol_CPMS_struct= + { "\n+CPMS:", ATHW_RX_Patrol_CPMS }; + +/* Note: "Status->UnRead" cannot be detected at all up to Nokia 9110i + * as its GEOS always reads the incoming message immediately. + * On some other devices it could be probably solved by: AT+CMGL="REC UNREAD" + */ +static GSM_Error ATHW_GetSMSStatus(GSM_Data *data, GSM_Statemachine *state) +{ + CurrentSMSStatus = data->SMSStatus; + if (ATHW_CNMI_count<0) + ATHW_Update_CNMI_count(); + CurrentSMSStatus->UnRead=(ATHW_CNMI_count<0 ? 0 : ATHW_CNMI_count); /* not present up to Nokia 9110i */ + CurrentSMSStatus->Used =10; /* default */ + CurrentSMSStatus->Slots=10; /* default */ + ATHW_TX_SENDCOMMAND_WAIT_ON(&CurrentSMSStatusError/*errorcodep*/,10/*timeout*/,&ATHW_RX_Patrol_CPMS_struct, + "AT+CPMS?\r"); + return(GE_NONE); +} + +static GSM_Error ATHW_GetImei(GSM_Data *data, GSM_Statemachine *state) +{ + if (*IMEI) { + strcpy(data->Imei,IMEI); + return (GE_NONE); + } else return (GE_TRYAGAIN); +} + +static GSM_Error ATHW_GetRevision(GSM_Data *data, GSM_Statemachine *state) +{ + if (*Revision) { + strcpy(data->Revision,Revision); + return (GE_NONE); + } else return (GE_TRYAGAIN); +} + +static GSM_Error ATHW_GetModel(GSM_Data *data, GSM_Statemachine *state) +{ + if (*Model) { + strcpy(data->Model,Model); + return (GE_NONE); + } else return (GE_TRYAGAIN); +} + +static GSM_Error ATHW_GetManufacturer(GSM_Data *data, GSM_Statemachine *state) +{ + if (*Model) { + strcpy(data->Manufacturer,Manufacturer); + return (GE_NONE); + } else return (GE_TRYAGAIN); +} + +/* This function translates GMT_MemoryType to the string for AT+CPBS + * Nokia 9000i: ("SM") + * Siemens M20: ("SM","FD","LD","RC","ON","ME","MC","MT") + */ + +#define GETMEMORYTYPE_ENTRY(code) \ + case GMT_##code: return( #code ); + +static const char *ATHW_GetMemoryType(GSM_MemoryType memory_type) +{ + switch (memory_type) { + GETMEMORYTYPE_ENTRY(ME) + GETMEMORYTYPE_ENTRY(SM) + GETMEMORYTYPE_ENTRY(FD) + GETMEMORYTYPE_ENTRY(ON) + GETMEMORYTYPE_ENTRY(EN) + GETMEMORYTYPE_ENTRY(DC) + GETMEMORYTYPE_ENTRY(RC) + GETMEMORYTYPE_ENTRY(MC) + GETMEMORYTYPE_ENTRY(LD) + GETMEMORYTYPE_ENTRY(MT) + GETMEMORYTYPE_ENTRY(TA) + GETMEMORYTYPE_ENTRY(CB) + default: return(NULL); + } +} + +#define ATHW_GETMEMORYTYPE(dst,memory_type) \ + do { \ + (dst)=ATHW_GetMemoryType((memory_type)); \ + if (!(dst)) \ + return(GE_INVALIDMEMORYTYPE); \ + } while (0) + +static GSM_Error ATHW_SelectPhonebookMemory(GSM_MemoryType memory_type) +{ +const char *atmemtype; + + if (memory_type==ATHW_CurrentMemoryType) + return(GE_NONE); + ATHW_CurrentMemoryType=GMT_XX; + + ATHW_GETMEMORYTYPE(atmemtype,memory_type); + ATHW_TX_SENDCOMMAND_WAIT_ON(&CurrentPhonebookError/*errorcodep*/,10/*timeout*/,NULL/*patrol*/, + "AT+CPBS=%s\r",ATHW_Enquote(atmemtype)); + + ATHW_CurrentMemoryType=memory_type; + + return(GE_NONE); +} + +/* +CPBR: (GetMemoryStatus) + * CurrentMemoryStatus->Free=1st arg (1-) + */ +static char *ATHW_RX_Patrol_CPBR_GetMemoryStatus(char *after) +{ +char buf[32]; +int num_1,num_2; + + ATHW_EXTRACTSTRING(buf,after/*src*/,0/*element_no*/); + if (2==sscanf(buf,"(%d-%d)",&num_1,&num_2)) { + CurrentMemoryStatus->Used=0; /* not present up to Nokia 9110i, we ignore it now */ + CurrentMemoryStatus->Free=num_2; + } + + return(after); /* eat line */ +} + +static const struct ATHW_RX_Patrol ATHW_RX_Patrol_CPBR_GetMemoryStatus_struct= + { "\n+CPBR:", ATHW_RX_Patrol_CPBR_GetMemoryStatus }; + +static GSM_Error ATHW_GetMemoryStatus(GSM_Data *data, GSM_Statemachine *state) +{ + CurrentMemoryStatus=data->MemoryStatus; + + ATHW_ERR_WRAPPER(ATHW_SelectPhonebookMemory(CurrentMemoryStatus->MemoryType)); + + CurrentMemoryStatus->Used=0; /* default */ + CurrentMemoryStatus->Free=0; /* default */ + + ATHW_TX_SENDCOMMAND_WAIT_ON(&CurrentMemoryStatusError/*errorcodep*/,10/*timeout*/,&ATHW_RX_Patrol_CPBR_GetMemoryStatus_struct, + "AT+CPBR=?\r"); + + return(GE_NONE); +} + +static void ATHW_DateTimeSetCurrent(GSM_DateTime *datetime) +{ +time_t current=time(NULL); +struct tm *tm=localtime(¤t); + + datetime->AlarmEnabled=false; + + datetime->Year =tm->tm_year+1900; + datetime->Month =tm->tm_mon+1; + datetime->Day =tm->tm_mday; + datetime->Hour =tm->tm_hour; + datetime->Minute=tm->tm_min; + datetime->Second=tm->tm_sec; + + datetime->Timezone=timezone; +} + +/* +CPBR: (ReadPhonebook) + * CurrentPhonebookEntry->Name =4th arg + * CurrentPhonebookEntry->Number=2nd arg + */ +static char *ATHW_RX_Patrol_CPBR_ReadPhonebook(char *after) +{ + CurrentPhonebookEntry->Empty=false; + ATHW_EXTRACTSTRING(CurrentPhonebookEntry->Name ,after/*src*/,3/*element_no*/); + ATHW_EXTRACTSTRING(CurrentPhonebookEntry->Number,after/*src*/,1/*element_no*/); + + return(after); /* eat line */ +} + +static const struct ATHW_RX_Patrol ATHW_RX_Patrol_CPBR_ReadPhonebook_struct= + { "\n+CPBR:", ATHW_RX_Patrol_CPBR_ReadPhonebook }; + +/* Routine to get specifed phone book location. Designed to be called by + * application. Will block until location is retrieved or a timeout/error + * occurs. + */ +static GSM_Error ATHW_ReadPhonebook(GSM_Data *data, GSM_Statemachine *state) +{ + CurrentPhonebookEntry=data->PhonebookEntry; + + ATHW_ERR_WRAPPER(ATHW_SelectPhonebookMemory(CurrentPhonebookEntry->MemoryType)); + + /* We may get just OK response (Siemens M20) which means empty location + */ + CurrentPhonebookEntry->Empty=true; + CurrentPhonebookEntry->Group=0; /* not present up to Nokia 9110i */ + ATHW_DateTimeSetCurrent(&CurrentPhonebookEntry->Date); /* not present up to Nokia 9110i */ + CurrentPhonebookEntry->SubEntriesCount=0; /* not present up to Nokia 9110i */ + CurrentPhonebookEntry->Name[0]='\0'; /* default */ + CurrentPhonebookEntry->Number[0]='\0'; /* default */ + + ATHW_TX_SendCommand(&CurrentPhonebookError/*errorcodep*/,&ATHW_RX_Patrol_CPBR_ReadPhonebook_struct, + "AT+CPBR=%d\r",CurrentPhonebookEntry->Location); + if (GE_NONE!=wait_on(&CurrentPhonebookError,10/*timeout*/)) { + /* Nokia 9000i returns ATHW_CME_NOT_FOUND error code for empty locations + */ + if (ATHW_CME_NOT_FOUND!=ATHW_RX_Patrol_CME_ERROR_code) + return(CurrentPhonebookError); + return(GE_NONE); + } + + return(GE_NONE); +} + + +/* Routine to write phonebook location in phone. Designed to be called by + application code. Will block until location is written or timeout + occurs. */ + +static GSM_Error ATHW_WritePhonebook(GSM_Data *data, GSM_Statemachine *state) +{ + CurrentPhonebookEntry=data->PhonebookEntry; + + ATHW_ERR_WRAPPER(ATHW_SelectPhonebookMemory(CurrentPhonebookEntry->MemoryType)); + + ATHW_TX_SENDCOMMAND_WAIT_ON(&CurrentPhonebookError/*errorcodep*/,60/*timeout*/,NULL/*patrol*/, + (CurrentPhonebookEntry->Empty ? "AT+CPBW=%d\r" : "AT+CPBW=%d,%s,,%s\r"), + CurrentPhonebookEntry->Location, + ATHW_Enquote(CurrentPhonebookEntry->Number), + ATHW_Enquote(CurrentPhonebookEntry->Name) + ); + + return(GE_NONE); +} + +static const char *ATHW_SMStoStat(GSM_SMSMessage *SMS) +{ + switch (CurrentSMSMessage->Type) { + case GST_MT: + switch (CurrentSMSMessage->Status) { + case GSS_NOTSENTREAD: + return("REC UNREAD"); + case GSS_SENTREAD: + return("REC READ"); + } + return(NULL); + case GST_MO: + switch (CurrentSMSMessage->Status) { + case GSS_NOTSENTREAD: + return("STO UNSENT"); + case GSS_SENTREAD: + return("STO SENT"); + } + return(NULL); + default: + return(NULL); + } + /* NOTREACHED */ +} + +/* RETURN: Success of recognizing "SMSstat" + */ +static bool ATHW_StattoSMS(GSM_SMSMessage *SMS,const char *SMSstat) +{ + /**/ if (!strcmp(SMSstat,"0") || !strcmp(SMSstat,"REC UNREAD")) { + SMS->Type=GST_MT; + SMS->Status=GSS_NOTSENTREAD; + } + else if (!strcmp(SMSstat,"1") || !strcmp(SMSstat,"REC READ")) { + SMS->Type=GST_MT; + SMS->Status=GSS_SENTREAD; + } + else if (!strcmp(SMSstat,"2") || !strcmp(SMSstat,"STO UNSENT")) { + SMS->Type=GST_MO; + SMS->Status=GSS_NOTSENTREAD; + } + else if (!strcmp(SMSstat,"3") || !strcmp(SMSstat,"STO SENT")) { + SMS->Type=GST_MO; + SMS->Status=GSS_SENTREAD; + } + else return(false); /* not recognized! */ + return(true); +} + +/* scts=="01/10/25,02:28:18+08", scts WILL BE DESTROYED! + */ +static bool ATHW_SCTStoSMS_CMGF1(GSM_SMSMessage *SMS,char *scts) +{ +GSM_DateTime *DateTime=&SMS->Time; +bool timezone_minus; +const char *fmt="%d/%d/%d,%d:%d:%d+%d"; /* trailing '\0' IS used! */ +int i; + + if (strlen(scts)!=20) + return(false); + if ((timezone_minus=(scts[17]=='-'))) + scts[17]='+'; + i=0; + do { + if (!isdigit(scts[i++])) + return(false); + if (!isdigit(scts[i++])) + return(false); + if (scts[i]!=fmt[i]) + return(false); + } while (fmt[i++]); + /* string is completely valid now */ + + sscanf(scts,fmt, + &DateTime->Year, + &DateTime->Month, + &DateTime->Day, + &DateTime->Hour, + &DateTime->Minute, + &DateTime->Second, + &DateTime->Timezone); + if (DateTime->Year>=85) + DateTime->Year-=100; + DateTime->Year+=2000; + if (timezone_minus) + DateTime->Timezone=-DateTime->Timezone; + return(true); +} + +static void ATHW_DCStoSMS(GSM_SMSMessage *SMS,unsigned char dcs) +{ + switch ((dcs&0xF0)>>4) { + case 0x0: + switch (dcs&0x0F) { + case 0x0: + CurrentSMSMessage->EightBit=false; + break; + } + break; + case 0xF: + CurrentSMSMessage->EightBit=!!(dcs&0x04); /* bit 2 */ + CurrentSMSMessage->Class=(dcs&0x03); /* bits 0 & 1 */ + break; + } +} + +static bool ATHW_SCTStoSMS_CMGF0(GSM_SMSMessage *SMS,unsigned char *scts) +{ +GSM_DateTime *DateTime=&SMS->Time; +int *fields[]={ /* FIXME: offsetof() would be nice here but currently not supported by Gnokii */ + &DateTime->Year, + &DateTime->Month, + &DateTime->Day, + &DateTime->Hour, + &DateTime->Minute, + &DateTime->Second, + &DateTime->Timezone, + }; +int i; +unsigned char digit0,digit1; + + for (i=0;i 9 + || (digit1=((*scts)>>4)&0x0F) > 9 + ) + return(false); + (*fields[i])=10*digit0 + digit1; + } + /* scts is completely valid now */ + + if (DateTime->Year>=85) + DateTime->Year-=100; + DateTime->Year+=2000; + return(true); +} + +/* Value MUST match ((fo>>3)&0x03) ! + */ +enum ATHW_FO_Validity { + ATHW_FOV_None =0, + ATHW_FOV_Reserved=1, + ATHW_FOV_Relative=2, + ATHW_FOV_Absolute=3, + }; +static const size_t ATHW_FO_Validity_sizes[]={ + 0, /* ATHW_FOV_None */ + 0, /* ATHW_FOV_Reserved - not valid */ + 1, /* ATHW_FOV_Relative */ + 7, /* ATHW_FOV_Absolute */ + }; + +/* RETURN: Success of recognizing "SMSstat" + */ +static void ATHW_FOtoSMS(GSM_SMSMessage *SMS,enum ATHW_FO_Validity *validityp,unsigned char fo) +{ + switch (fo&0x03) { + case 0: SMS->Type=GST_MT; break; + case 1: SMS->Type=GST_MO; break; + default: /* FIXME: value 2 and 3? */ + } + + /* bit 2 - reject duplices - not supported by Gnokii + */ + + if (validityp) + *validityp=(enum ATHW_FO_Validity)((fo>>3)&0x03); + + /* bit 5 - status report request - not supported by Gnokii + */ + + SMS->UDHPresent=!!(fo&(1<<6)); + + SMS->ReplyViaSameSMSC=!!(fo&(1<<7)); +} + +static GSM_Error ATHW_RX_Patrol_CMGR_CMGF0_core(char *after,char *messagetext,char *end) +{ +unsigned char pdu[GNOKII_MAX_PDU_LENGTH],*pduend,*s; +char *oada; +size_t oada_size,udl; +enum ATHW_FO_Validity FO_validity; +unsigned udbits; /* 7 or 8 bits in UserData */ + + if (end-messagetext>2*sizeof(pdu)) + return(GE_INTERNALERROR); /* input PDU hex too long! */ + if (!(pduend=SMS_BlockFromHex(pdu,messagetext,end-messagetext/*len*/))) + return(GE_INTERNALERROR); + s=pdu; + if (ATHW_CurrentSMSCPrefix) { + if (s >= pduend + || *s < 1/*type*/ + || *s > 1/*type*/ + + ( sizeof(CurrentSMSMessage->MessageCenter.Number) + -1/*'\0' termination*/ + +1 )/2/*bytes of rounded-up nibbles*/ + || s +1/*type*/ +((*s)+1)/2/*bytes of rounded-up nibbles*/ > pduend /* whole SMSC.Number must fit */ + ) + return(GE_INTERNALERROR); + if (!(s=SemiOctetUnpack(CurrentSMSMessage->MessageCenter.Number,sizeof(CurrentSMSMessage->MessageCenter.Number), + s+1,2*((*s) -1/*type*/ )))) + return(GE_INTERNALERROR); /* invalid SMSCenter */ + } + if (s +1/**/ +1/*received number length*/ > pduend) + return(GE_INTERNALERROR); + ATHW_FOtoSMS(CurrentSMSMessage,&FO_validity,*s++); + + switch (CurrentSMSMessage->Type) { + + case GST_MT: + oada =CurrentSMSMessage->Sender; + oada_size=sizeof(CurrentSMSMessage->Sender); + break; + + case GST_MO: + oada =CurrentSMSMessage->Destination; + oada_size=sizeof(CurrentSMSMessage->Destination); + + /* message reference is really not interesting to be read */ + if (s +1/**/ > pduend) + return(GE_INTERNALERROR); + s++; + + break; + + /* FIXME: GST_DR - Delivery Report - not supported! + */ + default: + /* Unable to skip OA/DA, parsing would fail + */ + return(GE_INTERNALERROR); + } + + if (oada) { + if (s + 1/*type*/ +((*s)+1)/2/*bytes of rounded-up nibbles*/ > pduend) + return(GE_INTERNALERROR); + if (!(s=SemiOctetUnpack(oada,oada_size,s+1,(*s)/*nibbles*/))) + return(GE_INTERNALERROR); /* invalid OA/DA */ + } + + if (s +1/**/ +1/**/ > pduend) + return(GE_INTERNALERROR); + + /* FIXME: Is it correct to fill "MessageCenter" fields from SMS body? */ + CurrentSMSMessage->MessageCenter.Format=*s++; /* */ + + ATHW_DCStoSMS(CurrentSMSMessage,*s++); /* */ + + switch (CurrentSMSMessage->Type) { + + case GST_MT: /* SCTS field */ + if (s +7/*scts*/ > pduend) + return(GE_INTERNALERROR); + if (!ATHW_SCTStoSMS_CMGF0(CurrentSMSMessage,s)) + return(GE_INTERNALERROR); + s+=7; + break; + + case GST_MO: /* VP field */ + if (s +ATHW_FO_Validity_sizes[(unsigned)FO_validity] > pduend) + return(GE_INTERNALERROR); + switch (FO_validity) { + case ATHW_FOV_None: + break; + case ATHW_FOV_Reserved: + return(GE_INTERNALERROR); /* not supported */ + case ATHW_FOV_Relative: + CurrentSMSMessage->Validity=SMS_VP_to_Validity((GSM_SMSMessageValidity)*s); + break; + case ATHW_FOV_Absolute: + /* leave default, not supported by Gnokii */ + break; + } + s+=ATHW_FO_Validity_sizes[(unsigned)FO_validity]; + break; + + default: + /* To be written when other types get supported in the above switch + */ + } + + if (s +1/*udl*/ > pduend) + return(GE_INTERNALERROR); + + /* We are pretty strict as UDL must exactly match the end of SMS + * as the is the primary check for the good guess of SMSCenter presentness + * during guessing by ATHW_RX_Patrol_CMGR_CMGF0_retrier(). + */ + udl=(*s++); + udbits=(CurrentSMSMessage->EightBit ? 8 : 7); + if (s +( udl*udbits +7/*round-up*/ )/8 != pduend) + return(GE_INTERNALERROR); + + if (CurrentSMSMessage->UDHPresent) { + if (0 + || s +1/*sizeof(UDH[0])*/ > pduend + || s +1/*sizeof(UDH[0])*/ + *s/*UDH[0]*/ > pduend + || 1/*sizeof(UDH[0])*/ + *s/*UDH[0]*/ > sizeof(CurrentSMSMessage->UDH) + ) + return(GE_INTERNALERROR); + memcpy(CurrentSMSMessage->UDH,s, 1/*sizeof(UDH[0])*/ + *s/*UDH[0]*/ ); + s+=1/*sizeof(UDH[0])*/ + *s/*UDH[0]*/; + udl-=(( 1/*sizeof(UDH[0])*/ +CurrentSMSMessage->UDH[0] )*8 +0/*round-down*/ )/udbits; + } + + if (udl > (sizeof(CurrentSMSMessage->MessageText) -1/*terminating '\0'*/)) + return(GE_INTERNALERROR); + CurrentSMSMessage->MessageTextLength=udl; + CurrentSMSMessage->MessageText[CurrentSMSMessage->MessageTextLength]='\0'; + + if (udbits==8) { + memcpy(CurrentSMSMessage->MessageText,s,udl); + } + else { /* udhbits==7 */ + UnpackEightBitsToSeven((7-(!CurrentSMSMessage->UDHPresent ? 0 : 1+CurrentSMSMessage->UDH[0]))%7, /* offset */ + pduend-s, /* in_length */ + udl, /* out_length */ + s, /* input */ + CurrentSMSMessage->MessageText /* output */ + ); + CurrentSMSMessage->MessageText[udl]='\0'; + } + + return(GE_NONE); +} + +/* This is just a variant of ATHW_SMS_CMGF0(), I was too lazy to generalize it + */ +static GSM_Error ATHW_RX_Patrol_CMGR_CMGF0_retrier(char *after,char *messagetext,char *end) +{ +GSM_Error err,err_first=GE_INTERNALERROR/*shut up GCC*/; +int retry; + + for (retry=0;retry<2;retry++) { + /* There is no need to give up trying decoding (=> retried>0 ) + * by both ways as it does't cost us anything (not as in ATHW_SMS_CMGF0()). + */ + if (GE_NONE==(err=ATHW_RX_Patrol_CMGR_CMGF0_core(after,messagetext,end),1/*retried*/)) { + ATHW_CurrentSMSCPrefix_force=true; + return(err); + } + if (ATHW_CurrentSMSCPrefix_force) + return(err); + if (!retry) + err_first=err; + ATHW_CurrentSMSCPrefix=!ATHW_CurrentSMSCPrefix; + } + /* Return rather the first error code as it is more probable that + * it was generated with valid ATHW_CurrentSMSCPrefix setting + */ + return(err_first); +} + +/* +CMGR message reading will be finalized by "\nOK\n" which will terminate wait_on(). + * But invalid message data followed by "\nOK\n" are still invalid so we have to indicate it. + */ +static void ATHW_RX_Patrol_CMGR_CMGF0(char *after,char *messagetext,char *end) +{ +GSM_Error err; + + err=ATHW_RX_Patrol_CMGR_CMGF0_retrier(after,messagetext,end); + if (err!=GE_NONE) + CurrentSMSMessageError=err; +} + +/* +CMGR: (+CMGF==1) + * CurrentSMSMessage->Status = 1st arg + * CurrentSMSMessage->Sender = 2nd arg + * CurrentSMSMessage->Destination = 2nd arg + * ...etc., see the code below + * + * Type==GST_MT: + * +CMGR: ,,,,,,, ,,, + * 0 1 2 3 4 5 6 7 8 9 10 + * Type==GSM_MO: + * +CMGR: ,, ,,,,,,,, + * 0 1 2 3 4 5 6 7 8 9 10 + */ +static void ATHW_RX_Patrol_CMGR_CMGF1(char *after,char *messagetext,char *end) +{ +char buf[32]; +int fieldno_fo=-1,fieldno_dcs=-1; +long l; + + switch (CurrentSMSMessage->Type) { + + case GST_MT: + ATHW_EXTRACTSTRING(CurrentSMSMessage->Sender,after/*src*/,1/*element_no*/); + + /* Service centre time stamp string format "01/10/25,02:28:18+08" + * Note: not present up to Nokia 9110i + */ + ATHW_EXTRACTSTRING(buf ,after/*src*/,3/*element_no*/); + ATHW_SCTStoSMS_CMGF1(CurrentSMSMessage,buf/*scts*/); /* error ignored, leave the default value */ + + fieldno_fo=5; + fieldno_dcs=7; + break; + + case GST_MO: + ATHW_EXTRACTSTRING(CurrentSMSMessage->Destination,after/*src*/,1/*element_no*/); + fieldno_fo=4; + fieldno_dcs=6; + + l=ATHW_ExtractNumber(after/*src*/,7/*element_no*/); + if (l>=0 && l<0x100) + CurrentSMSMessage->Validity=SMS_VP_to_Validity((GSM_SMSMessageValidity)l); + break; + + default: + /* Not supported */ + } + + if (fieldno_fo>=0) { + l=ATHW_ExtractNumber(after/*src*/,fieldno_fo/*element_no*/); + if (l>=0 && l<0x100) + ATHW_FOtoSMS(CurrentSMSMessage, + NULL, /* validityp - solved by GSM device in +CMGF==1 */ + l); + } + + if (fieldno_dcs>=0) { + l=ATHW_ExtractNumber(after/*src*/,fieldno_dcs/*element_no*/); + if (l>=0 && l<0x100) + ATHW_DCStoSMS(CurrentSMSMessage,l); + } + + ATHW_EXTRACTSTRING(CurrentSMSMessage->MessageCenter.Number,after/*src*/,8/*element_no*/); + + CurrentSMSMessage->MessageTextLength=GNOKII_MIN(end-messagetext,sizeof(CurrentSMSMessage->MessageText)-1); + memcpy(CurrentSMSMessage->MessageText,messagetext,CurrentSMSMessage->MessageTextLength); + CurrentSMSMessage->MessageText[CurrentSMSMessage->MessageTextLength]='\0'; +} + +/* +CMGR: + * CurrentSMSMessage->Type = 1st arg + */ +static char *ATHW_RX_Patrol_CMGR(char *after) +{ +char buf[32],*end,*messagetext; + + end=strchr(after,'\n'); + if (!end++) + return(after); /* assert, INTERNAL! */ + if (!*end) + return(NULL); /* need data */ + if (*end=='\n') /* 2nd optional '\n' */ + end++; /* '\n' should be really double as it was "\r\n" from the device */ + messagetext=end; + if (!(end=strchr(end,'\n'))) + return(NULL); /* need data */ + /* Now we have read "+CMGR:*\n[\n]*\n" */ + + /* 1st arg is numeric(+CMGF==0)/alpha(+CMGF==1), ATHW_StattoSMS parses it all + */ + ATHW_EXTRACTSTRING(buf,after/*src*/,0/*element_no*/); + ATHW_StattoSMS(CurrentSMSMessage,buf); /* error ignored: what to do if unknown? */; + + switch (ATHW_CurrentCMGF) { + case 0: ATHW_RX_Patrol_CMGR_CMGF0(after,messagetext,end); break; + case 1: ATHW_RX_Patrol_CMGR_CMGF1(after,messagetext,end); break; + } + + return(++end); /* eat the whole SMS block, INCLUDING the trailing '\n' */ +} + +static const struct ATHW_RX_Patrol ATHW_RX_Patrol_CMGR_struct= + { "\n+CMGR:", ATHW_RX_Patrol_CMGR }; + +static const struct ATHW_RX_Patrol ATHW_RX_Patrol_SiemensMGR_struct= + { "\n^SMGR:", ATHW_RX_Patrol_CMGR }; + +/* Currently we always set the first two memory types as the syntax with empty + * preceding elements is not supported at least by Nokia 9110i & Siemens M20. + * Ideal case would be to first query the state by AT+CPMS? and then the settings + * would be written back. + * We never need to set the third argument, for example on Nokia 9110i it even isn't + * supported for "SM" memory type! + */ +static GSM_Error ATHW_SMS_SelectMemoryType(GSM_SMSMessage *SMS) +{ +const char *atmemtype; +const char *atmemtype_quoted; + + ATHW_GETMEMORYTYPE(atmemtype,SMS->MemoryType); + atmemtype_quoted=ATHW_Enquote(atmemtype); + + ATHW_TX_SENDCOMMAND_WAIT_ON(&CurrentSMSMessageError/*errorcodep*/,10/*timeout*/,NULL/*patrol*/, + "AT+CPMS=%s,%s\r",atmemtype_quoted,atmemtype_quoted); + + return(GE_NONE); +} + +static GSM_Error ATHW_GetSMS(GSM_Data *data, GSM_Statemachine *state) +{ + CurrentSMSMessage = data->SMSMessage; + + ATHW_ERR_WRAPPER(ATHW_SMS_SelectMemoryType(CurrentSMSMessage)); /* select - reading/deleting */ + + ATHW_DateTimeSetCurrent(&CurrentSMSMessage->Time); /* not present up to Nokia 9110i */ + ATHW_DateTimeSetCurrent(&CurrentSMSMessage->SMSCTime); /* not present up to Nokia 9110i */ + CurrentSMSMessage->MessageTextLength=0; /* default */ + CurrentSMSMessage->Validity=72/*hours*/*60; /* default */ + CurrentSMSMessage->UDHPresent=false; /* default */ + CurrentSMSMessage->MessageText[0]='\0'; /* default */ + + ATHW_MessageCenterClear(&CurrentSMSMessage->MessageCenter); /* default */ + CurrentSMSMessage->MessageCenter.No=0; /* default - input for GetSMSCenter */ + + CurrentSMSMessage->Sender[0]='\0'; /* default */ + CurrentSMSMessage->Destination[0]='\0'; /* default */ + CurrentSMSMessage->MessageNumber=CurrentSMSMessage->Location; /* default */ + /* CurrentSMSMessage->MemoryType is input argument */ + CurrentSMSMessage->Type=GST_UN; /* default, detection of EMPTY SMSes! */ + CurrentSMSMessage->Status=GSS_SENTREAD; /* default */ + CurrentSMSMessage->Class=1; /* default */ + CurrentSMSMessage->EightBit=false; /* default */ + CurrentSMSMessage->Compression=false; /* default */ + /* CurrentSMSMessage->Location is input argument */ + CurrentSMSMessage->ReplyViaSameSMSC=false; /* default */ + + /* We may now read "unread" SMS which will change its status to "read". + * We don't know its current state so we don't know whether the number + * of "unread" SMSes will change. + */ + if (!ATHW_HaveSiemensMGR) + ATHW_CNMI_count=-1; + + ATHW_TX_SendCommand(&CurrentSMSMessageError/*errorcodep*/, + (ATHW_HaveSiemensMGR ? &ATHW_RX_Patrol_SiemensMGR_struct : &ATHW_RX_Patrol_CMGR_struct)/*patrol*/, + (ATHW_HaveSiemensMGR ? "AT^SMGR=%d\r" : "AT+CMGR=%d\r"), + CurrentSMSMessage->Location); + if (GE_NONE!=wait_on(&CurrentSMSMessageError,60/*timeout*/)) { + if (ATHW_CMS_INVALID_MEMORY_INDEX!=ATHW_RX_Patrol_CMS_ERROR_code) + return(CurrentSMSMessageError); + return(GE_EMPTYSMSLOCATION); + } + if (CurrentSMSMessage->Type==GST_UN) /* Empty slot with "\nOK\n" response detection */ + return(GE_EMPTYSMSLOCATION); + + return(GE_NONE); +} + +static GSM_Error ATHW_DeleteSMS(GSM_Data *data, GSM_Statemachine *state) +{ + CurrentSMSMessage = data->SMSMessage; + + ATHW_ERR_WRAPPER(ATHW_SMS_SelectMemoryType(CurrentSMSMessage)); /* select - reading/deleting */ + + ATHW_CNMI_count=-1; + + ATHW_TX_SENDCOMMAND_WAIT_ON(&CurrentSMSMessageError/*errorcodep*/,30/*timeout*/,NULL/*patrol*/, + "AT+CMGD=%d\r",CurrentSMSMessage->Location); + + return(GE_NONE); +} + +static const struct ATHW_RX_Patrol *ATHW_RX_Patrol_GT_SPACE_patrol_after; + +/* RETURNS: "true" if successful + */ +static bool WRITEPHONE_hex(unsigned char *buf,size_t buflen) +{ +char *hex; +size_t hexsize; /* should be ==2*buflen */ +size_t got; + + if (!(hex=malloc(2*buflen))) + return(false); + hexsize=(SMS_BlockToHex(hex,buf,buflen)-hex); + got=WRITEPHONE(PortFD,hex,hexsize); + free(hex); + + if (hexsize!=got) + return(false); + return(true); +} + +static char *ATHW_RX_Patrol_GT_SPACE(char *after) +{ + switch (ATHW_CurrentCMGF) { + + case 0: + if (!WRITEPHONE_hex(CurrentSMSMessagePDU,CurrentSMSMessagePDU_size)) + goto fail; + break; + + case 1: + if (CurrentSMSMessage->UDHPresent) { /* ATHW_CMGS_CMGF1_8bit_HaveBinHex==true assumed */ + if (!WRITEPHONE_hex(CurrentSMSMessage->UDH,1+CurrentSMSMessage->UDH[0])) + goto fail; + } + if (CurrentSMSMessage->EightBit && ATHW_CMGS_CMGF1_8bit_HaveBinHex) { + if (!WRITEPHONE_hex( CurrentSMSMessage->MessageText,CurrentSMSMessage->MessageTextLength)) + goto fail; + } + else { + if (CurrentSMSMessage->MessageTextLength!=WRITEPHONE(PortFD,CurrentSMSMessage->MessageText,CurrentSMSMessage->MessageTextLength)) + goto fail; + } + break; + } + + if (1 !=WRITEPHONE(PortFD,"\x1A"/*CTRL-Z*/,1)) { +fail: + CurrentSMSMessageError=GE_INTERNALERROR; + /* FALLTHRU to exit path */ + } + + /* We may be actually doing +CMGS instead of +CMGW but we do not yet + * need to patrol any output from +CMGS so don't bother its distinguishing now. + */ + ATHW_RX_Patrol_Current=ATHW_RX_Patrol_GT_SPACE_patrol_after; + + /* We just cannot return "after" as it would mean "eat line". + * Just leaving there an additional '\n' is pretty harmless. + */ + after[-1]='\n'; + return(after-1); +} + +static const struct ATHW_RX_Patrol ATHW_RX_Patrol_GT_SPACE_struct= + { "\n> ",ATHW_RX_Patrol_GT_SPACE }; + +static char *ATHW_SMS_TypeToSenderOrDestination(GSM_SMSMessage *SMS) +{ + switch (CurrentSMSMessage->Type) { + case GST_MO: + return(SMS->Destination); + case GST_MT: + return(SMS->Sender); + default: + return(NULL); + } + /* NOTREACHED */ +} + +/* The second argument is the size of the data in octets, + * excluding User Data Header - important only for 8bit data + * Ooops, we cannot share the PDU generating code with Gnokii FBUS code + * as FBUS doesn't use PDU format in its SMS-Send packet! + */ +static GSM_Error ATHW_SendSMS_CMGF0_core(GSM_Data *data, GSM_Statemachine *state,const char *commandfmt) G_GNUC_PRINTF(3,0); +static GSM_Error ATHW_SendSMS_CMGF0_core(GSM_Data *data, GSM_Statemachine *state,const char *commandfmt) +{ +unsigned char pdu[GNOKII_MAX_PDU_LENGTH]; +unsigned char *d,*pdustart,*bodystart,*pdudatalengthp; +int i; +char *SMSsenderdestination; + + d=pdu; + + if (ATHW_CurrentSMSCPrefix) { + + /* We should get SMSC number */ + if (CurrentSMSMessage->MessageCenter.No) { +GSM_Data data_messagecenter; + + data_messagecenter.MessageCenter=&CurrentSMSMessage->MessageCenter; + ATHW_ERR_WRAPPER(ATHW_GetSMSCenter(&data_messagecenter,state)); + CurrentSMSMessage->MessageCenter.No = 0; + } + if (!*CurrentSMSMessage->MessageCenter.Number) + *d++=0x00; /* total SMSC length */ + else { + i=SemiOctetPack(CurrentSMSMessage->MessageCenter.Number,d+1); + *d= 1/*type*/ + (i+1)/2/*rounded-up bytes of nibbles*/ ; + d+= 1/*length*/ + 1/*type*/ + (i+1)/2/*rounded-up bytes of nibbles*/ ; + } + } + /* We MUST NOT count SMSCenter length into +CMGS=%d count argument + */ + pdustart=d; + + *d++=ATHW_SMStoFO(CurrentSMSMessage); /* : First Octet of SMS-SUBMIT */ + *d++=ATHW_PDU_MR_DEFAULT; /* Message Reference */ + SMSsenderdestination=ATHW_SMS_TypeToSenderOrDestination(CurrentSMSMessage); + i=SemiOctetPack((!SMSsenderdestination ? "" : CurrentSMSMessage->Destination),d+1); + *d= i/*nibbles*/ ; + d+= 1/*length*/ + 1/*type*/ + (i+1)/2/*rounded-up bytes of nibbles*/ ; + *d++=(unsigned char)CurrentSMSMessage->MessageCenter.Format; + *d++=ATHW_SMStoDCS(CurrentSMSMessage); + *d++=SMS_Validity_to_VP(CurrentSMSMessage->Validity); + pdudatalengthp=d++; + + bodystart=d; + if (CurrentSMSMessage->UDHPresent) { +size_t UDHlen=1+CurrentSMSMessage->UDH[0]; + + memcpy(d,CurrentSMSMessage->UDH,UDHlen); + d+=UDHlen; + } + if (CurrentSMSMessage->EightBit) { + memcpy(d,CurrentSMSMessage->MessageText,CurrentSMSMessage->MessageTextLength); + d+=CurrentSMSMessage->MessageTextLength; + } else { +size_t byteslen=PackSevenBitsToEight( + /* check it out yourself, really the number of used bits for UDH header on the start + * as we will need to allocate initial bit to align SMS->MessageText on the 7-bit boundary + */ + (7-(d-bodystart))%7, + CurrentSMSMessage->MessageText,d); + d+=byteslen; + } + *pdudatalengthp=((d-bodystart)*8)/(CurrentSMSMessage->EightBit ? 8 : 7); + + CurrentSMSMessagePDU=pdu; + CurrentSMSMessagePDU_size=d-pdu; + + ATHW_ERR_WRAPPER(ATHW_SMS_CMGF01_pre()); + ATHW_TX_SENDCOMMAND_WAIT_ON(&CurrentSMSMessageError/*errorcodep*/,150/*timeout*/,&ATHW_RX_Patrol_GT_SPACE_struct/*patrol*/, + commandfmt,d-pdustart); + ATHW_ERR_WRAPPER(ATHW_SMS_CMGF01_post()); + + return(GE_NONE); +} + +/* Houston, we have a problem. + * Siemens M20 supports +CMGW specification but on my model it just + * reports ERROR (and is not respected). + * Fortunately it will write "+CMGW: \n" before and the message gets written + * so we try to ignore ERROR reports during initial probing of support. + */ +static bool ATHW_SaveSMS_StatSupported=true; +static bool ATHW_SaveSMS_StatSupported_force=false; +static int ATHW_SaveSMS_StatSupported_retries=ATHW_SAVESMS_STATSUPPORTED_RETRIES; + +static GSM_Error ATHW_SaveSMS_StatSupported_solve(GSM_Error err,int retried) +{ + if (ATHW_SaveSMS_StatSupported_force) + return(err); + if (err==GE_NONE || CurrentSMSMessage->MessageNumber) { + ATHW_SaveSMS_StatSupported_force=true; + return(GE_NONE); + } + if (!ATHW_SaveSMS_StatSupported_retries) { + ATHW_SaveSMS_StatSupported=false; + ATHW_SaveSMS_StatSupported_force=true; + return(err); + } + /* Count only the sending sessions, not each attempt. + * Otherwise SMS with not-acceptable for write would + * cost us ATHW_CURRENTSMSCPREFIX_RETRIES number of retries + * in ATHW_SaveSMS_StatSupported_retries counter! + */ + if (!retried) + ATHW_SaveSMS_StatSupported_retries--; + return(err); +} + +/* This is just a wrapper for ATHW_CurrentSMSCPrefix retrying, please see the comment + * at the definition of this variable. + */ +/* This is just a variant of ATHW_RX_Patrol_CMGR_CMGF0(), I was too lazy to generalize it + */ +static GSM_Error ATHW_SMS_CMGF0(GSM_Data *data, GSM_Statemachine *state,const char *commandfmt) +{ +GSM_Error err,err_first=GE_INTERNALERROR/*shut up GCC*/; +int retry; + + for (retry=0;retryDestination)); + ATHW_ERR_WRAPPER(ATHW_SMS_CMGF01_post()); + + return(GE_SMSSENDOK); +} + +static char *ATHW_RX_Patrol_CMGS_CMGW(char *after) +{ +long l; + + l=ATHW_ExtractNumber(after/*src*/,0/*element_no*/); + if (l>=0 && l<=INT_MAX/* SMS->Location is int */) + CurrentSMSMessage->MessageNumber=l; + + return(after); /* eat line */ +} + +static const struct ATHW_RX_Patrol ATHW_RX_Patrol_CMGS_struct= + { "\n+CMGS:", ATHW_RX_Patrol_CMGS_CMGW }; + +static GSM_Error ATHW_SendSMS(GSM_Data *data, GSM_Statemachine *state) +{ + CurrentSMSMessage = data->SMSMessage; + ATHW_RX_Patrol_GT_SPACE_patrol_after=&ATHW_RX_Patrol_CMGS_struct; + CurrentSMSMessage->MessageNumber=0; /* default */ + + switch (ATHW_CurrentCMGF) { + case 0: return(ATHW_SendSMS_CMGF0(data,state)); + case 1: return(ATHW_SendSMS_CMGF1(data,state)); + } + return(GE_INTERNALERROR); +} + +static const struct ATHW_RX_Patrol ATHW_RX_Patrol_CMGW_struct= + { "\n+CMGW:", ATHW_RX_Patrol_CMGS_CMGW }; + +static GSM_Error ATHW_SaveSMS_CMGF0(GSM_Data *data, GSM_Statemachine *state) +{ +const char *SMSstat; +char *commandfmt=NULL; /* just paranoia */ +GSM_Error err; + + SMSstat=(!ATHW_SaveSMS_StatSupported ? NULL : ATHW_SMStoStat(CurrentSMSMessage)); + gasprintf(&commandfmt,"AT+CMGW=%%d,%s\r",(!SMSstat ? "" : ATHW_Enquote(SMSstat))); + if (!commandfmt) + return(GE_INTERNALERROR); + + err=ATHW_SMS_CMGF0(data,state,commandfmt); + free(commandfmt); + + return(err); +} + +static GSM_Error ATHW_SaveSMS_CMGF1(GSM_Data *data, GSM_Statemachine *state) +{ +const char *SMSstat; +char *SMSsenderdestination; +GSM_Error err; + + SMSstat=(!ATHW_SaveSMS_StatSupported ? NULL : ATHW_SMStoStat(CurrentSMSMessage)); + SMSsenderdestination=ATHW_SMS_TypeToSenderOrDestination(CurrentSMSMessage); + + ATHW_ERR_WRAPPER(ATHW_SMS_CMGF01_pre()); + ATHW_TX_SendCommand(&CurrentSMSMessageError/*errorcodep*/,&ATHW_RX_Patrol_GT_SPACE_struct/*patrol*/, + "AT+CMGW=%s,,%s\r", + (!SMSsenderdestination ? "" : ATHW_Enquote(SMSsenderdestination)), + (!SMSstat ? "" : ATHW_Enquote(SMSstat))); + err=wait_on(&CurrentSMSMessageError,150/*timeout*/); + ATHW_ERR_WRAPPER(ATHW_SMS_CMGF01_post()); + + return(ATHW_SaveSMS_StatSupported_solve(err,0/*retried-no retry session here*/)); +} + +static GSM_Error ATHW_SaveSMS(GSM_Data *data, GSM_Statemachine *state) +{ + CurrentSMSMessage = data->SMSMessage; + ATHW_RX_Patrol_GT_SPACE_patrol_after=&ATHW_RX_Patrol_CMGW_struct; + CurrentSMSMessage->MessageNumber=0; /* default */ + + ATHW_ERR_WRAPPER(ATHW_SMS_SelectMemoryType(CurrentSMSMessage)); /* select - writing */ + + switch (ATHW_CurrentCMGF) { + case 0: return(ATHW_SaveSMS_CMGF0(data,state)); + case 1: return(ATHW_SaveSMS_CMGF1(data,state)); + } + return(GE_INTERNALERROR); +} + +static GSM_Error ATHW_Reset(GSM_Data *data, GSM_Statemachine *state) +{ + ATHW_ERR_WRAPPER(ATHW_PhoneSetup()); + + return(GE_NONE); +} + +/* +COPS: + * CurrentNetworkInfo->NetworkCode = 3rd arg + */ +static char *ATHW_RX_Patrol_COPS(char *after) +{ +long l; +char *s; + + l=ATHW_ExtractNumber(after/*src*/,1/*element_no*/); + /* check whether numeric operator mode is on */ + if (l!=2) + return(after); /* eat line */ + + ATHW_EXTRACTSTRING(CurrentNetworkInfo->NetworkCode,after/*src*/,2/*element_no*/); + if (strlen(CurrentNetworkInfo->NetworkCode)!=5) { +fail: + CurrentNetworkInfo->NetworkCode[0]='\0'; + return(after); /* eat line */ + } + for (s=CurrentNetworkInfo->NetworkCode;*s;s++) + if (!isdigit(*s)) + goto fail; + /* network code valid */ + + memmove(CurrentNetworkInfo->NetworkCode+3+1,CurrentNetworkInfo->NetworkCode+3,2 +1/*terminating '\0'*/); + CurrentNetworkInfo->NetworkCode[3]=' '; + + return(after); /* eat line */ +} + +static const struct ATHW_RX_Patrol ATHW_RX_Patrol_COPS_struct= + { "\n+COPS:", ATHW_RX_Patrol_COPS }; + +static void ATHW_RX_Patrol_CREG_hex4valid(char *hex4) +{ +char *s; + + if (strlen(hex4)!=4) { +fail: + hex4[0]='\0'; + return; + } + for (s=hex4;*s;s++) + if (!isxdigit(*s)) + goto fail; +} + +/* +CREG: + * CurrentNetworkInfo->CellID = 4rd arg + * CurrentNetworkInfo->LAC = 3nd arg + */ +static char *ATHW_RX_Patrol_CREG(char *after) +{ +long l; + + l=ATHW_ExtractNumber(after/*src*/,1/*element_no*/); + /* check whether we don't report stale information + */ + if (l==1/*registered-home network*/ || l==5/*registered-roaming*/) + return(after); /* eat line */ + + ATHW_EXTRACTSTRING( CurrentNetworkInfo->CellID,after/*src*/,3/*element_no*/); + ATHW_RX_Patrol_CREG_hex4valid(CurrentNetworkInfo->CellID); + ATHW_EXTRACTSTRING( CurrentNetworkInfo->LAC ,after/*src*/,2/*element_no*/); + ATHW_RX_Patrol_CREG_hex4valid(CurrentNetworkInfo->LAC ); + + return(after); /* eat line */ +} + +static const struct ATHW_RX_Patrol ATHW_RX_Patrol_CREG_struct= + { "\n+CREG:", ATHW_RX_Patrol_CREG }; + +static GSM_Error ATHW_GetNetworkInfo(GSM_Data *data, GSM_Statemachine *state) +{ + CurrentNetworkInfo=data->NetworkInfo; + + ATHW_TX_SENDCOMMAND_WAIT_ON(&CurrentNetworkInfoError/*errorcodep*/,10/*timeout*/,&ATHW_RX_Patrol_COPS_struct/*patrol*/, + "AT+COPS?\r"); + ATHW_TX_SENDCOMMAND_WAIT_ON(&CurrentNetworkInfoError/*errorcodep*/,10/*timeout*/,&ATHW_RX_Patrol_CREG_struct/*patrol*/, + "AT+CREG?\r"); + + /* When no information was gather we will rather report failure + */ + if (1 + && !*CurrentNetworkInfo->NetworkCode + && !*CurrentNetworkInfo->CellID + && !*CurrentNetworkInfo->LAC + ) + return(GE_INTERNALERROR); + + + return(GE_NONE); +} + + +#ifndef WIN32 + +/* Called by initialisation code to open comm port in asynchronous mode. */ + +static bool ATHW_OpenSerial(void) +{ + int result; + +#if __unices__ + int rtn; +#else + struct sigaction sig_io; + + /* Set up and install handler before enabling async IO on port. */ + + sig_io.sa_handler = ATHW_SigHandler; + sig_io.sa_flags = 0; + sigaction (SIGIO, &sig_io, NULL); +#endif + + /* Open device. */ + + result = device_open(PortDevice, false/*with_odd_parity*/, true/*with_async*/, -1/*with_hw_handshake*/, GCT_Serial); + + if (!result) { + perror(_("Couldn't open AT device")); + return false; + } + +#if __unices__ + /* create a thread to handle incoming data from mobile phone */ + rtn = pthread_create(&selThread, NULL, (void*)ATHW_SelectLoop, (void*)NULL); + if (rtn != 0) return false; +#endif + + /* device_changespeed() not needed as device_open() now automatically + * sets the user-specified (or default) speed. + */ + return (true); +} + +static void ATHW_SigHandler(int status) +{ + unsigned char buffer[255]; + int count, res; + res = device_read(buffer, 255); + for (count = 0; count < res ; count ++) + ATHW_RX_Char(buffer[count]); +} +#endif /* WIN32 */ + +static char *ATHW_RX_Patrol_OK(char *after) +{ + /* Some patrol may have already indicated some error! + */ + if (ATHW_CatchBufferErrorP && *ATHW_CatchBufferErrorP==GE_BUSY) + *ATHW_CatchBufferErrorP=GE_NONE; + + return(after); /* eat line */ +} + +static char *ATHW_RX_Patrol_ERROR(char *after) +{ + if (ATHW_CatchBufferErrorP) + *ATHW_CatchBufferErrorP=GE_INTERNALERROR; + + return(after); /* eat line */ +} + +/* We can't kick the user with anything else */ +#define ATHW_RX_Patrol_NO_CARRIER ATHW_RX_Patrol_ERROR +#define ATHW_RX_Patrol_DELAYED ATHW_RX_Patrol_ERROR +#define ATHW_RX_Patrol_NO_DIALTONE ATHW_RX_Patrol_ERROR +#define ATHW_RX_Patrol_BUSY ATHW_RX_Patrol_ERROR + +static char *ATHW_RX_Patrol_CMX_ERROR(char *after,long *errorp) +{ +char *end=NULL; +long l; + + while (*after==' ') after++; + + l=strtol(after,&end,10); + if (*after && l>=0 && l=0) { + ATHW_CNMI_count++; +#ifdef ATHW_DEBUG + printf("ATHW_CNMI_count increased to %d\n",ATHW_CNMI_count); +#endif + } + + return(after); /* eat line */ +} + +static const struct ATHW_RX_Patrol ATHW_RX_Patrols[]={ + { "\nOK\n" ,ATHW_RX_Patrol_OK }, + { "\nERROR\n" ,ATHW_RX_Patrol_ERROR }, + { "\nNO CARRIER\n" ,ATHW_RX_Patrol_NO_CARRIER }, + { "\nDELAYED\n" ,ATHW_RX_Patrol_DELAYED }, + { "\nNO DIALTONE\n" ,ATHW_RX_Patrol_NO_DIALTONE }, + { "\nBUSY\n" ,ATHW_RX_Patrol_BUSY }, + { "\n+CME ERROR:" ,ATHW_RX_Patrol_CME_ERROR, ATHW_RX_Patrol_CME_ERROR_reset }, + { "\n+CMS ERROR:" ,ATHW_RX_Patrol_CMS_ERROR, ATHW_RX_Patrol_CMS_ERROR_reset }, + { "\n+CRING: VOICE\n",ATHW_RX_Patrol_CRING_VOICE }, + { "\n+CMTI:" ,ATHW_RX_Patrol_CMTI }, + }; + +static void ATHW_CatchBufferReset(void) +{ + ATHW_CatchBufferPtr=ATHW_CatchBuffer; + *ATHW_CatchBufferPtr='\0'; + ATHW_CatchBufferMarker=NULL; +} + +static void ATHW_CatchBufferMarkStart(GSM_Error *errorcodep) +{ +static GSM_Error err_trashcan; +const struct ATHW_RX_Patrol *patrol; + + if (!errorcodep) + errorcodep=&err_trashcan; + ATHW_CatchBufferErrorP=errorcodep; + + ATHW_CatchBufferMarker=ATHW_CatchBufferPtr; + + for (patrol=ATHW_RX_Patrols;patrolreset) + (*patrol->reset)(); +} + +static const struct ATHW_RX_Patrol *ATHW_RX_Char_EvalPatrol_best; +static char *ATHW_RX_Char_EvalPatrol_best_found; + +static void ATHW_RX_Char_EvalPatrol(const struct ATHW_RX_Patrol *patrol) +{ +char *found,*foundend; + + if (!patrol) + return; + + if (!(found=strstr(ATHW_CatchBuffer,patrol->buoy))) + return; + + /* When the buoy doesn't end with '\n' we need to find some '\n' after it. + * Otherwise the whole line hasn't been read yet and we to yet wait. + * It means that we doesn't support Patrol which would catch an incomplete line + * - the only exception are the explicite checks for functions like "ATHW_RX_Patrol_GT_SPACE_struct" :-( + */ + foundend=found+strlen(patrol->buoy); + if (foundend<=found) /* assert */ + return; + if (1 /* FIXME: This list is an ugly solution... */ + && patrol!=&ATHW_RX_Patrol_GT_SPACE_struct + && patrol!=&ATHW_PhoneSetup_CMGF1_Detect_Patrol_GT_SPACE_struct + && patrol!=&ATHW_PhoneSetup_CMGF1_Detect_Patrol_9_struct + + && foundend>found && foundend[-1]!='\n' && !strchr(foundend,'\n')) + return; /* no whole line has been read yet */ + + if (!ATHW_RX_Char_EvalPatrol_best || ATHW_RX_Char_EvalPatrol_best_found>found) { + ATHW_RX_Char_EvalPatrol_best=patrol; + ATHW_RX_Char_EvalPatrol_best_found=found; + } +} + + +/* RX_State machine for receive handling. Called once for each character + received from the phone/phone. */ + +static void ATHW_RX_Char(char rx_byte) +{ +size_t offset; +#ifdef ATHW_DEBUG +#if 0 + dprintf(_("Received character '%c' (0x%02X)\n"), + (!isgraph(rx_byte) ? '?' : rx_byte),(unsigned char)rx_byte); +#endif + putchar(rx_byte); +#endif + +/* We try to keep back 1/2 of buffer data, ineffectively shifting it up when the buffer + * gets filled up. + */ + if (ATHW_CatchBufferPtr>=ATHW_CatchBuffer+sizeof(ATHW_CatchBuffer) -1/*Terminating '\0'*/ ) { +char *movefrom; + +#ifdef ATHW_DEBUG + dprintf(_("Shifting buffer:\n%s\n__END__\n"),ATHW_CatchBuffer); +#endif + movefrom=ATHW_CatchBuffer+(sizeof(ATHW_CatchBuffer)/2); + if (1 && ATHW_CatchBufferMarker + && ATHW_CatchBufferMarker>ATHW_CatchBuffer + && ATHW_CatchBufferMarkerbuoy); +#endif +#endif + found=ATHW_RX_Char_EvalPatrol_best_found; + foundend=found+strlen(ATHW_RX_Char_EvalPatrol_best->buoy); + end=(*ATHW_RX_Char_EvalPatrol_best->func)(foundend); + + if (!end) /* patrol returned NULL - it is on the track but it needs more data! */ + return; + if (end==foundend) { /* they did simple 'return(after);' */ + if (foundend[-1]!='\n') { + if (!(end=strchr(foundend,'\n'))) + end=foundend+strlen(foundend); + } + } + /* We place '\n' delimited at the *end */ + memmove(found+1,end,ATHW_CatchBufferPtr+1-end); + offset=end-(found+1); + ATHW_CatchBufferPtr-=offset; + ATHW_CatchBufferPtr[-1]='\n'; + + /* Move Marker right behind the squeezed data if we were inside + */ + if (ATHW_CatchBufferMarker>=found) { + if (ATHW_CatchBufferMarker<=end) + ATHW_CatchBufferMarker=ATHW_CatchBufferPtr+1; + else + ATHW_CatchBufferMarker-=offset; + } + } +} + +/* Here we initialise model specific functions. */ + +#define ATHW_FUNCTIONS_ENTRY(name) \ + case GOP_##name: return(ATHW_##name(data,state)); + +static GSM_Error ATHW_Functions(GSM_Operation op, GSM_Data *data, GSM_Statemachine *state) +{ +static GSM_Statemachine *catcher=NULL; + + if (!catcher || catcher==state) + catcher=state; + else + *((char *)NULL)=1; + + switch (op) { + ATHW_FUNCTIONS_ENTRY(Init) + ATHW_FUNCTIONS_ENTRY(Terminate) + ATHW_FUNCTIONS_ENTRY(GetMemoryStatus) + ATHW_FUNCTIONS_ENTRY(ReadPhonebook) + ATHW_FUNCTIONS_ENTRY(WritePhonebook) + ATHW_FUNCTIONS_ENTRY(GetSMSStatus) + ATHW_FUNCTIONS_ENTRY(GetSMSCenter) + ATHW_FUNCTIONS_ENTRY(SetSMSCenter) + ATHW_FUNCTIONS_ENTRY(GetSMS) + ATHW_FUNCTIONS_ENTRY(DeleteSMS) + ATHW_FUNCTIONS_ENTRY(SendSMS) + ATHW_FUNCTIONS_ENTRY(SaveSMS) + ATHW_FUNCTIONS_ENTRY(GetRFLevel) + ATHW_FUNCTIONS_ENTRY(GetBatteryLevel) + ATHW_FUNCTIONS_ENTRY(GetPowersource) + ATHW_FUNCTIONS_ENTRY(GetImei) + ATHW_FUNCTIONS_ENTRY(GetRevision) + ATHW_FUNCTIONS_ENTRY(GetModel) + ATHW_FUNCTIONS_ENTRY(GetManufacturer) + ATHW_FUNCTIONS_ENTRY(DialVoice) + ATHW_FUNCTIONS_ENTRY(DialData) + ATHW_FUNCTIONS_ENTRY(GetIncomingCallNr) + ATHW_FUNCTIONS_ENTRY(Reset) + ATHW_FUNCTIONS_ENTRY(CancelCall) + ATHW_FUNCTIONS_ENTRY(AnswerCall) + ATHW_FUNCTIONS_ENTRY(GetNetworkInfo) + + case GOP_Identify: { +GSM_Error err,r=GE_NONE; + if (GE_NONE!=(err=ATHW_GetImei (data,state))) + r=err; + if (GE_NONE!=(err=ATHW_GetRevision (data,state))) + r=err; + if (GE_NONE!=(err=ATHW_GetModel (data,state))) + r=err; + if (GE_NONE!=(err=ATHW_GetManufacturer(data,state))) + r=err; + return(r); + } + + default: + return(GE_NOTIMPLEMENTED); + } +} + +GSM_Phone phone_at_hw = { + UNIMPLEMENTED, /* IncomingFunctions - we don't use default StateMachine */ + UNIMPLEMENTED, /* DefaultFunction - we don't use default StateMachine */ + /* Mobile phone information */ + { + "AT", /* Supported models */ + 31, /* Max RF Level (AT+CSQ) */ + 0, /* Min RF Level (AT+CSQ) */ + GRF_CSQ, /* RF level units */ + 100, /* Max Battery Level (AT+CBC) */ + 0, /* Min Battery Level (AT+CBC) */ + GBU_Percentage, /* Battery level units */ + GDT_None, /* Have date/time support */ + GDT_None, /* Alarm supports time only */ + 0, /* No alarm available */ + 48, 84, /* Startup logo size */ + 14, 72, /* Op logo size */ + 14, 72, /* Caller logo size */ + }, + ATHW_Functions, +}; diff --git a/common/cfgreader.c b/common/cfgreader.c index 1b18760..16365a2 100644 --- a/common/cfgreader.c +++ b/common/cfgreader.c @@ -15,11 +15,8 @@ Modified from code by Tim Potter. $Log$ - Revision 1.1.1.1 2001/11/25 21:58:58 short - :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001 - - Revision 1.16 2001/11/14 10:46:12 pkot - Small cleanup with __unices__ + Revision 1.1.1.2 2002/04/03 00:07:51 short + Found in "gnokii-working" directory, some November-patches version Revision 1.15 2001/06/10 11:24:57 machek Kill "slash star" inside comment. @@ -49,11 +46,16 @@ #include #include #include +#if __unices__ +# include +#endif #include #include #include "cfgreader.h" +struct CFG_Header *CFG_Info; + /* Read configuration information from a ".INI" style file */ struct CFG_Header *CFG_ReadFile(char *filename) { @@ -208,7 +210,7 @@ int CFG_WriteFile(struct CFG_Header *cfg, char *filename) * with key or NULL if no such key exists. */ -char *CFG_Get(struct CFG_Header *cfg, char *section, char *key) +char *CFG_Get(struct CFG_Header *cfg, const char *section, const char *key) { struct CFG_Header *h; struct CFG_Entry *e; @@ -233,6 +235,29 @@ char *CFG_Get(struct CFG_Header *cfg, char *section, char *key) return NULL; } +/* + * Return all the entries of the fiven section. + */ + +void CFG_GetForeach(struct CFG_Header *cfg, const char *section, CFG_GetForeach_func func) +{ + struct CFG_Header *h; + struct CFG_Entry *e; + + if ((cfg == NULL) || (section == NULL) || (func == NULL)) { + return; + } + + /* Search for section name */ + for (h = cfg; h != NULL; h = h->next) { + if (strcmp(section, h->section) == 0) { + /* Search for key within section */ + for (e = h->entries; e != NULL; e = e->next) + (*func)(section,e->key,e->value); + } + } +} + /* Set the value of a key in a config file. Return the new value if the section/key can be found, else return NULL. */ @@ -269,12 +294,17 @@ char *CFG_Set(struct CFG_Header *cfg, char *section, char *key, int readconfig(char **model, char **port, char **initlength, char **connection, char **bindir) { - struct CFG_Header *cfg_info; char *homedir; char rcfile[200]; char *DefaultConnection = "serial"; char *DefaultBindir = "/usr/local/sbin/"; + /* I know that it doesn't belong here but currently there is now generic + * application init function anywhere. + */ + setvbuf(stdout, NULL, _IONBF, 0); + setvbuf(stderr, NULL, _IONBF, 0); + #ifdef WIN32 homedir = getenv("HOMEDRIVE"); strncpy(rcfile, homedir ? homedir : "", 200); @@ -288,34 +318,34 @@ int readconfig(char **model, char **port, char **initlength, #endif /* Try opening .gnokirc from users home directory first */ - if ((cfg_info = CFG_ReadFile(rcfile)) == NULL) { + if ((CFG_Info = CFG_ReadFile(rcfile)) == NULL) { /* It failed so try for /etc/gnokiirc */ - if ((cfg_info = CFG_ReadFile("/etc/gnokiirc")) == NULL) { + if ((CFG_Info = CFG_ReadFile("/etc/gnokiirc")) == NULL) { /* That failed too so exit */ fprintf(stderr, _("Couldn't open %s or /etc/gnokiirc. Exiting now...\n"), rcfile); return -1; } } - (char *)*model = CFG_Get(cfg_info, "global", "model"); + (char *)*model = CFG_Get(CFG_Info, "global", "model"); if (!*model) { fprintf(stderr, _("Config error - no model specified. Exiting now...\n")); return -2; } - (char *)*port = CFG_Get(cfg_info, "global", "port"); + (char *)*port = CFG_Get(CFG_Info, "global", "port"); if (!*port) { fprintf(stderr, _("Config error - no port specified. Exiting now...\n")); return -3; } - (char *)*initlength = CFG_Get(cfg_info, "global", "initlength"); + (char *)*initlength = CFG_Get(CFG_Info, "global", "initlength"); if (!*initlength) (char *)*initlength = "default"; - (char *)*connection = CFG_Get(cfg_info, "global", "connection"); + (char *)*connection = CFG_Get(CFG_Info, "global", "connection"); if (!*connection) (char *)*connection = DefaultConnection; - (char *)*bindir = CFG_Get(cfg_info, "global", "bindir"); + (char *)*bindir = CFG_Get(CFG_Info, "global", "bindir"); if (!*bindir) (char *)*bindir = DefaultBindir; return 0; diff --git a/common/cimd.c b/common/cimd.c new file mode 100644 index 0000000..e213170 --- /dev/null +++ b/common/cimd.c @@ -0,0 +1,1636 @@ +/* + + $Id$ + + G N O K I I + + A Linux/Unix toolset and driver for Nokia mobile phones. + + Copyright (C) 2001 Jan Kratochvil, + based on code by Hugh Blemings & Pavel Janík ml. + + Released under the terms of the GNU GPL, see file COPYING for more details. + + This file provides an API for accessing SMS centers by CIMD and related protococols. + See README-CIMD for more details on supported protocols. + + The various routines are prefixed by CIMD. + + $Log$ + Revision 1.1.1.1 2002/04/03 00:08:03 short + Found in "gnokii-working" directory, some November-patches version + + +*/ + +#define CIMD_DEBUG 1 + +/* System header files */ + +#include +#include +#include +#include +#include + + +#ifdef WIN32 + +#include +#include "win32/winserial.h" + +#undef IN +#undef OUT + +#define WRITEPHONE(a, b, c) WriteCommBlock(b, c) +#define sleep(x) Sleep((x) * 1000) +#define usleep(x) Sleep(((x) < 1000) ? 1 : ((x) / 1000)) +extern HANDLE hPhone; + +#else + +#define WRITEPHONE(a, b, c) device_write(b, c) +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "device.h" +#include "devices/unixserial.h" + +#endif + +/* Various header file */ + +#include "config.h" +#include "misc.h" +#include "gsm-common.h" +#include "cfgreader.h" + +/* Global variables used by code in gsm-api.c to expose the functions + supported by this model of phone. */ + + +#if __unices__ +/* fd opened in device.c */ +extern int device_portfd; +#endif + +/* Our private defines */ + +/* Define if plain (non-Bin) Submit is needed for 7bit messages + */ +#define CIMD_SUBMIT_7BIT 1 + +/* When now catchbuffer was provided and must have some space to decode + * OK/ERROR/... result codes. + */ +#define CIMD_CATCHBUFFER_LENGTH 0x400 + +/* +1 of maximum position number of CIMD protocol parameter */ +#define CIMD_PARAMSLOTS (0x10) + +/* We assume the 'right one' class is 1 (Mobile Equipment specific) */ +#define DEFAULT_CLASS 1 + +/* CIMD_Param_Nak_Error codes: + */ +#define CIMD_NAK_NO_SMS (0x5001) +#define CIMD_NAK_KEEPALIVE_REPLY (0x9998) +#define CIMD_NAK_RESEND (0x9999) + +/* Local variables */ + +#ifndef WIN32 +static char PortDevice[GSM_MAX_DEVICE_NAME_LENGTH]; +#endif +static bool RequestTerminate; + + +static u8 CIMD_CatchBuffer[CIMD_CATCHBUFFER_LENGTH]; +static u8 *CIMD_CatchBufferPtr=CIMD_CatchBuffer; /* current destination writing ptr */ +static GSM_Error *CIMD_CatchBufferErrorP; + +static void CIMD_CatchBufferStart(GSM_Error *errorcodep); + + +#define CIMD_MARK_START (0x02) +#define CIMD_MARK_STOP (0x03) +#define CIMD_MARK_SEP (0x09) +#define CIMD_MARK_SEPS "\x09" + +/* ELF=ELement Format */ +enum CIMD_ELF { + CIMD_ELF_HexByte, + CIMD_ELF_HexWord, + CIMD_ELF_Decimal, + CIMD_ELF_StringZ, + CIMD_ELF_HexBlock, + CIMD_ELF_Empty, + }; + +struct CIMD_Param { + u16 code; + enum CIMD_ELF elf; + }; + +enum CIMD_Param_SAMPLE { /* we need some universal enum for typecasting all params */ + CIMD_Param_SAMPLE_dummy, + }; + +/* CIMD_Cmd_Ack: + */ +enum CIMD_Param_Ack { + CIMD_Param_Ack_Cmd, + CIMD_Param_Ack_Error, + CIMD_Param_Ack_NULL + }; +static const struct CIMD_Param CIMD_Param_BIP_Ack[]={ + { /* CIMD_Param_Ack_Cmd */ 1,CIMD_ELF_HexByte }, + { /* CIMD_Param_Ack_Error */ 2,CIMD_ELF_StringZ }, /* protocol version on Cmd_Login, otherwise 0x0000 */ + }; + +/* CIMD_Cmd_Nak: + */ +enum CIMD_Param_Nak { + CIMD_Param_Nak_Cmd, + CIMD_Param_Nak_Error, + CIMD_Param_Nak_NULL + }; +static const struct CIMD_Param CIMD_Param_BIP_Nak[]={ + { /* CIMD_Param_Nak_Cmd */ 1,CIMD_ELF_HexByte }, + { /* CIMD_Param_Nak_Error */ 2,CIMD_ELF_HexWord }, + }; + +/* CIMD_Cmd_Login: + */ +enum CIMD_Param_Login { + CIMD_Param_Login_ID, + CIMD_Param_Login_PWD, + CIMD_Param_Login_NULL + }; +static const struct CIMD_Param CIMD_Param_BIP_Login[]={ + { /* CIMD_Param_Login_ID */ 1,CIMD_ELF_StringZ }, + { /* CIMD_Param_Login_PWD */ 2,CIMD_ELF_StringZ }, + }; + +/* CIMD_Cmd_Logout: + */ +enum CIMD_Param_Logout { + CIMD_Param_Logout_NULL + }; +static const struct CIMD_Param CIMD_Param_BIP_Logout[]={ + }; + +/* CIMD_Cmd_Retrieve: + */ +enum CIMD_Param_Retrieve { + CIMD_Param_Retrieve_NULL + }; +static const struct CIMD_Param CIMD_Param_BIP_Retrieve[]={ + }; + +/* CIMD_Cmd_RetrieveReply: + */ +enum CIMD_Param_RetrieveReply { + CIMD_Param_RetrieveReply_Destination, + CIMD_Param_RetrieveReply_SourceApplication, /* ??? */ + CIMD_Param_RetrieveReply_Text, + CIMD_Param_RetrieveReply_Timestamp, + CIMD_Param_RetrieveReply_Is8bit, /* protocol version 1.14+, CIMD_Param_DCSEnable_Type_*DCS* reqd */ + CIMD_Param_RetrieveReply_PID_DCS, /* protocol version 1.15+, CIMD_Param_DCSEnable_Type_*PID_DCS* reqd */ + CIMD_Param_RetrieveReply_SPEC, /* protocol version 1.16+, CIMD_Param_DCSEnable_Type_*SPEC* reqd */ + CIMD_Param_RetrieveReply_NULL + }; +static const struct CIMD_Param CIMD_Param_BIP_RetrieveReply[]={ + { /* CIMD_Param_RetrieveReply_Destination */ 1,CIMD_ELF_StringZ }, + { /* CIMD_Param_RetrieveReply_SourceApplication */ 2,CIMD_ELF_StringZ }, + { /* CIMD_Param_RetrieveReply_Text */ 3,CIMD_ELF_StringZ }, + { /* CIMD_Param_RetrieveReply_Timestamp */ 4,CIMD_ELF_StringZ }, + { /* CIMD_Param_RetrieveReply_Is8bit */ 5,CIMD_ELF_Decimal }, + { /* CIMD_Param_RetrieveReply_PID_DCS */ 6,CIMD_ELF_Decimal }, /* upper=PID, lower=DCS, FIXME: should be HexWord! */ + { /* CIMD_Param_RetrieveReply_SPEC */ 7,CIMD_ELF_Decimal }, /* FIXME: should be HexByte! */ + }; + +/* CIMD_Cmd_Count: + */ +enum CIMD_Param_Count { + CIMD_Param_Count_NULL + }; +static const struct CIMD_Param CIMD_Param_BIP_Count[]={ + }; + +/* CIMD_Cmd_CountReply: + */ +enum CIMD_Param_CountReply { + CIMD_Param_CountReply_Used, /* Used==NotRead==Slots */ + CIMD_Param_CountReply_NULL + }; +static const struct CIMD_Param CIMD_Param_BIP_CountReply[]={ + { /* CIMD_Param_CountReply_Used */ 1,CIMD_ELF_Decimal }, + }; + +/* CIMD_Cmd_Submit: + */ +enum CIMD_Param_Submit { + CIMD_Param_Submit_Destination, + CIMD_Param_Submit_Text, + CIMD_Param_Submit_ValidityPeriod, + CIMD_Param_Submit_AUX, /* protocol version 1.13+, empty for BMG<->SMSC link CIMD (just for OIS) */ + CIMD_Param_Submit_DCS, /* protocol version 1.14+ */ + CIMD_Param_Submit_PID, /* protocol version 1.15+ */ + CIMD_Param_Submit_SPEC, /* protocol version 1.16+ */ + CIMD_Param_Submit_NULL + }; +static const struct CIMD_Param CIMD_Param_BIP_Submit[]={ + { /* CIMD_Param_Submit_Destination */ 1,CIMD_ELF_StringZ }, + { /* CIMD_Param_Submit_Text */ 2,CIMD_ELF_StringZ }, + { /* CIMD_Param_Submit_ValidityPeriod */ 3,CIMD_ELF_HexByte }, + { /* CIMD_Param_Submit_AUX */ 4,CIMD_ELF_Empty }, + { /* CIMD_Param_Submit_DCS */ 5,CIMD_ELF_Decimal }, + { /* CIMD_Param_Submit_PID */ 6,CIMD_ELF_HexByte }, + { /* CIMD_Param_Submit_SPEC */ 7,CIMD_ELF_HexByte }, + }; + +/* CIMD_Cmd_SubmitBin: protocol version 1.12+ + */ +enum CIMD_Param_SubmitBin { + CIMD_Param_SubmitBin_Destination, + CIMD_Param_SubmitBin_Text, + CIMD_Param_SubmitBin_ValidityPeriod, + CIMD_Param_SubmitBin_AUX, /* protocol version 1.13+, empty for BMG<->SMSC link CIMD (just for OIS) */ + CIMD_Param_SubmitBin_DCS, /* protocol version 1.14+ */ + CIMD_Param_SubmitBin_PID, /* protocol version 1.15+ */ + CIMD_Param_SubmitBin_SPEC, /* protocol version 1.16+ */ + CIMD_Param_SubmitBin_NULL + }; +static const struct CIMD_Param CIMD_Param_BIP_SubmitBin[]={ + { /* CIMD_Param_SubmitBin_Destination */ 1,CIMD_ELF_StringZ }, + { /* CIMD_Param_SubmitBin_Text */ 2,CIMD_ELF_StringZ }, + { /* CIMD_Param_SubmitBin_ValidityPeriod */ 3,CIMD_ELF_HexByte }, + { /* CIMD_Param_SubmitBin_AUX */ 4,CIMD_ELF_Empty }, + { /* CIMD_Param_SubmitBin_DCS */ 5,CIMD_ELF_Decimal }, + { /* CIMD_Param_SubmitBin_PID */ 6,CIMD_ELF_HexByte }, + { /* CIMD_Param_SubmitBin_SPEC */ 7,CIMD_ELF_HexByte }, + }; + +/* CIMD_Cmd_DCSEnable: protocol version 1.14+ + */ +enum CIMD_Param_DCSEnable { + CIMD_Param_DCSEnable_Type, + CIMD_Param_DCSEnable_NULL + }; +static const struct CIMD_Param CIMD_Param_BIP_DCSEnable[]={ + { /* CIMD_Param_DCSEnable_Type */ 1,CIMD_ELF_HexWord }, + }; + +enum CIMD_Param_DCSEnable_Type { + CIMD_Param_DCSEnable_Type_None =0x0000, /* protocol version 1.14+ */ + CIMD_Param_DCSEnable_Type_DCS =0x0001, /* protocol version 1.14+ */ + CIMD_Param_DCSEnable_Type_PID_DCS =0x0002, /* protocol version 1.15+ */ + CIMD_Param_DCSEnable_Type_PID_DCS_SPEC=0x0003, /* protocol version 1.16+ */ + }; + +#define CIMD_PARAM_ENTRY(param) (param),ARRAY_LEN((param)) + +struct CIMD_Cmd { + u8 code; + const struct CIMD_Param *param; + unsigned paramcnt; + }; + +enum CIMD_Cmd_Type { + CIMD_Cmd_Ack, + CIMD_Cmd_Nak, + CIMD_Cmd_Login, + CIMD_Cmd_Logout, + CIMD_Cmd_Submit, + CIMD_Cmd_Retrieve, + CIMD_Cmd_RetrieveReply, + CIMD_Cmd_Count, + CIMD_Cmd_CountReply, + CIMD_Cmd_SubmitBin, /* protocol version 1.12+ */ + CIMD_Cmd_DCSEnable, /* protocol version 1.14+ */ + CIMD_Cmd_NULL /* stdarg termination, MUST be last! */ + }; +static const struct CIMD_Cmd CIMD_Cmd_BIP[]={ + { /* CIMD_Cmd_Ack */ 0x00,CIMD_PARAM_ENTRY(CIMD_Param_BIP_Ack ) }, + { /* CIMD_Cmd_Nak */ 0x99,CIMD_PARAM_ENTRY(CIMD_Param_BIP_Nak ) }, + { /* CIMD_Cmd_Login */ 0x01,CIMD_PARAM_ENTRY(CIMD_Param_BIP_Login ) }, + { /* CIMD_Cmd_Logout */ 0x02,CIMD_PARAM_ENTRY(CIMD_Param_BIP_Logout ) }, + { /* CIMD_Cmd_Submit */ 0x03,CIMD_PARAM_ENTRY(CIMD_Param_BIP_Submit ) }, + { /* CIMD_Cmd_Retrieve */ 0x05,CIMD_PARAM_ENTRY(CIMD_Param_BIP_Retrieve ) }, + { /* CIMD_Cmd_RetrieveReply */ 0x06,CIMD_PARAM_ENTRY(CIMD_Param_BIP_RetrieveReply) }, + { /* CIMD_Cmd_Count */ 0x51,CIMD_PARAM_ENTRY(CIMD_Param_BIP_Count ) }, + { /* CIMD_Cmd_CountReply */ 0x61,CIMD_PARAM_ENTRY(CIMD_Param_BIP_CountReply ) }, + { /* CIMD_Cmd_SubmitBin */ 0x31,CIMD_PARAM_ENTRY(CIMD_Param_BIP_SubmitBin ) }, + { /* CIMD_Cmd_DCSEnable */ 0x53,CIMD_PARAM_ENTRY(CIMD_Param_BIP_DCSEnable ) }, + }; + +static const struct CIMD_Cmd *CIMD_Cmd=CIMD_Cmd_BIP; /* FIXME: When other protocols get supported... */ +static unsigned CIMD_Cmdcnt=ARRAY_LEN(CIMD_Cmd_BIP); /* FIXME: When other protocols get supported... */ + +struct CIMD_Param_Ack_Nak_Error { + u16 code; + const char *msg; + }; + +static const struct CIMD_Param_Ack_Nak_Error CIMD_Param_Ack_Nak_Error[]={ + /* CIMD_Cmd_Login */ + { 0x1101,N_("User is already logged in") }, + { 0x1001,N_("Logging in is currently disabled") }, + { 0x9999,N_("Username not found") }, + /* 0x000? can be bitmask combined from: */ + { 0x0001,N_("Invalid password") }, + { 0x0002,N_("User has forbidden access") }, + { 0x0008,N_("User is already registered") }, /* ??? difference from 0x1101 ? */ + /* CIMD_Cmd_Retrieve / CIMD_Cmd_Count */ + { 0x5001,N_("No SMS found or not detectable") }, /* ==CIMD_NAK_NO_SMS */ + { 0x5011,N_("Function not enabled") }, + /* CIMD_Cmd_Retrieve */ + { 0x5021,N_("Automatical retrieve is active") }, + /* CIMD_Cmd_Submit / CIMD_Cmd_SubmitBin */ + { 0x3001,N_("Error during processing SMS in BMG") }, + { 0x3061,N_("Destination number has invalid format") }, + /* CIMD_Cmd_SubmitBin */ + { 0x3051,N_("Invalid DCS") }, /* protocol version 1.14+ */ + { 0x3081,N_("Invalid Text") }, /* protocol version 1.14+ */ + { 0x3091,N_("SMS is empty") }, /* protocol version 1.14+ */ + { 0x3099,N_("SMS submit too fast") }, /* protocol version 1.16+ */ + }; + + +static struct CIMD_paramslot CIMD_RX_Packet_slot[CIMD_PARAMSLOTS]; +#define CIMD_RX_PACKET_PARAMSLOT(paramsample) (CIMD_RX_Packet_slot+1+(unsigned)(paramsample)) +static enum CIMD_Cmd_Type CIMD_RX_Packet_Cmd; +static unsigned CIMD_RX_Packet_slots; + + +/* RETURNS: Processed */ +typedef bool (*CIMD_RX_PatrolFunc)(void); +typedef void (*CIMD_RX_PatrolReset)(void); + +struct CIMD_RX_Patrol { + enum CIMD_Cmd_Type cmd; + CIMD_RX_PatrolFunc func; + CIMD_RX_PatrolReset reset; + }; + +static const struct CIMD_RX_Patrol *CIMD_RX_Patrol_Current; + +static char *CIMD_RX_Patrol_Ack_Error; +static u16 CIMD_RX_Patrol_Nak_Error; + + +#ifndef WIN32 + +static pthread_t Thread; +# if __unices__ +static pthread_t selThread; +# endif + +#endif + +/* Local variables used by get/set phonebook entry code. Buffer is used as a + source or destination for phonebook data and other functions... Error is + set to GE_NONE by calling function, set to GE_COMPLETE or an error code by + handler routines as appropriate. */ + +static GSM_SMSMessage *CurrentSMSMessage; +static GSM_Error CurrentSMSMessageError; + +static GSM_SMSStatus *CurrentSMSStatus; +static GSM_Error CurrentSMSStatusError; + +static unsigned char Revision[GSM_MAX_REVISION_LENGTH]; +static unsigned char Model [GSM_MAX_MODEL_LENGTH]; + + +static u8 CIMD_TX_SendCommand_buf[sizeof(CIMD_CatchBuffer)]; /* sizeof() is not required to be == but it is appropriate */ +static u8 *CIMD_TX_SendCommand_buf_d=CIMD_TX_SendCommand_buf; + +struct CIMD_paramslot { + u16 code; + enum CIMD_ELF elf; + union { + struct { u8 i; } HexByte; + struct { u16 i; } HexWord; + struct { int i; } Decimal; + struct { char *s; } StringZ; + struct { u8 *buf; size_t len; } HexBlock; + struct { int _dummy; } Empty; + } u; + }; + +/* slots are sorted by moving the whole blocks but they are small so it is OK + */ +static struct CIMD_paramslot CIMD_TX_SendCommand_paramslots[CIMD_PARAMSLOTS]; +static int CIMD_TX_SendCommand_paramslots_full; +static enum CIMD_Cmd_Type CIMD_TX_SendCommand_Cmd; + +/* RETURNS: Success + */ +static bool CIMD_TX_SendCommand_vpushparam(u16 code,enum CIMD_ELF elf,va_list *app) +{ +struct CIMD_paramslot *slot=CIMD_TX_SendCommand_paramslots+(CIMD_TX_SendCommand_paramslots_full++); + + if (slot>=CIMD_TX_SendCommand_paramslots+ARRAY_LEN(CIMD_TX_SendCommand_paramslots)) { + /* assertion */ + fprintf(stderr,"Out of param slots!\n"); + return(false); + } + slot->code=code; + slot->elf=elf; + switch (elf) { + case CIMD_ELF_HexByte: + slot->u.HexByte.i=va_arg((*app),int); + break; + case CIMD_ELF_HexWord: + slot->u.HexWord.i=va_arg((*app),int); + break; + case CIMD_ELF_Decimal: + slot->u.Decimal.i=va_arg((*app),int); + break; + case CIMD_ELF_StringZ: + slot->u.StringZ.s=va_arg((*app),char *); + break; + case CIMD_ELF_HexBlock: + slot->u.HexBlock.buf=va_arg((*app),u8 *); + slot->u.HexBlock.len=va_arg((*app),size_t); + break; + case CIMD_ELF_Empty: + break; + } + return(true); +} + +/* RETURNS: Success + */ +static bool CIMD_TX_SendCommand_pushparam(u16 code,enum CIMD_ELF elf,...) +{ +va_list ap; +bool r; + + va_start(ap,elf); + r=CIMD_TX_SendCommand_vpushparam(code,elf,&ap); + va_end(ap); + return(r); +} + +static int CIMD_TX_SendCommand_paramslots_compare + (const struct CIMD_paramslot *a,const struct CIMD_paramslot *b) +{ + return((b->codecode)-(a->codecode)); +} + +/* RETURNS: Success + */ +static bool CIMD_TX_SendCommand_storeparam(struct CIMD_paramslot *slot) +{ + switch (slot->elf) { + case CIMD_ELF_HexByte: + CIMD_TX_SendCommand_buf_d+=sprintf(CIMD_TX_SendCommand_buf_d,"%02X",slot->u.HexByte.i); + break; + case CIMD_ELF_HexWord: + CIMD_TX_SendCommand_buf_d+=sprintf(CIMD_TX_SendCommand_buf_d,"%04X",slot->u.HexWord.i); + break; + case CIMD_ELF_Decimal: + CIMD_TX_SendCommand_buf_d+=sprintf(CIMD_TX_SendCommand_buf_d,"%d",slot->u.Decimal.i); + break; + case CIMD_ELF_StringZ: { +size_t len; + if (!slot->u.StringZ.s) /* NULL is interpreted as "" */ + break; + len=strlen(slot->u.StringZ.s); + if (CIMD_TX_SendCommand_buf_d+len > CIMD_TX_SendCommand_buf_d+sizeof(CIMD_TX_SendCommand_buf)) + return(false); /* error - overflow */ + memcpy(CIMD_TX_SendCommand_buf_d,slot->u.StringZ.s,len); + CIMD_TX_SendCommand_buf_d+=len; + } break; + case CIMD_ELF_HexBlock: + if (CIMD_TX_SendCommand_buf_d+2*slot->u.HexBlock.len + > CIMD_TX_SendCommand_buf_d+sizeof(CIMD_TX_SendCommand_buf)) + return(false); /* error - overflow */ + CIMD_TX_SendCommand_buf_d=SMS_BlockToHex(CIMD_TX_SendCommand_buf_d, + slot->u.HexBlock.buf,slot->u.HexBlock.len); /* never fails */ + break; + case CIMD_ELF_Empty: + break; + } + return(true); /* success */ +} + +static unsigned CIMD_KeepAlives=0; +static pthread_mutex_t CIMD_KeepAlivesLock; + +/* This function is NOT thread-safe! + */ +static void CIMD_KeepAlivesLockInit(void) +{ +static bool done=false; + + if (done) + return; + pthread_mutex_init(&CIMD_KeepAlivesLock,NULL); + done=true; +} + +static void CIMD_TX_SendCommand(GSM_Error *errorcodep,const struct CIMD_RX_Patrol *patrol,enum CIMD_Cmd_Type cmd,...); + +static void CIMD_KeepAlivesCheck(void) +{ +unsigned alives; + + CIMD_KeepAlivesLockInit(); + pthread_mutex_lock(&CIMD_KeepAlivesLock); + alives=CIMD_KeepAlives; + CIMD_KeepAlives=0; + pthread_mutex_unlock(&CIMD_KeepAlivesLock); + + while (alives) { + CIMD_TX_SendCommand(NULL/*errorcodep*/,NULL/*patrol*/, + CIMD_Cmd_Nak, + CIMD_Param_Nak_Cmd,(CIMD_Cmd+(unsigned)CIMD_Cmd_Ack)->code, /* ==0x00 */ + CIMD_Param_Nak_Error,CIMD_NAK_KEEPALIVE_REPLY, /* ==0x9998 */ + CIMD_Param_Nak_NULL); + alives--; + } +} + +/* RETURNS: Success + */ +static bool CIMD_TX_SendCommandResend(boid) +{ +int writephone_got; + + writephone_got=WRITEPHONE(PortFD, CIMD_TX_SendCommand_buf, CIMD_TX_SendCommand_buf_d-CIMD_TX_SendCommand_buf); + +#ifdef CIMD_DEBUG + write(1,"CMD:",9); + write(1,CIMD_TX_SendCommand_buf+1,CIMD_TX_SendCommand_buf_d-1-(CIMD_TX_SendCommand_buf+1)); + write(1,"\n",6); +#endif + + return(writephone_got==(CIMD_TX_SendCommand_buf_d-CIMD_TX_SendCommand_buf)); +} + +static void CIMD_TX_SendCommand(GSM_Error *errorcodep,const struct CIMD_RX_Patrol *patrol,enum CIMD_Cmd_Type cmd,...) +{ +va_list ap; +const struct CIMD_Cmd *cmdstruct; +enum CIMD_Param_SAMPLE param; +const struct CIMD_Param *paramstruct; +u8 *u8s,xsum; +struct CIMD_paramslot *slot; +int parami; + + CIMD_KeepAlivesCheck(); + + va_start(ap,cmd); + if (errorcodep) + *errorcodep=GE_BUSY; + CIMD_RX_Patrol_Current=patrol; + + CIMD_TX_SendCommand_Cmd=cmd; + CIMD_TX_SendCommand_paramslots_full=0; + if ((unsigned)cmd>=CIMD_Cmdcnt) + goto fail; /* assert */ + cmdstruct=CIMD_Cmd+(unsigned)cmd; + + if (!CIMD_TX_SendCommand_pushparam(0/*code*/,CIMD_ELF_HexByte/*elf*/,cmdstruct->code)) + goto fail; + for (;;) { + param=va_arg(ap,enum CIMD_Param_SAMPLE); + if ((unsigned)param==cmdstruct->paramcnt) + break; /* CIMD_Param_*_NULL reached */ + if ((unsigned)param>cmdstruct->paramcnt) + goto fail; /* assert */ + paramstruct=(cmdstruct->param+(unsigned)param); + if (!CIMD_TX_SendCommand_vpushparam(paramstruct->code,paramstruct->elf,&ap)) + goto fail; + } + qsort(CIMD_TX_SendCommand_paramslots,CIMD_TX_SendCommand_paramslots_full, + sizeof(*CIMD_TX_SendCommand_paramslots), + (int (*)(const void *,const void *))CIMD_TX_SendCommand_paramslots_compare); + + CIMD_TX_SendCommand_buf_d=CIMD_TX_SendCommand_buf; + *CIMD_TX_SendCommand_buf_d++=CIMD_MARK_START; + + slot=CIMD_TX_SendCommand_paramslots; + for (parami=0;slot CIMD_TX_SendCommand_buf_d+sizeof(CIMD_TX_SendCommand_buf)) { + /* error - overflow */ +fail: + if (errorcodep) + *errorcodep=GE_INTERNALERROR; + return; + } + if (slot->code==parami) { + if (!CIMD_TX_SendCommand_storeparam(slot)) /* error */ + goto fail; + } + if (slot->code>=parami) + *CIMD_TX_SendCommand_buf_d++=CIMD_MARK_SEP; + if (slot->code<=parami) + slot++; + } + xsum=0; + for (u8s=CIMD_TX_SendCommand_buf;u8sSMSC link + */ +static unsigned char CIMD_SMStoSPEC_BIP_CIMD(GSM_SMSMessage *SMS) +{ + return(0 + /* bit 0 (enable) & bits 4-7 (value) - priority - not supported by Gnokii + */ + |((!!SMS->ReplyViaSameSMSC)<<1) /*ReplyPath*/ + |((!!SMS->UDHPresent)<<2) /*UDH set*/ + ); +} + +static unsigned char CIMD_SMStoDCS(GSM_SMSMessage *SMS) +{ +int class=(SMS->Class==-1 ? DEFAULT_CLASS : SMS->Class); + +#if 0 /* NEVER send 0 for BIP CIMD as it would translate it to F6 !!! + */ + if (!SMS->EightBit && class==DEFAULT_CLASS) + return(0x00); +#endif + return(0xF0 | ((!!SMS->EightBit)<<2) | ((class&0x03)<<0)); +} + +static GSM_Error CIMD_PhoneSetup(void) +{ +#if 1 /* HACK */ + CIMD_TX_SENDCOMMAND_WAIT_ON(NULL/*errorcodep*/,100/*timeout*/,NULL/*patrol*/, + CIMD_Cmd_Login, + /* NULLs will be interpreted as "" + */ + CIMD_Param_Login_ID,CFG_Get(CFG_Info,"CIMD","name"), + CIMD_Param_Login_PWD,CFG_Get(CFG_Info,"CIMD","password"), + CIMD_Param_Login_NULL); + if (!CIMD_RX_Patrol_Ack_Error) + Revision[0]='\0'; + else + SAFE_STRNCPY_SIZEOF(Revision,CIMD_RX_Patrol_Ack_Error); + + CIMD_TX_SENDCOMMAND_WAIT_ON(NULL/*errorcodep*/,10/*timeout*/,NULL/*patrol*/, + CIMD_Cmd_DCSEnable, + CIMD_Param_DCSEnable_Type,(u16)CIMD_Param_DCSEnable_Type_PID_DCS_SPEC, + CIMD_Param_DCSEnable_NULL); +#endif + + return(GE_NONE); +} + + +static void CIMD_RX_Char(char rx_byte); +static void CIMD_SigHandler(int status); +static bool CIMD_OpenSerial(void); + +GSM_Phone phone_cimd; /* forward declaration */ + +/* Initialise variables and state machine. */ + +static GSM_Error CIMD_Init(GSM_Data *data, GSM_Statemachine *state) +{ + RequestTerminate = false; + + SAFE_STRNCPY_SIZEOF(Model,data->Model); + + /* Create and start main thread. */ + +#ifdef WIN32 +{ +int rtn; + rtn = ! OpenConnection(State->Link.PortDevice,CIMD_RX_Char,CIMD_KeepAliveProc); + if (rtn != 0) { + return(GE_INTERNALERROR); +} +#else + SAFE_STRNCPY_SIZEOF(PortDevice,state->Link.PortDevice); + if (!CIMD_OpenSerial()) + return(GE_INTERNALERROR); +#endif + + CIMD_ERR_WRAPPER(CIMD_PhoneSetup()); + + return (GE_NONE); +} + +#if __unices__ +/* thread for handling incoming data */ +void CIMD_SelectLoop() +{ + int err; + fd_set readfds; + struct timeval timeout; + + FD_ZERO(&readfds); + FD_SET(device_portfd, &readfds); + /* set timeout to 15 seconds */ + timeout.tv_sec=15; + timeout.tv_usec=0; + while (!RequestTerminate) { + err = select(device_portfd + 1, &readfds, NULL, NULL, &timeout); + /* call singal handler to process incoming data */ + if ( err > 0 ) CIMD_SigHandler(0); + else if (err == -1) perror("Error in SelectLoop"); + } +} +#endif + +/* Applications should call CIMD_Terminate to shut down the CIMD thread and + close the serial port. */ + +static GSM_Error CIMD_Terminate(GSM_Data *data, GSM_Statemachine *state) +{ +GSM_Error err; + +#if 1 /* HACK */ + /* Don't wait too much as we can have already broken link + */ + CIMD_TX_SendCommand(&err/*errorcodep*/,NULL/*patrol*/, + CIMD_Cmd_Logout, + CIMD_Param_Logout_NULL); + wait_on(&err,20/*timeout*/); /* errors ignored, of course */ +#endif + + /* Request termination of thread */ + RequestTerminate = true; + +#ifndef WIN32 + /* Now wait for thread to terminate. */ + pthread_join(Thread, NULL); + + /* Close serial port. */ + device_close(); + +#else + CloseConnection(); +#endif + + return(GE_NONE); +} + +/* messagecenter->No" is NOT set as it is input argument */ +static void CIMD_MessageCenterClear(GSM_MessageCenter *messagecenter) +{ + messagecenter->Name[0]='\0'; /* not present up to Nokia 9110i */ + messagecenter->Recipient[0]='\0'; /* not present up to Nokia 9110i */ + messagecenter->Number[0]='\0'; /* default */ + messagecenter->Format=GSMF_Text; /* default */ + messagecenter->Validity=GSMV_72_Hours; /* default */ +} + +static bool CIMD_RX_Patrol_CountReply(void) +{ + CurrentSMSStatus->UnRead=/*FALLTHRU*/ + CurrentSMSStatus->Used =/*FALLTHRU*/ + CurrentSMSStatus->Slots =/*FALLTHRU*/ + CIMD_RX_PACKET_PARAMSLOT(CIMD_Param_CountReply_Used)->u.Decimal.i; + + CurrentSMSStatusError=GE_NONE; + return(true); +} + +static const struct CIMD_RX_Patrol CIMD_RX_Patrol_CountReply_struct= + { CIMD_Cmd_CountReply,CIMD_RX_Patrol_CountReply }; + +static GSM_Error CIMD_GetSMSStatus(GSM_Data *data, GSM_Statemachine *state) +{ + CurrentSMSStatus = data->SMSStatus; + CurrentSMSStatus->UnRead=0; /* default */ + CurrentSMSStatus->Used =0; /* default */ + CurrentSMSStatus->Slots =0; /* default */ +#if 1 /* HACK */ + CIMD_TX_SENDCOMMAND_WAIT_ON(&CurrentSMSStatusError/*errorcodep*/,100/*timeout*/,&CIMD_RX_Patrol_CountReply_struct/*patrol*/, + CIMD_Cmd_Count, + CIMD_Param_Count_NULL); +#endif + + return(GE_NONE); +} + +static GSM_Error CIMD_GetImei(GSM_Data *data, GSM_Statemachine *state) +{ + /* not supported by the protocol */ + data->Imei[0]='\0'; + return (GE_NONE); +} + +static GSM_Error CIMD_GetRevision(GSM_Data *data, GSM_Statemachine *state) +{ + if (*Revision) { + strcpy(data->Revision,Revision); + return (GE_NONE); + } else return (GE_TRYAGAIN); +} + +static GSM_Error CIMD_GetModel(GSM_Data *data, GSM_Statemachine *state) +{ + /* not supported by the protocol */ + strcpy(data->Model,Model); + return (GE_NONE); +} + +static GSM_Error CIMD_GetManufacturer(GSM_Data *data, GSM_Statemachine *state) +{ + /* not supported by the protocol */ + data->Imei[0]='\0'; + return (GE_NONE); +} + +static void CIMD_DateTimeSetCurrent(GSM_DateTime *datetime) +{ +time_t current=time(NULL); +struct tm *tm=localtime(¤t); + + datetime->AlarmEnabled=false; + + datetime->Year =tm->tm_year+1900; + datetime->Month =tm->tm_mon+1; + datetime->Day =tm->tm_mday; + datetime->Hour =tm->tm_hour; + datetime->Minute=tm->tm_min; + datetime->Second=tm->tm_sec; + + datetime->Timezone=timezone; +} + +/* scts=="18.06.1998 22:33:23" + */ +static bool CIMD_SCTStoSMS(GSM_SMSMessage *SMS,const char *scts) +{ +GSM_DateTime *DateTime=&SMS->Time; +const char *fmt="%2d.%2d.%4d %2d:%2d:%2d"; /* trailing '\0' IS used! */ +const char *fs,*ss; + + fs=fmt; + ss=scts; + do { + while (*fs=='%') { +int nums=(*++fs)-'0'; + while (nums--) + if (!isdigit(*ss++)) + return(false); + } + if (*fs++!=*ss) + return(false); + } while (fs[-1]); + /* string is completely valid now */ + + sscanf(scts,fmt, + &DateTime->Day, + &DateTime->Month, + &DateTime->Year, + &DateTime->Hour, + &DateTime->Minute, + &DateTime->Second); + DateTime->Timezone=0; + + return(true); +} + +static void CIMD_DCStoSMS(GSM_SMSMessage *SMS,unsigned char dcs) +{ + switch ((dcs&0xF0)>>4) { + case 0x0: + switch (dcs&0x0F) { + case 0x0: + CurrentSMSMessage->EightBit=false; + break; + } + break; + case 0xF: + CurrentSMSMessage->EightBit=!!(dcs&0x04); /* bit 2 */ + CurrentSMSMessage->Class=(dcs&0x03); /* bits 0 & 1 */ + break; + } +} + +/* Convert SPEC field of BIP protocol using CIMD protocol on BMG<->SMSC link + */ +static void CIMD_SPEC_BIP_CIMDtoSMS(GSM_SMSMessage *SMS,u8 spec) +{ + /* Such specification not supported by BIP: + */ + CurrentSMSMessage->Type=GST_MT; + CurrentSMSMessage->Status=GSS_NOTSENTREAD; + + /* bit 0 (enable) & bits 4-7 (value) - priority - not supported by Gnokii + */ + + SMS->UDHPresent=!!(spec&(1<<2)); + + SMS->ReplyViaSameSMSC=!!(spec&(1<<1)); +} + +static bool CIMD_RX_Patrol_RetrieveReply(void) +{ +u16 pid_dcs; /* upper=PID, lower=DCS */ + + { +const char *destination=CIMD_RX_PACKET_PARAMSLOT(CIMD_Param_RetrieveReply_Destination)->u.StringZ.s; + + if (strlen(destination)+1 > sizeof(CurrentSMSMessage->Sender)) { +fail: + CurrentSMSMessageError=GE_INTERNALERROR; + return(true); /* error */ + } + strcpy(CurrentSMSMessage->Sender,destination); + } + + if ((CurrentSMSMessage->EightBit=CIMD_RX_PACKET_PARAMSLOT(CIMD_Param_RetrieveReply_Is8bit)->u.Decimal.i)) { +const char *hextext=CIMD_RX_PACKET_PARAMSLOT(CIMD_Param_RetrieveReply_Text)->u.StringZ.s; +size_t hextextlen=strlen(hextext); + + if ((hextextlen&1) || (hextextlen/2 > sizeof(CurrentSMSMessage->MessageText))) + goto fail; /* error - message too long */ + if (!SMS_BlockFromHex(CurrentSMSMessage->MessageText/*d*/,hextext,hextextlen)) + goto fail; /* error - parse error */ + CurrentSMSMessage->MessageTextLength=hextextlen/2; + } + else { /* 7bit */ +const char *text=CIMD_RX_PACKET_PARAMSLOT(CIMD_Param_RetrieveReply_Text)->u.StringZ.s; +size_t textlen=strlen(text); + + if (textlen+1 > sizeof(CurrentSMSMessage->MessageText)) + goto fail; /* error - message too long */ + strcpy(CurrentSMSMessage->MessageText,text); + CurrentSMSMessage->MessageTextLength=textlen; + } + + /* errors ignored as it is not fatal */ + CIMD_SCTStoSMS(CurrentSMSMessage,CIMD_RX_PACKET_PARAMSLOT(CIMD_Param_RetrieveReply_Timestamp)->u.StringZ.s); + + pid_dcs=CIMD_RX_PACKET_PARAMSLOT(CIMD_Param_RetrieveReply_PID_DCS)->u.HexWord.i; + + /* FIXME: Is it correct to fill "MessageCenter" fields from SMS body? */ + CurrentSMSMessage->MessageCenter.Format=(GSM_SMSMessageFormat)(pid_dcs>>8U); /* */ + CIMD_DCStoSMS(CurrentSMSMessage,(pid_dcs&0x00FFU)); + CIMD_SPEC_BIP_CIMDtoSMS(CurrentSMSMessage,CIMD_RX_PACKET_PARAMSLOT(CIMD_Param_RetrieveReply_SPEC)->u.HexByte.i); + + if (CurrentSMSMessage->UDHPresent) { +u8 udhlen; + if (CurrentSMSMessage->MessageTextLength<=0) + goto fail; + udhlen=1/*sizeof(udhlen)*/ +CurrentSMSMessage->MessageText[0]; + if (udhlen > CurrentSMSMessage->MessageTextLength) + goto fail; + memcpy(CurrentSMSMessage->UDH,CurrentSMSMessage->MessageText,udhlen); + memmove(CurrentSMSMessage->MessageText,CurrentSMSMessage->MessageText+udhlen, + CurrentSMSMessage->MessageTextLength-udhlen +1/*Trailing '\0'*/); + CurrentSMSMessage->MessageTextLength-=udhlen; + } + + CurrentSMSMessageError=GE_NONE; + return(true); +} + +static const struct CIMD_RX_Patrol CIMD_RX_Patrol_RetrieveReply_struct= + { CIMD_Cmd_RetrieveReply,CIMD_RX_Patrol_RetrieveReply }; + +static GSM_Error CIMD_GetSMS(GSM_Data *data, GSM_Statemachine *state) +{ + CurrentSMSMessage = data->SMSMessage; + + if (CurrentSMSMessage->MemoryType!=GMT_SM) + return(GE_INVALIDMEMORYTYPE); + + CIMD_DateTimeSetCurrent(&CurrentSMSMessage->Time); /* default */ + CIMD_DateTimeSetCurrent(&CurrentSMSMessage->SMSCTime); /* not present in the protocol */ + CurrentSMSMessage->MessageTextLength=0; /* default */ + CurrentSMSMessage->Validity=72/*hours*/*60; /* default */ + CurrentSMSMessage->UDHPresent=false; /* default */ + CurrentSMSMessage->MessageText[0]='\0'; /* default */ + + CIMD_MessageCenterClear(&CurrentSMSMessage->MessageCenter); /* default */ + CurrentSMSMessage->MessageCenter.No=0; /* default - input for GetSMSCenter */ + + CurrentSMSMessage->Sender[0]='\0'; /* default */ + CurrentSMSMessage->Destination[0]='\0'; /* default */ + CurrentSMSMessage->MessageNumber=CurrentSMSMessage->Location; /* default */ + /* CurrentSMSMessage->MemoryType is input argument */ + CurrentSMSMessage->Type=GST_UN; /* default, detection of EMPTY SMSes! */ + CurrentSMSMessage->Status=GSS_SENTREAD; /* default */ + CurrentSMSMessage->Class=DEFAULT_CLASS; /* default */ + CurrentSMSMessage->EightBit=false; /* default */ + CurrentSMSMessage->Compression=false; /* default */ + /* CurrentSMSMessage->Location is input argument */ + CurrentSMSMessage->ReplyViaSameSMSC=false; /* default */ + + CIMD_TX_SendCommand(&CurrentSMSMessageError/*errorcodep*/,&CIMD_RX_Patrol_RetrieveReply_struct/*patrol*/, + CIMD_Cmd_Retrieve, + CIMD_Param_Retrieve_NULL); + if (GE_NONE!=wait_on(&CurrentSMSMessageError,90/*timeout*/)) { + if (CIMD_RX_Patrol_Nak_Error!=CIMD_NAK_NO_SMS) + return(CurrentSMSMessageError); + /* We don't return GE_EMPTYSMSLOCATION as when we have already eaten + * all the wating SMSes there cannot be any other one + */ + return(GE_INVALIDSMSLOCATION); + } + + return(GE_NONE); +} + +static GSM_Error CIMD_SendSMS(GSM_Data *data, GSM_Statemachine *state) +{ +u8 bintext[sizeof(CurrentSMSMessage->UDH)+sizeof(CurrentSMSMessage->MessageText)],*d; +char hexbintext[sizeof(bintext) +1/*Trailing '\0'*/]; + + CurrentSMSMessage = data->SMSMessage; + + CurrentSMSMessage->MessageNumber=0; /* default */ + + d=bintext; + if (CurrentSMSMessage->UDHPresent) { +size_t UDHlen=1+CurrentSMSMessage->UDH[0]; + + memcpy(d,CurrentSMSMessage->UDH,UDHlen); + d+=UDHlen; +#ifdef CIMD_SUBMIT_7BIT + if (!CurrentSMSMessage->EightBit) /* We are not able to send UDH by 7bit channel */ + return(GE_NOTSUPPORTED); +#endif + } + if ( +#ifdef CIMD_SUBMIT_7BIT + 1 /* Never do 7bit->8bit encoding when CIMD_SUBMIT_7BIT */ +#else + CurrentSMSMessage->EightBit +#endif + ) { + memcpy(d,CurrentSMSMessage->MessageText,CurrentSMSMessage->MessageTextLength); + d+=CurrentSMSMessage->MessageTextLength; + } +#ifndef CIMD_SUBMIT_7BIT + else { +size_t byteslen=PackSevenBitsToEight( + /* check it out yourself, really the number of used bits for UDH header on the start + * as we will need to allocate initial bit to align SMS->MessageText on the 7-bit boundary + */ + (7-(d-bintext))%7, + CurrentSMSMessage->MessageText,d); + d+=byteslen; + } +#endif + + if ( +#ifdef CIMD_SUBMIT_7BIT + CurrentSMSMessage->EightBit +#else + 1 /* Never use plain Submit for 8bit messages */ +#endif + ) { + *(SMS_BlockToHex(hexbintext,bintext,(d-bintext)/*len*/))='\0'; + + /* DANGER: Keep in sync with CIMD_Cmd_Submit !!! + */ + CIMD_TX_SENDCOMMAND_WAIT_ON(NULL/*errorcodep*/,150/*timeout*/,NULL/*patrol*/, + CIMD_Cmd_SubmitBin, + CIMD_Param_SubmitBin_Destination,CurrentSMSMessage->Destination, + CIMD_Param_SubmitBin_Text,hexbintext, + CIMD_Param_SubmitBin_ValidityPeriod,SMS_Validity_to_VP(CurrentSMSMessage->Validity), + CIMD_Param_SubmitBin_AUX, /* Empty */ + CIMD_Param_SubmitBin_DCS,(unsigned)CIMD_SMStoDCS(CurrentSMSMessage), + CIMD_Param_SubmitBin_PID,(u8)CurrentSMSMessage->MessageCenter.Format, + CIMD_Param_SubmitBin_SPEC,CIMD_SMStoSPEC_BIP_CIMD(CurrentSMSMessage), + CIMD_Param_SubmitBin_NULL); + } +#ifdef CIMD_SUBMIT_7BIT + else { + *d='\0'; + + /* DANGER: Keep in sync with CIMD_Cmd_SubmitBin !!! + */ + CIMD_TX_SENDCOMMAND_WAIT_ON(NULL/*errorcodep*/,150/*timeout*/,NULL/*patrol*/, + CIMD_Cmd_Submit, + CIMD_Param_Submit_Destination,CurrentSMSMessage->Destination, + CIMD_Param_Submit_Text,bintext, + CIMD_Param_Submit_ValidityPeriod,SMS_Validity_to_VP(CurrentSMSMessage->Validity), + CIMD_Param_Submit_AUX, /* Empty */ + CIMD_Param_Submit_DCS,(unsigned)CIMD_SMStoDCS(CurrentSMSMessage), + CIMD_Param_Submit_PID,(u8)CurrentSMSMessage->MessageCenter.Format, + CIMD_Param_Submit_SPEC,CIMD_SMStoSPEC_BIP_CIMD(CurrentSMSMessage), + CIMD_Param_Submit_NULL); + } +#endif + + return(GE_SMSSENDOK); +} + +static GSM_Error CIMD_Reset(GSM_Data *data, GSM_Statemachine *state) +{ + CIMD_ERR_WRAPPER(CIMD_PhoneSetup()); + + return(GE_NONE); +} + +#ifndef WIN32 + +/* Called by initialisation code to open comm port in asynchronous mode. */ + +static bool CIMD_OpenSerial(void) +{ + int result; + +#if __unices__ + int rtn; +#else + struct sigaction sig_io; + + /* Set up and install handler before enabling async IO on port. */ + + sig_io.sa_handler = CIMD_SigHandler; + sig_io.sa_flags = 0; + sigaction (SIGIO, &sig_io, NULL); +#endif + + /* Open device. */ + + result = device_open(PortDevice, false/*with_odd_parity*/, true/*with_async*/, -1/*with_hw_handshake*/, GCT_Serial); + + if (!result) { + perror(_("Couldn't open CIMD device")); + return false; + } + +#if __unices__ + /* create a thread to handle incoming data from mobile phone */ + rtn = pthread_create(&selThread, NULL, (void*)CIMD_SelectLoop, (void*)NULL); + if (rtn != 0) return false; +#endif + + /* device_changespeed() not needed as device_open() now automatically + * sets the user-specified (or default) speed. + */ + return (true); +} + +static void CIMD_SigHandler(int status) +{ + unsigned char buffer[255]; + int count, res; + res = device_read(buffer, 255); + for (count = 0; count < res ; count ++) + CIMD_RX_Char(buffer[count]); +} +#endif /* WIN32 */ + +static bool CIMD_RX_Patrol_Ack(void) +{ + if ((CIMD_Cmd+(unsigned)CIMD_Cmd_Nak)->code == CIMD_RX_PACKET_PARAMSLOT(CIMD_Param_Ack_Cmd)->u.HexByte.i) { /* ==0x99 */ + /* We cannot send the keepalive here as some dangerous operation may be in progress + */ + CIMD_KeepAlivesLockInit(); + pthread_mutex_lock(&CIMD_KeepAlivesLock); + CIMD_KeepAlives++; + pthread_mutex_unlock(&CIMD_KeepAlivesLock); + return(false); + } + + if (CIMD_RX_PACKET_PARAMSLOT(CIMD_Param_Ack_Cmd)->u.HexByte.i!=(CIMD_Cmd+(unsigned)CIMD_TX_SendCommand_Cmd)->code) + return(false); /* Ack for some unknown command */ + + free(CIMD_RX_Patrol_Ack_Error); + CIMD_RX_Patrol_Ack_Error=strdup(CIMD_RX_PACKET_PARAMSLOT(CIMD_Param_Ack_Error)->u.StringZ.s); + + /* Some patrol may have already indicated some error! + */ + if (CIMD_CatchBufferErrorP && *CIMD_CatchBufferErrorP==GE_BUSY) + *CIMD_CatchBufferErrorP=GE_NONE; + + return(true); +} + +static void CIMD_RX_Patrol_Ack_reset(void) +{ + free(CIMD_RX_Patrol_Ack_Error); + CIMD_RX_Patrol_Ack_Error=NULL; +} + +static const char *CIMD_RX_Patrol_Nak_resolve(u16 errorcode) +{ +const struct CIMD_Param_Ack_Nak_Error *errorp; + + for (errorp=CIMD_Param_Ack_Nak_Error;errorpcode) + return(_(errorp->msg)); + return(_("Unknown error code")); +} + +static void CIMD_RX_Patrol_Nak_dump(u16 errorcode) +{ + fprintf(stderr,_("Got CIMD error code 0x%04X: "),errorcode); + if (!(errorcode & ~0x000F)) { /* combined error code */ +u16 errormask; + fprintf(stderr,_("combined:")); + for (errormask=0x0001;errormask<=errorcode;errormask<<=1) + if (errorcode&errormask) + fprintf(stderr," +%s",CIMD_RX_Patrol_Nak_resolve(errormask)); + fputc('\n',stderr); + return; + } + fprintf(stderr,"%s\n",CIMD_RX_Patrol_Nak_resolve(errorcode)); +} + +static bool CIMD_RX_Patrol_Nak(void) +{ + if ((CIMD_Cmd+(unsigned)CIMD_Cmd_Nak)->code == CIMD_RX_PACKET_PARAMSLOT(CIMD_Param_Nak_Cmd)->u.HexByte.i /* ==0x99 */ + && CIMD_NAK_RESEND == CIMD_RX_PACKET_PARAMSLOT(CIMD_Param_Nak_Error)->u.HexWord.i) { /* 0x9999 */ + fprintf(stderr,_("WARNING: Requested to resend last packet!!\n")); + CIMD_TX_SendCommandResend(); + return(true); + } + + if (CIMD_RX_PACKET_PARAMSLOT(CIMD_Param_Nak_Cmd)->u.HexByte.i!=(CIMD_Cmd+(unsigned)CIMD_TX_SendCommand_Cmd)->code) + return(false); /* Nak for some unknown command */ + + CIMD_RX_Patrol_Nak_Error=CIMD_RX_PACKET_PARAMSLOT(CIMD_Param_Nak_Error)->u.HexWord.i; + if (CIMD_CatchBufferErrorP) + *CIMD_CatchBufferErrorP=GE_INTERNALERROR; + + CIMD_RX_Patrol_Nak_dump(CIMD_RX_Patrol_Nak_Error); + + return(true); +} + +static void CIMD_RX_Patrol_Nak_reset(void) +{ + CIMD_RX_Patrol_Nak_Error=0; +} + +static const struct CIMD_RX_Patrol CIMD_RX_Patrols[]={ + { CIMD_Cmd_Ack,CIMD_RX_Patrol_Ack,CIMD_RX_Patrol_Ack_reset }, + { CIMD_Cmd_Nak,CIMD_RX_Patrol_Nak,CIMD_RX_Patrol_Nak_reset }, + }; + + +static void CIMD_CatchBufferReset(void) +{ + CIMD_CatchBufferPtr=CIMD_CatchBuffer; +} + +static void CIMD_CatchBufferStart(GSM_Error *errorcodep) +{ +static GSM_Error err_trashcan; +const struct CIMD_RX_Patrol *patrol; + + if (!errorcodep) + errorcodep=&err_trashcan; + CIMD_CatchBufferErrorP=errorcodep; + + CIMD_CatchBufferReset(); + + for (patrol=CIMD_RX_Patrols;patrolreset) + (*patrol->reset)(); +} + +static u8 *CIMD_RX_ProcessRawPacket_parseparam_buf_s; + +/* RETURNS: Success + */ +static bool CIMD_RX_ProcessRawPacket_parseparam(struct CIMD_paramslot *slot) +{ + switch (slot->elf) { + + case CIMD_ELF_HexByte: { +unsigned parsedbyte; + if (0 || !isxdigit(CIMD_RX_ProcessRawPacket_parseparam_buf_s[0]) + || !isxdigit(CIMD_RX_ProcessRawPacket_parseparam_buf_s[1]) + || CIMD_MARK_SEP!=CIMD_RX_ProcessRawPacket_parseparam_buf_s[2] + ) + return(false); + if (1!=sscanf(CIMD_RX_ProcessRawPacket_parseparam_buf_s,"%X" CIMD_MARK_SEPS,&parsedbyte)) + return(false); + slot->u.HexByte.i=parsedbyte; + CIMD_RX_ProcessRawPacket_parseparam_buf_s+=2+1; + } break; + + case CIMD_ELF_HexWord: { +unsigned parsedword; + if (0 || !isxdigit(CIMD_RX_ProcessRawPacket_parseparam_buf_s[0]) + || !isxdigit(CIMD_RX_ProcessRawPacket_parseparam_buf_s[1]) + || !isxdigit(CIMD_RX_ProcessRawPacket_parseparam_buf_s[2]) + || !isxdigit(CIMD_RX_ProcessRawPacket_parseparam_buf_s[3]) + || CIMD_MARK_SEP!=CIMD_RX_ProcessRawPacket_parseparam_buf_s[4] + ) + return(false); + if (1!=sscanf(CIMD_RX_ProcessRawPacket_parseparam_buf_s,"%X" CIMD_MARK_SEPS,&parsedword)) + return(false); + slot->u.HexWord.i=parsedword; + CIMD_RX_ProcessRawPacket_parseparam_buf_s+=4+1; + } break; + + case CIMD_ELF_Decimal: { +int parsedint; +u8 *start=CIMD_RX_ProcessRawPacket_parseparam_buf_s; + if (CIMD_MARK_SEP==*start) + return(false); /* empty Decimal not permitted */ + while (isdigit(*CIMD_RX_ProcessRawPacket_parseparam_buf_s)) + CIMD_RX_ProcessRawPacket_parseparam_buf_s++; + if (CIMD_MARK_SEP!=*CIMD_RX_ProcessRawPacket_parseparam_buf_s++) /* skip CIMD_MARK_SEP */ + return(false); + if (1!=sscanf(start,"%d" CIMD_MARK_SEPS,&parsedint)) + return(false); + slot->u.Decimal.i=parsedint; + } break; + + case CIMD_ELF_StringZ: + slot->u.StringZ.s=CIMD_RX_ProcessRawPacket_parseparam_buf_s; + while (CIMD_MARK_SEP!=*CIMD_RX_ProcessRawPacket_parseparam_buf_s) + CIMD_RX_ProcessRawPacket_parseparam_buf_s++; + *CIMD_RX_ProcessRawPacket_parseparam_buf_s++='\0'; /* skip CIMD_MARK_SEP */ + break; + + case CIMD_ELF_HexBlock: + slot->u.HexBlock.buf=CIMD_RX_ProcessRawPacket_parseparam_buf_s; + + while (CIMD_MARK_SEP!=*CIMD_RX_ProcessRawPacket_parseparam_buf_s) + CIMD_RX_ProcessRawPacket_parseparam_buf_s++; + if ((CIMD_RX_ProcessRawPacket_parseparam_buf_s-slot->u.HexBlock.buf)&1) + return(false); /* odd number of xdigits */ + + slot->u.HexBlock.len=(CIMD_RX_ProcessRawPacket_parseparam_buf_s-slot->u.HexBlock.buf); + if (!SMS_BlockFromHex(slot->u.HexBlock.buf/*d*/,slot->u.HexBlock.buf/*s*/,slot->u.HexBlock.len*2)) + return(false); /* parse error */ + + CIMD_RX_ProcessRawPacket_parseparam_buf_s++; /* skip CIMD_MARK_SEP */ + break; + + case CIMD_ELF_Empty: + if (CIMD_MARK_SEP!=*CIMD_RX_ProcessRawPacket_parseparam_buf_s) + return(false); /* some content found */ + break; + } + return(true); /* success */ +} + + +static bool CIMD_RX_EvalPatrol(const struct CIMD_RX_Patrol *patrol) +{ + if (!patrol) + return(false); /* not recognized */ + if (CIMD_RX_Packet_Cmd!=patrol->cmd) + return(false); /* not recognized */ + return((*patrol->func)()); +} + +static inline void CIMD_RX_ProcessPacket(void) +{ +const struct CIMD_RX_Patrol *patrol; + + for (patrol=CIMD_RX_Patrols;patrol",9); + write(1,CIMD_CatchBuffer+1,CIMD_CatchBufferPtr-1-(CIMD_CatchBuffer+1)); + write(1,"\n",6); +#endif + + if (CIMD_CatchBufferPtrcode==CIMD_RX_Packet_slot[0].u.HexByte.i) break; + if (cmdp>=CIMD_Cmd+CIMD_Cmdcnt) + return; /* error - unknown command */ + CIMD_RX_Packet_Cmd=(enum CIMD_Cmd_Type)(cmdp-CIMD_Cmd); + + /* "position" handling is BIP dependency! */ + for (position=1;CIMD_RX_ProcessRawPacket_parseparam_buf_sparam;paramparam+cmdp->paramcnt;param++) + if (position==param->code) + break; + if (param>=cmdp->param+cmdp->paramcnt) { /* not found - ignore */ + while (CIMD_MARK_SEP!=*CIMD_RX_ProcessRawPacket_parseparam_buf_s++); /* skip CIMD_MARK_SEP */ + continue; + } + slot=CIMD_RX_Packet_slot+1+(param-cmdp->param); + slot->code=param->code; + slot->elf=param->elf; + if (!CIMD_RX_ProcessRawPacket_parseparam(slot)) + return; /* error - unable to parse required param */ + /* CIMD_MARK_SEP is skipped by CIMD_RX_ProcessRawPacket_parseparam() automatically + */ + CIMD_RX_Packet_slots++; + } + /* The packet is now parsed */ + + CIMD_RX_ProcessPacket(); +} + +/* RX_State machine for receive handling. Called once for each character + received from the phone/phone. */ + +static void CIMD_RX_Char(char rx_byte) +{ +#ifdef CIMD_DEBUG +#if 0 + dprintf(_("Received character '%c' (0x%02X)\n"), + (!isgraph(rx_byte) ? '?' : rx_byte),(unsigned char)rx_byte); +#endif + putchar(rx_byte); +#endif + + /* NEVER store '\0' as it would knock-out completely our patrolling system! + * It is invalid anyway + */ + if (rx_byte=='\0') { + CIMD_CatchBufferReset(); + return; + } + + if (CIMD_CatchBufferPtr==CIMD_CatchBuffer && rx_byte!=CIMD_MARK_START) { + /* No haven't yet catched any START yet */ + return; + } + if (CIMD_CatchBufferPtr>=CIMD_CatchBuffer+sizeof(CIMD_CatchBuffer)) { + fprintf(stderr,_("WARNING: Incoming CIMD packet too long to fit (>%d bytes)!\n"),sizeof(CIMD_CatchBuffer)); + CIMD_CatchBufferReset(); + } + + *CIMD_CatchBufferPtr++=rx_byte; + if (rx_byte==CIMD_MARK_STOP) { + CIMD_RX_ProcessRawPacket(); + CIMD_CatchBufferReset(); + } +} + +/* Here we initialise model specific functions. */ + +#define CIMD_FUNCTIONS_ENTRY(name) \ + case GOP_##name: return(CIMD_##name(data,state)); + +static GSM_Error CIMD_Functions(GSM_Operation op, GSM_Data *data, GSM_Statemachine *state) +{ +static GSM_Statemachine *catcher=NULL; + + if (!catcher || catcher==state) + catcher=state; + else + *((char *)NULL)=1; + + switch (op) { + CIMD_FUNCTIONS_ENTRY(Init) + CIMD_FUNCTIONS_ENTRY(Terminate) + CIMD_FUNCTIONS_ENTRY(GetSMSStatus) + CIMD_FUNCTIONS_ENTRY(GetSMS) + CIMD_FUNCTIONS_ENTRY(SendSMS) + CIMD_FUNCTIONS_ENTRY(GetImei) + CIMD_FUNCTIONS_ENTRY(GetRevision) + CIMD_FUNCTIONS_ENTRY(GetModel) + CIMD_FUNCTIONS_ENTRY(GetManufacturer) + CIMD_FUNCTIONS_ENTRY(Reset) + + case GOP_Identify: { +GSM_Error err,r=GE_NONE; + if (GE_NONE!=(err=CIMD_GetImei (data,state))) + r=err; + if (GE_NONE!=(err=CIMD_GetRevision (data,state))) + r=err; + if (GE_NONE!=(err=CIMD_GetModel (data,state))) + r=err; + if (GE_NONE!=(err=CIMD_GetManufacturer(data,state))) + r=err; + return(r); + } + + default: + return(GE_NOTIMPLEMENTED); + } +} + +GSM_Phone phone_cimd = { + UNIMPLEMENTED, /* IncomingFunctions - we don't use default StateMachine */ + UNIMPLEMENTED, /* DefaultFunction - we don't use default StateMachine */ + /* Mobile phone information */ + { + "BIP" /* |CIMD - not yet */, /* Supported models */ + 100, /* Max RF Level (AT+CSQ) */ + 0, /* Min RF Level (AT+CSQ) */ + GRF_Percentage, /* RF level units */ + 100, /* Max Battery Level (AT+CBC) */ + 0, /* Min Battery Level (AT+CBC) */ + GBU_Percentage, /* Battery level units */ + GDT_None, /* Have date/time support */ + GDT_None, /* Alarm supports time only */ + 0, /* No alarm available */ + 48, 84, /* Startup logo size */ + 14, 72, /* Op logo size */ + 14, 72, /* Caller logo size */ + }, + CIMD_Functions, +}; diff --git a/common/data/at-emulator.c b/common/data/at-emulator.c index 41445c8..3c2eb86 100644 --- a/common/data/at-emulator.c +++ b/common/data/at-emulator.c @@ -6,12 +6,29 @@ A Linux/Unix toolset and driver for Nokia mobile phones. + Copyright (C) 1999, 2000 Hugh Blemings & Pavel Janík ml. + Released under the terms of the GNU GPL, see file COPYING for more details. This file provides a virtual modem or "AT" interface to the GSM phone by calling code in gsm-api.c. Inspired by and in places copied from the Linux kernel AT Emulator IDSN code by Fritz Elfert and others. + $Log$ + Revision 1.1.1.5 2002/04/03 00:08:04 short + Found in "gnokii-working" directory, some November-patches version + + Revision 1.5 2001/11/08 16:34:19 pkot + Updates to work with new libsms + + Revision 1.4 2001/07/03 15:27:03 pkot + AT commands for SMS handling support (Tamas Bondar) + Small at-emulator code cleanup (me) + + Revision 1.3 2001/02/21 19:56:59 chris + More fiddling with the directory layout + + */ #define __data_at_emulator_c @@ -305,7 +322,7 @@ static GSM_Error ATEM_ReadSMS(int number, GSM_MemoryType type, GSM_SMSMessage *m GSM_Error error; message->MemoryType = type; - message->Location = number; + message->Number = number; error = GSM->GetSMSMessage(message); return error; @@ -315,13 +332,14 @@ static void ATEM_PrintSMS(char *line, GSM_SMSMessage *message, int mode) { switch (mode) { case INTERACT_MODE: - gsprintf(line, MAX_LINE_LENGTH, _("\n\rDate/time: %d/%d/%d %d:%02d:%02d Sender: %s Msg Center: %s\n\rText: %s\n\r"), message->Time.Day, message->Time.Month, message->Time.Year, message->Time.Hour, message->Time.Minute, message->Time.Second, message->Sender, message->MessageCenter.Number, message->MessageText); + gsprintf(line, MAX_LINE_LENGTH, _("\n\rDate/time: %d/%d/%d %d:%02d:%02d Sender: %s Msg Center: %s\n\rText: %s\n\r"), message->Time.Day, message->Time.Month, message->Time.Year, message->Time.Hour, message->Time.Minute, message->Time.Second, message->RemoteNumber.number, message->MessageCenter.Number, message->MessageText); break; case TEXT_MODE: - if (message->Coding==GSM_Coding_8bit) - gsprintf(line, MAX_LINE_LENGTH, _("\"%s\",\"%s\",,\"%02d/%02d/%02d,%02d:%02d:%02d+%02d\"\n\r%s"), (message->Status ? _("REC READ") : _("REC UNREAD")), message->Sender, message->Time.Year, message->Time.Month, message->Time.Day, message->Time.Hour, message->Time.Minute, message->Time.Second, message->Time.Timezone, _("")); + if ((message->DCS.Type == SMS_GeneralDataCoding) && + (message->DCS.u.General.Alphabet == SMS_8bit)) + gsprintf(line, MAX_LINE_LENGTH, _("\"%s\",\"%s\",,\"%02d/%02d/%02d,%02d:%02d:%02d+%02d\"\n\r%s"), (message->Status ? _("REC READ") : _("REC UNREAD")), message->RemoteNumber.number, message->Time.Year, message->Time.Month, message->Time.Day, message->Time.Hour, message->Time.Minute, message->Time.Second, message->Time.Timezone, _("")); else - gsprintf(line, MAX_LINE_LENGTH, _("\"%s\",\"%s\",,\"%02d/%02d/%02d,%02d:%02d:%02d+%02d\"\n\r%s"), (message->Status ? _("REC READ") : _("REC UNREAD")), message->Sender, message->Time.Year, message->Time.Month, message->Time.Day, message->Time.Hour, message->Time.Minute, message->Time.Second, message->Time.Timezone, message->MessageText); + gsprintf(line, MAX_LINE_LENGTH, _("\"%s\",\"%s\",,\"%02d/%02d/%02d,%02d:%02d:%02d+%02d\"\n\r%s"), (message->Status ? _("REC READ") : _("REC UNREAD")), message->RemoteNumber.number, message->Time.Year, message->Time.Month, message->Time.Day, message->Time.Hour, message->Time.Minute, message->Time.Second, message->Time.Timezone, message->MessageText); break; case PDU_MODE: gsprintf(line, MAX_LINE_LENGTH, _("")); @@ -336,7 +354,7 @@ static void ATEM_EraseSMS(int number, GSM_MemoryType type) { GSM_SMSMessage message; message.MemoryType = type; - message.Location = number; + message.Number = number; if (GSM->DeleteSMSMessage(&message) == GE_NONE) { ATEM_ModemResult(MR_OK); } else { @@ -552,12 +570,12 @@ bool ATEM_CommandPlusC(char **buf) strcasecmp(*buf, "3") == 0 || strcasecmp(*buf, "\"REC READ\"") == 0 || strcasecmp(*buf, "\"STO SENT\"") == 0) { - status = GSS_SENTREAD; + status = SMS_Sent; } else if (strcasecmp(*buf, "0") == 0 || strcasecmp(*buf, "2") == 0 || strcasecmp(*buf, "\"REC UNREAD\"") == 0 || strcasecmp(*buf, "\"STO UNSENT\"") == 0) { - status = GSS_NOTSENTREAD; + status = SMS_Unsent; } else if (strcasecmp(*buf, "4") == 0 || strcasecmp(*buf, "\"ALL\"") == 0) { status = 4; /* ALL */ diff --git a/common/data/datapump.c b/common/data/datapump.c index 4eede53..134bb3c 100644 --- a/common/data/datapump.c +++ b/common/data/datapump.c @@ -6,12 +6,25 @@ A Linux/Unix toolset and driver for Nokia mobile phones. + Copyright (C) 1999, 2000 Hugh Blemings & Pavel Janík ml. + Released under the terms of the GNU GPL, see file COPYING for more details. This file provides routines to handle processing of data when connected in fax or data mode. Converts data from/to GSM phone to virtual modem interface. + $Log$ + Revision 1.1.1.3 2002/04/03 00:08:04 short + Found in "gnokii-working" directory, some November-patches version + + Revision 1.3 2001/02/21 19:57:00 chris + More fiddling with the directory layout + + Revision 1.2 2001/02/17 22:40:51 chris + ATA support + + */ #define __data_datapump_c diff --git a/common/data/rlp-common.c b/common/data/rlp-common.c index 9c46e0d..e392661 100644 --- a/common/data/rlp-common.c +++ b/common/data/rlp-common.c @@ -6,6 +6,8 @@ A Linux/Unix toolset and driver for Nokia mobile phones. + Copyright (C) 1999, 2000 Hugh Blemings & Pavel Janík ml. + Released under the terms of the GNU GPL, see file COPYING for more details. The development of RLP protocol is sponsored by SuSE CR, s.r.o. (Pavel use @@ -14,6 +16,26 @@ Actual implementation of RLP protocol. Based on GSM 04.22 version 7.1.0, downloadable from www.etsi.org (if you register with them) + $Log$ + Revision 1.1.1.3 2002/04/03 00:08:05 short + Found in "gnokii-working" directory, some November-patches version + + Revision 1.5 2001/03/26 23:39:36 pkot + Minor updates: + - Windows INLINE patch (Manfred Jonsson) + - patch to configure.in to compile under FreeBSD (Panagiotis Astithas) + - other cleanups (me) + + Revision 1.4 2001/03/13 01:23:18 pkot + Windows updates (Manfred Jonsson) + + Revision 1.3 2001/02/21 19:57:00 chris + More fiddling with the directory layout + + Revision 1.2 2001/02/17 22:40:51 chris + ATA support + + */ #include diff --git a/common/data/rlp-crc24.c b/common/data/rlp-crc24.c index cc8af90..ab975c1 100644 --- a/common/data/rlp-crc24.c +++ b/common/data/rlp-crc24.c @@ -6,10 +6,20 @@ A Linux/Unix toolset and driver for Nokia mobile phones. + Copyright (C) 1999, 2000 Hugh Blemings & Pavel Janík ml. + Released under the terms of the GNU GPL, see file COPYING for more details. CRC24 (aka FCS) implementation in RLP. + $Log$ + Revision 1.1.1.3 2002/04/03 00:08:06 short + Found in "gnokii-working" directory, some November-patches version + + Revision 1.2 2001/02/21 19:57:02 chris + More fiddling with the directory layout + + */ #include "data/rlp-crc24.h" diff --git a/common/data/virtmodem.c b/common/data/virtmodem.c index 7c7f4e2..2c389f9 100644 --- a/common/data/virtmodem.c +++ b/common/data/virtmodem.c @@ -5,6 +5,8 @@ A Linux/Unix toolset and driver for Nokia mobile phones. + Copyright (C) 1999, 2000 Hugh Blemings & Pavel Janík ml. + Released under the terms of the GNU GPL, see file COPYING for more details. This file provides a virtual modem interface to the GSM phone by calling @@ -13,6 +15,39 @@ (AT-emulator) and "online" mode where the data pump code translates data from/to the GSM handset and the modem data/fax stream. + $Log$ + Revision 1.1.1.3 2002/04/03 00:08:06 short + Found in "gnokii-working" directory, some November-patches version + + Revision 1.4 2001/04/14 23:23:43 pkot + Fixed problems with grantpt + + Revision 1.3 2001/03/21 23:36:04 chris + Added the statemachine + This will break gnokii --identify and --monitor except for 6210/7110 + + Revision 1.2 2001/02/21 19:57:02 chris + More fiddling with the directory layout + + Revision 1.1 2001/02/16 14:29:51 chris + Restructure of common/. Fixed a problem in fbus-phonet.c + Lots of dprintfs for Marcin + Any size xpm can now be loaded (eg for 7110 startup logos) + nk7110 code detects 7110/6210 and alters startup logo size to suit + Moved Marcin's extended phonebook code into gnokii.c + + Revision 1.5 2001/01/08 15:11:37 pkot + Documentation updates. + Fixed some bugs and removed FIXMEs. + We need to move some stuff from configure.in to aclocal.m4 + + Revision 1.4 2001/01/02 09:09:09 pkot + Misc fixes and updates. + + Revision 1.3 2000/12/27 10:54:14 pkot + Added Unix98 PTYs support (Michael Mráka). + + */ #define __virtmodem_c @@ -49,7 +84,7 @@ /* Global variables */ -//extern bool TerminateThread; +extern bool TerminateThread; int ConnectCount; /* Local variables */ @@ -66,7 +101,7 @@ bool RequestTerminate; /* If initialised in debug mode, stdin/out is used instead of ptys for interface. */ -bool VM_Initialise(char *model,char *port, char *initlength, GSM_ConnectionType connection, char *bindir, bool debug_mode, bool GSMInit,char *synchronizetime) +bool VM_Initialise(char *model,char *port, char *initlength, GSM_ConnectionType connection, char *bindir, bool debug_mode, bool GSMInit) { int rtn; @@ -85,10 +120,9 @@ bool VM_Initialise(char *model,char *port, char *initlength, GSM_ConnectionType #ifdef DEBUG fprintf (stderr , "Initialising GSM\n"); #endif /* DEBUG */ - if ((VM_GSMInitialise(model, port, initlength, connection, synchronizetime) != GE_NONE)) { + if ((VM_GSMInitialise(model, port, initlength, connection) != GE_NONE)) { fprintf (stderr, _("VM_Initialise - VM_GSMInitialise failed!\n")); return (false); - } } GSMInit=false; @@ -241,7 +275,7 @@ void VM_CharHandler(void) /* Note that file closure etc. should have been dealt with in ThreadLoop */ if (res < 0) { -// TerminateThread=true; + TerminateThread=true; return; } @@ -250,14 +284,15 @@ void VM_CharHandler(void) } /* Initialise GSM interface, returning GSM_Error as appropriate */ -GSM_Error VM_GSMInitialise(char *model, char *port, char *initlength, GSM_ConnectionType connection, char *synchronizetime) +GSM_Error VM_GSMInitialise(char *model, char *port, char *initlength, GSM_ConnectionType connection) { int count=0; GSM_Error error; + static GSM_Statemachine sm; /* Initialise the code for the GSM interface. */ - error = GSM_Initialise(model,port, initlength, connection, RLP_DisplayF96Frame, synchronizetime); + error = GSM_Initialise(model,port, initlength, connection, RLP_DisplayF96Frame, &sm); if (error != GE_NONE) { fprintf(stderr, _("GSM/FBUS init failed! (Unknown model ?). Quitting.\n")); diff --git a/common/devices/tekram.c b/common/devices/tekram.c index 5da6097..413581c 100644 --- a/common/devices/tekram.c +++ b/common/devices/tekram.c @@ -6,6 +6,9 @@ * * A Linux/Unix toolset and driver for Nokia mobile phones. * + * Copyright (C) 1999, 2000 Hugh Blemings & Pavel Janík ml. + * Copyright (C) 2000-2001 Marcel Holtmann + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either @@ -20,23 +23,45 @@ * License along with this library; if not, write to the Free * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * + * $Log$ + * Revision 1.1.1.3 2002/04/03 00:08:06 short + * Found in "gnokii-working" directory, some November-patches version + * + * Revision 1.2 2001/02/21 19:57:03 chris + * More fiddling with the directory layout + * + * Revision 1.1 2001/02/16 14:29:51 chris + * Restructure of common/. Fixed a problem in fbus-phonet.c + * Lots of dprintfs for Marcin + * Any size xpm can now be loaded (eg for 7110 startup logos) + * nk7110 code detects 7110/6210 and alters startup logo size to suit + * Moved Marcin's extended phonebook code into gnokii.c + * + * Revision 1.2 2001/02/12 15:13:46 chris + * Fixed my bug in xgnokii_contacts.c and added to tekram.c + * + * Revision 1.1 2001/02/09 18:12:53 chris + * Marcel's tekram support + * */ #include +#include +#include +#include #include #ifndef WIN32 - #include - #include - #include - #include "devices/unixserial.h" +#include "devices/unixserial.h" #else - #include - #include "devices/winserial.h" +#include "winserial.h" #endif #include "devices/tekram.h" + + + int tekram_open(__const char *__file) { return (serial_open(__file, O_RDWR | O_NOCTTY | O_NONBLOCK)); @@ -51,9 +76,18 @@ void tekram_close(int __fd) { void tekram_reset(int __fd) { - serial_setdtrrts(__fd, 0, 0); usleep(50000); - serial_setdtrrts(__fd, 1, 0); usleep(1000); - serial_setdtrrts(__fd, 1, 1); usleep(50); + serial_setdtrrts(__fd, 0, 0); + + usleep(50000); + + serial_setdtrrts(__fd, 1, 0); + + usleep(1000); + + serial_setdtrrts(__fd, 1, 1); + + usleep(50); + serial_changespeed(__fd, 9600); } diff --git a/common/devices/unixirda.c b/common/devices/unixirda.c index cfbf39a..31beb66 100644 --- a/common/devices/unixirda.c +++ b/common/devices/unixirda.c @@ -1,10 +1,14 @@ /* * $Id$ * + * * G N O K I I * * A Linux/Unix toolset and driver for Nokia mobile phones. * + * Copyright (C) 1999, 2000 Hugh Blemings & Pavel Janík ml. + * Copyright (C) 2000-2001 Marcel Holtmann + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either @@ -19,22 +23,45 @@ * License along with this library; if not, write to the Free * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * + * $Log$ + * Revision 1.1.1.3 2002/04/03 00:08:06 short + * Found in "gnokii-working" directory, some November-patches version + * + * Revision 1.7 2001/11/08 16:49:19 pkot + * Cleanups + * + * Revision 1.6 2001/08/17 00:18:12 pkot + * Removed recv() from IrDA initializing procedure (many people) + * + * Revision 1.5 2001/06/27 23:52:48 pkot + * 7110/6210 updates (Marian Jancar) + * + * Revision 1.4 2001/06/20 21:27:34 pkot + * IrDA patch (Marian Jancar) + * + * Revision 1.3 2001/02/21 19:57:04 chris + * More fiddling with the directory layout + * + * Revision 1.2 2001/02/20 21:55:10 pkot + * Small #include updates + * + * Revision 1.1 2001/02/16 14:29:52 chris + * Restructure of common/. Fixed a problem in fbus-phonet.c + * Lots of dprintfs for Marcin + * Any size xpm can now be loaded (eg for 7110 startup logos) + * nk7110 code detects 7110/6210 and alters startup logo size to suit + * Moved Marcin's extended phonebook code into gnokii.c + * + * Revision 1.2 2001/02/06 21:15:35 chris + * Preliminary irda support for 7110 etc. Not well tested! + * + * Revision 1.1 2001/02/03 23:56:17 chris + * Start of work on irda support (now we just need fbus-irda.c!) + * Proper unicode support in 7110 code (from pkot) + * */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include "devices/unixirda.h" -#include "devices/linuxirda.h" - #ifndef AF_IRDA #define AF_IRDA 23 @@ -45,10 +72,7 @@ #define DISCOVERY_SLEEP 0.4 static char *phone[] = { - "Nokia 5210", - "Nokia 6210", "Nokia 6250", "Nokia 6310", - "Nokia 7110", - "Nokia 8210", "Nokia 8310", "Nokia 8850" + "Nokia 7110", "Nokia 6210" }; double d_time(void) @@ -77,17 +101,18 @@ double d_sleep(double s) return time; } -static int irda_discover_device(int fd) +static int irda_discover_device(void) { struct irda_device_list *list; struct irda_device_info *dev; unsigned char *buf; - int s, len, i, j; - int daddr = -1; + int s, len, i, j, daddr = -1, fd; double t1, t2; int phones = sizeof(phone) / sizeof(*phone); + fd = socket(AF_IRDA, SOCK_STREAM, 0); + len = sizeof(*list) + sizeof(*dev) * 10; // 10 = max devices in discover buf = malloc(len); list = (struct irda_device_list *)buf; @@ -104,15 +129,11 @@ static int irda_discover_device(int fd) for (j = 0; (j < phones) && (daddr == -1); j++) { if (strncmp(dev[i].info, phone[j], INFO_LEN) == 0) { daddr = dev[i].daddr; -#ifdef DEBUG - fprintf(stdout,_("%s\t%x\n"), dev[i].info, dev[i].daddr); -#endif + dprintf("%s\t%x\n", dev[i].info, dev[i].daddr); } } if (daddr == -1) { -#ifdef DEBUG - fprintf(stdout,_("unknown: %s\t%x\n"), dev[i].info, dev[i].daddr); -#endif + dprintf("unknown: %s\t%x\n", dev[i].info, dev[i].daddr); } } } @@ -126,6 +147,7 @@ static int irda_discover_device(int fd) } while ((t2 - t1 < DISCOVERY_TIMEOUT) && (daddr == -1)); free(buf); + close(fd); return daddr; } @@ -134,44 +156,24 @@ int irda_open(void) { struct sockaddr_irda peer; int fd = -1, daddr; - int pgrp; + daddr = irda_discover_device(); /* discover the devices */ - fd = socket(AF_IRDA, SOCK_STREAM, 0); /* Create socket */ - if (fd == -1) { - perror("socket"); - exit(1); - } - - /* discover the devices */ - daddr = irda_discover_device(fd); - if (daddr == -1) { - printf("irda_discover: no nokia devices found"); - exit(1); - } - - /* Arrange for the current process to receive - SIGIO when the state of the socket changes. */ - pgrp = getpid(); - if (fcntl (fd, F_SETOWN, pgrp) < 0) - perror("F_SETOWN"); - - /* Set the socket state for Asynchronous */ - if (fcntl (fd, F_SETFL, FASYNC) < 0) { - perror("fcntl"); - exit(1); - } - - peer.sir_family = AF_IRDA; - peer.sir_lsap_sel = LSAP_ANY; - peer.sir_addr = daddr; - strcpy(peer.sir_name, "Nokia:PhoNet"); + if (daddr != -1) { + fd = socket(AF_IRDA, SOCK_STREAM, 0); /* Create socket */ + peer.sir_family = AF_IRDA; + peer.sir_lsap_sel = LSAP_ANY; + peer.sir_addr = daddr; + strcpy(peer.sir_name, "Nokia:PhoNet"); - if (connect(fd, (struct sockaddr *)&peer, sizeof(peer))) { /* Connect to service "Nokia:PhoNet" */ - perror("connect"); - close(fd); - fd = -1; + if (connect(fd, (struct sockaddr *)&peer, sizeof(peer))) { /* Connect to service "Nokia:PhoNet" */ + perror("connect"); + close(fd); + fd = -1; +/* } else { FIXME: It does not work in most cases. Why? Or why it should work? + recv(fd, NULL, 0, 0); call recv first to make select work correctly */ } + } return fd; } @@ -184,20 +186,7 @@ int irda_close(int fd) int irda_write(int __fd, __const __ptr_t __bytes, int __size) { - int actual,ret; - - actual = 0; - - do { - if ((ret = send(__fd, __bytes, __size - actual, 0)) < 0) - return(actual); - - actual += ret; - __bytes += ret; - - } while (actual < __size); - - return (actual); + return (send(__fd, __bytes, __size, 0)); } int irda_read(int __fd, __ptr_t __bytes, int __size) diff --git a/common/devices/unixserial.c b/common/devices/unixserial.c index bc7e37e..9594d89 100644 --- a/common/devices/unixserial.c +++ b/common/devices/unixserial.c @@ -6,11 +6,47 @@ A Linux/Unix toolset and driver for Nokia mobile phones. + Copyright (C) 1999, 2000 Hugh Blemings & Pavel Janík ml. + Released under the terms of the GNU GPL, see file COPYING for more details. + $Log$ + Revision 1.1.1.5 2002/04/03 00:08:07 short + Found in "gnokii-working" directory, some November-patches version + + Revision 1.9 2001/09/14 12:15:28 pkot + Cleanups from 0.3.3 (part1) + + Revision 1.8 2001/08/20 23:27:37 pkot + Add hardware shakehand to the link layer (Manfred Jonsson) + + Revision 1.7 2001/07/03 00:03:36 pkot + Small fixes to let gnokii compile and work under solaris (thanks to Artur Kubiak) + + Revision 1.6 2001/03/21 23:36:04 chris + Added the statemachine + This will break gnokii --identify and --monitor except for 6210/7110 + + Revision 1.5 2001/03/19 23:43:46 pkot + Solaris/ *BSD '#if defined' cleanup + + Revision 1.4 2001/03/13 01:21:38 pkot + *BSD updates (Bert Driehuis) + + Revision 1.3 2001/03/06 22:27:46 pkot + Misc docs and Makefiles updates and cleanups + + Revision 1.2 2001/02/21 19:57:05 chris + More fiddling with the directory layout + + */ +/* [global] option "serial_write_usleep" default: */ +#define SERIAL_WRITE_USLEEP_DEFAULT (-1) + #include "misc.h" +#include "cfgreader.h" /* Do not compile this file under Win32 systems. */ @@ -20,6 +56,12 @@ #include #include #include +#include +#include +#include +#include +#include +#include #if __unices__ # include @@ -64,12 +106,91 @@ struct termios serial_termios; +/* Script handling: */ + +static void device_script_cfgfunc(const char *section,const char *key,const char *value) +{ + setenv(key,value,1/*overwrite*/); /* errors ignored */ +} + +static int device_script(int fd, const char *section) +{ +pid_t pid; +const char *scriptname = CFG_Get(CFG_Info, "global", section); + + if (!scriptname) + return(0); + + errno=0; + switch ((pid=fork())) { + case -1: + fprintf(stderr,_("device_script(\"%s\"): fork() failure: %s!\n"),scriptname,strerror(errno)); + return(-1); + + default: { /* parent */ +int status; + if (pid==waitpid(pid,&status,0/*options*/) && WIFEXITED(status) && !WEXITSTATUS(status)) + return(0); + fprintf(stderr,_("device_script(\"%s\"): child script failure: %s, exit code=%d\n"),scriptname, + (WIFEXITED(status) ? _("normal exit") : _("abnormal exit")), + (WIFEXITED(status) ? WEXITSTATUS(status) : -1)); + errno=EIO; + return(-1); + } + + case 0: { /* child */ + CFG_GetForeach(CFG_Info,section,device_script_cfgfunc); + errno=0; + if (0!=dup2(fd,0) || 1!=dup2(fd,1) || close(fd)) { + fprintf(stderr,_("device_script(\"%s\"): file descriptor prepare: %s\n"),scriptname,strerror(errno)); + _exit(-1); + } + /* FIXME: close all open descriptors - how to track them? + */ + execl("/bin/sh","sh","-c",scriptname,NULL); + fprintf(stderr,_("device_script(\"%s\"): execute script: %s\n"),scriptname,strerror(errno)); + _exit(-1); + /* NOTREACHED */ + } + } + /* NOTREACHED */ +} + +int serial_close_all_openfds[0x10]; /* -1 when entry not used, fd otherwise */ +int serial_close(int __fd); + +static void serial_close_all(void) +{ + int i; + + dprintf("serial_close_all() executed\n"); + for (i=0;i= 0) { +#if 1 /* HACK */ + serial_termios.c_cflag |= HUPCL; /* production == 1 */ +#else + serial_termios.c_cflag &= ~HUPCL; /* debugging == 0 */ +#endif - if (__fd >= 0) tcsetattr(__fd, TCSANOW, &serial_termios); + } return (close(__fd)); } -/* Open a device with standard options. */ - +/* Open a device with standard options. + * Use value (-1) for "__with_hw_handshake" if its specification is required from the user + */ int serial_opendevice(__const char *__file, int __with_odd_parity, int __with_async, int __with_hw_handshake) { int fd; int retcode; struct termios tp; + /* handle config file handshake override: */ + { +char *s=CFG_Get(CFG_Info, "global", "handshake"); + + if (s && (!strcasecmp(s,"software") || !strcasecmp(s,"rtscts"))) + __with_hw_handshake=false; + else if (s && (!strcasecmp(s,"hardware") || !strcasecmp(s,"xonxoff"))) + __with_hw_handshake=true; + else if (s) + fprintf(stderr,_("Unrecognized [%s] option \"%s\", use \"%s\" or \"%s\" value, ignoring!"), + "global","handshake","software","hardware"); + + if (__with_hw_handshake==-1) { + fprintf(stderr,_("[%s] option \"%s\" not found, trying to use \"%s\" value!"), + "global","handshake","software"); + __with_hw_handshake=false; + } + } + /* Open device */ + /* O_NONBLOCK MUST be used here as the CLOCAL may be currently off + * and if DCD is down the "open" syscall would be stuck wating for DCD. + */ fd = serial_open(__file, O_RDWR | O_NOCTTY | O_NONBLOCK); if (fd < 0) return fd; - /* Allow process/thread to receive SIGIO */ - -#if !(__unices__) - retcode = fcntl(fd, F_SETOWN, getpid()); - if (retcode == -1){ - perror("Gnokii serial_opendevice: fnctl(F_SETOWN)"); - serial_close(fd); - return(-1); - } -#endif - - /* Make filedescriptor asynchronous. */ - - if (__with_async) { - retcode=fcntl(fd, F_SETFL, FASYNC); - if (retcode == -1){ - perror("Gnokii serial_opendevice: fnctl(F_SETFL)"); - serial_close(fd); - return(-1); - } - } - /* Initialise the port settings */ memcpy(&tp, &serial_termios, sizeof(struct termios)); /* Set port settings for canonical input processing */ - tp.c_cflag = B0 | CS8 | CLOCAL | CREAD; + tp.c_cflag = B0 | CS8 | CLOCAL | CREAD | HUPCL; if (__with_odd_parity) { tp.c_cflag |= (PARENB | PARODD); tp.c_iflag = 0; @@ -172,6 +317,61 @@ int serial_opendevice(__const char *__file, int __with_odd_parity, int __with_as return(-1); } + /* Set speed */ + { +char *baudratestring=CFG_Get(CFG_Info, "global", "serial_baudrate"); +int baudrate=0; + + if (baudratestring) + baudrate=atoi(baudratestring); + if (baudrate && !serial_changespeed(fd,baudrate)) + baudrate=0; + if (!baudrate) + serial_changespeed(fd,19200/*default value*/); + } + + /* We need to turn off O_NONBLOCK now (we have CLOCAL set so it is safe). + * When we run some device script it really doesn't expect NONBLOCK! + */ + + retcode=fcntl(fd, F_SETFL, 0); + if (retcode == -1){ + perror("Gnokii serial_opendevice: fnctl(F_SETFL)"); + serial_close(fd); + return(-1); + } + + /* handle config file connect_script: + */ + if (-1 == device_script(fd,"connect_script")) { + fprintf(stderr,"Gnokii serial_opendevice: connect_script\n"); + serial_close(fd); + return(-1); + } + + /* Allow process/thread to receive SIGIO */ + +#if !(__unices__) + retcode = fcntl(fd, F_SETOWN, getpid()); + if (retcode == -1){ + perror("Gnokii serial_opendevice: fnctl(F_SETOWN)"); + serial_close(fd); + return(-1); + } +#endif + + /* Make filedescriptor asynchronous. */ + + /* We need to supply FNONBLOCK (or O_NONBLOCK) again as it would get reset + * by F_SETFL as a side-effect! + */ + retcode=fcntl(fd, F_SETFL, (__with_async ? FASYNC : 0) | FNONBLOCK); + if (retcode == -1){ + perror("Gnokii serial_opendevice: fnctl(F_SETFL)"); + serial_close(fd); + return(-1); + } + return fd; } @@ -183,13 +383,17 @@ void serial_setdtrrts(int __fd, int __dtr, int __rts) { flags = TIOCM_DTR; - if (__dtr) ioctl(__fd, TIOCMBIS, &flags); - else ioctl(__fd, TIOCMBIC, &flags); + if (__dtr) + ioctl(__fd, TIOCMBIS, &flags); + else + ioctl(__fd, TIOCMBIC, &flags); flags = TIOCM_RTS; - if (__rts) ioctl(__fd, TIOCMBIS, &flags); - else ioctl(__fd, TIOCMBIC, &flags); + if (__rts) + ioctl(__fd, TIOCMBIS, &flags); + else + ioctl(__fd, TIOCMBIC, &flags); } @@ -205,9 +409,12 @@ int serial_select(int fd, struct timeval *timeout) { } -/* Change the speed of the serial device. */ +/* Change the speed of the serial device. + * RETURNS: Success + */ -void serial_changespeed(int __fd, int __speed) { +bool serial_changespeed(int __fd, int __speed) { + bool retcode = true; #ifndef SGTTY struct termios t; @@ -223,30 +430,36 @@ void serial_changespeed(int __fd, int __speed) { case 38400: speed = B38400; break; case 57600: speed = B57600; break; case 115200: speed = B115200; break; + default: + fprintf(stderr,_("Serial port speed %d not supported!\n"),__speed); + return(false); } #ifndef SGTTY - tcgetattr(__fd, &t); + if (tcgetattr(__fd, &t)) + retcode = false; // This is not needed! We set up the speed via cfsetspeed // t.c_cflag &= ~CBAUD; // t.c_cflag |= speed; -#ifdef DEBUG - if (cfsetspeed(&t, speed) == -1) - fprintf(stdout,_("Serial port speed setting failed\n")); -#else - cfsetspeed(&t, speed); -#endif + if (cfsetspeed(&t, speed) == -1) { + dprintf(_("Serial port speed setting failed\n")); + retcode = false; + } tcsetattr(__fd, TCSADRAIN, &t); #else - ioctl(__fd, TIOCGETP, &t); + if (ioctl(__fd, TIOCGETP, &t)) + retcode = false; t.sg_ispeed = speed; t.sg_ospeed = speed; - ioctl(__fd, TIOCSETN, &t); + if (ioctl(__fd, TIOCSETN, &t)) + retcode = false; #endif + + return(retcode); } /* Read from serial device. */ @@ -256,11 +469,65 @@ size_t serial_read(int __fd, __ptr_t __buf, size_t __nbytes) { return (read(__fd, __buf, __nbytes)); } +#if !defined(TIOCMGET) && defined(TIOCMODG) +#define TIOCMGET TIOCMODG +#endif + +static void check_dcd(int __fd) +{ +#ifdef TIOCMGET +int mcs; + + if (ioctl(__fd, TIOCMGET, &mcs) || !(mcs & TIOCM_CAR)) { + fprintf(stderr,_("ERROR: Modem DCD is down and global/require_dcd parameter is set!\n")); + exit(EXIT_FAILURE); /* Hard quit of all threads */ + } +#else + /* Impossible!! (eg. Coherent) */ +#endif +} + /* Write to serial device. */ size_t serial_write(int __fd, __const __ptr_t __buf, size_t __n) { - - return (write(__fd, __buf, __n)); + +size_t r=0; +ssize_t got; +static long serial_write_usleep=LONG_MIN; +static int require_dcd=-1; + + if (serial_write_usleep==LONG_MIN) { +char *s=CFG_Get(CFG_Info, "global", "serial_write_usleep"); + + serial_write_usleep=(!s ? + SERIAL_WRITE_USLEEP_DEFAULT : atol(CFG_Get(CFG_Info, "global", "serial_write_usleep"))); + } + + if (require_dcd==-1) { + require_dcd=(!!CFG_Get(CFG_Info, "global", "require_dcd")); +#ifndef TIOCMGET + if (require_dcd) + fprintf(stderr,_("WARNING: global/require_dcd argument was set but it is not supported on this system!\n")); +#endif + } + + if (require_dcd) + check_dcd(__fd); + + if (serial_write_usleep<0) + return(write(__fd, __buf, __n)); + + while (__n>0) { + got=write(__fd, __buf, 1); + if (got<=0) + return((!r ? -1 : r)); + __buf++; + __n--; + r++; + if (serial_write_usleep) + usleep(serial_write_usleep); + } + return(r); } #endif /* WIN32 */ diff --git a/common/fbus-6110.c b/common/fbus-6110.c index 0eacb4a..5e827ee 100644 --- a/common/fbus-6110.c +++ b/common/fbus-6110.c @@ -17,8 +17,8 @@ and 6110. $Log$ - Revision 1.1.1.1 2001/11/25 21:59:03 short - :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001 + Revision 1.1.1.2 2002/04/03 00:07:54 short + Found in "gnokii-working" directory, some November-patches version Revision 1.136 2001/08/20 23:27:37 pkot Add hardware shakehand to the link layer (Manfred Jonsson) @@ -206,7 +206,6 @@ GSM_Functions FB61_Functions = { FB61_GetBitmap, FB61_SetBitmap, FB61_SetRingTone, - FB61_SendRingTone, FB61_Reset, FB61_GetProfile, FB61_SetProfile, @@ -240,31 +239,6 @@ GSM_Information FB61_Information = { 14, 72 /* Caller logo size */ }; -unsigned char GSM_Default_Alphabet[] = { - - /* ETSI GSM 03.38, version 6.0.1, section 6.2.1; Default alphabet */ - /* Characters in hex position 10, [12 to 1a] and 24 are not present on - latin1 charset, so we cannot reproduce on the screen, however they are - greek symbol not present even on my Nokia */ - - '@', 0xa3, '$', 0xa5, 0xe8, 0xe9, 0xf9, 0xec, - 0xf2, 0xc7, '\n', 0xd8, 0xf8, '\r', 0xc5, 0xe5, - '?', '_', '?', '?', '?', '?', '?', '?', - '?', '?', '?', '?', 0xc6, 0xe6, 0xdf, 0xc9, - ' ', '!', '\"', '#', 0xa4, '%', '&', '\'', - '(', ')', '*', '+', ',', '-', '.', '/', - '0', '1', '2', '3', '4', '5', '6', '7', - '8', '9', ':', ';', '<', '=', '>', '?', - 0xa1, 'A', 'B', 'C', 'D', 'E', 'F', 'G', - 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', - 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', - 'X', 'Y', 'Z', 0xc4, 0xd6, 0xd1, 0xdc, 0xa7, - 0xbf, 'a', 'b', 'c', 'd', 'e', 'f', 'g', - 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', - 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', - 'x', 'y', 'z', 0xe4, 0xf6, 0xf1, 0xfc, 0xe0 -}; - const char *FB61_MemoryType_String [] = { "", /* 0x00 */ "MT", /* 0x01 */ @@ -331,7 +305,6 @@ static GSM_Error CurrentSpeedDialError; static GSM_SMSMessage *CurrentSMSMessage; static GSM_Error CurrentSMSMessageError; -static int CurrentSMSPointer; static GSM_MemoryStatus *CurrentMemoryStatus; static GSM_Error CurrentMemoryStatusError; @@ -1052,93 +1025,6 @@ void FB61_Terminate(void) #endif } -#define ByteMask ((1 << Bits) - 1) - -int UnpackEightBitsToSeven(int offset, int in_length, int out_length, - unsigned char *input, unsigned char *output) -{ - unsigned char *OUT = output; /* Current pointer to the output buffer */ - unsigned char *IN = input; /* Current pointer to the input buffer */ - unsigned char Rest = 0x00; - int Bits; - - Bits = offset ? offset : 7; - - while ((IN - input) < in_length) { - - *OUT = ((*IN & ByteMask) << (7 - Bits)) | Rest; - Rest = *IN >> Bits; - - /* If we don't start from 0th bit, we shouldn't go to the - next char. Under *OUT we have now 0 and under Rest - - _first_ part of the char. */ - if ((IN != input) || (Bits == 7)) OUT++; - IN++; - - if ((OUT - output) >= out_length) break; - - /* After reading 7 octets we have read 7 full characters but - we have 7 bits as well. This is the next character */ - if (Bits == 1) { - *OUT = Rest; - OUT++; - Bits = 7; - Rest = 0x00; - } else { - Bits--; - } - } - - return OUT - output; -} - -unsigned char GetAlphabetValue(unsigned char value) -{ - unsigned char i; - - if (value == '?') return 0x3f; - - for (i = 0 ; i < 128 ; i++) - if (GSM_Default_Alphabet[i] == value) - return i; - - return 0x3f; /* '?' */ -} - -int PackSevenBitsToEight(int offset, unsigned char *input, unsigned char *output) -{ - unsigned char *OUT = output; /* Current pointer to the output buffer */ - unsigned char *IN = input; /* Current pointer to the input buffer */ - int Bits; /* Number of bits directly copied to - the output buffer */ - Bits = (7 + offset) % 8; - - /* If we don't begin with 0th bit, we will write only a part of the - first octet */ - if (offset) { - *OUT = 0x00; - OUT++; - } - - while ((IN - input) < strlen(input)) { - unsigned char Byte = GetAlphabetValue(*IN); - - *OUT = Byte >> (7 - Bits); - /* If we don't write at 0th bit of the octet, we should write - a second part of the previous octet */ - if (Bits != 7) - *(OUT-1) |= (Byte & ((1 << (7-Bits)) - 1)) << (Bits+1); - - Bits--; - - if (Bits == -1) Bits = 7; - else OUT++; - - IN++; - } - return (OUT - output); -} - GSM_Error FB61_GetRFLevel(GSM_RFUnits *units, float *level) { /* FIXME - these values are from 3810 code, may be incorrect. Map from @@ -1621,55 +1507,9 @@ GSM_Error FB61_DeleteSMSMessage(GSM_SMSMessage *message) return wait_on(&CurrentSMSMessageError, 50); } -/* This function implements packing of numbers (SMS Center number and - destination number) for SMS sending function. */ - -int SemiOctetPack(char *Number, unsigned char *Output) -{ - unsigned char *IN = Number; /* Pointer to the input number */ - unsigned char *OUT = Output; /* Pointer to the output */ - int count = 0; /* This variable is used to notify us about count of already - packed numbers. */ - - /* The first byte in the Semi-octet representation of the address field is - the Type-of-Address. This field is described in the official GSM - specification 03.40 version 5.3.0, section 9.1.2.5, page 33. We support - only international and unknown number. */ - - if (*IN == '+') { - *OUT++ = GNT_INTERNATIONAL; /* International number */ - IN++; - } else *OUT++ = GNT_UNKNOWN; /* Unknown number */ - - /* The next field is the number. It is in semi-octet representation - see - GSM scpecification 03.40 version 5.3.0, section 9.1.2.3, page 31. */ - - while (*IN) { - if (count & 0x01) { - *OUT = *OUT | ((*IN - '0') << 4); - OUT++; - } - else - *OUT = *IN - '0'; - count++; IN++; - } - - /* We should also fill in the most significant bits of the last byte with - 0x0f (1111 binary) if the number is represented with odd number of - digits. */ - - if (count & 0x01) { - *OUT=*OUT | 0xf0; - OUT++; - return (2 * (OUT - Output - 1) - 1); - } - - return (2 * (OUT - Output - 1)); -} - /* The second argument is the size of the data in octets, excluding User Data Header - important only for 8bit data */ -GSM_Error FB61_SendSMSMessage(GSM_SMSMessage *SMS, int data_size) +GSM_Error FB61_SendSMSMessage(GSM_SMSMessage *SMS) { GSM_Error error; @@ -1710,7 +1550,7 @@ GSM_Error FB61_SendSMSMessage(GSM_SMSMessage *SMS, int data_size) } dprintf(_("Sending SMS to %s via message center %s\n"), SMS->Destination, SMS->MessageCenter.Number); - if (SMS->UDHType) { + if (SMS->UDHPresent) { /* offset - length of the user data header */ offset = 1 + SMS->UDH[0]; /* we copy the udh and set the mask for the indicator */ @@ -1724,25 +1564,25 @@ GSM_Error FB61_SendSMSMessage(GSM_SMSMessage *SMS, int data_size) } /* size is the length of the data in octets including udh */ - /* SMS->Length is: + /* req[22] is: - integer representation of the number od octets within the user data when UD is coded using 8bit data - the sum of the number of septets in UDH including any padding and number of septets in UD in other case */ + + size = offset; /* offset now denotes UDH length */ if (SMS->EightBit) { - memcpy(req + 42 + offset, SMS->MessageText, data_size); - SMS->Length = size = data_size + offset; + memcpy(req + 42 + offset, SMS->MessageText, SMS->MessageTextLength); /* the mask for the 8-bit data */ req[21] |= 0xf4; + size += SMS->MessageTextLength; + req[22] = size; } else { - size = PackSevenBitsToEight((7-offset)%7, SMS->MessageText, req + 42 + offset); - size += offset; - SMS->Length = (offset*8 + ((7-offset)%7)) / 7 + strlen(SMS->MessageText); + size += PackSevenBitsToEight((7-offset)%7, SMS->MessageText, req + 42 + offset); + req[22] = (offset*8 +6/*round-up*/)/7 +strlen(SMS->MessageText)*7; } - req[22] = SMS->Length; - CurrentSMSMessageError=GE_BUSY; req[6] = SemiOctetPack(SMS->MessageCenter.Number, req+7); @@ -1770,34 +1610,13 @@ GSM_Error FB61_SendSMSMessage(GSM_SMSMessage *SMS, int data_size) req[23] = SemiOctetPack(SMS->Destination, req+24); /* TP-Validity Period handling */ - - /* FIXME: error-checking for correct Validity - it should not be bigger then - 63 weeks and smaller then 5minutes. We should also test intervals because - the SMS->Validity to TP-VP is not continuos. I think that the simplest - solution will be an array of correct values. We should parse it and if we - find the closest TP-VP value we should use it. Or is it good to take - closest smaller TP-VP as we do now? I think it is :-) */ - - /* 5 minutes intervals up to 12 hours = 720 minutes */ - if (SMS->Validity <= 720) - req[35] = (unsigned char) (SMS->Validity/5)-1; - - /* 30 minutes intervals up to 1 day */ - else if ((SMS->Validity > 720) && (SMS->Validity <= 1440)) - req[35] = (unsigned char) ((SMS->Validity-720)/30)+143; - - /* 1 day intervals up to 30 days */ - else if ((SMS->Validity > 1440) && (SMS->Validity <= 43200)) - req[35] = (unsigned char) (SMS->Validity/1440)+166; - - /* 1 week intervals up to 63 weeks */ - else if ((SMS->Validity > 43200) && (SMS->Validity <= 635040)) - req[35] = (unsigned char) (SMS->Validity/10080)+192; + req[35] = SMS_Validity_to_VP(SMS->Validity); FB61_TX_SendMessage(42+size, 0x02, req); return wait_on(&CurrentSMSMessageError, 70); } +/* FIXME: UDH & EightBit not implemented yet */ GSM_Error FB61_SaveSMSMessage(GSM_SMSMessage *SMS) { unsigned char req[256] = { @@ -1840,7 +1659,7 @@ GSM_Error FB61_SaveSMSMessage(GSM_SMSMessage *SMS) return(GE_SMSTOOLONG); /* size is the length of the data in octets including udh */ - /* SMS->Length is: + /* req[24] is: - integer representation of the number od octets within the user data when UD is coded using 8bit data - the sum of the number of septets in UDH including any padding and number of septets in UD in other case */ @@ -1848,9 +1667,9 @@ GSM_Error FB61_SaveSMSMessage(GSM_SMSMessage *SMS) /* offset now denotes UDH length */ size = PackSevenBitsToEight((7-offset)%7, SMS->MessageText, req + 44 + offset); size += offset; - SMS->Length = (offset*8 + ((7-offset)%7)) / 7 + strlen(SMS->MessageText); - req[24] = SMS->Length; + req[24] = (offset*8 + ((7-offset)%7)) / 7 + strlen(SMS->MessageText); + FB61_TX_SendMessage(44+size, 0x14, req); return wait_on(&CurrentSMSMessageError, 70); } @@ -2066,56 +1885,6 @@ GSM_Error FB61_SetRingTone(GSM_Ringtone *ringtone) return (GE_NONE); } -GSM_Error FB61_SendRingTone(GSM_Ringtone *ringtone, char *dest) -{ - GSM_SMSMessage SMS; - GSM_Error error; - - int size = GSM_MAX_RINGTONE_PACKAGE_LENGTH; - char Package[GSM_MAX_RINGTONE_PACKAGE_LENGTH]; - char udh[] = { - 0x06, /* User Data Header Length */ - 0x05, /* IEI */ - 0x04, /* IEDL */ - 0x15, 0x81, /* Destination port */ - 0x15, 0x81 /* Originator port, only - to fill in the two - bytes :-) */ - }; - - /* Default settings for SMS message: - - no delivery report - - Class Message 1 - - no compression - - 8 bit data - - SMSC no. 1 - - validity 3 days - - set UserDataHeaderIndicator - */ - - SMS.Type = GST_MO; - SMS.Class = 1; - SMS.Compression = false; - SMS.EightBit = true; - SMS.MessageCenter.No = 1; - SMS.Validity = 4320; /* 4320 minutes == 72 hours */ - - SMS.UDHType = GSM_RingtoneUDH; - - strcpy(SMS.Destination, dest); - GSM_PackRingtone(ringtone, Package, &size); - memcpy(SMS.UDH, udh, 7); - memcpy(SMS.MessageText, Package, size); - - /* Send the message. */ - error = FB61_SendSMSMessage(&SMS, size); - - if (error == GE_SMSSENDOK) dprintf(_("Send succeeded!\n")); - else dprintf(_("SMS Send failed (error=%d)\n"), error); - - return (GE_NONE); -} - GSM_Error FB61_Reset(unsigned char type) { unsigned char req[4] = { 0x00,0x01,0x64,0x03 }; @@ -2230,28 +1999,6 @@ void FB61_SigHandler(int status) } #endif /* WIN32 */ -char *FB61_GetBCDNumber(u8 *Number) -{ - static char Buffer[20] = ""; - - /* This is the length of BCD coded number */ - int length = Number[0]; - int count; - - if (Number[1] == 0x91) sprintf(Buffer, "+"); - else Buffer[0] = '\0'; - - for (count = 0; count < length-1; count++) { - int Digit; - Digit = Number[count+2] & 0x0f; - if (Digit < 10) sprintf(Buffer, "%s%d", Buffer, Digit); - Digit = Number[count+2] >> 4; - if (Digit < 10) sprintf(Buffer, "%s%d", Buffer, Digit); - } - - return Buffer; -} - char *FB61_GetPackedDateTime(u8 *Number) { static char Buffer[20] = ""; @@ -2414,11 +2161,11 @@ enum FB61_RX_States FB61_RX_DispatchMessage(void) case 0x10: dprintf(_("Message: SMS Message Received\n")); - dprintf(_(" SMS center number: %s\n"), FB61_GetBCDNumber(MessageBuffer+7)); + dprintf(_(" SMS center number: %s\n"), SEMIOCTETUNPACK_STATIC_BYTES(MessageBuffer+7)); MessageBuffer[23] = (MessageBuffer[23]+1)/2+1; - dprintf(_(" Remote number: %s\n"), FB61_GetBCDNumber(MessageBuffer+23)); + dprintf(_(" Remote number: %s\n"), SEMIOCTETUNPACK_STATIC_BYTES(MessageBuffer+23)); dprintf(_(" Date: %s\n"), FB61_GetPackedDateTime(MessageBuffer+35)); dprintf(_(" SMS: ")); @@ -2462,7 +2209,7 @@ enum FB61_RX_States FB61_RX_DispatchMessage(void) CurrentMessageCenter->Format = MessageBuffer[6]; CurrentMessageCenter->Validity = MessageBuffer[8]; sprintf(CurrentMessageCenter->Name, "%s", MessageBuffer+33); - sprintf(CurrentMessageCenter->Number, "%s", FB61_GetBCDNumber(MessageBuffer+21)); + sprintf(CurrentMessageCenter->Number, "%s", SEMIOCTETUNPACK_STATIC_BYTES(MessageBuffer+21)); dprintf(_("Message: SMS Center received:\n")); dprintf(_(" %d. SMS Center name is %s\n"), CurrentMessageCenter->No, CurrentMessageCenter->Name); @@ -3281,35 +3028,7 @@ enum FB61_RX_States FB61_RX_DispatchMessage(void) CurrentSMSMessage->Status = GSS_SENTREAD; off = 0; - if (MessageBuffer[20] & 0x40) { - switch (MessageBuffer[40+offset]) { - case 0x00: /* concatenated messages */ - dprintf(_("Concatenated message!!!\n")); - CurrentSMSMessage->UDHType = GSM_ConcatenatedMessages; - if (MessageBuffer[41+offset] != 0x03) { - /* should be some error */ - } - break; - case 0x05: /* logos */ - switch (MessageBuffer[43+offset]) { - case 0x82: - CurrentSMSMessage->UDHType = GSM_OpLogo; - break; - case 0x83: - CurrentSMSMessage->UDHType = GSM_CallerIDLogo; - break; - } - break; - default: - break; - } - /* Skip user data header when reading data */ - off = (MessageBuffer[39+offset] + 1); - for (i = 0; i < off; i++) - CurrentSMSMessage->UDH[i] = MessageBuffer[39+offset+i]; - } else { - CurrentSMSMessage->UDHType = GSM_NoUDH; - } + CurrentSMSMessage->UDHPresent=!!(MessageBuffer[20] & 0x40); MessageBuffer[20+offset] = (MessageBuffer[20+offset]+1)/2+1; @@ -3359,8 +3078,8 @@ enum FB61_RX_States FB61_RX_DispatchMessage(void) } dprintf("\n"); } - dprintf(_(" SMS center number: %s\n"), FB61_GetBCDNumber(MessageBuffer + 8)); - dprintf(_(" Remote number: %s\n"), FB61_GetBCDNumber(MessageBuffer + 20 + offset)); + dprintf(_(" SMS center number: %s\n"), SEMIOCTETUNPACK_STATIC_BYTES(MessageBuffer + 8)); + dprintf(_(" Remote number: %s\n"), SEMIOCTETUNPACK_STATIC_BYTES(MessageBuffer + 20 + offset)); break; } @@ -3380,28 +3099,29 @@ enum FB61_RX_States FB61_RX_DispatchMessage(void) CurrentSMSMessage->Time.Timezone = (10 * (MessageBuffer[38+offset] & 0x07) + (MessageBuffer[38+offset] >> 4)) / 4; if (MessageBuffer[38+offset] & 0x08) CurrentSMSMessage->Time.Timezone = -CurrentSMSMessage->Time.Timezone; - strcpy(CurrentSMSMessage->Sender, FB61_GetBCDNumber(MessageBuffer + 20 + offset)); - strcpy(CurrentSMSMessage->MessageCenter.Number, FB61_GetBCDNumber(MessageBuffer + 8)); + strcpy(CurrentSMSMessage->Sender, SEMIOCTETUNPACK_STATIC_BYTES(MessageBuffer + 20 + offset)); + strcpy(CurrentSMSMessage->MessageCenter.Number, SEMIOCTETUNPACK_STATIC_BYTES(MessageBuffer + 8)); } if (CurrentSMSMessage->Type != GST_DR) { /* 8bit SMS */ if ((MessageBuffer[18+offset] & 0xf4) == 0xf4) { CurrentSMSMessage->EightBit = true; - tmp=CurrentSMSMessage->Length=MessageBuffer[19+offset]; + tmp=MessageBuffer[19+offset]; offset += off; memcpy(output, MessageBuffer - 39 - offset - 2, tmp - offset); /* 7bit SMS */ } else { CurrentSMSMessage->EightBit = false; - CurrentSMSMessage->Length=MessageBuffer[19+offset] - (off * 8 + ((7-off)%7)) / 7; + tmp=MessageBuffer[19+offset] - (off * 8 + ((7-off)%7)) / 7; offset += off; - tmp=UnpackEightBitsToSeven((7-off)%7, MessageLength - 39 - offset - 2, CurrentSMSMessage->Length, MessageBuffer + 39 + offset, output); + tmp=UnpackEightBitsToSeven((7-off)%7, MessageLength - 39 - offset - 2, tmp, MessageBuffer + 39 + offset, output); } for (i = 0; i < tmp;i++) { dprintf("%c", GSM_Default_Alphabet[output[i]]); CurrentSMSMessage->MessageText[i] = GSM_Default_Alphabet[output[i]]; } + CurrentSMSMessage->MessageTextLength = tmp; } else { /* CurrentSMSMessage->Type == GST_DR (Delivery Report) */ /* SMSC Response time */ CurrentSMSMessage->SMSCTime.Year = 10 * (MessageBuffer[39+offset] & 0x0f) + (MessageBuffer[39+offset] >> 4); @@ -3425,7 +3145,6 @@ enum FB61_RX_States FB61_RX_DispatchMessage(void) dprintf(_("SM replaced by the SC")); break; } - CurrentSMSMessage->Length = tmp = 10; } else if (MessageBuffer[22] & 0x40) { strcpy(CurrentSMSMessage->MessageText, _("Failed")); @@ -3496,7 +3215,6 @@ enum FB61_RX_States FB61_RX_DispatchMessage(void) break; } } - CurrentSMSMessage->Length = tmp = 6; } else if (MessageBuffer[22] & 0x20) { strcpy(CurrentSMSMessage->MessageText, _("Pending")); @@ -3525,20 +3243,17 @@ enum FB61_RX_States FB61_RX_DispatchMessage(void) dprintf(_("Reserved/Specific to SC: %x"), MessageBuffer[22]); break; } - CurrentSMSMessage->Length = tmp = 7; } else { strcpy(CurrentSMSMessage->MessageText, _("Unknown")); /* more detailed reason only for debug */ dprintf(_("Reserved/Specific to SC: %x"), MessageBuffer[22]); - CurrentSMSMessage->Length = tmp = 8; } + CurrentSMSMessage->MessageTextLength = strlen(CurrentSMSMessage->MessageText); } - CurrentSMSMessage->MessageText[CurrentSMSMessage->Length] = 0; + CurrentSMSMessage->MessageText[CurrentSMSMessage->MessageTextLength] = 0; - CurrentSMSPointer = tmp; - CurrentSMSMessage->MemoryType = MessageBuffer[5]; CurrentSMSMessage->MessageNumber = MessageBuffer[6]; @@ -3596,7 +3311,8 @@ enum FB61_RX_States FB61_RX_DispatchMessage(void) dprintf(_(" The number of messages: %d\n"), MessageBuffer[10]); dprintf(_(" Unread messages: %d\n"), MessageBuffer[11]); CurrentSMSStatus->UnRead = MessageBuffer[11]; - CurrentSMSStatus->Number = MessageBuffer[10]; + CurrentSMSStatus->Used = MessageBuffer[10]; + CurrentSMSStatus->Slots = CurrentSMSStatus->Used; /* is it correct? */ CurrentSMSStatusError = GE_NONE; break; diff --git a/common/gsm-api.c b/common/gsm-api.c index 3c090a0..5f86eff 100644 --- a/common/gsm-api.c +++ b/common/gsm-api.c @@ -1,9 +1,13 @@ /* + $Id$ + G N O K I I A Linux/Unix toolset and driver for Nokia mobile phones. + Copyright (C) 1999, 2000 Hugh Blemings & Pavel Janík ml. + Released under the terms of the GNU GPL, see file COPYING for more details. Provides a generic API for accessing functions on the phone, wherever @@ -16,47 +20,56 @@ Unless otherwise noted, all functions herein block until they complete. The functions themselves are defined in a structure in gsm-common.h. + $Log$ + Revision 1.1.1.5 2002/04/03 00:07:54 short + Found in "gnokii-working" directory, some November-patches version + + Revision 1.31 2001/11/08 16:45:58 pkot + Obsolete old structure, kill treads where possible and make shared library + + Revision 1.30 2001/08/09 11:51:38 pkot + Generic AT support updates and cleanup (Manfred Jonsson) + + Revision 1.29 2001/07/27 00:02:20 pkot + Generic AT support for the new structure (Manfred Jonsson) + + Revision 1.28 2001/06/06 09:05:56 machek + Convert Grab/Release display to new structure. + + Revision 1.27 2001/05/07 14:13:06 machek + nokia-2110 module converted to suit new API better. --identify now works. + + Revision 1.26 2001/04/25 12:54:47 machek + Partly converted nokia 2110 to "new" form, and moved it to phone + directory. + + Revision 1.25 2001/03/26 23:39:21 pkot + Minor updates: + - Windows INLINE patch (Manfred Jonsson) + - patch to configure.in to compile under FreeBSD (Panagiotis Astithas) + - other cleanups (me) + + */ #include #include -#include -#include -#ifdef WIN32 - #include - #include "misc_win32.h" -#endif +#include "misc.h" +#include "gsm-common.h" +#include "data/rlp-common.h" +#include "gsm-statemachine.h" +#include "phones/nk7110.h" +#include "phones/nk6100.h" +#include "phones/nk3110.h" +#include "phones/nk2110.h" -#include "gsm-api.h" - -#include "newmodules/n3110.h" -#include "newmodules/n6110.h" -#include "newmodules/n7110.h" -#include "newmodules/newat.h" -#ifdef DEBUG - #include "newmodules/sniff/sniff.h" -#endif -#include "protocol/fbusirda.h" -#include "protocol/fbus.h" -#include "protocol/fbus3110.h" -#include "protocol/mbus.h" -#include "protocol/at.h" -#include "files/cfgreader.h" - -#ifndef WIN32 - #include "devices/device.h" -#endif - -#ifdef VC6 - /* for VC6 make scripts save VERSION constant in mversion.h file */ - #include "mversion.h" -#endif /* GSM_LinkOK is set to true once normal communications with the phone have been established. */ bool *GSM_LinkOK; +bool LinkAlwaysOK = true; /* Define pointer to the GSM_Functions structure used by external code to call relevant API functions. This structure is defined in gsm-common.h. */ @@ -69,773 +82,622 @@ GSM_Functions *GSM; GSM_Information *GSM_Info; -/* Initialise interface to the phone. Model number should be a string such as - 3810, 5110, 6110 etc. Device is the serial port to use e.g. /dev/ttyS0, the - user must have write permission to the device. */ -GSM_Protocol *Protocol; -/* Local variables used by get/set phonebook entry code. Buffer is used as a - source or destination for phonebook data and other functions... Error is - set to GE_NONE by calling function, set to GE_COMPLETE or an error code by - handler routines as appropriate. */ - -GSM_PhonebookEntry *CurrentPhonebookEntry; -GSM_Error CurrentPhonebookError; +/* From here starts the ugly compatibility cludge to complete WIPE OUT the + * insane "Sorry, phone has not yet been converted to new style. + * Phone.Functions == NULL!" message out of the Earth surface to make the world + * a happy place back again! Wiping out, wiping out, wiping out! + * The most World's evil GSM_Error code: GE_NOTIMPLEMENTED + * Completely non-systematic naming is not my souvenir - it is just copied + * from the existing include files. (Jan Kratochvil) + */ + +static GSM_Statemachine *compat_Functions_Statemachine; + +#define INVOKE_COMPAT_FUNCTIONS_SM(gop) \ + (compat_Functions_Statemachine->Phone.Functions((gop),&data,compat_Functions_Statemachine)) +#define RETURN_COMPAT_FUNCTIONS_SM(gop) \ + return((INVOKE_COMPAT_FUNCTIONS_SM((gop)))) +#define BODY_COMPAT_FUNCTIONS_SM_CORE(core,gop) \ + GSM_Data data; \ + core \ + RETURN_COMPAT_FUNCTIONS_SM((gop)); +#define BODY_COMPAT_FUNCTIONS_SM0(gop) \ + BODY_COMPAT_FUNCTIONS_SM_CORE( ,(gop)) +#define BODY_COMPAT_FUNCTIONS_SM1(field1,arg1,gop) \ + BODY_COMPAT_FUNCTIONS_SM_CORE( data.field1=(arg1); ,(gop)) +#define BODY_COMPAT_FUNCTIONS_SM2(field1,arg1,field2,arg2,gop) \ + BODY_COMPAT_FUNCTIONS_SM_CORE( data.field1=(arg1);data.field2=(arg2); ,(gop)) +#define BODY_COMPAT_FUNCTIONS_SM3(field1,arg1,field2,arg2,field3,arg3,gop) \ + BODY_COMPAT_FUNCTIONS_SM_CORE( data.field1=(arg1);data.field2=(arg2);data.field3=(arg3); ,(gop)) + +static GSM_Error compat_Functions_Initialise + (char *port_device, char *initlength, GSM_ConnectionType connection, void (*rlp_callback)(RLP_F96Frame *frame)) +{ + fprintf(stderr,"FATAL: GSM->Initialise called for new style phone implementation!\n"); + return(GE_NOTIMPLEMENTED); +} -GSM_SpeedDial *CurrentSpeedDialEntry; -GSM_Error CurrentSpeedDialError; +static void compat_Functions_Terminate(void) +{ +GSM_Data data; /* void */ -unsigned char Current_IMEI[GSM_MAX_IMEI_LENGTH]; -unsigned char Current_Revision[GSM_MAX_REVISION_LENGTH]; -unsigned char Current_Model[GSM_MAX_MODEL_LENGTH]; + INVOKE_COMPAT_FUNCTIONS_SM(GOP_Terminate); +} -GSM_SMSMessage *CurrentSMSMessage; -GSM_Error CurrentSMSMessageError; -int CurrentSMSPointer; +static GSM_Error compat_Functions_GetMemoryLocation( GSM_PhonebookEntry *entry ) +{ + BODY_COMPAT_FUNCTIONS_SM1(PhonebookEntry,entry,GOP_ReadPhonebook); +} -GSM_SMSFolders *CurrentSMSFolders; -GSM_Error CurrentSMSFoldersError; -int CurrentSMSFoldersCount; +static GSM_Error compat_Functions_WritePhonebookLocation( GSM_PhonebookEntry *entry ) +{ + BODY_COMPAT_FUNCTIONS_SM1(PhonebookEntry,entry,GOP_WritePhonebook); +} -GSM_OneSMSFolder CurrentSMSFolder; -GSM_Error CurrentSMSFolderError; -int CurrentSMSFolderID; +static GSM_Error compat_Functions_GetSpeedDial( GSM_SpeedDial *entry ) +{ + BODY_COMPAT_FUNCTIONS_SM1(SpeedDial,entry,GOP_GetSpeedDial); +} -GSM_MemoryStatus *CurrentMemoryStatus; -GSM_Error CurrentMemoryStatusError; +static GSM_Error compat_Functions_SetSpeedDial( GSM_SpeedDial *entry ) +{ + BODY_COMPAT_FUNCTIONS_SM1(SpeedDial,entry,GOP_SetSpeedDial); +} -GSM_NetworkInfo *CurrentNetworkInfo; -GSM_Error CurrentNetworkInfoError; +static GSM_Error compat_Functions_GetMemoryStatus( GSM_MemoryStatus *Status ) +{ + BODY_COMPAT_FUNCTIONS_SM1(MemoryStatus,Status,GOP_GetMemoryStatus); +} -GSM_SMSStatus *CurrentSMSStatus; -GSM_Error CurrentSMSStatusError; +static GSM_Error compat_Functions_GetSMSStatus( GSM_SMSStatus *Status ) +{ + BODY_COMPAT_FUNCTIONS_SM1(SMSStatus,Status,GOP_GetSMSStatus); +} -GSM_MessageCenter *CurrentMessageCenter; -GSM_Error CurrentMessageCenterError; +static GSM_Error compat_Functions_GetSMSCenter( GSM_MessageCenter *MessageCenter ) +{ + BODY_COMPAT_FUNCTIONS_SM1(MessageCenter,MessageCenter,GOP_GetSMSCenter); +} -int *CurrentSecurityCodeStatus; -GSM_Error CurrentSecurityCodeError; -GSM_SecurityCode *CurrentSecurityCode; +static GSM_Error compat_Functions_SetSMSCenter( GSM_MessageCenter *MessageCenter ) +{ + BODY_COMPAT_FUNCTIONS_SM1(MessageCenter,MessageCenter,GOP_SetSMSCenter); +} -GSM_DateTime *CurrentDateTime; -GSM_Error CurrentDateTimeError; +static GSM_Error compat_Functions_GetSMSMessage( GSM_SMSMessage *Message ) +{ + BODY_COMPAT_FUNCTIONS_SM1(SMSMessage,Message,GOP_GetSMS); +} -GSM_DateTime *CurrentAlarm; -GSM_Error CurrentAlarmError; +static GSM_Error compat_Functions_DeleteSMSMessage( GSM_SMSMessage *Message ) +{ + BODY_COMPAT_FUNCTIONS_SM1(SMSMessage,Message,GOP_DeleteSMS); +} -GSM_CalendarNote *CurrentCalendarNote; -GSM_Error CurrentCalendarNoteError; +static GSM_Error compat_Functions_SendSMSMessage( GSM_SMSMessage *Message ) +{ + BODY_COMPAT_FUNCTIONS_SM1(SMSMessage,Message,GOP_SendSMS); +} -GSM_NotesInfo CurrentCalendarNotesInfo,*CurrentCalendarNotesInfo2; -GSM_Error CurrentCalendarNotesInfoError; +static GSM_Error compat_Functions_SaveSMSMessage( GSM_SMSMessage *Message ) +{ + BODY_COMPAT_FUNCTIONS_SM1(SMSMessage,Message,GOP_SaveSMS); +} -GSM_Error CurrentSetDateTimeError; -GSM_Error CurrentSetAlarmError; +static GSM_Error compat_Functions_GetRFLevel( GSM_RFUnits *units, float *level ) +{ + BODY_COMPAT_FUNCTIONS_SM2(RFUnits,units,RFLevel,level,GOP_GetRFLevel); +} -GSM_Error CurrentEnableExtendedCommandsError; +static GSM_Error compat_Functions_GetBatteryLevel( GSM_BatteryUnits *units, float *level ) +{ + BODY_COMPAT_FUNCTIONS_SM2(BatteryUnits,units,BatteryLevel,level,GOP_GetBatteryLevel); +} -int CurrentRFLevel, - CurrentBatteryLevel, - CurrentPowerSource; +static GSM_Error compat_Functions_GetPowerSource( GSM_PowerSource *source ) +{ + BODY_COMPAT_FUNCTIONS_SM1(PowerSource,source,GOP_GetPowersource); +} -int CurrentDisplayStatus; -GSM_Error CurrentDisplayStatusError; +static GSM_Error compat_Functions_GetDisplayStatus( int *Status ) +{ + BODY_COMPAT_FUNCTIONS_SM1(DisplayStatus,Status,GOP_GetDisplayStatus); +} -GSM_Error CurrentResetPhoneSettingsError; +static GSM_Error compat_Functions_EnterSecurityCode( GSM_SecurityCode Code ) +{ + BODY_COMPAT_FUNCTIONS_SM1(SecurityCode,&Code,GOP_EnterSecurityCode); +} -char *CurrentNetmonitor; -GSM_Error CurrentNetmonitorError; +/* FIXME: GetSecurityCodeStatus() should have GSM_SecurityCodeType as its argument! + */ +static GSM_Error compat_Functions_GetSecurityCodeStatus( int *Status ) +{ +GSM_SecurityCodeType status_local; +GSM_Data data; +GSM_Error err; + + data.SecurityCodeStatus=&status_local; + err=INVOKE_COMPAT_FUNCTIONS_SM(GOP_GetSecurityCodeStatus); + *Status=status_local; + return(err); +} -GSM_Bitmap *CurrentGetBitmap=NULL; -GSM_Error CurrentGetBitmapError; +static GSM_Error compat_Functions_GetIMEI( char *imei ) +{ + BODY_COMPAT_FUNCTIONS_SM1(Imei,imei,GOP_GetImei); +} -GSM_Error CurrentSetBitmapError; +static GSM_Error compat_Functions_GetRevision( char *revision ) +{ + BODY_COMPAT_FUNCTIONS_SM1(Revision,revision,GOP_GetRevision); +} -GSM_Error CurrentSendDTMFError; +static GSM_Error compat_Functions_GetModel( char *model ) +{ + BODY_COMPAT_FUNCTIONS_SM1(Model,model,GOP_GetModel); +} -GSM_Profile *CurrentProfile; -GSM_Error CurrentProfileError; +static GSM_Error compat_Functions_GetManufacturer( char *manufacturer ) +{ + BODY_COMPAT_FUNCTIONS_SM1(Manufacturer,manufacturer,GOP_GetManufacturer); +} -GSM_Error CurrentDisplayOutputError; +static GSM_Error compat_Functions_GetDateTime( GSM_DateTime *date_time) +{ + BODY_COMPAT_FUNCTIONS_SM1(DateTime,date_time,GOP_GetDateTime); +} -GSM_CBMessage *CurrentCBMessage; -GSM_Error CurrentCBError; +static GSM_Error compat_Functions_SetDateTime( GSM_DateTime *date_time) +{ + BODY_COMPAT_FUNCTIONS_SM1(DateTime,date_time,GOP_SetDateTime); +} -int CurrentPressKeyEvent; -GSM_Error CurrentPressKeyError; +static GSM_Error compat_Functions_GetAlarm( int alarm_number, GSM_DateTime *date_time ) +{ + BODY_COMPAT_FUNCTIONS_SM2(AlarmNumber,&alarm_number,AlarmDateTime,date_time,GOP_GetAlarm); +} -GSM_Error CurrentPlayToneError=GE_UNKNOWN; +static GSM_Error compat_Functions_SetAlarm( int alarm_number, GSM_DateTime *date_time ) +{ + BODY_COMPAT_FUNCTIONS_SM2(AlarmNumber,&alarm_number,AlarmDateTime,date_time,GOP_SetAlarm); +} + +static GSM_Error compat_Functions_DialVoice( char *Number ) +{ + BODY_COMPAT_FUNCTIONS_SM1(VoiceNumber,Number,GOP_DialVoice); +} -GSM_Error CurrentDialVoiceError; +static GSM_Error compat_Functions_DialData( char *Number, char type, void (* callpassup)(char c) ) +{ + BODY_COMPAT_FUNCTIONS_SM3(DataNumber,Number,DataType,&type,DataCallPassUp,callpassup,GOP_DialData); +} -GSM_Error CurrentGetOperatorNameError; -GSM_Network *CurrentGetOperatorNameNetwork; -GSM_Error CurrentSetOperatorNameError; +static GSM_Error compat_Functions_GetIncomingCallNr( char *Number ) +{ + BODY_COMPAT_FUNCTIONS_SM1(IncomingCallNr,Number,GOP_GetIncomingCallNr); +} -GSM_Error CurrentGetIMEIError; +static GSM_Error compat_Functions_GetNetworkInfo ( GSM_NetworkInfo *NetworkInfo ) +{ + BODY_COMPAT_FUNCTIONS_SM1(NetworkInfo,NetworkInfo,GOP_GetNetworkInfo); +} -GSM_Error CurrentGetHWError; +static GSM_Error compat_Functions_GetCalendarNote ( GSM_CalendarNote *CalendarNote) +{ + BODY_COMPAT_FUNCTIONS_SM1(CalendarNote,CalendarNote,GOP_GetCalendarNote); +} -unsigned char CurrentPPS[4]; -GSM_Error CurrentProductProfileSettingsError; +static GSM_Error compat_Functions_WriteCalendarNote ( GSM_CalendarNote *CalendarNote) +{ + BODY_COMPAT_FUNCTIONS_SM1(CalendarNote,CalendarNote,GOP_WriteCalendarNote); +} -char CurrentIncomingCall[20]; +static GSM_Error compat_Functions_DeleteCalendarNote ( GSM_CalendarNote *CalendarNote) +{ + BODY_COMPAT_FUNCTIONS_SM1(CalendarNote,CalendarNote,GOP_DeleteCalendarNote); +} -GSM_Error CurrentBinRingtoneError; -GSM_BinRingtone *CurrentGetBinRingtone=NULL; +static GSM_Error compat_Functions_NetMonitor ( unsigned char mode, char *Screen ) +{ + BODY_COMPAT_FUNCTIONS_SM2(NetMonitorMode,&mode,NetMonitorScreen,Screen,GOP_NetMonitor); +} -GSM_Error CurrentRingtoneError; +static GSM_Error compat_Functions_SendDTMF ( char *String ) +{ + BODY_COMPAT_FUNCTIONS_SM1(DTMF,String,GOP_SendDTMF); +} -GSM_Error CurrentMagicError; +static GSM_Error compat_Functions_GetBitmap ( GSM_Bitmap *Bitmap ) +{ + BODY_COMPAT_FUNCTIONS_SM1(Bitmap,Bitmap,GOP_GetBitmap); +} + +static GSM_Error compat_Functions_SetBitmap ( GSM_Bitmap *Bitmap ) +{ + BODY_COMPAT_FUNCTIONS_SM1(Bitmap,Bitmap,GOP_SetBitmap); +} -GSM_Error CurrentSimlockInfoError; -GSM_AllSimlocks *CurrentSimLock; +static GSM_Error compat_Functions_SetRingtone ( GSM_Ringtone *ringtone ) +{ + BODY_COMPAT_FUNCTIONS_SM1(Ringtone,ringtone,GOP_SetRingtone); +} -GSM_Error CurrentGetWAPBookmarkError; -GSM_Error CurrentSetWAPBookmarkError; -GSM_WAPBookmark *WAPBookmark; +static GSM_Error compat_Functions_Reset ( unsigned char type ) +{ + BODY_COMPAT_FUNCTIONS_SM1(ResetType,&type,GOP_Reset); +} -GSM_Error CurrentGetWAPSettingsError; -GSM_WAPSettings *WAPSettings; +static GSM_Error compat_Functions_GetProfile ( GSM_Profile *Profile ) +{ + BODY_COMPAT_FUNCTIONS_SM1(Profile,Profile,GOP_GetProfile); +} -GSM_Error CurrentCallDivertError; -GSM_CallDivert *CurrentCallDivert; +static GSM_Error compat_Functions_SetProfile ( GSM_Profile *Profile ) +{ + BODY_COMPAT_FUNCTIONS_SM1(Profile,Profile,GOP_SetProfile); +} -char *CurrentManufacturer; +/* return type "bool" is fortunately compatible with "GSM_Error" + */ +static bool compat_Functions_SendRLPFrame ( RLP_F96Frame *frame, bool out_dtx ) +{ + BODY_COMPAT_FUNCTIONS_SM2(RLPFrame,frame,RLPFrame_out_dtx,&out_dtx,GOP_SendRLPFrame); +} -/* This is the connection type used in gnokii. */ -GSM_ConnectionType CurrentConnectionType; +static GSM_Error compat_Functions_CancelCall ( void ) +{ + BODY_COMPAT_FUNCTIONS_SM0(GOP_CancelCall); +} + +static GSM_Error compat_Functions_EnableDisplayOutput ( void ) +{ + BODY_COMPAT_FUNCTIONS_SM0(GOP_EnableDisplayOutput); +} + +static GSM_Error compat_Functions_DisableDisplayOutput ( void ) +{ + BODY_COMPAT_FUNCTIONS_SM0(GOP_DisableDisplayOutput); +} + +static GSM_Error compat_Functions_EnableCellBroadcast ( void ) +{ + BODY_COMPAT_FUNCTIONS_SM0(GOP_EnableCellBroadcast); +} -/* Pointer to a callback function used to return changes to a calls status */ -/* This saves unreliable polling */ -void (*CurrentCallPassup)(char c); +static GSM_Error compat_Functions_DisableCellBroadcast ( void ) +{ + BODY_COMPAT_FUNCTIONS_SM0(GOP_DisableCellBroadcast); +} -/* Pointer to callback function in user code to be called when RLP frames - are received. */ -void (*CurrentRLP_RXCallback)(RLP_F96Frame *frame); +static GSM_Error compat_Functions_ReadCellBroadcast ( GSM_CBMessage *Message ) +{ + BODY_COMPAT_FUNCTIONS_SM1(CBMessage,Message,GOP_ReadCellBroadcast); +} + +static GSM_Error compat_Functions_SetKey (int c, int up) +{ + BODY_COMPAT_FUNCTIONS_SM2(SetKeyKey,&c,SetKeyUp,&up,GOP_SetKey); +} + +static GSM_Error compat_Functions_HandleString (char *s) +{ + BODY_COMPAT_FUNCTIONS_SM1(HandleString,s,GOP_HandleString); +} + +static GSM_Error compat_Functions_AnswerCall (char s) +{ + BODY_COMPAT_FUNCTIONS_SM1(CallNo,&s,GOP_AnswerCall); +} -/* Used to disconnect the call */ -u8 CurrentCallSequenceNumber; +static GSM_Functions compat_Functions={ + compat_Functions_Initialise, + compat_Functions_Terminate, + compat_Functions_GetMemoryLocation, + compat_Functions_WritePhonebookLocation, + compat_Functions_GetSpeedDial, + compat_Functions_SetSpeedDial, + compat_Functions_GetMemoryStatus, + compat_Functions_GetSMSStatus, + compat_Functions_GetSMSCenter, + compat_Functions_SetSMSCenter, + compat_Functions_GetSMSMessage, + compat_Functions_DeleteSMSMessage, + compat_Functions_SendSMSMessage, + compat_Functions_SaveSMSMessage, + compat_Functions_GetRFLevel, + compat_Functions_GetBatteryLevel, + compat_Functions_GetPowerSource, + compat_Functions_GetDisplayStatus, + compat_Functions_EnterSecurityCode, + compat_Functions_GetSecurityCodeStatus, + compat_Functions_GetIMEI, + compat_Functions_GetRevision, + compat_Functions_GetModel, + compat_Functions_GetManufacturer, + compat_Functions_GetDateTime, + compat_Functions_SetDateTime, + compat_Functions_GetAlarm, + compat_Functions_SetAlarm, + compat_Functions_DialVoice, + compat_Functions_DialData, + compat_Functions_GetIncomingCallNr, + compat_Functions_GetNetworkInfo, + compat_Functions_GetCalendarNote, + compat_Functions_WriteCalendarNote, + compat_Functions_DeleteCalendarNote, + compat_Functions_NetMonitor, + compat_Functions_SendDTMF, + compat_Functions_GetBitmap, + compat_Functions_SetBitmap, + compat_Functions_SetRingtone, + compat_Functions_Reset, + compat_Functions_GetProfile, + compat_Functions_SetProfile, + compat_Functions_SendRLPFrame, + compat_Functions_CancelCall, + compat_Functions_EnableDisplayOutput, + compat_Functions_DisableDisplayOutput, + compat_Functions_EnableCellBroadcast, + compat_Functions_DisableCellBroadcast, + compat_Functions_ReadCellBroadcast, + compat_Functions_SetKey, + compat_Functions_HandleString, + compat_Functions_AnswerCall, + }; + +GSM_Error compat_Phone_Functions(GSM_Operation op, GSM_Data *data, GSM_Statemachine *state) +{ + switch (op) { + + case GOP_Init: + fprintf(stderr,"FATAL: compat_Phone_Functions(GOP_Init) called for old style phone implementation!\n"); + return(GE_NOTIMPLEMENTED); -bool CurrentLinkOK; + case GOP_Terminate: + GSM->Terminate(); + return(GE_NONE); -bool CurrentRequestTerminate; + case GOP_ReadPhonebook: + return(GSM->GetMemoryLocation(data->PhonebookEntry/*entry*/)); -bool CurrentDisableKeepAlive; + case GOP_WritePhonebook: + return(GSM->WritePhonebookLocation(data->PhonebookEntry/*entry*/)); -bool CheckModel (GSM_Information InfoToCheck, char *model, GSM_ConnectionType connection) { + case GOP_GetSpeedDial: + return(GSM->GetSpeedDial(data->SpeedDial/*entry*/)); - bool found_match=false; + case GOP_SetSpeedDial: + return(GSM->SetSpeedDial(data->SpeedDial/*entry*/)); - if (strstr(InfoToCheck.FBUSModels, model) != NULL) { - if (connection==GCT_FBUS) found_match=true; - } - if (strstr(InfoToCheck.MBUSModels, model) != NULL) { - if (connection==GCT_MBUS) found_match=true; - } - if (strstr(InfoToCheck.InfraredModels, model) != NULL) { - if (connection==GCT_Infrared) found_match=true; - } - if (strstr(InfoToCheck.DLR3Models, model) != NULL) { - if (connection==GCT_DLR3) found_match=true; - } - if (strstr(InfoToCheck.IrdaModels, model) != NULL) { - if (connection==GCT_Irda) found_match=true; - } - if (strstr(InfoToCheck.ATModels, model) != NULL) { - if (connection==GCT_AT) found_match=true; - } - if (strstr(InfoToCheck.TekramModels, model) != NULL) { - if (connection==GCT_Tekram) found_match=true; - } - if (strstr(InfoToCheck.FBUS3110Models, model) != NULL) { - if (connection==GCT_FBUS3110) found_match=true; - } + case GOP_GetMemoryStatus: + return(GSM->GetMemoryStatus(data->MemoryStatus/*Status*/)); - return found_match; -} - -GSM_Error TryNewNokia(char *model, char *device, char *initlength, GSM_ConnectionType connection, void (*rlp_callback)(RLP_F96Frame *frame)) { - int InitLength; - int count; - unsigned char init_char = N6110_SYNC_BYTE; + case GOP_GetSMSStatus: + return(GSM->GetSMSStatus(data->SMSStatus/*Status*/)); - /* Hopefully is 64 larger as FB38_MAX* / N6110_MAX* */ - char phonemodel[64]; + case GOP_GetSMSCenter: + return(GSM->GetSMSCenter(data->MessageCenter/*MessageCenter*/)); - if (Protocol->Initialise(device,initlength,connection,rlp_callback)!=GE_NONE) - { - return GE_NOTSUPPORTED; - } + case GOP_SetSMSCenter: + return(GSM->SetSMSCenter(data->MessageCenter/*MessageCenter*/)); - if (connection!=GCT_MBUS) { - InitLength = atoi(initlength); + case GOP_GetSMS: + return(GSM->GetSMSMessage(data->SMSMessage/*Message*/)); - if ((strcmp(initlength, "default") == 0) || (InitLength == 0)) { - InitLength = 250; /* This is the usual value, lower may work. */ - } + case GOP_DeleteSMS: + return(GSM->DeleteSMSMessage(data->SMSMessage/*Message*/)); -#ifdef DEBUG - fprintf(stdout,_("Writing init chars....")); -#endif + case GOP_SendSMS: + return(GSM->SendSMSMessage(data->SMSMessage/*Message*/)); - /* Initialise link with phone or what have you */ - /* Send init string to phone, this is a bunch of 0x55 characters. Timing is - empirical. */ - for (count = 0; count < InitLength; count ++) { - usleep(100); - Protocol->WritePhone(1,&init_char); - } + case GOP_SaveSMS: + return(GSM->SaveSMSMessage(data->SMSMessage/*Message*/)); -#ifdef DEBUG - fprintf(stdout,_("Done\n")); -#endif + case GOP_GetRFLevel: + return(GSM->GetRFLevel(data->RFUnits/*units*/,data->RFLevel/*level*/)); - N6110_SendStatusRequest(); - } + case GOP_GetBatteryLevel: + return(GSM->GetBatteryLevel(data->BatteryUnits/*units*/,data->BatteryLevel/*level*/)); - usleep(100); + case GOP_GetPowersource: + return(GSM->GetPowerSource(data->PowerSource/*source*/)); - if (N6110_SendIDFrame()!=GE_NONE) - return GE_TIMEOUT; - - while (N6110_GetModel(phonemodel) != GE_NONE) - sleep(1); + case GOP_GetDisplayStatus: + return(GSM->GetDisplayStatus(data->DisplayStatus/*Status*/)); - if (!strcmp(phonemodel,"NPE-3") || !strcmp(phonemodel,"NSE-5") || - !strcmp(phonemodel,"NHM-3")) - { - GSM->Terminate(); - - /* Set pointers to relevant addresses */ - GSM = &N7110_Functions; - GSM_Info = &N7110_Information; - GSM_LinkOK = &CurrentLinkOK; - return GE_NONE; - } + case GOP_EnterSecurityCode: + return(GSM->EnterSecurityCode(*data->SecurityCode/*Code*/)); - return GE_NONE; -} + case GOP_GetSecurityCodeStatus: { +int status_local=*data->SecurityCodeStatus; +GSM_Error err; -GSM_Error GSM_Initialise(char *model, char *device, char *initlength, GSM_ConnectionType connection, void (*rlp_callback)(RLP_F96Frame *frame), char* SynchronizeTime) -{ - bool found_match=false; - - GSM_ConnectionType connection2; + err=GSM->GetSecurityCodeStatus(&status_local); + *data->SecurityCodeStatus=status_local; + return(err); + } - struct tm *now; - time_t nowh; - GSM_DateTime Date; - GSM_Error error; - - connection2=connection; - - CurrentRLP_RXCallback = rlp_callback; - CurrentCallPassup=NULL; - CurrentCallDivert=NULL; - CurrentPhonebookEntry=NULL; - CurrentNetworkInfo = NULL; - CurrentGetBitmap=NULL; - CurrentPlayToneError=GE_UNKNOWN; - strcpy(CurrentIncomingCall," "); - CurrentGetBinRingtone=NULL; - CurrentNetworkInfo=NULL; - CurrentRequestTerminate=false; - CurrentDisableKeepAlive=false; - CurrentCalendarNotesInfo.HowMany=2000; - CurrentSMSMessage=NULL; - CurrentMagicError = GE_BUSY; - - if (!strcmp(model,"auto")) { - - /* For now */ - GSM = &N6110_Functions; - GSM_Info = &N6110_Information; - GSM_LinkOK = &CurrentLinkOK; -#ifdef DEBUG - fprintf(stdout,_("Trying FBUS for new Nokia phones...\n")); -#endif - /* Trying FBUS */ - Protocol = &FBUS_Functions; - CurrentConnectionType=GCT_FBUS; - connection2=GCT_FBUS; - if (TryNewNokia(model,device,initlength,CurrentConnectionType,rlp_callback)==GE_NONE) - { - found_match=true; - } else { - GSM->Terminate(); - } - - if (!found_match) { - usleep(100); - - /* For now */ - GSM = &N6110_Functions; - GSM_Info = &N6110_Information; - GSM_LinkOK = &CurrentLinkOK; -#ifdef DEBUG - fprintf(stdout,_("Trying DLR3 for new Nokia phones...\n")); -#endif - /* Trying DLR3 */ - Protocol = &FBUS_Functions; - CurrentConnectionType=GCT_DLR3; - connection2=GCT_DLR3; - if (TryNewNokia(model,device,initlength,CurrentConnectionType,rlp_callback)==GE_NONE) - { - found_match=true; - } else { - GSM->Terminate(); - } - } - - if (!found_match) { - usleep(100); - - /* For now */ - GSM = &N6110_Functions; - GSM_Info = &N6110_Information; - GSM_LinkOK = &CurrentLinkOK; -#ifdef DEBUG - fprintf(stdout,_("Trying MBUS for new Nokia phones...\n")); -#endif - /* Trying MBUS */ - Protocol = &MBUS_Functions; - CurrentConnectionType=GCT_MBUS; - connection2=GCT_MBUS; - if (TryNewNokia(model,device,initlength,CurrentConnectionType,rlp_callback)==GE_NONE) - { - found_match=true; - } else { - GSM->Terminate(); - } - } - - if (!found_match) return GE_NOTSUPPORTED; - - usleep(50); - - } else { - if (!strcmp(model,"modelauto")) { - /* For now */ - GSM = &N6110_Functions; - GSM_Info = &N6110_Information; - GSM_LinkOK = &CurrentLinkOK; -#ifdef DEBUG - fprintf(stdout,_("Trying to find connected model...\n")); -#endif - switch (connection) { - case GCT_FBUS : Protocol = &FBUS_Functions; break; - case GCT_Infrared: Protocol = &FBUS_Functions; break; - case GCT_Tekram : Protocol = &FBUS_Functions; break; - case GCT_DLR3 : Protocol = &FBUS_Functions; break; - case GCT_MBUS : Protocol = &MBUS_Functions; break; - case GCT_Irda : Protocol = &FBUSIRDA_Functions;break; - case GCT_AT : Protocol = &AT_Functions; break; - case GCT_FBUS3110: Protocol = &FBUS3110_Functions;break; - } - CurrentConnectionType=connection; - connection2=connection; - if (TryNewNokia(model,device,initlength,CurrentConnectionType,rlp_callback)==GE_NONE) - { - found_match=true; - } else { - GSM->Terminate(); - } - - if (!found_match) return GE_NOTSUPPORTED; - - usleep(50); - - } else { -#ifdef DEBUG - if (CheckModel (Nsniff_Information, model, connection)) { - /* Set pointers to relevant addresses */ - GSM = &Nsniff_Functions; - GSM_Info = &Nsniff_Information; - GSM_LinkOK = &CurrentLinkOK; - found_match=true; - } -#endif + case GOP_GetImei: + return(GSM->GetIMEI(data->Imei/*imei*/)); - if (CheckModel (N3110_Information, model, connection)) { - /* Set pointers to relevant addresses */ - GSM = &N3110_Functions; - GSM_Info = &N3110_Information; - GSM_LinkOK = &CurrentLinkOK; - found_match=true; - } - if (CheckModel (N6110_Information, model, connection)) { - /* Set pointers to relevant addresses */ - GSM = &N6110_Functions; - GSM_Info = &N6110_Information; - GSM_LinkOK = &CurrentLinkOK; - found_match=true; - } - if (CheckModel (N7110_Information, model, connection)) { - /* Set pointers to relevant addresses */ - GSM = &N7110_Functions; - GSM_Info = &N7110_Information; - GSM_LinkOK = &CurrentLinkOK; - found_match=true; - } - if (CheckModel (Nat_Information, model, connection)) { - /* Set pointers to relevant addresses */ - GSM = &Nat_Functions; - GSM_Info = &Nat_Information; - GSM_LinkOK = &CurrentLinkOK; - found_match=true; - } - - if (found_match) { - switch (connection) { - case GCT_FBUS : Protocol = &FBUS_Functions; break; - case GCT_Infrared: Protocol = &FBUS_Functions; break; - case GCT_Tekram : Protocol = &FBUS_Functions; break; - case GCT_DLR3 : Protocol = &FBUS_Functions; break; - case GCT_MBUS : Protocol = &MBUS_Functions; break; - case GCT_Irda : Protocol = &FBUSIRDA_Functions;break; - case GCT_AT : Protocol = &AT_Functions; break; - case GCT_FBUS3110: Protocol = &FBUS3110_Functions;break; - } - } else - return GE_NOTSUPPORTED; - } - } - - - /* Now call model specific initialisation code. */ - error=(GSM->Initialise(device, initlength, connection2, rlp_callback)); - - /* RTH: FIXME: second try for Irda (6210 only?)*/ - if ( error!=GE_NONE && connection == GCT_Irda) - { - #ifdef DEBUG - fprintf(stdout,"Irda connection: second try!\n"); - #endif - device_close(); - error=(GSM->Initialise(device, initlength, connection2, rlp_callback)); - } - - if (error==GE_NONE && !strcmp(SynchronizeTime,"yes")) - { - nowh=time(NULL); - now=localtime(&nowh); - - Date.Year = now->tm_year; - Date.Month = now->tm_mon+1; - Date.Day = now->tm_mday; - Date.Hour = now->tm_hour; - Date.Minute = now->tm_min; - Date.Second = now->tm_sec; - - if (Date.Year<1900) - { - - /* Well, this thing is copyrighted in U.S. This technique is known as - Windowing and you can read something about it in LinuxWeekly News: - http://lwn.net/1999/features/Windowing.phtml. This thing is beeing - written in Czech republic and Poland where algorithms are not allowed - to be patented. */ - - if (Date.Year>90) - Date.Year = Date.Year+1900; - else - Date.Year = Date.Year+2000; - } - - /* FIXME: Error checking should be here. */ - GSM->SetDateTime(&Date); - } - - return error; -} - -GSM_Error Unimplemented(void) -{ - return GE_NOTIMPLEMENTED; -} - -GSM_Error NotSupported(void) -{ - return GE_NOTSUPPORTED; -} - -/* Applications should call N6110_Terminate to shut down the N6110 thread and - close the serial port. */ -void NULL_Terminate(void) -{ - Protocol->Terminate(); -} - -#ifdef WIN32 -/* Here are things made for keeping connecting */ -void NULL_KeepAlive() -{ -} -#else -/* Here are things made for keeping connecting */ -void NULL_KeepAlive() -{ -} -#endif + case GOP_GetRevision: + return(GSM->GetRevision(data->Revision/*revision*/)); -#ifdef DEBUG -void NULL_TX_DisplayMessage(u16 MessageLength, u8 *MessageBuffer) -{ - fprintf(stdout, _("PC: ")); + case GOP_GetModel: + return(GSM->GetModel(data->Model/*model*/)); - txhexdump(MessageLength,MessageBuffer); -} -#endif + case GOP_GetManufacturer: + return(GSM->GetManufacturer(data->Manufacturer/*manufacturer*/)); -bool NULL_WritePhone (u16 length, u8 *buffer) { - if (device_write(buffer,length)!=length) return false; - else return true; -} + case GOP_GetDateTime: + return(GSM->GetDateTime(data->DateTime/*date_time*/)); -GSM_Error NULL_WaitUntil (int time, GSM_Error *value) -{ - int timeout; + case GOP_SetDateTime: + return(GSM->SetDateTime(data->DateTime/*date_time*/)); - timeout=time; - - /* Wait for timeout or other error. */ - while (timeout != 0 && *value == GE_BUSY ) { - - if (--timeout == 0) - return (GE_TIMEOUT); - - usleep (100000); - } + case GOP_GetAlarm: + return(GSM->GetAlarm((!data->AlarmNumber ? 0 : *data->AlarmNumber)/*alarm_number*/, + data->AlarmDateTime/*date_time*/)); - return *value; -} + case GOP_SetAlarm: + return(GSM->SetAlarm((!data->AlarmNumber ? 0 : *data->AlarmNumber)/*alarm_number*/, + data->AlarmDateTime/*date_time*/)); -GSM_Error NULL_SendMessageSequence (int time, GSM_Error *value, - u16 message_length, u8 message_type, u8 *buffer) -{ - *value=GE_BUSY; - - Protocol->SendMessage(message_length, message_type, buffer); + case GOP_DialVoice: + return(GSM->DialVoice(data->VoiceNumber/*Number*/)); - return NULL_WaitUntil (time, value); -} + case GOP_DialData: + return(GSM->DialData(data->DataNumber/*Number*/, + (!data->DataType ? -1 : *data->DataType)/*type*/, + data->DataCallPassUp/*callpassup*/)); -GSM_ConnectionType GetConnectionTypeFromString(char *Connection) { + case GOP_GetIncomingCallNr: + return(GSM->GetIncomingCallNr(data->IncomingCallNr/*Number*/)); - GSM_ConnectionType connection=GCT_FBUS; + case GOP_GetNetworkInfo: + return(GSM->GetNetworkInfo(data->NetworkInfo/*NetworkInfo*/)); - if (!strcmp(Connection, "irda")) connection=GCT_Irda; - if (!strcmp(Connection, "infrared")) connection=GCT_Infrared; - if (!strcmp(Connection, "mbus")) connection=GCT_MBUS; - if (!strcmp(Connection, "dlr3")) connection=GCT_DLR3; - if (!strcmp(Connection, "fbus3110")) connection=GCT_FBUS3110; - if (!strcmp(Connection, "at")) connection=GCT_AT; - if (!strcmp(Connection, "tekram210"))connection=GCT_Tekram; - - return connection; -} + case GOP_GetCalendarNote: + return(GSM->GetCalendarNote(data->CalendarNote/*CalendarNote*/)); -bool GetMemoryTypeString(char *memorytext, GSM_MemoryType *type) -{ - int i=0; + case GOP_WriteCalendarNote: + return(GSM->WriteCalendarNote(data->CalendarNote/*CalendarNote*/)); - typedef struct { - GSM_MemoryType type; - char *name; - } GSM_MTStrings; + case GOP_DeleteCalendarNote: + return(GSM->DeleteCalendarNote(data->CalendarNote/*CalendarNote*/)); - GSM_MTStrings mystring[] = { - {GMT_ME,"ME"}, - {GMT_SM,"SM"}, - {GMT_FD,"FD"}, - {GMT_ON,"ON"}, - {GMT_EN,"EN"}, - {GMT_DC,"DC"}, - {GMT_RC,"RC"}, - {GMT_MC,"MC"}, - {GMT_LD,"LD"}, - {GMT_MT,"MT"}, - {GMT_ME,"undefined"} - }; + case GOP_NetMonitor: + return(GSM->NetMonitor((!data->NetMonitorMode ? 0 : *data->NetMonitorMode)/*mode*/, + data->NetMonitorScreen/*Screen*/)); - while (strcmp(mystring[i].name,"undefined")) { - if (*type==mystring[i].type) { - strcpy(memorytext,mystring[i].name); - return true; - } - i++; - } - return false; -} + case GOP_SendDTMF: + return(GSM->SendDTMF(data->DTMF/*String*/)); -bool GetMemoryTypeID(char *memorytext, GSM_MemoryType *type) -{ - int i=0; + case GOP_GetBitmap: + return(GSM->GetBitmap(data->Bitmap/*Bitmap*/)); - typedef struct { - GSM_MemoryType type; - char *name; - } GSM_MTStrings; + case GOP_SetBitmap: + return(GSM->SetBitmap(data->Bitmap/*Bitmap*/)); - GSM_MTStrings mystring[] = { - {GMT_ME,"ME"}, - {GMT_SM,"SM"}, - {GMT_FD,"FD"}, - {GMT_ON,"ON"}, - {GMT_EN,"EN"}, - {GMT_DC,"DC"}, - {GMT_RC,"RC"}, - {GMT_MC,"MC"}, - {GMT_LD,"LD"}, - {GMT_MT,"MT"}, - {GMT_ME,"undefined"} - }; + case GOP_SetRingtone: + return(GSM->SetRingtone(data->Ringtone/*ringtone*/)); - while (strcmp(mystring[i].name,"undefined")) { - if (strcmp(mystring[i].name,memorytext)==0) { - *type=mystring[i].type; - return true; - } - i++; - } + case GOP_Reset: + return(GSM->Reset((!data->ResetType ? 0x03 : *data->ResetType)/*type*/)); - return false; -} + case GOP_GetProfile: + return(GSM->GetProfile(data->Profile/*Profile*/)); -char *GetMygnokiiVersion() { + case GOP_SetProfile: + return(GSM->SetProfile(data->Profile/*Profile*/)); - static char Buffer[1000]=""; + /* return type "bool" is fortunately compatible with "GSM_Error" + */ + case GOP_SendRLPFrame: + return(GSM->SendRLPFrame(data->RLPFrame/*frame*/, + (!data->RLPFrame_out_dtx ? 0 : *data->RLPFrame_out_dtx)/*out_dtx*/)); - sprintf(Buffer, "%s",VERSION); + case GOP_CancelCall: + return(GSM->CancelCall()); - return Buffer; -} + case GOP_EnableDisplayOutput: + return(GSM->EnableDisplayOutput()); -/* -1.Name,2.CodeName,3.Calendar,4.Netmonitor,5.Caller groups,6.Phonebook, -7.Authentication 8.Datacalls 9.KeysPressing 10.SMSC Default Recipient -11.SpeedDials 12.ScreenSavers 13.DTMF 14.SMS 15.NoPowerFrame 16.StartUpLogo -17.Profiles 18.Ringtones 19.WAP 20.RIngtonesNumber -*/ + case GOP_DisableDisplayOutput: + return(GSM->DisableDisplayOutput()); -static OnePhoneModel allmodels[] = { - -/*1, 2, 3, 4, 5, 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 */ -{"3210","NSE-8",{ 0,F_NETMON, 0, 0, 0, 0, 0,F_SMSCDEF,F_SPEED, 0, 0,F_SMS ,F_NOPOWER,F_STANIM,F_PROF51,F_RINGBIN, 0, 2}}, -{"3210","NSE-9",{ 0,F_NETMON, 0, 0, 0, 0, 0,F_SMSCDEF,F_SPEED, 0, 0,F_SMS ,F_NOPOWER,F_STANIM,F_PROF51,F_RINGBIN, 0, 2}}, -{"3310","NHM-5",{F_CAL33,F_NETMON, 0,F_PBK33SIM, 0, 0, 0,F_SMSCDEF,F_SPEED,F_SCRSAV, 0,F_SMS ,F_NOPOWER,F_STANIM,F_PROF33,F_RING_SM, 0, 7}}, -{"3330","NHM-6",{F_CAL33,F_NETMON, 0,F_PBK33INT, 0, 0,F_KEYB,F_SMSCDEF,F_SPEED,F_SCRSAV, 0,F_SMS , 0,F_STANIM,F_PROF33,F_RING_SM,F_WAP, 7}}, -{"5110","NSE-1",{ 0,F_NETMON, 0, 0,F_AUTH,F_DATA61,F_KEYB,F_SMSCDEF,F_SPEED, 0,F_DTMF,F_SMS , 0, 0,F_PROF51, 0, 0, 0}}, -{"5130","NSK-1",{ 0,F_NETMON, 0, 0,F_AUTH,F_DATA61,F_KEYB,F_SMSCDEF,F_SPEED, 0,F_DTMF,F_SMS , 0, 0,F_PROF51, 0, 0, 0}}, -{"5190","NSB-1",{ 0,F_NETMON, 0, 0,F_AUTH,F_DATA61,F_KEYB,F_SMSCDEF,F_SPEED, 0,F_DTMF,F_SMS , 0, 0,F_PROF51, 0, 0, 0}}, -{"6110","NSE-3",{F_CAL61,F_NETMON,F_CALER61,F_PBK61INT,F_AUTH,F_DATA61,F_KEYB,F_SMSCDEF,F_SPEED, 0,F_DTMF,F_SMS , 0,F_STA ,F_PROF61,F_RINGBIN, 0, 1}}, -{"6130","NSK-3",{F_CAL61,F_NETMON,F_CALER61,F_PBK61INT,F_AUTH,F_DATA61,F_KEYB,F_SMSCDEF,F_SPEED, 0,F_DTMF,F_SMS , 0,F_STA ,F_PROF61,F_RINGBIN, 0, 1}}, -{"6150","NSM-1",{F_CAL61,F_NETMON,F_CALER61,F_PBK61INT,F_AUTH,F_DATA61,F_KEYB,F_SMSCDEF,F_SPEED, 0,F_DTMF,F_SMS , 0,F_STA ,F_PROF61,F_RINGBIN, 0, 1}}, -{"6190","NSB-3",{F_CAL61,F_NETMON,F_CALER61,F_PBK61INT,F_AUTH,F_DATA61,F_KEYB,F_SMSCDEF,F_SPEED, 0,F_DTMF,F_SMS , 0,F_STA ,F_PROF61,F_RINGBIN, 0, 1}}, -{"6210","NPE-3",{F_CAL71,F_NETMON,F_CALER61,F_PBK71INT, 0,F_DATA71, 0,F_SMSCDEF,F_SPEED, 0, 0,F_SMS71, 0,F_STA62 ,F_PROF61,F_RINGBIN,F_WAP, 5}}, -{"6250","NHM-3",{F_CAL71,F_NETMON,F_CALER61,F_PBK71INT, 0,F_DATA71, 0,F_SMSCDEF,F_SPEED, 0, 0,F_SMS71, 0,F_STA62 ,F_PROF61,F_RINGBIN,F_WAP, 5}}, -{"7110","NSE-5",{F_CAL71,F_NETMON,F_CALER61,F_PBK71INT, 0,F_DATA71, 0,F_SMSCDEF,F_SPEED, 0, 0,F_SMS71, 0,F_STA71 ,F_PROF61,F_RINGBIN,F_WAP, 5}}, -{"8210","NSM-3",{ 0,F_NETMON,F_CALER61,F_PBK61INT, 0,F_DATA61,F_KEYB,F_SMSCDEF,F_SPEED, 0,F_DTMF,F_SMS , 0,F_STA ,F_PROF61,F_RINGBIN, 0, 1}}, -{"8850","NSM-2",{ 0,F_NETMON,F_CALER61,F_PBK61INT, 0,F_DATA61,F_KEYB,F_SMSCDEF,F_SPEED, 0,F_DTMF,F_SMS , 0,F_STA ,F_PROF61,F_RINGBIN, 0, 1}}, -{"9210","RAE-3",{ 0,F_NETMON,F_CALER61, 0, 0,F_DATA61,F_KEYB,F_SMSCDEF,F_SPEED, 0,F_DTMF,F_SMS , 0,F_STA ,F_PROF61,F_RINGBIN, 0, 0}},//quesses only ! -{"" ,"" ,{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}} -}; - -OnePhoneModel *GetPhoneModelData (const char *num) -{ - register int i = 0; - - while (allmodels[i].number != "") { - if (strcmp (num, allmodels[i].number) == 0) { - return (&allmodels[i]); - } - i++; - } + case GOP_EnableCellBroadcast: + return(GSM->EnableCellBroadcast()); - return (&allmodels[i]); -} + case GOP_DisableCellBroadcast: + return(GSM->DisableCellBroadcast()); -char *GetModelName () -{ - static char model[64]; + case GOP_ReadCellBroadcast: + return(GSM->ReadCellBroadcast(data->CBMessage/*Message*/)); - while (GSM->GetModel(model) != GE_NONE) sleep(1); + case GOP_SetKey: + return(GSM->SetKey(*data->SetKeyKey/*c*/, + (!data->SetKeyUp ? 0 : *data->SetKeyUp)/*up*/)); - return (GetPhoneModelData(model)->model); -} + case GOP_HandleString: + return(GSM->HandleString(data->HandleString/*s*/)); -int GetModelFeature (featnum_index num) -{ - static char model[64]; + case GOP_AnswerCall: + return(GSM->AnswerCall((!data->CallNo ? 0 : *data->CallNo)/*s*/)); - while (GSM->GetModel(model) != GE_NONE) sleep(1); - return (GetPhoneModelData(model)->features[num]); + default: + return(GE_NOTIMPLEMENTED); + } } -int LogAvailable=-1; //-1 not checked earlier, 0 not, 1 yes -char *logfilename; +/* Initialise interface to the phone. Model number should be a string such as + 3810, 5110, 6110 etc. Device is the serial port to use e.g. /dev/ttyS0, the + user must have write permission to the device. */ -bool AppendLog(u8 *buffer, int length,bool format) +static GSM_Error register_phone(GSM_Phone *phone, char *model, char *setupmodel, GSM_Statemachine *sm) { - FILE *file=NULL; - char buffer2[50001]; - int i; - - struct CFG_Header *cfg_info; - char *LogFile; - - if (LogAvailable==-1) { - - LogAvailable=0; - - cfg_info=CFG_FindGnokiirc(); - if (cfg_info==NULL) return false; + GSM_Data data; + GSM_Data *p_data; + if (setupmodel) { + GSM_DataClear(&data); + data.Model = setupmodel; + p_data = &data; + } else { + p_data = NULL; + } + sm->Phone=*phone; + if (strstr(phone->Info.Models, model) != NULL) + return phone->Functions(GOP_Init, p_data, sm); + return GE_UNKNOWNMODEL; +} - LogFile = CFG_Get(cfg_info, "global", "logfile"); - if (LogFile) { - LogAvailable=1; - logfilename=LogFile; +#define MODULE(x) { \ + extern GSM_Functions x##_Functions; \ + extern GSM_Information x##_Information; \ + extern bool x##_LinkOK; \ + if (strstr(x##_Information.Models, model) != NULL) { \ + GSM = & x##_Functions; \ + GSM_Info = & x##_Information; \ + GSM_LinkOK = & x##_LinkOK; \ + return (GSM->Initialise(device, initlength, connection, rlp_callback)); \ + } \ +} - file=fopen(logfilename, "a+"); +#define REGISTER_PHONE(x, y) { \ + extern GSM_Phone phone_##x; \ + if ((ret = register_phone(&phone_##x, model, y, sm)) != GE_UNKNOWNMODEL) \ + return ret; \ + } + +GSM_Error GSM_Initialise(char *model, char *device, char *initlength, GSM_ConnectionType connection, void (*rlp_callback)(RLP_F96Frame *frame), GSM_Statemachine *sm) +{ + GSM_Error ret; + compat_Functions_Statemachine=sm; +#ifndef WIN32 /* MB21 not supported in win32 */ + if (strstr("2110", model)) { + extern GSM_Phone phone_nokia_2110; + memcpy(&(sm->Phone), &phone_nokia_2110, sizeof(GSM_Phone)); + sm->Phone.Functions(GOP_Init, NULL, sm); + } + MODULE(N2110); + + GSM_LinkOK = &LinkAlwaysOK; + sm->Link.ConnectionType=connection; + sm->Link.InitLength=atoi(initlength); + strcpy(sm->Link.PortDevice,device); + GSM=&compat_Functions; + + REGISTER_PHONE(nokia_7110, NULL); + REGISTER_PHONE(at_hw, model); /* FIXME: why 7110 does not to set sm->Model? */ + REGISTER_PHONE(cimd, model); /* FIXME: why 7110 does not to set sm->Model? */ +#if 0 + REGISTER_PHONE(nokia_3110, NULL); +#endif - /* We have first entry in this session and too large file */ - if (fread( buffer2, 1, 50000,file )==50000) { - fclose(file); - file=fopen(logfilename, "w"); - } - } - } else { - if (LogAvailable==1) { - file=fopen(logfilename, "a"); - } - } - - if (LogAvailable==1) { - for (i=0;i @@ -18,179 +22,98 @@ #include "gsm-common.h" #include "gsm-bitmaps.h" -#include "gsm-sms.h" -#include "gsm-coding.h" -#include "gsm-networks.h" +#include "gsm-api.h" -void GSM_SetPointBitmap(GSM_Bitmap *bmp, int x, int y) -{ - int pixel; - if (bmp->type == GSM_StartupLogo || bmp->type == GSM_6210StartupLogo || bmp->type == GSM_7110StartupLogo) - bmp->bitmap[((y/8)*bmp->width)+x] |= 1 << (y%8); - if (bmp->type == GSM_OperatorLogo || bmp->type == GSM_7110OperatorLogo || bmp->type == GSM_CallerLogo) { - pixel=bmp->width*y + x; - bmp->bitmap[pixel/8] |= 1 << (7-(pixel%8)); - } +/* A few useful functions for bitmaps */ + +void GSM_SetPointBitmap(GSM_Bitmap *bmp, int x, int y) { + if (bmp->type == GSM_StartupLogo) bmp->bitmap[((y/8)*bmp->width)+x] |= 1 << (y%8); + if (bmp->type == GSM_OperatorLogo || bmp->type == GSM_CallerLogo) bmp->bitmap[(y*bmp->width+x)/8] |= 1 << (7-((y*bmp->width+x)%8)); + + /* Testing only! */ if (bmp->type == GSM_PictureImage) bmp->bitmap[9*y + (x/8)] |= 1 << (7-(x%8)); } - -void GSM_ClearPointBitmap(GSM_Bitmap *bmp, int x, int y) -{ - int pixel; - if (bmp->type == GSM_StartupLogo || bmp->type == GSM_6210StartupLogo || bmp->type == GSM_7110StartupLogo) - bmp->bitmap[((y/8)*bmp->width)+x] &= 255 - (1 << (y%8)); - if (bmp->type == GSM_OperatorLogo || bmp->type == GSM_7110OperatorLogo || bmp->type == GSM_CallerLogo) { - pixel=bmp->width*y + x; - bmp->bitmap[pixel/8] &= ~(1 << (7-(pixel%8))); - } + +void GSM_ClearPointBitmap(GSM_Bitmap *bmp, int x, int y) { + if (bmp->type == GSM_StartupLogo) bmp->bitmap[((y/8)*bmp->width)+x] &= 255 - (1 << (y%8)); +if (bmp->type == GSM_OperatorLogo || bmp->type == GSM_CallerLogo) bmp->bitmap[(y*bmp->width+x)/8] &= 255 - (1 << (7-((y*bmp->width+x)%8))); + + /* Testing only ! */ if (bmp->type == GSM_PictureImage) bmp->bitmap[9*y + (x/8)] &= 255 - (1 << (7-(x%8))); } -bool GSM_IsPointBitmap(GSM_Bitmap *bmp, int x, int y) -{ +bool GSM_IsPointBitmap(GSM_Bitmap *bmp, int x, int y) { int i=0; - int pixel; - if (bmp->type == GSM_StartupLogo || bmp->type == GSM_6210StartupLogo || bmp->type == GSM_7110StartupLogo) - i=(bmp->bitmap[((y/8)*bmp->width) + x] & 1<<((y%8))); - if (bmp->type == GSM_OperatorLogo || bmp->type == GSM_7110OperatorLogo || bmp->type == GSM_CallerLogo) { - pixel=bmp->width*y + x; - i=(bmp->bitmap[pixel/8] & 1<<(7-(pixel%8))); - } + if (bmp->type == GSM_StartupLogo) i=(bmp->bitmap[((y/8)*bmp->width) + x] & 1<<((y%8))); + if (bmp->type == GSM_OperatorLogo || bmp->type == GSM_CallerLogo) i=(bmp->bitmap[(y*bmp->width+x)/8] & 1 << (7-((y*bmp->width+x)%8))); + /* Testing only ! */ if (bmp->type == GSM_PictureImage) i=(bmp->bitmap[9*y + (x/8)] & 1<<(7-(x%8))); - + if (i) return true; else return false; } - + void GSM_ClearBitmap(GSM_Bitmap *bmp) { int i; + for (i=0;isize;i++) bmp->bitmap[i]=0; } -int GSM_GetBitmapSize(GSM_Bitmap *bitmap) -{ - switch (bitmap->type) { - case GSM_StartupLogo : /*size 84*48*/ - case GSM_OperatorLogo : /*size 72*14*/ - case GSM_CallerLogo : /*size 72*14*/ - case GSM_PictureImage : /*size 72*28*/ - return bitmap->height*bitmap->width/8; - - case GSM_7110OperatorLogo: /*size 78*21*/ - return (bitmap->width*bitmap->height + 7)/8; - - case GSM_7110StartupLogo: /*size 96*65*/ - case GSM_6210StartupLogo: /*size 96*60*/ - return (bitmap->height+7)/8*bitmap->width; - - default: - return 0; - } -} -GSM_Error GSM_ReadBitmap(GSM_SMSMessage *message, GSM_Bitmap *bitmap) -{ - int offset = 1; - unsigned char buffer[20]; - - switch (message->UDHType) { - case GSM_OpLogo: - EncodeUDHHeader(buffer, GSM_OperatorLogo); - if (message->Length!=133) return GE_UNKNOWN; - - bitmap->type = GSM_OperatorLogo; - - DecodeNetworkCode(message->MessageText, bitmap->netcode); - - offset = 4; - break; - - case GSM_CallerIDLogo: - EncodeUDHHeader(buffer, GSM_CallerLogo); - if (message->Length!=130) return GE_UNKNOWN; - - bitmap->type=GSM_CallerLogo; - - break; - default: /* error */ - return GE_UNKNOWN; - break; - } - bitmap->width = message->MessageText[offset]; - bitmap->height = message->MessageText[offset + 1]; - - if (bitmap->width!=72 || bitmap->height!=14) return GE_INVALIDIMAGESIZE; - - bitmap->size = GSM_GetBitmapSize(bitmap); - memcpy(bitmap->bitmap, message->MessageText + offset + 3, bitmap->size); - -#ifdef DEBUG - fprintf(stdout, _("Bitmap from SMS: width %i, height %i\n"),bitmap->width,bitmap->height); -#endif - - return GE_NONE; -} - -void GSM_ResizeBitmap(GSM_Bitmap *bitmap, GSM_Bitmap_Types target) +void GSM_ResizeBitmap(GSM_Bitmap *bitmap, GSM_Bitmap_Types target, GSM_Information *info) { GSM_Bitmap backup; - int x,y,width,height; - - backup=*bitmap; + int x,y,copywidth,copyheight; + + /* Copy into the backup */ + memcpy(&backup,bitmap,sizeof(GSM_Bitmap)); if (target==GSM_StartupLogo) { - bitmap->width=84; - bitmap->height=48; - } - if (target==GSM_7110StartupLogo) { - bitmap->width=96; - bitmap->height=65; - } - if (target==GSM_6210StartupLogo) { - bitmap->width=96; - bitmap->height=60; - } - if (target==GSM_OperatorLogo || target==GSM_CallerLogo) { - bitmap->width=72; - bitmap->height=14; - } - if (target==GSM_PictureImage ) { + bitmap->width=info->StartupLogoW; + bitmap->height=info->StartupLogoH; + bitmap->size=((bitmap->height/8)+(bitmap->height%8>0))*bitmap->width; + } + if (target==GSM_OperatorLogo) { + bitmap->width=info->OpLogoW; + bitmap->height=info->OpLogoH; + x=bitmap->width*bitmap->height; + bitmap->size=(x/8)+(x%8>0); + } + if (target==GSM_CallerLogo) { + bitmap->width=info->CallerLogoW; + bitmap->height=info->CallerLogoH; + x=bitmap->width*bitmap->height; + bitmap->size=(x/8)+(x%8>0); + } + if (target==GSM_PictureImage) { bitmap->width=72; bitmap->height=28; - } - if (target==GSM_7110OperatorLogo) { - bitmap->width=78; - bitmap->height=21; + bitmap->size=bitmap->width*bitmap->height/8; } bitmap->type=target; - bitmap->size=GSM_GetBitmapSize(bitmap); - - width=backup.width; - if (bitmap->widthwidth; + + if (backup.width>bitmap->width) { + copywidth=bitmap->width; #ifdef DEBUG - fprintf(stdout,_("We lost some part of image - it's cut (width from %i to %i) !\n"),backup.width,width); + fprintf(stdout,_("We lost some part of image - it's cut (width from %i to %i) !\n"),backup.width,bitmap->width); #endif /* DEBUG */ - } - - height=backup.height; - if (bitmap->heightheight; + } else copywidth=backup.width; + + if (backup.height>bitmap->height) { + copyheight=bitmap->height; #ifdef DEBUG - fprintf(stdout,_("We lost some part of image - it's cut (height from %i to %i) !\n"),backup.height,height); + fprintf(stdout,_("We lost some part of image - it's cut (height from %i to %i) !\n"),backup.height,bitmap->height); #endif /* DEBUG */ - } + } else copyheight=backup.height; + GSM_ClearBitmap(bitmap); - for (y=0;ytype) { - case GSM_OperatorLogo: - UDHType=GSM_OpLogo; - EncodeNetworkCode(MessageBuffer, bitmap->netcode); - MessageLength=3; - - /* Set the logo size */ - MessageBuffer[MessageLength++] = 0x00; - MessageBuffer[MessageLength++] = bitmap->width; - MessageBuffer[MessageLength++] = bitmap->height; - MessageBuffer[MessageLength++] = 0x01; - - memcpy(MessageBuffer+MessageLength,bitmap->bitmap,bitmap->size); - MessageLength=MessageLength+bitmap->size; - - break; - case GSM_CallerLogo: - UDHType=GSM_CallerIDLogo; - - /* Set the logo size */ - MessageBuffer[MessageLength++] = 0x00; - MessageBuffer[MessageLength++] = bitmap->width; - MessageBuffer[MessageLength++] = bitmap->height; - MessageBuffer[MessageLength++] = 0x01; - - memcpy(MessageBuffer+MessageLength,bitmap->bitmap,bitmap->size); - MessageLength=MessageLength+bitmap->size; +GSM_Error GSM_ReadSMSBitmap(GSM_SMSMessage *message, GSM_Bitmap *bitmap) +{ + int offset = 1; - break; - case GSM_PictureImage: - UDHType=GSM_ProfileUDH; + switch (SMS_DetectUDH(message)) { + case GSM_OpLogo: + if (message->MessageTextLength!=133+7) return GE_UNKNOWN; + + bitmap->type = GSM_OperatorLogo; - MessageBuffer[MessageLength++]=0x30; //SM version. Here 3.0 + bitmap->netcode[0] = '0' + (message->MessageText[0] & 0x0f); + bitmap->netcode[1] = '0' + (message->MessageText[0] >> 4); + bitmap->netcode[2] = '0' + (message->MessageText[1] & 0x0f); + bitmap->netcode[3] = ' '; + bitmap->netcode[4] = '0' + (message->MessageText[2] & 0x0f); + bitmap->netcode[5] = '0' + (message->MessageText[2] >> 4); + bitmap->netcode[6] = 0; - if (!ScreenSaver) - MessageBuffer[MessageLength++]=SM30_OTA; //ID for OTA bitmap - else - MessageBuffer[MessageLength++]=SM30_SCREENSAVER; //ID for screen saver + offset = 4; + break; - /* Length for picture part */ - MessageBuffer[MessageLength++]=0x01; //length hi - MessageBuffer[MessageLength++]=0x00; //length lo + case GSM_CallerIDLogo: + if (message->MessageTextLength!=130+7) return GE_UNKNOWN; + bitmap->type=GSM_CallerLogo; + break; + default: /* error */ + return GE_UNKNOWN; + break; + } + bitmap->width = message->MessageText[offset]; + bitmap->height = message->MessageText[offset + 1]; + + if (bitmap->width!=72 || bitmap->height!=14) return GE_INVALIDIMAGESIZE; + + bitmap->size = (bitmap->width * bitmap->height) / 8; + memcpy(bitmap->bitmap, message->MessageText + offset + 3, bitmap->size); - /* Set the logo size */ - MessageBuffer[MessageLength++] = 0x00; - MessageBuffer[MessageLength++] = bitmap->width; - MessageBuffer[MessageLength++] = bitmap->height; - MessageBuffer[MessageLength++] = 0x01; +#ifdef DEBUG + fprintf(stdout, _("Bitmap from SMS: width %i, height %i\n"),bitmap->width,bitmap->height); +#endif - memcpy(MessageBuffer+MessageLength,bitmap->bitmap,bitmap->size); - MessageLength=MessageLength+bitmap->size; + return GE_NONE; +} - if (strlen(bitmap->text)!=0) { - if (UnicodeText) { - MessageBuffer[MessageLength++]=SM30_UNICODETEXT; //ID for Unicode text - /* Length for text part */ - MessageBuffer[MessageLength++]=0x00; //length of text1 - MessageBuffer[MessageLength++]=strlen(bitmap->text)*2;//length of text2 +/* Returns message length */ - EncodeUnicode (MessageBuffer+MessageLength,bitmap->text,strlen(bitmap->text)); - MessageLength=MessageLength+2*strlen(bitmap->text); - } else { - MessageBuffer[MessageLength++]=SM30_ISOTEXT; //ID for ISO-8859-1 text +int GSM_SaveSMSBitmap(GSM_SMSMessage *message, GSM_Bitmap *bitmap) +{ + int current=0; + + char UserDataHeader[7] = { 0x06, /* UDH Length */ + 0x05, /* IEI: application port addressing scheme, 16 bit address */ + 0x04, /* IEI length */ + 0x15, /* destination address: high byte */ + 0x00, /* destination address: low byte */ + 0x00, /* originator address */ + 0x00}; + + char Data[7] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + + /* Default settings for SMS message: + - no delivery report + - Class Message 1 + - no compression + - 8 bit data + - SMSC no. 1 + - validity 3 days + - set UserDataHeaderIndicator + */ + + message->Type = GST_MO; + message->Class = 1; + message->Compression = false; + message->EightBit = true; + message->MessageCenter.No = 1; + message->Validity = 4320; /* 4320 minutes == 72 hours */ + message->ReplyViaSameSMSC = false; - /* Length for text part */ - MessageBuffer[MessageLength++]=0x00; //length of text1 - MessageBuffer[MessageLength++]=strlen(bitmap->text); //length of text2 + switch (bitmap->type) { + case GSM_OperatorLogo: + message->UDHPresent = true; + UserDataHeader[4] = 0x82; /* NBS port 0x1582 */ + + /* Set the network code */ + Data[current++] = ((bitmap->netcode[1] & 0x0f) << 4) | (bitmap->netcode[0] & 0xf); + Data[current++] = 0xf0 | (bitmap->netcode[2] & 0x0f); + Data[current++] = ((bitmap->netcode[5] & 0x0f) << 4) | (bitmap->netcode[4] & 0xf); - memcpy(MessageBuffer+MessageLength,bitmap->text,strlen(bitmap->text)); - MessageLength=MessageLength+strlen(bitmap->text); - } - } break; - + case GSM_CallerLogo: + message->UDHPresent = true; + UserDataHeader[4] = 0x83; /* NBS port 0x1583 */ + break; default: /* error */ break; } - GSM_MakeMultiPartSMS2(SMS,MessageBuffer,MessageLength, UDHType, GSM_Coding_Default); + /* Set the logo size */ + current++; + Data[current++] = bitmap->width; + Data[current++] = bitmap->height; - return 0; -} + Data[current++] = 0x01; + + memcpy(message->UDH,UserDataHeader,7); + memcpy(message->MessageText,Data,current); + memcpy(message->MessageText+current,bitmap->bitmap,bitmap->size); + return current; +} diff --git a/common/gsm-common.c b/common/gsm-common.c index 54e63cb..72c1b8d 100644 --- a/common/gsm-common.c +++ b/common/gsm-common.c @@ -11,14 +11,8 @@ Released under the terms of the GNU GPL, see file COPYING for more details. $Log$ - Revision 1.1.1.1 2001/11/25 21:58:59 short - :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001 - - Revision 1.8 2001/11/13 16:12:20 pkot - Preparing libsms to get to work. 6210/7110 SMS and SMS Folder updates - - Revision 1.7 2001/11/08 16:34:19 pkot - Updates to work with new libsms + Revision 1.1.1.2 2002/04/03 00:07:55 short + Found in "gnokii-working" directory, some November-patches version Revision 1.6 2001/09/14 12:15:28 pkot Cleanups from 0.3.3 (part1) @@ -43,8 +37,72 @@ */ +#include #include -#include "gsm-common.h" +#include /* for rand() */ +#include + +/* Coding functions */ +#define NUMBER_OF_7_BIT_ALPHABET_ELEMENTS 128 +static unsigned char GSM_DefaultAlphabet[NUMBER_OF_7_BIT_ALPHABET_ELEMENTS] = { + + /* ETSI GSM 03.38, version 6.0.1, section 6.2.1; Default alphabet */ + /* Characters in hex position 10, [12 to 1a] and 24 are not present on + latin1 charset, so we cannot reproduce on the screen, however they are + greek symbol not present even on my Nokia */ + + '@', 0xa3, '$', 0xa5, 0xe8, 0xe9, 0xf9, 0xec, + 0xf2, 0xc7, '\n', 0xd8, 0xf8, '\r', 0xc5, 0xe5, + '?', '_', '?', '?', '?', '?', '?', '?', + '?', '?', '?', '?', 0xc6, 0xe6, 0xdf, 0xc9, + ' ', '!', '\"', '#', 0xa4, '%', '&', '\'', + '(', ')', '*', '+', ',', '-', '.', '/', + '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', ':', ';', '<', '=', '>', '?', + 0xa1, 'A', 'B', 'C', 'D', 'E', 'F', 'G', + 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', + 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', + 'X', 'Y', 'Z', 0xc4, 0xd6, 0xd1, 0xdc, 0xa7, + 0xbf, 'a', 'b', 'c', 'd', 'e', 'f', 'g', + 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', + 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', + 'x', 'y', 'z', 0xe4, 0xf6, 0xf1, 0xfc, 0xe0 +}; + +unsigned char EncodeWithDefaultAlphabet(unsigned char value) +{ + unsigned char i; + + if (value == '?') return 0x3f; + + for (i = 0; i < NUMBER_OF_7_BIT_ALPHABET_ELEMENTS; i++) + if (GSM_DefaultAlphabet[i] == value) + return i; + + return '?'; +} + +unsigned char DecodeWithDefaultAlphabet(unsigned char value) +{ + return GSM_DefaultAlphabet[value]; +} + +wchar_t EncodeWithUnicodeAlphabet(unsigned char value) +{ + wchar_t retval; + + if (mbtowc(&retval, &value, 1) == -1) return '?'; + else return retval; +} + +unsigned char DecodeWithUnicodeAlphabet(wchar_t value) +{ + unsigned char retval; + + if (wctomb(&retval, value) == -1) return '?'; + else return retval; +} + GSM_Error Unimplemented(void) { @@ -64,30 +122,6 @@ GSM_MemoryType StrToMemoryType(const char *s) X(MC); X(LD); X(MT); - X(IN); - X(OU); - X(AR); - X(TE); - X(F1); - X(F2); - X(F3); - X(F4); - X(F5); - X(F6); - X(F7); - X(F8); - X(F9); - X(F10); - X(F11); - X(F12); - X(F13); - X(F14); - X(F15); - X(F16); - X(F17); - X(F18); - X(F19); - X(F20); return GMT_XX; #undef X } @@ -98,3 +132,493 @@ inline void GSM_DataClear(GSM_Data *data) { memset(data, 0, sizeof(GSM_Data)); } + /* TP-Validity Period handling */ + +/* TP-Validity Period handling */ +unsigned char SMS_Validity_to_VP(int Validity) +{ + /* FIXME: error-checking for correct Validity - it should not be bigger then + 63 weeks and smaller then 5minutes. We should also test intervals because + the SMS->Validity to TP-VP is not continuos. I think that the simplest + solution will be an array of correct values. We should parse it and if we + find the closest TP-VP value we should use it. Or is it good to take + closest smaller TP-VP as we do now? I think it is :-) */ + + /* 5 minutes intervals up to 12 hours = 720 minutes */ + if (Validity <= 720) + return((unsigned char) (Validity/5)-1); + + /* 30 minutes intervals up to 1 day */ + else if ((Validity > 720) && (Validity <= 1440)) + return((unsigned char) ((Validity-720)/30)+143); + + /* 1 day intervals up to 30 days */ + else if ((Validity > 1440) && (Validity <= 43200)) + return((unsigned char) (Validity/1440)+166); + + /* 1 week intervals up to 63 weeks */ + else if ((Validity > 43200) && (Validity <= 635040)) + return((unsigned char) (Validity/10080)+192); + + /* Validity too big, strip it to the highest possible value */ + return((unsigned char)0xFF); +} + +int SMS_VP_to_Validity(GSM_SMSMessageValidity Validity) +{ + if (Validity<=GSMV_1_Hour) + return(1*60); + if (Validity<=GSMV_6_Hours) + return(6*60); + if (Validity<=GSMV_24_Hours) + return(24*60); + if (Validity<=GSMV_72_Hours) + return(72*60); + if (Validity<=GSMV_1_Week) + return(7*24*60); + if (Validity<=GSMV_Max_Time) + return(63*7*24*60); + /* Validity too big, strip it to the highest possible value */ + return(63*7*24*60); +} + +/* This function implements packing of numbers (SMS Center number and + * destination number) for SMS sending function. + * RETURN: strlen(Number+(*Number=='+')), that means the number of INPUT + * digits (without '+' marker) which is equal to the number of written + * digit nibbles (without possible trailing 0xF filler) + */ +int SemiOctetPack(char *Number, unsigned char *Output) +{ + unsigned char *IN = Number; /* Pointer to the input number */ + unsigned char *OUT = Output; /* Pointer to the output */ + int count = 0; /* This variable is used to notify us about count of already + packed numbers. */ + + /* The first byte in the Semi-octet representation of the address field is + the Type-of-Address. This field is described in the official GSM + specification 03.40 version 5.3.0, section 9.1.2.5, page 33. We support + only international and unknown number. */ + + if (*IN == '+') { + *OUT++ = GNT_INTERNATIONAL; /* International number */ + IN++; + } else *OUT++ = GNT_UNKNOWN; /* Unknown number */ + + /* The next field is the number. It is in semi-octet representation - see + GSM scpecification 03.40 version 5.3.0, section 9.1.2.3, page 31. */ + + while (*IN) { + if (count & 0x01) { + *OUT = *OUT | ((*IN - '0') << 4); + OUT++; + } + else + *OUT = *IN - '0'; + count++; IN++; + } + + /* We should also fill in the most significant bits of the last byte with + 0x0f (1111 binary) if the number is represented with odd number of + digits. */ + + if (count & 0x01) { + *OUT=*OUT | 0xf0; + OUT++; + return (2 * (OUT - Output - 1) - 1); + } + + return (2 * (OUT - Output - 1)); +} + +/* This function implements unpacking of numbers (SMS Center number and + * destination number) for SMS receiving function. + * INPUT: Number of NIBBLES which is + * equal to the number of written OUTPUT characters (without optional '+' + * marker), may be +1 as it is hard to predict possible trailing 0xF filler + * RETURN: Number with skipped number or NULL for error + */ +char *SemiOctetUnpack(char *dest,size_t destlen,u8 *Number,size_t nibbles) +{ + int i; + char *d; + u8 *s,Digit; + + if (destlen<2) + return(NULL); /* buffer overflow */ + + d=dest; + s=Number; + if (*s++ == GNT_INTERNATIONAL) + *d++='+'; + + for (i=0;idest+destlen) + return(NULL); /* buffer overflow */ + /* Here we advance "s" during first nibble read as when we finish + * now we must return the pointer AFTER it + */ + if (!(i&1)) + Digit= (*s++ ) & 0x0F; + else + Digit=((s[-1])>>4) & 0x0F; + if (i+1==nibbles && Digit==0xF) + break; /* nibbles+1 is allowed */ + if (Digit>9) + return(NULL); /* digit=A..F */ + *d++=Digit+'0'; + } + *d='\0'; + + return(s); +} + +/* When you are so poor that you even don't have your own buffer... + * RETURN: local static buffer address or NULL for error + * Note: address of Number with skipped number is lost! + * Note: be sure that this function is called only once before processing the result! + */ +char *SemiOctetUnpack_static(u8 *Number,size_t nibbles) +{ + static char Buffer[GNOKII_MAX( + GNOKII_MAX(GSM_MAX_SMS_CENTER_LENGTH,GSM_MAX_SENDER_LENGTH) + ,GSM_MAX_DESTINATION_LENGTH) + ] = ""; + char *r; + + if (!(r=SemiOctetUnpack(Buffer,sizeof(Buffer),Number,nibbles))) + return(NULL); + return(Buffer); +} + +unsigned char GSM_Default_Alphabet[] = { + + /* ETSI GSM 03.38, version 6.0.1, section 6.2.1; Default alphabet */ + /* Characters in hex position 10, [12 to 1a] and 24 are not present on + latin1 charset, so we cannot reproduce on the screen, however they are + greek symbol not present even on my Nokia */ + + '@', 0xa3, '$', 0xa5, 0xe8, 0xe9, 0xf9, 0xec, + 0xf2, 0xc7, '\n', 0xd8, 0xf8, '\r', 0xc5, 0xe5, + '?', '_', '?', '?', '?', '?', '?', '?', + '?', '?', '?', '?', 0xc6, 0xe6, 0xdf, 0xc9, + ' ', '!', '\"', '#', 0xa4, '%', '&', '\'', + '(', ')', '*', '+', ',', '-', '.', '/', + '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', ':', ';', '<', '=', '>', '?', + 0xa1, 'A', 'B', 'C', 'D', 'E', 'F', 'G', + 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', + 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', + 'X', 'Y', 'Z', 0xc4, 0xd6, 0xd1, 0xdc, 0xa7, + 0xbf, 'a', 'b', 'c', 'd', 'e', 'f', 'g', + 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', + 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', + 'x', 'y', 'z', 0xe4, 0xf6, 0xf1, 0xfc, 0xe0 +}; + +static unsigned char GetAlphabetValue(unsigned char value) +{ + unsigned char i; + + if (value == '?') return 0x3f; + + for (i = 0 ; i < 128 ; i++) + if (GSM_Default_Alphabet[i] == value) + return i; + + return 0x3f; /* '?' */ +} + +/* Function packs the '\0'-terminated 7-bit "input" string to the "output" 8-bit stream. + * UsedBits specifies the number of bottom bits already used in (*output) byte. + * RETURNS: Number of bytes written, at least partially + */ +int PackSevenBitsToEight(int UsedBits, unsigned char *input, unsigned char *output) +{ + unsigned char *OUT = output; /* Current pointer to the output buffer */ + unsigned char *IN = input; /* Current pointer to the input buffer */ + + UsedBits %= 8; /* just sanity, (0<=x<8) assert would be appropriate */ + + while (*IN) { + unsigned char Byte = GetAlphabetValue(*IN); + + /* UsedBits specifies the number of already allocated bits in OUT[-1] + * byte. If there were no bits used, we just don't advance the destination + * pointer and we gain the full 8 bits of free space in the current byte. + */ + if (UsedBits == 0) + UsedBits = 8; + else + OUT++; + + /* Write upper (UsedBits) of Byte to the bottom of (*OUT) */ + *OUT = Byte >> (8 - UsedBits); + /* If we don't write at 0th bit of the octet, we should write + * a second part of the previous octet + * Write lower (8-UsedBits) to the top of OUT[-1] + */ + if (UsedBits != 8) + OUT[-1] = (OUT[-1] & ((1<> Bits; + + /* If we don't start from 0th bit, we shouldn't go to the + next char. Under *OUT we have now 0 and under Rest - + _first_ part of the char. */ + if ((IN != input) || (Bits == 7)) OUT++; + IN++; + + if ((OUT - output) >= out_length) break; + + /* After reading 7 octets we have read 7 full characters but + we have 7 bits as well. This is the next character */ + if (Bits == 1) { + *OUT = Rest; + OUT++; + Bits = 7; + Rest = 0x00; + } else { + Bits--; + } + } + + return OUT - output; +} + +GSM_Error SMS_SetupUDH(GSM_SMSMessage *sms,GSM_UDH UDHType) +{ +unsigned short srcport,dstport; + + sms->UDHPresent=true; + switch (UDHType) { + case GSM_RingtoneUDH: /* FALLTHRU */ + case GSM_OpLogo: /* FALLTHRU */ + case GSM_CallerIDLogo: + sms->UDH[1+0]=0x05; /* logos (16-bit ports) */ + sms->UDH[1+1]=4; /* sizeof(dstport)+sizeof(srcport) */ + sms->UDH[0]=2+sms->UDH[1+1]; /* total UserDataHeader size */ + switch (UDHType) { + case GSM_RingtoneUDH: dstport=0x1581; break; + case GSM_OpLogo: dstport=0x1582; break; + case GSM_CallerIDLogo: dstport=0x1583; break; + default: dstport=0; /* double shut up GCC */ + } + /* I have tested on Nokia 9000i on GSM_RingtoneUDH that it will silently + * ignore Multi-SMS incoming ringtone with srcport==0 . + * Despite this Single-SMS incoming ringtone is accepted even with srcport==0 ! + * When both ports were equal to 0x1581 everything was fine. + */ + srcport=dstport; + sms->UDH[1+2+0+0]=dstport>>8; + sms->UDH[1+2+0+1]=dstport>>0; + sms->UDH[1+2+2+0]=srcport>>8; + sms->UDH[1+2+2+1]=srcport>>0; + return(GE_NONE); + default: + break; + } + sms->UDHPresent=false; + return(GE_NOTIMPLEMENTED); /* error */ +} + +GSM_UDH SMS_DetectUDH(GSM_SMSMessage *sms) +{ + if (!sms->UDHPresent) + return(GSM_NoUDH); + if (sms->UDH[0]< 1/*type*/ +1/*sub-length*/) + return(GSM_NoUDH); /* error */ + switch (sms->UDH[1]) { + + case 0x00: /* concatenated messages (8-bit reference) */ + dprintf(_("Concatenated message!!!\n")); + if (sms->UDH[2]<3) + return(GSM_NoUDH); /* error */ + return(GSM_ConcatenatedMessages); + break; + + case 0x08: /* concatenated messages (16-bit reference) */ + dprintf(_("Concatenated message!!!\n")); + if (sms->UDH[2]<4) + return(GSM_NoUDH); /* error */ + return(GSM_ConcatenatedMessages); + break; + + case 0x05: /* logos (16-bit ports) */ + if (sms->UDH[2]<4) + return(GSM_NoUDH); /* error */ + switch ((sms->UDH[3]<<8) | (sms->UDH[4]<<0)) { + case 0x1582: + return(GSM_OpLogo); + case 0x1583: + return(GSM_CallerIDLogo); + } + break; + default: + break; + } + return(GSM_NoUDH); /* error - not recognized */ +} + +/* RETURNS: Total number of SMSes, sms->MessageTextLength will contain cargoitems + */ +static int SMS_Deconcatenate_calcparts(GSM_SMSMessage *sms,size_t *cargoitemsp,size_t buflen,size_t messagetextpreitems) +{ +int bits=(sms->EightBit ? 8 : 7); +int UDHbytes=(!sms->UDHPresent ? 0 : 1+sms->UDH[0]); +int UDHitems=(UDHbytes*8 +bits-1/*round-up*/)/bits; +int lengthitems=(sms->EightBit ? GSM_MAX_SMS_8BIT_LENGTH : GSM_MAX_SMS_LENGTH); +int cargoitems=lengthitems-UDHitems-messagetextpreitems; + + if (cargoitemsp) + *cargoitemsp=cargoitems; + + return((buflen +cargoitems-1/*round-up*/)/cargoitems); +} + +/* RETURNS: Whether we should send the prepared (*sms) + */ +bool SMS_Deconcatenate(GSM_Deconcatenate_state *state,GSM_SMSMessage *sms,char *buf,size_t buflen,bool useudh) +{ +size_t offset_start,offset_end,messagetextpreitems; + +#define CONCAT_TEXT_HEADER "%2d/%-2d: " +/* This length has to match 7bit-to-8bit length of single concat UDH + * due to broken assumptions at least in xgnokii_sms.c + * =round-up((UDHlength+IEItype+IEIlength+reference+total+sequence)*8/7) + */ +#define CONCAT_TEXT_HEADER_LENGTH 7 + + if (state->first) { + /* INIT */ + state->first=false; + + if ((state->singleshot=(1>=SMS_Deconcatenate_calcparts(sms,NULL,buflen,0)))) { + memcpy(sms->MessageText,buf,buflen); + sms->MessageText[sms->MessageTextLength=buflen]='\0'; + return(true); /* send it */ + } + state->sequence=0; + state->sequencep=NULL; + } + if (state->singleshot) + return(false); /* done */ + + if (!state->sequence && useudh) { +u8 *d; + if (!sms->UDHPresent) { + sms->UDHPresent=true; + sms->UDH[0]=0; + } + if (1/*sizeof(UDH[0])*/ +sms->UDH[0]/*current UDH len*/ +6/*concatenation UDH len*/ + > sizeof(sms->UDH)) + return(false); /* error - UDH buffer overflow - shouldn't happen */ + d=(sms->UDH+1)+sms->UDH[0]; + + *d++=0x00; /* concatenated messages (IEI) (8-bit reference number) */ + *d++=0x03; /* IEI data length */ + *d++=rand(); /* 8-bit reference number */ + *d++=0; /* number of messages - not yet known, filled by d[-2] below! */ + state->sequencep=d; + *d++=0; /* message sequence number - not yet filled */ + + sms->UDH[0]=d-(sms->UDH+1); + + d[-2]=SMS_Deconcatenate_calcparts(sms,&state->cargoitems,buflen,0); /* UDH[0] must be already set */ + } + if (!state->sequence && !useudh) { + gsprintf(sms->MessageText,sizeof(sms->MessageText),CONCAT_TEXT_HEADER, + 0, SMS_Deconcatenate_calcparts(sms,&state->cargoitems,buflen,CONCAT_TEXT_HEADER_LENGTH)); + } + + /* It is important that "lastsequence" is not "u8" and so it will not overflow + * on the 255th part of SMS + */ + state->sequence++; + + if (useudh) + *state->sequencep=state->sequence; + else { + gsprintf(sms->MessageText,3,"%2d",state->sequence); + sms->MessageText[2]='/'; /* it may got overwritten by '\0' */ + } + + offset_start=(state->sequence-1)*state->cargoitems; + offset_end=GNOKII_MIN(buflen,(state->sequence-1+1)*state->cargoitems); + + if (offset_start>=offset_end) + return(false); /* no more data available */ + + messagetextpreitems=(useudh ? 0 : CONCAT_TEXT_HEADER_LENGTH); + memcpy(sms->MessageText+messagetextpreitems,buf+offset_start,offset_end-offset_start); + sms->MessageText[sms->MessageTextLength=messagetextpreitems+offset_end-offset_start]='\0'; + dprintf(_("Fragment %d: %d..%d (buflen=%d)\n"),state->sequence,offset_start,offset_end,buflen); + + return(true); /* send it! */ +} + +static inline u8 SMS_CharFromHex(unsigned u) +{ + u&=0xDF; + return(u<'A'?u-('0'&0xDF):(u-('A'&0xDF))+0xA); +} + +/* RETURN: end of "d" block or NULL if error + * Note: s==d on input is permitted + */ +u8 *SMS_BlockFromHex(u8 *d,const char *s,size_t len) +{ + while (len>=2) { + if (!isxdigit(s[0]) || !isxdigit(s[1])) + break; /* error */ + *d++=(SMS_CharFromHex(s[0])<<4)|SMS_CharFromHex(s[1]); + s+=2; + len-=2; + } + if (len) + return(NULL); /* error */ + return(d); +} + +static inline char SMS_CharToHex(u8 x) +{ + x&=0x0F; + if (x<10) return(x +'0'); + else return(x-10+'A'); +} + +/* RETURN: end of "d" block (no errors generated) + */ +char *SMS_BlockToHex(char *d,const u8 *s,size_t len) +{ + while (len--) { + *d++=SMS_CharToHex(*s>>4U); + *d++=SMS_CharToHex(*s ); + s++; + } + return(d); +} diff --git a/common/gsm-encoding.c b/common/gsm-encoding.c index b539505..7408b27 100644 --- a/common/gsm-encoding.c +++ b/common/gsm-encoding.c @@ -13,14 +13,8 @@ Functions for encoding SMS, calendar and other things. $Log$ - Revision 1.1.1.1 2001/11/25 21:59:06 short - :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001 - - Revision 1.4 2001/11/22 17:56:53 pkot - smslib update. sms sending - - Revision 1.3 2001/11/17 20:15:31 pkot - Typo in default alphabet + Revision 1.1.1.2 2002/04/03 00:08:03 short + Found in "gnokii-working" directory, some November-patches version Revision 1.2 2001/11/08 16:34:19 pkot Updates to work with new libsms @@ -32,6 +26,7 @@ */ #include +#include #define NUMBER_OF_7_BIT_ALPHABET_ELEMENTS 128 @@ -55,7 +50,7 @@ static unsigned char GSM_DefaultAlphabet[NUMBER_OF_7_BIT_ALPHABET_ELEMENTS] = { 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 0xc4, 0xd6, 0xd1, 0xdc, 0xa7, 0xbf, 'a', 'b', 'c', 'd', 'e', 'f', 'g', - 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', + 'H', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 0xe4, 0xf6, 0xf1, 0xfc, 0xe0 }; @@ -155,6 +150,7 @@ int Pack7BitCharacters(int offset, unsigned char *input, unsigned char *output) while ((IN - input) < strlen(input)) { unsigned char Byte = EncodeWithDefaultAlphabet(*IN); + *OUT = Byte >> (7 - Bits); /* If we don't write at 0th bit of the octet, we should write a second part of the previous octet */ diff --git a/common/gsm-error.c b/common/gsm-error.c index 2aab609..bc9d095 100644 --- a/common/gsm-error.c +++ b/common/gsm-error.c @@ -13,11 +13,8 @@ Error codes. $Log$ - Revision 1.1.1.2 2001/12/14 19:48:52 short - :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Fri Dec 14 20:46 CET 2001 - - Revision 1.3 2001/12/14 14:37:41 pkot - Cleanups. Call divert support for at and 7110 series + Revision 1.1.1.3 2002/04/03 00:08:02 short + Found in "gnokii-working" directory, some November-patches version Revision 1.2 2001/11/08 16:34:19 pkot Updates to work with new libsms @@ -40,7 +37,7 @@ char *print_error(GSM_Error e) case GE_TIMEOUT: return "Command timed out."; case GE_TRYAGAIN: return "Try again."; case GE_INVALIDSECURITYCODE: return "Invalid Security code."; - case GE_NOTIMPLEMENTED: return "Called command is not implemented for the used model."; + case GE_NOTIMPLEMENTED: return "Command called isn't implemented in model."; case GE_INVALIDSMSLOCATION: return "Invalid SMS location."; case GE_INVALIDPHBOOKLOCATION: return "Invalid phonebook location."; case GE_INVALIDMEMORYTYPE: return "Invalid type of memory."; diff --git a/common/gsm-networks.c b/common/gsm-networks.c index 4101a38..1a72427 100644 --- a/common/gsm-networks.c +++ b/common/gsm-networks.c @@ -1,20 +1,29 @@ /* + $Id$ + G N O K I I A Linux/Unix toolset and driver for Nokia mobile phones. + Copyright (C) 1999, 2000 Hugh Blemings & Pavel Janík ml. + Released under the terms of the GNU GPL, see file COPYING for more details. This file implements GSM networks searching. + $Log$ + Revision 1.1.1.8 2002/04/03 00:07:56 short + Found in "gnokii-working" directory, some November-patches version + + Revision 1.14 2001/06/28 00:28:45 pkot + Small docs updates (Pawel Kot) + + */ #include - -#include "gsm-common.h" #include "gsm-networks.h" -#include "gsm-coding.h" GSM_Country GSM_Countries[] = { @@ -268,50 +277,19 @@ GSM_Network GSM_Networks[] = { "340 01", "AMERIS" }, { "400 01", "AZERCELL GSM" }, { "400 02", "Bakcell GSM 2000" }, - - { "404 01", "AIRCELL"}, - { "404 02", "Evergrowth"}, - { "404 03", "Bharthi Telenet"}, - { "404 05", "Fascel"}, - { "404 07", "Tata Cell"}, //TATA Cellular - { "404 08", "Koshika"}, - { "404 09", "Reliance"}, - { "404 10", "AIRTEL"}, //AirTel - { "404 11", "Essar"}, //Essar Cellphone - { "404 12", "Escotel"}, - { "404 14", "Spice"}, //Modicom - { "404 15", "AIRCELL"}, //Essar Cellphone - { "404 18", "Reliance"}, - { "404 19", "Escotel"}, - { "404 20", "Orange"}, //Max Touch - { "404 21", "BPL Mobile"}, //BPL - Mobile - { "404 22", "Birla AT&T"}, - { "404 24", "Birla AT&T"}, - { "404 26", "Koshika"}, - { "404 27", "BPL Mobile"}, //BPL USWEST Cellular - { "404 30", "Usha"}, //Command - { "404 31", "AIRCELL"}, //? - { "404 31", "Command"}, //? - { "404 32", "Koshika"}, - { "404 34", "Koshika"}, - { "404 36", "Reliance"}, - { "404 40", "SkyCell"}, - { "404 41", "RPG"}, //RPG Cellular - { "404 42", "AIRCELL"}, //AIRCEL - { "404 43", "BPL Mobile"}, - { "404 44", "Spice"}, - { "404 45", "AIRTEL-blr"}, - { "404 46", "BPL Moibile"}, - { "404 49", "AIRTEL"}, - { "404 50", "Reliance"}, - { "404 52", "Reliance"}, - { "404 56", "Escotel"}, - { "404 60", "AIRCELL"}, - { "404 67", "Reliance"}, - { "404 70", "Hexacom"}, - { "404 78", "RPG"}, - { "404 85", "Reliance"}, - + { "404 07", "TATA Cellular" }, + { "404 10", "AirTel" }, + { "404 11", "Essar Cellphone" }, + { "404 12", "Escotel" }, + { "404 14", "Modicom" }, + { "404 15", "Essar Cellphone" }, + { "404 20", "Max Touch" }, + { "404 21", "BPL - Mobile" }, + { "404 27", "BPL USWEST Cellular" }, + { "404 30", "Command" }, + { "404 40", "SkyCell" }, + { "404 41", "RPG Cellular" }, + { "404 42", "AIRCEL" }, { "410 01", "Mobilink" }, { "413 02", "DIALOG GSM" }, { "415 01", "CELLIS" }, @@ -465,18 +443,3 @@ char *GSM_GetCountryCode(char *CountryName) return GSM_Countries[index].Code; } - -void EncodeNetworkCode(unsigned char* buffer, unsigned char* output) -{ - EncodeBCD (buffer, output, 6, false); - buffer[1]=buffer[1] | 0xf0; -} - -void DecodeNetworkCode(unsigned char* buffer, unsigned char* output) -{ - DecodeBCD (output, buffer, 3); - output[6]=output[5]; - output[5]=output[4]; - output[4]=output[3]; - output[3]=' '; -} diff --git a/common/gsm-ringtones.c b/common/gsm-ringtones.c index 3db43b6..6b9d357 100644 --- a/common/gsm-ringtones.c +++ b/common/gsm-ringtones.c @@ -1,1036 +1,615 @@ /* + $Id$ + G N O K I I A Linux/Unix toolset and driver for Nokia mobile phones. + Copyright (C) 1999, 2000 Hugh Blemings & Pavel Janík ml. + Released under the terms of the GNU GPL, see file COPYING for more details. This file provides support for ringtones. -*/ + $Log$ + Revision 1.1.1.8 2002/04/03 00:07:57 short + Found in "gnokii-working" directory, some November-patches version -#ifdef WIN32 - #include - #include "misc_win32.h" -#else - #include -#endif + Revision 1.2 2001/09/20 21:46:21 pkot + Locale cleanups (Pawel Kot) -#include "gsm-api.h" -GSM_Ringtone SMringtone; -GSM_BinRingtone ringtone; +*/ + +#include "gsm-ringtones.h" +#include "misc.h" /* Beats-per-Minute Encoding */ int BeatsPerMinute[] = { - 25, 28, 31, 35, 40, 45, 50, 56, 63, 70, - 80, 90, 100, 112, 125, 140, 160, 180, 200, 225, - 250, 285, 320, 355, 400, 450, 500, 565, 635, 715, - 800, 900 -}; - -struct OneRingtone RingingTones[] = { - {"",0,0}, -/* 1 */ {"Uploaded #1",0,0}, /* 2 */ {"Ring ring",0,0}, -/* 3 */ {"Low",0,0}, /* 4 */ {"Fly",0,0}, -/* 5 */ {"Mosquito",0,0}, /* 6 */ {"Bee",0,0}, -/* 7 */ {"Intro",0,0}, /* 8 */ {"Etude",0,0}, -/* 9 */ {"Hunt",0,0}, /* 10 */ {"Going up",0,0}, -/* 11 */ {"City bird",0,0}, /* 12 */ {"Chase",0,0}, -/* 13 */ {"Scifi",0,0}, /* 14 */ {"Kick",0,0}, -/* 15 */ {"Do-mi-so",0,0}, /* 16 */ {"Robo N1X",0,0}, -/* 17 */ {"Dizzy",0,0}, /* 18 */ {"Playground",0,0}, -/* 19 */ {"That's it!",0,0}, /* 20 */ {"Grande valse",0,0}, -/* 21 */ {"Knock knock",0,0}, /* 22 */ {"Knock again",0,0}, -/* 23 */ {"Helan",0,0}, /* 24 */ {"Fuga",0,0}, -/* 25 */ {"Menuet",0,0}, /* 26 */ {"Ode to Joy",0,0}, -/* 27 */ {"Elise",0,0}, /* 28 */ {"Mozart 40",0,0}, -/* 29 */ {"Piano Concerto",0,0},/* 30 */ {"William Tell",0,0}, -/* 31 */ {"Badinerie",0,0}, /* 32 */ {"Polka",0,0}, -/* 33 */ {"Attraction",0,0}, /* 34 */ {"Polite",0,0}, -/* 35 */ {"Persuasion",0,0}, /* 36 */ {"Tick tick",0,0}, -/* 37 */ {"Samba",0,0}, /* 38 */ {"Orient",0,0}, -/* 39 */ {"Charleston",0,0}, /* 40 */ {"Songette",0,0}, -/* 41 */ {"Jumping",0,0}, /* 42 */ {"Lamb",0,0}, -/* 43 */ {"Marry",0,0}, /* 44 */ {"Tango",0,0}, -/* 45 */ {"Tangoed",0,0}, /* 46 */ {"Down",0,0}, -/* 47 */ {"Polska",0,0}, /* 48 */ {"WalzeBrilliant",0,0}, -/* 49 */ {"Cicada",0,0}, /* 50 */ {"Trio",0,0}, -/* 51 */ {"Circles",0,0}, /* 52 */ {"Nokia tune",0,0}, -/* 53 */ {"Sunny walks",0,0}, /* 54 */ {"Basic rock",0,0}, -/* 55 */ {"Reveille",0,0}, /* 56 */ {"Groovy Blue",0,0}, -/* 57 */ {"Brave Scotland",0,0},/* 58 */ {"Matilda",0,0}, -/* 59 */ {"Bumblebee",0,0}, /* 60 */ {"Hungarian",0,0}, -/* 61 */ {"Valkyrie",0,0}, /* 62 */ {"Bach #3",0,0}, -/* 63 */ {"Toreador",0,0}, /* 64 */ {"9th Symphony",0,0}, -/* 65 */ {"Uploaded #2",0,0}, /* 66 */ {"Uploaded #3",0,0}, -/* 67 */ {"Uploaded #4",0,0}, /* 68 */ {"Uploaded #5",0,0}, - {"",0,0} + 25, + 28, + 31, + 35, + 40, + 45, + 50, + 56, + 63, + 70, + 80, + 90, + 100, + 112, + 125, + 140, + 160, + 180, + 200, + 225, + 250, + 285, + 320, + 355, + 400, + 450, + 500, + 565, + 635, + 715, + 800, + 900 }; int OctetAlign(unsigned char *Dest, int CurrentBit) { - int i=0; + int i=0; - while((CurrentBit+i)%8) { - ClearBit(Dest, CurrentBit+i); - i++; - } + while((CurrentBit+i)%8) { + ClearBit(Dest, CurrentBit+i); + i++; + } - return CurrentBit+i; + return CurrentBit+i; } int OctetAlignNumber(int CurrentBit) { - int i=0; + int i=0; - while((CurrentBit+i)%8) { i++; } + while((CurrentBit+i)%8) { + i++; + } - return CurrentBit+i; + return CurrentBit+i; } int BitPack(unsigned char *Dest, int CurrentBit, unsigned char *Source, int Bits) { + int i; - int i; + for (i=0; i is always + octet-aligned. */ + StartBit=OctetAlign(package, StartBit); + + StartBit=BitPackByte(package, StartBit, Sound, 7); + StartBit=BitPackByte(package, StartBit, BasicSongType, 3); + + /* Packing the name of the tune. */ + StartBit=BitPackByte(package, StartBit, strlen(ringtone->name)<<4, 4); + StartBit=BitPack(package, StartBit, ringtone->name, 8*strlen(ringtone->name)); + + /* Info about song pattern */ + StartBit=BitPackByte(package, StartBit, 0x01, 8); /* One song pattern */ + StartBit=BitPackByte(package, StartBit, PatternHeaderId, 3); + StartBit=BitPackByte(package, StartBit, A_part, 2); + StartBit=BitPackByte(package, StartBit, 0, 4); /* No loop value */ + + /* Info, how long is contents for SMS */ + HowLong=30+8*strlen(ringtone->name)+17+8+8+13; - /* Find the most frequently used duration and use this for the default */ - for (i=0;i<6;i++) buffer[i]=0; - for (i=0;iNrNotes;i++) { - switch (ringtone->notes[i].duration) { - case 192: buffer[0]++; break; - case 128: buffer[0]++; break; - case 96: buffer[1]++; break; - case 64: buffer[1]++; break; - case 48: buffer[2]++; break; - case 32: buffer[2]++; break; - case 24: buffer[3]++; break; - case 16: buffer[3]++; break; - case 12: buffer[4]++; break; - case 8: buffer[4]++; break; - case 6: buffer[5]++; break; - case 4: buffer[5]++; break; - } - } - - /* Now find the most frequently used */ - j=0; - for (i=0;i<6;i++) { - if (buffer[i]>j) { - k=i; - j=buffer[i]; - } - } - - /* Finally convert the default duration */ - switch (k) { - case 0: DefNoteDuration=128; break; - case 1: DefNoteDuration= 64; break; - case 2: DefNoteDuration= 32; break; - case 3: DefNoteDuration= 16; break; - case 4: DefNoteDuration= 8; break; - case 5: DefNoteDuration= 4; break; - default: DefNoteDuration= 16; break; - } - - /* Find the most frequently used scale and use this for the default */ - for (i=0;i<6;i++) buffer[i]=0; - for (i=0;iNrNotes;i++) { - if (ringtone->notes[i].note!=255) { - buffer[ringtone->notes[i].note/14]++; - } - } - j=0; - for (i=0;i<6;i++) { - if (buffer[i]>j) { - DefNoteScale=i; - j=buffer[i]; - } - } - - StartBit=BitPackByte(package, StartBit, CommandLength, 8); - StartBit=BitPackByte(package, StartBit, RingingToneProgramming, 7); - - /* The page 3-23 of the specs says that is always - octet-aligned. */ - StartBit=OctetAlign(package, StartBit); - - StartBit=BitPackByte(package, StartBit, Sound, 7); - StartBit=BitPackByte(package, StartBit, BasicSongType, 3); - - /* Set special chars in ringtone name */ - for (i=0;iname);i++) { - if (ringtone->name[i]=='~') ringtone->name[i]=1; //enables/disables blinking - if (ringtone->name[i]=='`') ringtone->name[i]=0; //hides rest ot contents - } - - /* Packing the name of the tune. */ - StartBit=BitPackByte(package, StartBit, strlen(ringtone->name)<<4, 4); - StartBit=BitPack(package, StartBit, ringtone->name, 8*strlen(ringtone->name)); - - /* Set special chars in ringtone name */ - for (i=0;iname);i++) { - if (ringtone->name[i]==1) ringtone->name[i]='~'; //enables/disables blinking - if (ringtone->name[i]==0) ringtone->name[i]='`'; //hides rest ot contents - } - - /* Info about song pattern */ - StartBit=BitPackByte(package, StartBit, 0x01, 8); /* One song pattern */ - StartBit=BitPackByte(package, StartBit, PatternHeaderId, 3); - StartBit=BitPackByte(package, StartBit, A_part, 2); - StartBit=BitPackByte(package, StartBit, ringtone->Loop<<4, 4); - - /* Info, how long is contents for SMS */ - HowLong=8+8+7+3+4+8*strlen(ringtone->name)+8+3+2+4+8+3+2+3+5; - - /* Calculating number of instructions in the tune. - Each Note contains Note and (sometimes) Scale. - Default Tempo and Style are instructions too. */ - HowMany=2; /* Default Tempo and Style */ - - /* Default style and tempo */ - DefNoteStyle=ringtone->notes[0].style; - DefNoteTempo=ringtone->notes[0].tempo; - oldstyle=DefNoteStyle; - oldtempo=DefNoteTempo; - - for(i=0; iNrNotes; i++) { - - /* PC Composer 2.0.010 doesn't like, when we start ringtone from pause: - displays, that format is invalid and - hangs, when you move mouse over place, where pause is */ - if (GSM_GetNote(ringtone->notes[i].note)==Note_Pause && oldscale==10) { - StartNote++; - } else { - - thisnote=0; - thisnotelong=0; - - /* we don't write Scale/Style info before "Pause" note - it saves place */ - if (GSM_GetNote(ringtone->notes[i].note)!=Note_Pause) { - - if (ringtone->allnotesscale || - oldscale!=(newscale=GSM_GetScale(ringtone->notes[i].note))) { - - /* We calculate, if we have space to add next scale instruction */ - if (((OctetAlignNumber(HowLong+5)+8)/8)<=(*maxlength)) { - oldscale=newscale; - HowLong+=5; - HowMany++; - thisnote++; - thisnotelong+=5; - } else { - break; - } - } - if (ringtone->notes[i].style!=oldstyle) { - /* We calculate, if we have space to add next style instruction */ - if (((OctetAlignNumber(HowLong+5)+8)/8)<=(*maxlength)) { - oldstyle=ringtone->notes[i].style; - HowLong+=5; - HowMany++; - thisnote++; - thisnotelong+=5; - } else { - HowLong=HowLong-thisnotelong; - HowMany=HowMany-thisnote; - break; - } - } - } + /* Calculate the number of instructions in the tune. + Each Note contains Note and (sometimes) Scale. + Default Tempo and Style are instructions too. */ + HowMany=2; /* Default Tempo and Style */ + + for(i=0; iNrNotes; i++) { + + /* PC Composer 2.0.010 doesn't like, when we start ringtone from pause: + it displays that the format is invalid and + hangs, when you move mouse over place, where pause is */ + if (GSM_GetNote(ringtone->notes[i].note)==Note_Pause && oldscale==10) { + StartNote++; + } else { - if (ringtone->notes[i].tempo!=oldtempo) { - /* We calculate, if we have space to add next tempo instruction */ - if (((OctetAlignNumber(HowLong+8)+8)/8)<=(*maxlength)) { - oldtempo=ringtone->notes[i].tempo; - HowLong+=8; - HowMany++; - thisnote++; - thisnotelong+=8; - } else { - HowLong=HowLong-thisnotelong; - HowMany=HowMany-thisnote; - break; - } - } - - /* We calculate, if we have space to add next note instruction */ - if (((OctetAlignNumber(HowLong+12)+8)/8)<=(*maxlength)) { - HowMany++; - EndNote++; - HowLong+=12; - } else { - HowLong=HowLong-thisnotelong; - HowMany=HowMany-thisnote; - break; - } - } - - /* We are sure, we pack it for SMS or setting to phone, not for OTT file */ - if (*maxlength<1000) { - /* Like Pc Composer say - before of phone limitations...*/ - if ((EndNote-StartNote)==FB61_MAX_RINGTONE_NOTES-1) break; - } - } - - StartBit=BitPackByte(package, StartBit, HowMany, 8); -#ifdef DEBUG -// fprintf(stdout,_("length of new pattern: %i %i\n"),HowMany,StartBit); -#endif - - /* Style */ - StartBit=BitPackByte(package, StartBit, StyleInstructionId, 3); - StartBit=BitPackByte(package, StartBit, DefNoteStyle, 2); + /* we don't write Scale info before "Pause" note - it saves space */ + if (GSM_GetNote(ringtone->notes[i].note)!=Note_Pause && + oldscale!=(newscale=GSM_GetScale(ringtone->notes[i].note))) { + + /* We calculate, if we have space to add next scale instruction */ + if (((HowLong+5)/8)<=(*maxlength-1)) { + oldscale=newscale; + HowMany++; + HowLong+=5; + } else { + break; + } + } - /* Beats per minute/tempo of the tune */ - StartBit=BitPackByte(package, StartBit, TempoInstructionId, 3); - StartBit=BitPackByte(package, StartBit, GSM_GetTempo(DefNoteTempo), 5); -#ifdef DEBUG -// fprintf(stdout,_("def temp: %i %i\n"),GSM_GetTempo(DefNoteTempo),StartBit); -#endif - - /* Default scale */ - oldscale=10; - - /* Default style */ - oldstyle=DefNoteStyle; - - /* Default tempo */ - oldtempo=DefNoteTempo; - - /* Notes packing */ - for(i=StartNote; i<(EndNote+StartNote); i++) { - - /* we don't write Scale info before "Pause" note - it saves place */ - if (GSM_GetNote(ringtone->notes[i].note)!=Note_Pause) { - if (ringtone->allnotesscale || - oldscale!=(newscale=GSM_GetScale(ringtone->notes[i].note))) { -#ifdef DEBUG -// fprintf(stdout,_("Scale\n")); -#endif - oldscale=newscale; - StartBit=BitPackByte(package, StartBit, ScaleInstructionId, 3); - StartBit=BitPackByte(package, StartBit, GSM_GetScale(ringtone->notes[i].note), 2); - } - if (ringtone->notes[i].style!=oldstyle) { - /* Style */ - StartBit=BitPackByte(package, StartBit, StyleInstructionId, 3); - StartBit=BitPackByte(package, StartBit, ringtone->notes[i].style, 2); - oldstyle=ringtone->notes[i].style; - } - } - - if (ringtone->notes[i].tempo!=oldtempo) { - /* Beats per minute/tempo of the tune */ - StartBit=BitPackByte(package, StartBit, TempoInstructionId, 3); - StartBit=BitPackByte(package, StartBit, GSM_GetTempo(ringtone->notes[i].tempo), 5); - oldtempo=ringtone->notes[i].tempo; - } - - /* Note */ - StartBit=BitPackByte(package, StartBit, NoteInstructionId, 3); - StartBit=BitPackByte(package, StartBit, GSM_GetNote(ringtone->notes[i].note), 4); - StartBit=BitPackByte(package, StartBit, GSM_GetDuration(ringtone->notes[i].duration,&spec), 3); - StartBit=BitPackByte(package, StartBit, spec, 2); + /* We calculate, if we have space to add next note instruction */ + if (((HowLong+12)/8)<=(*maxlength-1)) { + HowMany++; + EndNote++; + HowLong+=12; + } else { + break; + } + } + + /* If we are sure, we pack it for SMS or setting to phone, not for OTT file */ + if (*maxlength<1000) { + /* Pc Composer gives this as the phone limitation */ + if ((EndNote-StartNote)==GSM_MAX_RINGTONE_NOTES-1) break; + } + } + + StartBit=BitPackByte(package, StartBit, HowMany, 8); -#ifdef DEBUG -// fprintf(stdout,_("note(%i): %i, scale: %i, duration: %i, spec: %i\n"),i,ringtone->notes[i].note,GSM_GetScale(ringtone->notes[i].note),GSM_GetDuration(ringtone->notes[i].duration,&spec),spec); -#endif + /* Style */ + StartBit=BitPackByte(package, StartBit, StyleInstructionId, 3); + StartBit=BitPackByte(package, StartBit, ContinuousStyle, 2); - } + /* Beats per minute/tempo of the tune */ + StartBit=BitPackByte(package, StartBit, TempoInstructionId, 3); + StartBit=BitPackByte(package, StartBit, GetTempo(ringtone->tempo), 5); + + /* Default scale */ + oldscale=10; + + /* Notes packing */ + for(i=StartNote; i<(EndNote+StartNote); i++) { + + /* we don't write Scale info before "Pause" note - it saves place */ + if (GSM_GetNote(ringtone->notes[i].note)!=Note_Pause && + oldscale!=(newscale=GSM_GetScale(ringtone->notes[i].note))) { + oldscale=newscale; + StartBit=BitPackByte(package, StartBit, ScaleInstructionId, 3); + StartBit=BitPackByte(package, StartBit, GSM_GetScale(ringtone->notes[i].note), 2); + } + + /* Note */ + StartBit=BitPackByte(package, StartBit, NoteInstructionId, 3); + StartBit=BitPackByte(package, StartBit, GSM_GetNote(ringtone->notes[i].note), 4); + StartBit=BitPackByte(package, StartBit, GSM_GetDuration(ringtone->notes[i].duration,&spec), 3); + StartBit=BitPackByte(package, StartBit, spec, 2); + } - StartBit=OctetAlign(package, StartBit); + StartBit=OctetAlign(package, StartBit); - StartBit=BitPackByte(package, StartBit, CommandEnd, 8); + StartBit=BitPackByte(package, StartBit, CommandEnd, 8); -#ifdef DEBUG - if (StartBit!=OctetAlignNumber(HowLong)+8) - fprintf(stdout,_("Error in PackRingtone - StartBit different to HowLong %d - %d)\n"),StartBit,OctetAlignNumber(HowLong)+8); -#endif + if (StartBit!=OctetAlignNumber(HowLong)) + dprintf("Error in PackRingtone - StartBit different to HowLong %d - %d)\n", StartBit,OctetAlignNumber(HowLong)); - *maxlength=StartBit/8; + *maxlength=StartBit/8; - return(EndNote+StartNote); + return(EndNote+StartNote); } + int BitUnPack(unsigned char *Dest, int CurrentBit, unsigned char *Source, int Bits) { - int i; + int i; - for (i=0; iallnotesscale=false; - - StartBit=BitUnPackInt(package,StartBit,&l,8); -#ifdef DEBUG - if (l!=0x02) - fprintf(stdout,_("Not header\n")); -#endif - if (l!=0x02) return GE_SUBFORMATNOTSUPPORTED; - - StartBit=BitUnPackInt(package,StartBit,&l,7); -#ifdef DEBUG - if (l!=RingingToneProgramming) - fprintf(stdout,_("Not RingingToneProgramming\n")); -#endif - if (l!=RingingToneProgramming) return GE_SUBFORMATNOTSUPPORTED; - - /* The page 3-23 of the specs says that is always - octet-aligned. */ - StartBit=OctetUnAlign(StartBit); - - StartBit=BitUnPackInt(package,StartBit,&l,7); -#ifdef DEBUG - if (l!=Sound) - fprintf(stdout,_("Not Sound\n")); -#endif - if (l!=Sound) return GE_SUBFORMATNOTSUPPORTED; - - StartBit=BitUnPackInt(package,StartBit,&l,3); -#ifdef DEBUG - if (l!=BasicSongType) - fprintf(stdout,_("Not BasicSongType\n")); -#endif - if (l!=BasicSongType) return GE_SUBFORMATNOTSUPPORTED; - - /* Getting length of the tune name */ - StartBit=BitUnPackInt(package,StartBit,&l,4); - l=l>>4; -#ifdef DEBUG -// fprintf(stdout,_("Length of name: %i\n"),l); -#endif - - /* Unpacking the name of the tune. */ - StartBit=BitUnPack(package, StartBit, ringtone->name, 8*l); - ringtone->name[l]=0; - - /* Set special chars in ringtone name */ - for (i=0;iname);i++) { - if (ringtone->name[i]==1) ringtone->name[i]='~'; //enables/disables blinking - if (ringtone->name[i]==0) ringtone->name[i]='`'; //hides rest ot contents - } - -#ifdef DEBUG -// fprintf(stdout,_("Name: %s\n"),ringtone->name); -#endif - - StartBit=BitUnPackInt(package,StartBit,&l,8); -#ifdef DEBUG -// fprintf(stdout,_("Number of song patterns: %i\n"),l); -#endif - if (l!=1) return GE_SUBFORMATNOTSUPPORTED; //we support only one song pattern - - StartBit=BitUnPackInt(package,StartBit,&l,3); -#ifdef DEBUG - if (l!=PatternHeaderId) - fprintf(stdout,_("Not PatternHeaderId\n")); -#endif - if (l!=PatternHeaderId) return GE_SUBFORMATNOTSUPPORTED; - - StartBit+=2; //Pattern ID - we ignore it - - StartBit=BitUnPackInt(package,StartBit,&l,4); - l=l>>4; -#ifdef DEBUG - fprintf(stdout,_("Loop value: %i\n"),l); -#endif - ringtone->Loop=l; - - HowMany=0; - StartBit=BitUnPackInt(package, StartBit, &HowMany, 8); -#ifdef DEBUG - fprintf(stdout,_("length of new pattern: %i %i\n"),HowMany,StartBit); -#endif - - ringtone->NrNotes=0; + StartBit=BitUnPackInt(package,StartBit,&l,7); + if (l!=RingingToneProgramming) { + dprintf("Not RingingToneProgramming\n"); + return GE_SUBFORMATNOTSUPPORTED; + } - for (i=0;i>6); -#endif - switch (l) { - case StaccatoStyle : DefNoteStyle=StaccatoStyle; break; - case ContinuousStyle: DefNoteStyle=ContinuousStyle; break; - case NaturalStyle : DefNoteStyle=NaturalStyle; break; +/* The page 3-23 of the specs says that is always + octet-aligned. */ + StartBit=OctetUnAlign(StartBit); + + StartBit=BitUnPackInt(package,StartBit,&l,7); + if (l!=Sound) { + dprintf("Not Sound\n"); + return GE_SUBFORMATNOTSUPPORTED; } - break; - case TempoInstructionId: - StartBit=BitUnPackInt(package,StartBit,&l,5); - l=l>>3; - DefNoteTempo=BeatsPerMinute[l]; -#ifdef DEBUG -// fprintf(stdout,_("Tempo %i\n"),l); -#endif - break; - case ScaleInstructionId: - StartBit=BitUnPackInt(package,StartBit,&l,2); - DefNoteScale=l>>6; -#ifdef DEBUG -// fprintf(stdout,_("scale: %i %i\n"),DefNoteScale,ringtone->NrNotes); -#endif - break; - case NoteInstructionId: - StartBit=BitUnPackInt(package,StartBit,&l,4); - - switch (l) { - case Note_C :ringtone->notes[ringtone->NrNotes].note=0;break; - case Note_Cis:ringtone->notes[ringtone->NrNotes].note=1;break; - case Note_D :ringtone->notes[ringtone->NrNotes].note=2;break; - case Note_Dis:ringtone->notes[ringtone->NrNotes].note=3;break; - case Note_E :ringtone->notes[ringtone->NrNotes].note=4;break; - case Note_F :ringtone->notes[ringtone->NrNotes].note=6;break; - case Note_Fis:ringtone->notes[ringtone->NrNotes].note=7;break; - case Note_G :ringtone->notes[ringtone->NrNotes].note=8;break; - case Note_Gis:ringtone->notes[ringtone->NrNotes].note=9;break; - case Note_A :ringtone->notes[ringtone->NrNotes].note=10;break; - case Note_Ais:ringtone->notes[ringtone->NrNotes].note=11;break; - case Note_H :ringtone->notes[ringtone->NrNotes].note=12;break; - default :ringtone->notes[ringtone->NrNotes].note=255;break; //Pause ? - } - - if (ringtone->notes[ringtone->NrNotes].note!=255) - ringtone->notes[ringtone->NrNotes].note=ringtone->notes[ringtone->NrNotes].note+DefNoteScale*14; - - StartBit=BitUnPackInt(package,StartBit,&l,3); - DefNoteDuration=l; - - StartBit=BitUnPackInt(package,StartBit,&spec,2); - - if (DefNoteDuration==Duration_Full && spec==DottedNote) - ringtone->notes[ringtone->NrNotes].duration=128*3/2; - if (DefNoteDuration==Duration_Full && spec==Length_2_3) - ringtone->notes[ringtone->NrNotes].duration=128*2/3; - if (DefNoteDuration==Duration_Full && spec==NoSpecialDuration) - ringtone->notes[ringtone->NrNotes].duration=128; - if (DefNoteDuration==Duration_1_2 && spec==DottedNote) - ringtone->notes[ringtone->NrNotes].duration=64*3/2; - if (DefNoteDuration==Duration_1_2 && spec==Length_2_3) - ringtone->notes[ringtone->NrNotes].duration=64*2/3; - if (DefNoteDuration==Duration_1_2 && spec==NoSpecialDuration) - ringtone->notes[ringtone->NrNotes].duration=64; - if (DefNoteDuration==Duration_1_4 && spec==DottedNote) - ringtone->notes[ringtone->NrNotes].duration=32*3/2; - if (DefNoteDuration==Duration_1_4 && spec==Length_2_3) - ringtone->notes[ringtone->NrNotes].duration=32*2/3; - if (DefNoteDuration==Duration_1_4 && spec==NoSpecialDuration) - ringtone->notes[ringtone->NrNotes].duration=32; - if (DefNoteDuration==Duration_1_8 && spec==DottedNote) - ringtone->notes[ringtone->NrNotes].duration=16*3/2; - if (DefNoteDuration==Duration_1_8 && spec==Length_2_3) - ringtone->notes[ringtone->NrNotes].duration=16*2/3; - if (DefNoteDuration==Duration_1_8 && spec==NoSpecialDuration) - ringtone->notes[ringtone->NrNotes].duration=16; - if (DefNoteDuration==Duration_1_16 && spec==DottedNote) - ringtone->notes[ringtone->NrNotes].duration=8*3/2; - if (DefNoteDuration==Duration_1_16 && spec==Length_2_3) - ringtone->notes[ringtone->NrNotes].duration=8*2/3; - if (DefNoteDuration==Duration_1_16 && spec==NoSpecialDuration) - ringtone->notes[ringtone->NrNotes].duration=8; - if (DefNoteDuration==Duration_1_32 && spec==DottedNote) - ringtone->notes[ringtone->NrNotes].duration=4*3/2; - if (DefNoteDuration==Duration_1_32 && spec==Length_2_3) - ringtone->notes[ringtone->NrNotes].duration=4*2/3; - if (DefNoteDuration==Duration_1_32 && spec==NoSpecialDuration) - ringtone->notes[ringtone->NrNotes].duration=4; - - ringtone->notes[ringtone->NrNotes].style=DefNoteStyle; - - ringtone->notes[ringtone->NrNotes].tempo=DefNoteTempo; - -#ifdef DEBUG -// fprintf(stdout,_("note(%i): %i, scale: %i, duration: %i, spec: %i\n"),ringtone->NrNotes,ringtone->notes[ringtone->NrNotes].note,DefNoteScale,DefNoteDuration,spec); -#endif - if (ringtone->NrNotes==FB61_MAX_RINGTONE_NOTES) break; - - ringtone->NrNotes++; - break; - default: -#ifdef DEBUG - fprintf(stdout,_("Unsupported block %i %i\n"),q,i); -#endif - return GE_SUBFORMATNOTSUPPORTED; - } - } - -#ifdef DEBUG -// printf("Number of notes=%d\n",ringtone->NrNotes); -#endif - - return GE_NONE; -} -GSM_Error GSM_ReadRingtone(GSM_SMSMessage *message, GSM_Ringtone *ringtone) -{ - if (message->UDHType==GSM_RingtoneUDH) { - return GSM_UnPackRingtone(ringtone, message->MessageText, message->Length); - } else return GE_SUBFORMATNOTSUPPORTED; -} - -int GSM_GetFrequency(int number) { - - int freq=0; + StartBit=BitUnPackInt(package,StartBit,&l,3); + if (l!=BasicSongType) { + dprintf("Not BasicSongType\n"); + return GE_SUBFORMATNOTSUPPORTED; + } - /* Values according to the software from http://iki.fi/too/sw/xring/ - generated with: - perl -e 'print int(4400 * (2 **($_/12)) + .5)/10, "\n" for(3..14)' - */ - if (number!=255) { - freq=number%14; - switch (freq) { +/* Getting length of the tune name */ + StartBit=BitUnPackInt(package,StartBit,&l,4); + l=l>>4; - case 0: freq=523.3; break; // C - case 1: freq=554.4; break; // Cis +/* Unpacking the name of the tune. */ + StartBit=BitUnPack(package, StartBit, ringtone->name, 8*l); + ringtone->name[l]=0; - case 2: freq=587.3; break; //D - case 3: freq=622.3; break; //Dis - - case 4: freq=659.3; break; //E + StartBit=BitUnPackInt(package,StartBit,&l,8); + if (l!=1) return GE_SUBFORMATNOTSUPPORTED; //we support only one song pattern - case 6: freq=698.5; break; //F - case 7: freq=740; break; //Fis + StartBit=BitUnPackInt(package,StartBit,&l,3); + if (l!=PatternHeaderId) { + dprintf("Not PatternHeaderId\n"); + return GE_SUBFORMATNOTSUPPORTED; + } - case 8: freq=784; break; //G - case 9: freq=830.6; break; //Gis + StartBit+=2; //Pattern ID - we ignore it - case 10: freq=880; break; //A - case 11: freq=932.3; break; //Ais + StartBit=BitUnPackInt(package,StartBit,&l,4); - case 12: freq=987.8; break; //H - - default: freq=0; break; - } - } - else freq = 0; - - if ((number/14)!=0) freq=freq*(number/14); - else freq=freq/2; - - return freq; + HowMany=0; + StartBit=BitUnPackInt(package, StartBit, &HowMany, 8); -} - -/* Very fast hack. It should be written correctly ! */ -void GSM_PlayOneNote (GSM_RingtoneNote note) { - int Hz; - - Hz=GSM_GetFrequency(note.note); - - GSM->PlayTone(Hz,5); - - /* Is it correct ? Experimental values here */ - switch (note.style) { - case StaccatoStyle: - usleep (7500); - GSM->PlayTone(0,0); - usleep ((1500000/note.tempo*note.duration)-(7500)); - break; - case ContinuousStyle: - usleep (1500000/note.tempo*note.duration); - break; - case NaturalStyle: - usleep (1500000/note.tempo*note.duration-50); - GSM->PlayTone(0,0); - usleep (50); - break; - } -} - -void GSM_PlayRingtone (GSM_Ringtone *ringtone) { - - int i; - - for (i=0;iNrNotes;i++) { - GSM_PlayOneNote(ringtone->notes[i]); - } - - /* Disables buzzer */ - GSM->PlayTone(255*255,0); -} - -/* Initializes one ringtone: first is number of ringtone in - RingingTones in gnokii.h, second its' code, last position in phone menu */ -void RT(int number, int code, int menu) { - RingingTones[number].code=code; - RingingTones[number].menu=menu; -} - -/* This function initializes structures with ringtones names adequate for - your phone model and firmware; if your phone is not now supported: - 1.set first ringtone in 1'st profile in your phone - 2.make ./gnokii --getprofile 1 - 3.read ringtone code - 4.see in gnokii.h, if ringtone name is gnokii.h in RingingTones (if not, add) - 5.put here RT(a,b,c), where a is number of name in RingingTones in gnokii.h, - b is its' code and c is number of ringtone in phone menu - 6.repeat steps 1-5 for all ringtones - 7.send me (Marcin-Wiacek@Topnet.PL) all RT and phone model */ -void PrepareRingingTones(char model[64], char rev[64]) { - - char rev2[64]; - int i; - bool doit; - - if (!RingingTones[0].code) { - if (!strcmp(model,"NSE-1")) //5110 - { - RT( 2,18, 1);RT( 3,19, 2);RT( 7,23, 3);RT( 5,21, 4);RT( 9,25, 5); - RT(20,48, 7);RT(11,27, 8);RT(33,59, 9);RT(35,62,10); - RT(46,60,11);RT(16,36,12);RT(17,37,13);RT(13,32,14);RT(14,34,15); - RT(19,43,16);RT(18,39,17);RT(24,50,18);RT(31,57,19);RT(28,54,20); - RT(30,56,21);RT(40,73,22);RT(39,72,23);RT(37,69,24); - RT(23,49,26);RT(38,71,27); RT(41,74,29); - - strcpy(rev2,"05.23"); //5.24 and higher - doit=false; - for(i=0;i<5;i++) - { - if (rev[i]rev2[i]) doit=true; - } + scale=0; + ringtone->NrNotes=0; + + for (i=0;i>3; + break; + case TempoInstructionId: + StartBit=BitUnPackInt(package,StartBit,&l,5); + l=l>>3; + ringtone->tempo=BeatsPerMinute[l]; + break; + case ScaleInstructionId: + StartBit=BitUnPackInt(package,StartBit,&scale,2); + scale=scale>>6; + break; + case NoteInstructionId: + StartBit=BitUnPackInt(package,StartBit,&l,4); + + switch (l) { + case Note_C :ringtone->notes[ringtone->NrNotes].note=0;break; + case Note_Cis:ringtone->notes[ringtone->NrNotes].note=1;break; + case Note_D :ringtone->notes[ringtone->NrNotes].note=2;break; + case Note_Dis:ringtone->notes[ringtone->NrNotes].note=3;break; + case Note_E :ringtone->notes[ringtone->NrNotes].note=4;break; + case Note_F :ringtone->notes[ringtone->NrNotes].note=6;break; + case Note_Fis:ringtone->notes[ringtone->NrNotes].note=7;break; + case Note_G :ringtone->notes[ringtone->NrNotes].note=8;break; + case Note_Gis:ringtone->notes[ringtone->NrNotes].note=9;break; + case Note_A :ringtone->notes[ringtone->NrNotes].note=10;break; + case Note_Ais:ringtone->notes[ringtone->NrNotes].note=11;break; + case Note_H :ringtone->notes[ringtone->NrNotes].note=12;break; + default :ringtone->notes[ringtone->NrNotes].note=255;break; //Pause ? + } - if (doit) { - RT(22,47, 6);RT(47,58,25);RT(45,80,28);RT(43,75,30); - } else - { - RT(21,47, 6);RT(32,58,25);RT(44,80,28);RT(42,75,30); - } - RingingTones[0].menu=30; /* How many ringtones in phone */ - } - if (!strcmp(model,"NSM-1")) //6150 - { - RT( 2,18, 1);RT( 3,19, 2);RT( 7,23, 3);RT( 6,22, 4); - RT( 4,20, 5);RT( 5,21, 6);RT(15,35, 7);RT(12,30, 8); - RT( 9,25, 9);RT(20,47,10);RT( 8,24,11);RT(11,27,12); - RT(10,26,13);RT(34,60,14);RT(33,58,15);RT(35,61,16); - RT(16,36,17);RT(13,32,18);RT(19,43,19);RT(18,39,20); - RT(24,49,21);RT(31,56,22);RT(25,50,23);RT(27,52,24); - RT(26,51,25);RT(28,53,26);RT(29,54,27);RT(30,55,28); - RT(39,71,29);RT(37,68,30);RT(47,57,31);RT(23,48,32); - RT(38,70,33);RT(36,67,34);RT(41,73,35); - /*uploadable ringtone*/ - RT( 1,17,36); - RingingTones[0].menu=36; /* How many ringtones in phone */ - } - if (!strcmp(model,"NPE-3")) //6210 - { - RT(19,64, 1);RT( 2,65, 2);RT( 3,66, 3);RT(15,67, 4);RT( 6,68, 5); - RT(49,69, 6);RT(50,70, 7);RT( 7,71, 8);RT(35,72, 9);RT(33,73,10); - RT(18,74,11);RT( 5,75,12);RT(51,76,13);RT(52,77,14);RT(53,78,15); - RT(37,79,16);RT(54,80,17);RT(55,81,18);RT(56,82,19);RT(57,83,20); - RT(58,84,21);RT(59,85,22);RT(25,86,23);RT(27,87,24);RT(30,88,25); - RT(39,89,26);RT(24,90,27);RT( 8,91,28);RT(60,92,29);RT(61,93,30); - RT(31,94,31);RT(62,95,32);RT(63,96,33);RT(64,97,34);RT(48,98,35); - /* Uploadable ringtones */ - RT( 1,137,36);RT(65,138,37);RT(66,139,38);RT(67,140,39);RT(68,141,40); - - RingingTones[0].menu=40; /* How many ringtones in phone */ - } - RingingTones[0].code=true; - } -} - -/* returns names from code or number in menu */ -char *RingingToneName(int code, int menu) -{ - int index=1; - GSM_Error error; - - if (code==0) - { - while (strcmp(RingingTones[index].name,"")) { - if (RingingTones[index].menu==menu) break; - index++; - } - } else - { - while (strcmp(RingingTones[index].name,"")) { - if (RingingTones[index].code==code) break; - index++; - } - } - - if (!strncmp(RingingTones[index].name,"Uploaded ",9)) { - ringtone.location=atoi(&RingingTones[index].name[10]); - - error=GSM_GetPhoneRingtone(&ringtone,&SMringtone); - - if (error==GE_NONE) { - if (GetModelFeature (FN_RINGTONES)==F_RING_SM) return SMringtone.name; - else return ringtone.name; - } - } - - return RingingTones[index].name; -} - -/* returns code from number in menu */ -int RingingToneCode(int menu) -{ - int index=1; - - while ( RingingTones[index].menu!=menu) index++; + if (ringtone->notes[ringtone->NrNotes].note!=255) + ringtone->notes[ringtone->NrNotes].note=ringtone->notes[ringtone->NrNotes].note+scale*14; + + StartBit=BitUnPackInt(package,StartBit,&duration,3); + + StartBit=BitUnPackInt(package,StartBit,&spec,2); + + if (duration==Duration_Full && spec==DottedNote) + ringtone->notes[ringtone->NrNotes].duration=128*3/2; + if (duration==Duration_Full && spec==Length_2_3) + ringtone->notes[ringtone->NrNotes].duration=128*2/3; + if (duration==Duration_Full && spec==NoSpecialDuration) + ringtone->notes[ringtone->NrNotes].duration=128; + if (duration==Duration_1_2 && spec==DottedNote) + ringtone->notes[ringtone->NrNotes].duration=64*3/2; + if (duration==Duration_1_2 && spec==Length_2_3) + ringtone->notes[ringtone->NrNotes].duration=64*2/3; + if (duration==Duration_1_2 && spec==NoSpecialDuration) + ringtone->notes[ringtone->NrNotes].duration=64; + if (duration==Duration_1_4 && spec==DottedNote) + ringtone->notes[ringtone->NrNotes].duration=32*3/2; + if (duration==Duration_1_4 && spec==Length_2_3) + ringtone->notes[ringtone->NrNotes].duration=32*2/3; + if (duration==Duration_1_4 && spec==NoSpecialDuration) + ringtone->notes[ringtone->NrNotes].duration=32; + if (duration==Duration_1_8 && spec==DottedNote) + ringtone->notes[ringtone->NrNotes].duration=16*3/2; + if (duration==Duration_1_8 && spec==Length_2_3) + ringtone->notes[ringtone->NrNotes].duration=16*2/3; + if (duration==Duration_1_8 && spec==NoSpecialDuration) + ringtone->notes[ringtone->NrNotes].duration=16; + if (duration==Duration_1_16 && spec==DottedNote) + ringtone->notes[ringtone->NrNotes].duration=8*3/2; + if (duration==Duration_1_16 && spec==Length_2_3) + ringtone->notes[ringtone->NrNotes].duration=8*2/3; + if (duration==Duration_1_16 && spec==NoSpecialDuration) + ringtone->notes[ringtone->NrNotes].duration=8; + if (duration==Duration_1_32 && spec==DottedNote) + ringtone->notes[ringtone->NrNotes].duration=4*3/2; + if (duration==Duration_1_32 && spec==Length_2_3) + ringtone->notes[ringtone->NrNotes].duration=4*2/3; + if (duration==Duration_1_32 && spec==NoSpecialDuration) + ringtone->notes[ringtone->NrNotes].duration=4; + + if (ringtone->NrNotes==MAX_RINGTONE_NOTES) break; + + ringtone->NrNotes++; + break; + default: + dprintf("Unsupported block\n"); + return GE_SUBFORMATNOTSUPPORTED; + } + } - return RingingTones[index].code; + return GE_NONE; } -/* returns number in menu from code */ -int RingingToneMenu(int code) -{ - int index=1; - - while ( RingingTones[index].code!=code) index++; - - return RingingTones[index].menu; -} -int NumberOfRingtones() +#if 0 /* unused */ +GSM_Error GSM_ReadRingtoneFromSMS(GSM_SMSMessage *message, GSM_Ringtone *ringtone) { - return RingingTones[0].menu; + if (message->UDHType==GSM_RingtoneUDH) { + return GSM_UnPackRingtone(ringtone, message->MessageText, message->Length); + } else return GE_SUBFORMATNOTSUPPORTED; } +#endif /* unused */ -int GSM_SaveRingtoneToSMS(GSM_MultiSMSMessage *SMS, - GSM_Ringtone *ringtone, bool profilestyle) +#if 0 /* unused */ +int GSM_SaveRingtoneToSMS(GSM_SMSMessage *message, GSM_Ringtone *ringtone) { - int i, j; - unsigned char MessageBuffer[GSM_MAX_SMS_8_BIT_LENGTH*4]; - unsigned char MessageBuffer2[GSM_MAX_SMS_8_BIT_LENGTH*4]; - int MessageLength; - GSM_UDH UDHType; + int i, j=GSM_MAX_SMS_8_BIT_LENGTH; - EncodeUDHHeader(MessageBuffer, GSM_RingtoneUDH); - MessageLength=GSM_MAX_SMS_8_BIT_LENGTH-(MessageBuffer[0]+1); - i=GSM_PackRingtone(ringtone, MessageBuffer, &MessageLength); - - if (i!=ringtone->NrNotes && profilestyle) - { - MessageLength=0; - MessageBuffer[MessageLength++]=0x30; //SM version. Here 3.0 - MessageBuffer[MessageLength++]=SM30_RINGTONE; //ID for ringtone - - MessageBuffer[MessageLength++]=0x01; //length hi.Later changed - MessageBuffer[MessageLength++]=0x00; //length lo.Later changed - - j=SM30_MAX_RINGTONE_FRAME_LENGTH; - i=GSM_PackRingtone(ringtone, MessageBuffer2, &j); - MessageLength=MessageLength+j; - memcpy(MessageBuffer+4,MessageBuffer2,j); - - MessageBuffer[2]=j/256; - MessageBuffer[3]=j%256; - - UDHType=GSM_ProfileUDH; - } else - UDHType=GSM_RingtoneUDH; - - GSM_MakeMultiPartSMS2(SMS,MessageBuffer,MessageLength, UDHType, GSM_Coding_Default); - - return i; -} - -GSM_Error GSM_GetPhoneRingtone(GSM_BinRingtone *ringtone,GSM_Ringtone *SMringtone) -{ - GSM_Error error; - int i; - - error=GSM->GetBinRingtone(ringtone); - - if (error==GE_UNKNOWNMODEL) - { - /* In 3310,... we have normal "Smart Messaging" format */ - if (GetModelFeature (FN_RINGTONES)==F_RING_SM) { - i=7; - if (ringtone->frame[9]==0x4a && ringtone->frame[10]==0x3a) i=8; - ringtone->frame[i]=0x02; - - GSM_UnPackRingtone(SMringtone, ringtone->frame+i, ringtone->length-i); - - return GE_NONE; - } - } + char UserDataHeader[7]= { 0x06, /* User Data Header Length */ + 0x05, /* IEI: application port addressing scheme, 16 bit address */ + 0x04, /* IEDL (IED length ?) */ + 0x15, /* destination address: high byte */ + 0x81, /* destination address: low byte */ + 0x15, /* originator address: high byte */ + 0x81}; /* originator address: low byte */ + + /* Default settings for SMS message: + - no delivery report + - Class Message 1 + - no compression + - 8 bit data + - SMSC no. 1 + - validity 3 days + - set UserDataHeaderIndicator + */ + + message->Type = GST_MO; + message->Class = 1; + message->Compression = false; + message->EightBit = true; + message->MessageCenter.No = 1; + message->Validity = 4320; /* 4320 minutes == 72 hours */ + message->ReplyViaSameSMSC = false; + + message->UDHType = GSM_RingtoneUDH; + + i=GSM_PackRingtone(ringtone, message->MessageText, &j); - return error; + message->Length=j; + + memcpy(message->UDH,UserDataHeader,7); + + return i; } +#endif /* unused */ diff --git a/common/gsm-sms.c b/common/gsm-sms.c index 9fbb114..b28454c 100644 --- a/common/gsm-sms.c +++ b/common/gsm-sms.c @@ -1,1024 +1,695 @@ /* + $Id$ + G N O K I I A Linux/Unix toolset and driver for Nokia mobile phones. - Released under the terms of the GNU GPL, see file COPYING for more details. - -*/ - -#include -#include -#include -#include -#include - -#include "gsm-api.h" -#include "gsm-coding.h" - -/* User data headers */ -GSM_UDHHeader UDHHeaders[] = { - { GSM_ConcatenatedMessages, 0x05, "\x00\x03\x01\x00\x00" }, - /* See GSM 03.40 section 9.2.3.24.1 */ - { GSM_DisableVoice, 0x04, "\x01\x02\x00\x00" }, - { GSM_DisableFax, 0x04, "\x01\x02\x01\x00" }, - { GSM_DisableEmail, 0x04, "\x01\x02\x02\x00" }, - { GSM_EnableVoice, 0x04, "\x01\x02\x00\x01" }, - { GSM_EnableFax, 0x04, "\x01\x02\x01\x01" }, - { GSM_EnableEmail, 0x04, "\x01\x02\x02\x01" }, - /* See GSM 03.40 section 9.2.3.24.2 for voice, fax and email messages */ - { GSM_VoidSMS, 0x08, "\x01\x02\x02\x01\x01\x02\x02\x00" }, - /* When send such SMS to some phones, they don't display anything, - only beep and enable vibra/light */ - { GSM_BugSMS, 0x09, "\x01\x02\x02\x01\x01\x02\x02\x00\xc0" }, - - /* Short Smart Messaging UDH */ - /* General format: */ - /* 1 byte 0x05 : IEI application port addressing scheme, 16 bit address */ - /* 1 byte 0x04 : IEI length */ - /* 2 bytes : destination address: high & low byte */ - /* 2 bytes 0x00 0x00: originator address: high & low byte */ - { GSM_RingtoneUDH, 0x06, "\x05\x04\x15\x81\x00\x00" }, - { GSM_OpLogo, 0x06, "\x05\x04\x15\x82\x00\x00" }, - { GSM_CallerIDLogo, 0x06, "\x05\x04\x15\x83\x00\x00" }, - { GSM_WAPBookmarkUDH, 0x06, "\x05\x04\xc3\x4f\x00\x00" }, - - /* Long Smart Messaging UDH */ - /* General format: */ - /* 1 byte 0x05 : IEI application port addressing scheme, 16 bit address */ - /* 1 byte 0x04 : IEI length */ - /* 2 bytes 0x00 0x00: destination address: high & low byte */ - /* 2 bytes 0x00 0x00: originator address: high & low byte */ - /* 1 byte 0x00 : null byte for end first part ? */ - /* 1 byte 0x03 : length for rest ? */ - /* 1 byte */ - /* 1 byte : number of all SMS */ - /* 1 byte : number of current SMS */ - { GSM_CalendarNoteUDH, 0x0b, "\x05\x04\x00\xe4\x00\x00\x00\x03\xc7\x00\x00" }, //from 3310 ? - { GSM_CalendarNoteUDH2, 0x0b, "\x05\x04\x23\xf5\x00\x00\x00\x03\x01\x00\x00" }, //from 6210 or 9210 Note: last 0x01 changes according to note type - { GSM_ProfileUDH, 0x0b, "\x05\x04\x15\x8a\x00\x00\x00\x03\xce\x00\x00" }, - { GSM_WAPBookmarkUDH, 0x0b, "\x05\x04\xc3\x4f\x00\x00\x00\x03\x01\x00\x00" },//note last 0x01 can change - { GSM_WAPSettingsUDH, 0x0b, "\x05\x04\xc3\x4f\x00\x00\x00\x03\x7f\x00\x00" }, - { GSM_PhonebookUDH, 0x0b, "\x05\x04\x23\xf4\x00\x00\x00\x03\x01\x00\x00" }, - - { GSM_NoUDH, 0x00, "" } -}; + Copyright (C) 2001 Pawe³ Kot -#define ByteMask ((1 << Bits) - 1) + Released under the terms of the GNU GPL, see file COPYING for more details. -int GSM_PackSevenBitsToEight(int offset, unsigned char *input, unsigned char *output) -{ - unsigned char *OUT = output; /* Current pointer to the output buffer */ - unsigned char *IN = input; /* Current pointer to the input buffer */ - int Bits; /* Number of bits directly copied to - the output buffer */ - Bits = (7 + offset) % 8; - - /* If we don't begin with 0th bit, we will write only a part of the - first octet */ - if (offset) { - *OUT = 0x00; - OUT++; - } + Library for parsing and creating Short Messages (SMS). - while ((IN - input) < strlen(input)) { - unsigned char Byte = EncodeWithDefaultAlphabet(*IN); + $Log$ + Revision 1.1.1.8 2002/04/03 00:08:04 short + Found in "gnokii-working" directory, some November-patches version - *OUT = Byte >> (7 - Bits); - /* If we don't write at 0th bit of the octet, we should write - a second part of the previous octet */ - if (Bits != 7) - *(OUT-1) |= (Byte & ((1 << (7-Bits)) - 1)) << (Bits+1); + Revision 1.1 2001/11/08 16:23:21 pkot + New version of libsms. Not functional yet, but it reasonably stable API. - Bits--; + Revision 1.1 2001/07/09 23:06:26 pkot + Moved sms.* files from my hard disk to CVS - if (Bits == -1) Bits = 7; - else OUT++; +*/ - IN++; - } - return (OUT - output); -} +#include -int GSM_UnpackEightBitsToSeven(int offset, int in_length, int out_length, - unsigned char *input, unsigned char *output) -{ - unsigned char *OUT = output; /* Current pointer to the output buffer */ - unsigned char *IN = input; /* Current pointer to the input buffer */ - unsigned char Rest = 0x00; - int Bits; - - Bits = offset ? offset : 7; - - while ((IN - input) < in_length) { - - *OUT = ((*IN & ByteMask) << (7 - Bits)) | Rest; - Rest = *IN >> Bits; - - /* If we don't start from 0th bit, we shouldn't go to the - next char. Under *OUT we have now 0 and under Rest - - _first_ part of the char. */ - if ((IN != input) || (Bits == 7)) OUT++; - IN++; - - if ((OUT - output) >= out_length) break; - - /* After reading 7 octets we have read 7 full characters but - we have 7 bits as well. This is the next character */ - if (Bits == 1) { - *OUT = Rest; - OUT++; - Bits = 7; - Rest = 0x00; - } else { - Bits--; - } - } +#include "gsm-common.h" +#include "gsm-encoding.h" - return OUT - output; -} +struct udh_data { + unsigned int length; + char *header; +}; -/* This function implements packing of numbers (SMS Center number and - destination number) for SMS sending function. */ -/* See GSM 03.40 9.1.1: - 1 byte - length of number given in semioctets or bytes (when given in bytes, - includes one byte for byte with number format. - Returned by function (set semioctet to true, if want result - in semioctets). - 1 byte - format of number. See GSM_NumberType; in gsm-common.h. Returned - in u8 *Output. - n bytes - 2n or 2n-1 semioctets with number. For some types of numbers - in the most significant bits of the last byte with 0x0f - (1111 binary) are filled if the number is represented - with odd number of digits. Returned in u8 *Output. */ -/* 1 semioctet = 4 bits = half of byte */ -int GSM_PackSemiOctetNumber(u8 *Number, u8 *Output, bool semioctet) { - - u8 *IN=Number; /* Pointer to the input number */ - u8 *OUT=Output; /* Pointer to the output */ - int length=0,j; - unsigned char format=GNT_UNKNOWN; // format of number used by us - - /* Checking for format number */ - while (*IN) { - if (length==0 && *IN=='+') - format=GNT_INTERNATIONAL; // first byte is '+'. It can be international - else { - if (*IN>'9' || *IN<'0') { - format=GNT_ALPHANUMERIC; //char is not number. It must be alphanumeric - } - } - IN++;length++; - } - - /* Now we return to first byte */ - for (j=0;j> 4; + if (Digit < 10) sprintf(Buffer, "%s%d", Buffer, Digit); + } + break; + } + return Buffer; } -/* See GSM 03.40 section 9.2.3.11 */ -GSM_Error GSM_EncodeSMSDateTime(GSM_DateTime *DT, unsigned char *req) +#if 0 +char *GetBCDNumber(u8 *Number, int maxdigits, int maxbytes) { -#ifdef DEBUG - fprintf(stdout,_("Date & time in saved SMS: %02i/%02i/%04i %02i:%02i:%02i\n"), - DT->Day,DT->Month,DT->Year,DT->Hour,DT->Minute,DT->Second); -#endif - - req[0]=EncodeWithBCDAlphabet(DT->Year); - req[1]=EncodeWithBCDAlphabet(DT->Month); - req[2]=EncodeWithBCDAlphabet(DT->Day); - req[3]=EncodeWithBCDAlphabet(DT->Hour); - req[4]=EncodeWithBCDAlphabet(DT->Minute); - req[5]=EncodeWithBCDAlphabet(DT->Second); - - /* FIXME: do it */ - req[6]=0; /* TimeZone = +-0 */ - - return GE_NONE; + static char Buffer[22] = ""; + int length = Number[0]; /* This is the length of BCD coded number */ + int bytes = 0, digits = 0; + int Digit = 0; + + dprintf("%i\n", length); + + if (Number[1] == 0x91) { + sprintf(Buffer, "+"); + } else { + Buffer[0] = '\0'; + } + + while ((Digit < 10) && (bytes < length) && (digits < maxdigits)) { + Digit = Number[bytes + 2] & 0x0f; + if (Digit < 10) { + sprintf(Buffer, "%s%d", Buffer, Digit); + digits++; + Digit = Number[bytes + 2] >> 4; + if (Digit < 10) { + sprintf(Buffer, "%s%d", Buffer, Digit); + digits++; + } + } + bytes++; + } + + return Buffer; } - -/* See GSM 03.40 section 9.2.3.11 */ -GSM_Error GSM_DecodeSMSDateTime(GSM_DateTime *DT, unsigned char *req) -{ - DT->Year = DecodeWithBCDAlphabet(req[0]); - DT->Month = DecodeWithBCDAlphabet(req[1]); - DT->Day = DecodeWithBCDAlphabet(req[2]); - DT->Hour = DecodeWithBCDAlphabet(req[3]); - DT->Minute = DecodeWithBCDAlphabet(req[4]); - DT->Second = DecodeWithBCDAlphabet(req[5]); - - DT->Timezone=(10*(req[6]&0x07)+(req[6]>>4))/4; - if (req[6]&0x08) DT->Timezone = -DT->Timezone; - -#ifdef DEBUG - fprintf(stdout, _("%d%d-"), req[0]&0xf, req[0]>>4); - fprintf(stdout, _("%d%d-"), req[1]&0xf, req[1]>>4); - fprintf(stdout, _("%d%d "), req[2]&0xf, req[2]>>4); - fprintf(stdout, _("%d%d:"), req[3]&0xf, req[3]>>4); - fprintf(stdout, _("%d%d:"), req[4]&0xf, req[4]>>4); - fprintf(stdout, _("%d%d "), req[5]&0xf, req[5]>>4); - - if (req[6]) { - if (req[6] & 0x08) fprintf(stdout, "-"); - else fprintf(stdout, "+"); - - fprintf(stdout, _("%02d00"), (10*(req[6]&0x07)+(req[6]>>4))/4); - } - - fprintf(stdout, "\n"); #endif - return GE_NONE; +static char *PrintDateTime(u8 *Number) +{ + static char Buffer[23] = ""; + + memset(Buffer, 0, 23); + sprintf(Buffer, "%d%d-", Number[0] & 0x0f, Number[0] >> 4); + sprintf(Buffer, "%s%d%d-", Buffer, Number[1] & 0x0f, Number[1] >> 4); + sprintf(Buffer, "%s%d%d ", Buffer, Number[2] & 0x0f, Number[2] >> 4); + sprintf(Buffer, "%s%d%d:", Buffer, Number[3] & 0x0f, Number[3] >> 4); + sprintf(Buffer, "%s%d%d:", Buffer, Number[4] & 0x0f, Number[4] >> 4); + sprintf(Buffer, "%s%d%d", Buffer, Number[5] & 0x0f, Number[5] >> 4); + if (Number[6] & 0x08) + sprintf(Buffer, "%s-", Buffer); + else + sprintf(Buffer, "%s+", Buffer); + sprintf(Buffer, "%s%02d00", Buffer, (10 * (Number[6] & 0x07) + (Number[6] >> 4)) / 4); + + return Buffer; } -int GSM_EncodeETSISMSSubmitData(GSM_SMSMessage *SMS, GSM_ETSISMSMessage *ETSI) +static SMS_DateTime *UnpackDateTime(u8 *Number, SMS_DateTime *dt) { - int off,size=0,size2=0,w,i; - - /* off - length of the user data header */ - off = 0; - - if (SMS->UDHType) { - /* GSM 03.40 section 9.2.3.23 (TP-User-Data-Header-Indicator) */ - ETSI->firstbyte |= 0x40; - - /* off - length of the user data header */ - off = 1 + SMS->UDH[0]; - - /* we copy the udh */ - memcpy(ETSI->MessageText, SMS->UDH, off); + dt->Year = 10 * (Number[0] & 0x0f) + (Number[0] >> 4); + dt->Month = 10 * (Number[1] & 0x0f) + (Number[1] >> 4); + dt->Day = 10 * (Number[2] & 0x0f) + (Number[2] >> 4); + dt->Hour = 10 * (Number[3] & 0x0f) + (Number[3] >> 4); + dt->Minute = 10 * (Number[4] & 0x0f) + (Number[4] >> 4); + dt->Second = 10 * (Number[5] & 0x0f) + (Number[5] >> 4); + dt->Timezone = (10 * (Number[6] & 0x07) + (Number[6] >> 4)) / 4; + if (Number[6] & 0x08) dt->Timezone = -dt->Timezone; + + return dt; +} -// if (SMS->UDHType==GSM_HangSMS) ETSI->TPDCS=0x08; //Such SMS hangs phone (5110, 5.07), - //when saved to Outbox atry try to read it - /*from phone's menu*/ - } +/*** + *** ENCODING SMS + ***/ - switch (SMS->Coding) { - /* When save SMS to SIM and it's 8 bit SMS, - "Edit" is not displayed in phone menu and - "Message cannot be displayed here" instead of message text */ - case GSM_Coding_8bit: +/* This function encodes the UserDataHeader as described in: + - GSM 03.40 version 6.1.0 Release 1997, section 9.2.3.24 + - Smart Messaging Specification, Revision 1.0.0, September 15, 1997 +*/ +static GSM_Error EncodeUDH(SMS_UDHInfo UDHi, char *UDH) +{ + unsigned char pos; - /* the mask for the 8-bit data */ - /* GSM 03.40 section 9.2.3.10 (TP-Data-Coding-Scheme) and GSM 03.38 section 4 */ - ETSI->TPDCS |= 0xf4; - - memcpy(ETSI->MessageText + off, SMS->MessageText, SMS->Length); + pos = UDH[0]; + switch (UDHi.Type) { + case SMS_NoUDH: + break; + case SMS_VoiceMessage: + case SMS_FaxMessage: + case SMS_EmailMessage: + UDH[pos+4] = UDHi.u.SpecialSMSMessageIndication.MessageCount; + if (UDHi.u.SpecialSMSMessageIndication.Store) UDH[pos+3] |= 0x80; + case SMS_ConcatenatedMessages: + case SMS_OpLogo: + case SMS_CallerIDLogo: + case SMS_Ringtone: + UDH[0] += headers[UDHi.Type].length; + memcpy(UDH+pos+1, headers[UDHi.Type].header, headers[UDHi.Type].length); + break; + default: + fprintf(stderr, _("Not supported User Data Header type\n")); + break; + } + return GE_NONE; +} - size2 = size = SMS->Length+off; +static GSM_Error EncodeSMSSubmitHeader(GSM_SMSMessage *SMS, char *frame) +{ + GSM_Error error = GE_NONE; + int i; - break; + /* SMS Center */ - case GSM_Coding_Default: + /* Reply Path */ + if (SMS->ReplyViaSameSMSC) frame[13] |= 0x80; - w=(7-off)%7; - if (w<0) w=(14-off)%14; + /* User Data Header */ + for (i = 0; SMS->UDH[i].Type != SMS_NoUDH; i++) { + frame[13] |= 0x40; + error = EncodeUDH(SMS->UDH[i], frame); + if (error != GE_NONE) return error; + } - size = GSM_PackSevenBitsToEight(w, SMS->MessageText, ETSI->MessageText + off); - size += off; - size2 = (off*8 + w) / 7 + strlen(SMS->MessageText); + /* Status (Delivery) Report Request */ + if (SMS->Report) frame[13] |= 0x20; - break; + /* Validity Period Format: mask - 0x00, 0x10, 0x08, 0x18 */ + frame[13] |= ((SMS->Validity.VPF & 0x03) << 3); - case GSM_Coding_Unicode: + /* Reject Duplicates */ + if (SMS->RejectDuplicates) frame[13] |= 0x04; - /* GSM 03.40 section 9.2.3.10 (TP-Data-Coding-Scheme) and GSM 03.38 section 4 */ - ETSI->TPDCS |= 0x08; + /* Message Type is already set */ -#ifdef DEBUG - fprintf(stdout,_("SMS Length is %i\n"),strlen(SMS->MessageText)); -#endif + /* Message Reference */ + /* Can we set this? */ - EncodeUnicode (ETSI->MessageText+off,SMS->MessageText,strlen(SMS->MessageText)); - /* here we code "special" chars */ - for (i=0;iMessageText);i++) { - if (SMS->MessageText[i]=='~') ETSI->MessageText[off+1+i*2]=1; //enables/disables blinking - if (SMS->MessageText[i]=='`') ETSI->MessageText[off+1+i*2]=0; //hides rest ot contents - } + /* Protocol Identifier */ + /* FIXME: allow to change this in better way. + currently only 0x5f == `Return Call Message' is used */ + frame[16] = SMS->PID; - size=size2=strlen(SMS->MessageText)*2+off; + /* Data Coding Scheme */ + switch (SMS->DCS.Type) { + case SMS_GeneralDataCoding: + if (SMS->DCS.u.General.Compressed) frame[17] |= 0x20; + if (SMS->DCS.u.General.Class) frame[17] |= (0x10 | (SMS->DCS.u.General.Class - 1)); + frame[17] |= ((SMS->DCS.u.General.Alphabet & 0x03) << 2); + break; + case SMS_MessageWaiting: + if (SMS->DCS.u.MessageWaiting.Discard) frame[17] |= 0xc0; + else if (SMS->DCS.u.MessageWaiting.Alphabet == SMS_UCS2) frame[17] |= 0xe0; + else frame[17] |= 0xd0; + if (SMS->DCS.u.MessageWaiting.Active) frame[17] |= 0x80; + frame[17] |= (SMS->DCS.u.MessageWaiting.Type & 0x03); + break; + default: + fprintf(stderr, _("Wrong Data Coding Scheme (DCS) format\n")); + return GE_SMSWRONGFORMAT; + } - break; - } + /* User Data Length */ + /* Will be filled later. */ - /* FIXME: support for compression */ - /* GSM 03.40 section 9.2.3.10 (TP-Data-Coding-Scheme) and GSM 03.38 section 4 */ - /* See also GSM 03.42 */ - /* if (SMS->Compression) ETSI->TPDCS |= 0x20; */ + /* Destination Address */ - /* SMS->Length is: - - integer representation of the number od octets within the user data when UD is coded using 8bit data - - the sum of the number of septets in UDH including any padding and number of septets in UD in other case */ - /* GSM 03.40 section 9.2.3.16 (TP-User-Data-Length) */ - ETSI->TPUDL = size2; + /* Validity Period */ + switch (SMS->Validity.VPF) { + case SMS_EnhancedFormat: + break; + case SMS_RelativeFormat: + break; + case SMS_AbsoluteFormat: + break; + default: + break; + } - return size; + return GE_NONE; } -GSM_Error GSM_DecodeETSISMSSubmitData(GSM_SMSMessage *SMS, GSM_ETSISMSMessage *ETSI) +static GSM_Error EncodeSMSDeliverHeader() { - int off,w,i,tmp=0; - unsigned char output[161]; - bool UDHOK; + return GE_NONE; +} - /* off - length of the user data header */ - off = 0; - - SMS->UDHType = GSM_NoUDH; +static GSM_Error EncodeSMSHeader(GSM_SMSMessage *SMS, char *frame) +/* We can create either SMS DELIVER (for saving in Inbox) or SMS SUBMIT + (for sending or saving in Outbox) message */ +{ + /* Set SMS type */ + frame[12] |= (SMS->Type >> 1); + switch (SMS->Type) { + case SMS_Submit: /* we send SMS or save it in Outbox */ + return EncodeSMSSubmitHeader(SMS, frame); + case SMS_Deliver: /* we save SMS in Inbox */ + return EncodeSMSSubmitHeader(SMS, frame); + default: /* we don't create other formats of SMS */ + return GE_SMSWRONGFORMAT; + } +} - if (ETSI->firstbyte & 64) { /* UDH header available */ +/* This function encodes SMS as described in: + - GSM 03.40 version 6.1.0 Release 1997, section 9 +*/ +GSM_Error EncodePDUSMS(GSM_SMSMessage *SMS, char *frame) +{ + GSM_Error error = GE_NONE; + int i; - off = (ETSI->MessageText[0] + 1); /* Length of UDH header */ - - /* Copy UDH header into SMS->UDH */ - for (i = 0; i < off; i++) SMS->UDH[i] = ETSI->MessageText[i]; + /* Short Message Data info element id */ -#ifdef DEBUG - fprintf(stdout, " UDH header available (length %i",off); -#endif - - SMS->UDHType = GSM_UnknownUDH; - - i=-1; - while (true) { - i++; - if (UDHHeaders[i].UDHType==GSM_NoUDH) break; - tmp=UDHHeaders[i].Length; - if (tmp==SMS->UDH[0]) { //if length is the same - - if (tmp==0x05) tmp=tmp-2;/*two last bytes can be different for such UDH*/ - if (tmp==0x0b) tmp=tmp-3;/*three last bytes can be different for such UDH*/ - - UDHOK=true; - for (w=0;wUDH[w+1]) { - UDHOK=false; - break; - } - } - if (UDHOK) { - SMS->UDHType=UDHHeaders[i].UDHType; - break; - } - } - } - -#ifdef DEBUG - switch (SMS->UDHType) { - case GSM_ConcatenatedMessages: - fprintf(stdout,_(", concatenated (linked) message %d/%d"),SMS->UDH[5],SMS->UDH[4]);break; - case GSM_DisableVoice: - fprintf(stdout,_(", disables voice indicator"));break; - case GSM_EnableVoice: - fprintf(stdout,_(", enables voice indicator"));break; - case GSM_DisableFax: - fprintf(stdout,_(", disables fax indicator"));break; - case GSM_EnableFax: - fprintf(stdout,_(", enables fax indicator"));break; - case GSM_DisableEmail: - fprintf(stdout,_(", disables email indicator"));break; - case GSM_EnableEmail: - fprintf(stdout,_(", enables email indicator"));break; - case GSM_VoidSMS: - fprintf(stdout,_(", void SMS"));break; - case GSM_WAPBookmarkUDH: - fprintf(stdout,_(", WAP Bookmark"));break; - case GSM_WAPBookmarkUDHLong: - fprintf(stdout,_(", WAP Bookmark, part %i/%i"),SMS->UDH[11],SMS->UDH[10]);break; - case GSM_WAPSettingsUDH: - fprintf(stdout,_(", WAP Settings, part %i/%i"),SMS->UDH[11],SMS->UDH[10]);break; - case GSM_RingtoneUDH: - fprintf(stdout,_(", ringtone"));break; - case GSM_OpLogo: - fprintf(stdout,_(", GSM Operator Logo"));break; - case GSM_CallerIDLogo: - fprintf(stdout,_(", Caller Logo"));break; - case GSM_ProfileUDH: - fprintf(stdout,_(", Profile SMS, part %i/%i"),SMS->UDH[11],SMS->UDH[10]);break; - case GSM_CalendarNoteUDH: - fprintf(stdout,_(", Calendar note SMS, part %i/%i"),SMS->UDH[11],SMS->UDH[10]);break; - case GSM_CalendarNoteUDH2: - fprintf(stdout,_(", Calendar note SMS, part %i/%i"),SMS->UDH[11],SMS->UDH[10]);break; - case GSM_PhonebookUDH: - fprintf(stdout,_(", Phonebook Entry, part %i/%i"),SMS->UDH[11],SMS->UDH[10]);break; - default: - fprintf(stdout,_(", UNKNOWN"));break; - } - - fprintf(stdout, ")\n"); - - hexdump(off,SMS->UDH); -#endif - } + /* Length of Short Message Data */ - SMS->Coding = GSM_Coding_Default; + /* Short Message Reference value */ + if (SMS->Number) frame[3] = SMS->Number; - /* GSM 03.40 section 9.2.3.10 (TP-Data-Coding-Scheme) and GSM 03.38 section 4 */ - if ((ETSI->TPDCS & 0xf4) == 0xf4) SMS->Coding=GSM_Coding_8bit; - if ((ETSI->TPDCS & 0x08) == 0x08) SMS->Coding=GSM_Coding_Unicode; + /* Short Message status */ + if (SMS->Status) frame[1] = SMS->Status; - switch (SMS->Coding) { - case GSM_Coding_Default: - w=(7-off)%7; - if (w<0) w=(14-off)%14; - - SMS->Length=ETSI->TPUDL - (off*8 + w) / 7; + /* Message Type */ - tmp=GSM_UnpackEightBitsToSeven(w,ETSI->TPUDL-off, SMS->Length, ETSI->MessageText+off, output); + /* SMSC number */ + if (SMS->MessageCenter.Number) { +// error = GSM->GetSMSCenter(&SMS->MessageCenter); + + if (error != GE_NONE) + return error; + strcpy(SMS->MessageCenter.Number, "0"); + } + dprintf("Sending SMS to %s via message center %s\n", SMS->Sender, SMS->MessageCenter.Number); -#ifdef DEBUG - fprintf(stdout, " 7 bit SMS, body is (length %i): ",SMS->Length); -#endif /* DEBUG */ + /* Header coding */ +// EncodeUDH(SMS, frame); +// if (error != GE_NONE) return error; - DecodeDefault (SMS->MessageText, output, SMS->Length); + /* User Data Header - if present */ + for (i = 0; SMS->UDH[i].Type != SMS_NoUDH; i++) { + error = EncodeUDH(SMS->UDH[i], frame); + if (error != GE_NONE) return error; + } -#ifdef DEBUG - fprintf(stdout, "%s\n",SMS->MessageText); -#endif + /* User Data */ + // EncodeData(&(SMS->MessageText), &(SMS->DCS), frame); - break; - case GSM_Coding_8bit: - SMS->Length=ETSI->TPUDL - off; - - memcpy(SMS->MessageText,ETSI->MessageText+off,SMS->Length); - -#ifdef DEBUG - fprintf(stdout, " 8 bit SMS, body is (length %i)\n",SMS->Length); - hexdump(SMS->Length,SMS->MessageText); -#endif /* DEBUG */ - - break; - case GSM_Coding_Unicode: - SMS->Length=(ETSI->TPUDL - off) / 2; - -#ifdef DEBUG - fprintf(stdout, " 7 bit SMS, body is (length %i), Unicode coding: ",SMS->Length); - for (i=0; iLength;i++) { - fprintf(stdout, "[%02x %02x]", ETSI->MessageText[off+i*2] , ETSI->MessageText[off+i*2+1]); - } - fprintf(stdout, "\n"); -#endif /* DEBUG */ - - /* here we decode "special" chars */ - for (i=0; iLength;i++) { - if (ETSI->MessageText[off+i*2] ==0x00 && - ETSI->MessageText[off+i*2+1]==0x01) - ETSI->MessageText[off+i*2+1]='~'; //enables/disables blinking - if (ETSI->MessageText[off+i*2] ==0x00 && - ETSI->MessageText[off+i*2+1]==0x00) - ETSI->MessageText[off+i*2+1]='`'; //hides rest ot contents - } - - DecodeUnicode (SMS->MessageText, ETSI->MessageText+off, SMS->Length); - - break; - } - - return GE_NONE; + return error; } -GSM_Error GSM_DecodeETSISMSStatusReportData(GSM_SMSMessage *SMS, GSM_ETSISMSMessage *ETSI) +/* This function does simple SMS encoding - no PDU coding */ +GSM_Error EncodeTextSMS() { - /* See GSM 03.40 section 9.2.3.11 (TP-Service-Centre-Time-Stamp) */ -#ifdef DEBUG - fprintf(stdout, _(" SMSC response date: ")); -#endif - GSM_DecodeSMSDateTime(&SMS->SMSCTime, ETSI->SMSCDateTime); - - if (ETSI->TPStatus < 0x03) { - strcpy(SMS->MessageText,_("Delivered")); - -#ifdef DEBUG - /* more detailed reason only for debug */ - /* See GSM 03.40 section 9.2.3.15 (TP-Status) */ - switch (ETSI->TPStatus) { - case 0x00: fprintf(stdout, _(" SM received by the SME"));break; - case 0x01: fprintf(stdout, _(" SM forwarded by the SC to the SME but the SC is unable to confirm delivery"));break; - case 0x02: fprintf(stdout, _(" SM replaced by the SC"));break; - } -#endif /* DEBUG */ - - SMS->Length = 10; - - } else if (ETSI->TPStatus & 0x40) { - - strcpy(SMS->MessageText,_("Failed")); - -#ifdef DEBUG - /* more detailed reason only for debug */ - if (ETSI->TPStatus & 0x20) { - - /* See GSM 03.40 section 9.2.3.15 (TP-Status) */ - fprintf(stdout, _(" Temporary error, SC is not making any more transfer attempts\n")); - switch (ETSI->TPStatus) { - case 0x60: fprintf(stdout, _(" Congestion"));break; - case 0x61: fprintf(stdout, _(" SME busy"));break; - case 0x62: fprintf(stdout, _(" No response from SME"));break; - case 0x63: fprintf(stdout, _(" Service rejected"));break; - case 0x64: fprintf(stdout, _(" Quality of service not available"));break; - case 0x65: fprintf(stdout, _(" Error in SME"));break; - default : fprintf(stdout, _(" Reserved/Specific to SC: %x"),ETSI->TPStatus);break; - } - - } else { - - /* See GSM 03.40 section 9.2.3.15 (TP-Status) */ - fprintf(stdout, _(" Permanent error, SC is not making any more transfer attempts\n")); - switch (ETSI->TPStatus) { - case 0x40: fprintf(stdout, _(" Remote procedure error"));break; - case 0x41: fprintf(stdout, _(" Incompatibile destination"));break; - case 0x42: fprintf(stdout, _(" Connection rejected by SME"));break; - case 0x43: fprintf(stdout, _(" Not obtainable"));break; - case 0x44: fprintf(stdout, _(" Quality of service not available"));break; - case 0x45: fprintf(stdout, _(" No internetworking available"));break; - case 0x46: fprintf(stdout, _(" SM Validity Period Expired"));break; - case 0x47: fprintf(stdout, _(" SM deleted by originating SME"));break; - case 0x48: fprintf(stdout, _(" SM Deleted by SC Administration"));break; - case 0x49: fprintf(stdout, _(" SM does not exist"));break; - default : fprintf(stdout, _(" Reserved/Specific to SC: %x"),ETSI->TPStatus);break; - } - } -#endif /* DEBUG */ - - SMS->Length = 6; - } else if (ETSI->TPStatus & 0x20) { - strcpy(SMS->MessageText,_("Pending")); - -#ifdef DEBUG - /* more detailed reason only for debug */ - /* See GSM 03.40 section 9.2.3.15 (TP-Status) */ - fprintf(stdout, _(" Temporary error, SC still trying to transfer SM\n")); - switch (ETSI->TPStatus) { - case 0x20: fprintf(stdout, _(" Congestion"));break; - case 0x21: fprintf(stdout, _(" SME busy"));break; - case 0x22: fprintf(stdout, _(" No response from SME"));break; - case 0x23: fprintf(stdout, _(" Service rejected"));break; - case 0x24: fprintf(stdout, _(" Quality of service not aviable"));break; - case 0x25: fprintf(stdout, _(" Error in SME"));break; - default : fprintf(stdout, _(" Reserved/Specific to SC: %x"),ETSI->TPStatus);break; - } -#endif /* DEBUG */ - SMS->Length = 7; - } else { - strcpy(SMS->MessageText,_("Unknown")); - -#ifdef DEBUG - /* more detailed reason only for debug */ - fprintf(stdout, _(" Reserved/Specific to SC: %x"),ETSI->TPStatus); -#endif /* DEBUG */ - SMS->Length = 8; - } - -#ifdef DEBUG - fprintf(stdout, _("\n")); -#endif /* DEBUG */ - - return GE_NONE; + return GE_NONE; } -GSM_Error GSM_EncodeETSISMSSubmitHeader(GSM_SMSMessage *SMS,GSM_ETSISMSMessage *ETSI) -{ - GSM_Error error; - - /* First of all we should get SMSC number */ - if (SMS->MessageCenter.No) { - error = GSM->GetSMSCenter(&SMS->MessageCenter); - if (error != GE_NONE) return error; - SMS->MessageCenter.No = 0; - } - -#ifdef DEBUG - fprintf(stdout, _("Packing SMS to \"%s\" via message center \"%s\"\n"), SMS->Destination, SMS->MessageCenter.Number); -#endif /* DEBUG */ - - ETSI->SMSCNumber[0]=GSM_PackSemiOctetNumber(SMS->MessageCenter.Number, ETSI->SMSCNumber+1, false); - - /* GSM 03.40 section 9.2.3.17 (TP-Reply-Path) */ - if (SMS->ReplyViaSameSMSC) ETSI->firstbyte |= 128; - - /* When save to Outbox with SMS Class, "Edit" is not displayed in phone menu - and can forward it to another phone with set class (for example, 0=Flash) */ - /* Message Class*/ - /* GSM 03.40 section 9.2.3.10 (TP-Data-Coding-Scheme) and GSM 03.38 section 4 */ - if (SMS->Class>=0 && SMS->Class<5) ETSI->TPDCS |= (240+SMS->Class); - - /* When is not set for SMS saved for Inbox, phone displays "Message" instead - of number and doesn't display "Details" info */ - ETSI->Number[0] = GSM_PackSemiOctetNumber(SMS->Destination, ETSI->Number+1, true); - - return GE_NONE; -} +/*** + *** DECODING SMS + ***/ -GSM_Error GSM_DecodeETSISMSHeader(GSM_SMSMessage *SMS, GSM_ETSISMSMessage *ETSI) +static GSM_Error SMSStatus(unsigned char status, GSM_SMSMessage *sms) { -#ifdef DEBUG - fprintf(stdout, _(" SMS center number: %s"), GSM_UnpackSemiOctetNumber(ETSI->SMSCNumber,false)); - if (SMS->folder==0 && (ETSI->firstbyte & 128)!=0) //GST_INBOX - fprintf(stdout, _(" (centre set for reply)")); -#endif - - strcpy(SMS->MessageCenter.Number, GSM_UnpackSemiOctetNumber(ETSI->SMSCNumber,false)); - - SMS->ReplyViaSameSMSC=false; - if ((ETSI->firstbyte & 128)!=0) SMS->ReplyViaSameSMSC=true; - -#ifdef DEBUG - fprintf(stdout, _("\n Remote number (recipient or sender): %s\n"), GSM_UnpackSemiOctetNumber(ETSI->Number,true)); -#endif - - strcpy(SMS->Sender, GSM_UnpackSemiOctetNumber(ETSI->Number,true)); - - return GE_NONE; + if (status < 0x03) { + strcpy(sms->MessageText, _("Delivered")); + switch (status) { + case 0x00: + dprintf(_("SM received by the SME")); + break; + case 0x01: + dprintf(_("SM forwarded by the SC to the SME but the SC is unable to confirm delivery")); + break; + case 0x02: + dprintf(_("SM replaced by the SC")); + break; + } + sms->Length = 10; + } else if (status & 0x40) { + + strcpy(sms->MessageText, _("Failed")); + + /* more detailed reason only for debug */ + + if (status & 0x20) { + dprintf(_("Temporary error, SC is not making any more transfer attempts\n")); + + switch (status) { + case 0x60: + dprintf(_("Congestion")); + break; + case 0x61: + dprintf(_("SME busy")); + break; + case 0x62: + dprintf(_("No response from SME")); + break; + case 0x63: + dprintf(_("Service rejected")); + break; + case 0x64: + dprintf(_("Quality of service not aviable")); + break; + case 0x65: + dprintf(_("Error in SME")); + break; + default: + dprintf(_("Reserved/Specific to SC: %x"), status); + break; + } + } else { + dprintf(_("Permanent error, SC is not making any more transfer attempts\n")); + switch (status) { + case 0x40: + dprintf(_("Remote procedure error")); + break; + case 0x41: + dprintf(_("Incompatibile destination")); + break; + case 0x42: + dprintf(_("Connection rejected by SME")); + break; + case 0x43: + dprintf(_("Not obtainable")); + break; + case 0x44: + dprintf(_("Quality of service not aviable")); + break; + case 0x45: + dprintf(_("No internetworking available")); + break; + case 0x46: + dprintf(_("SM Validity Period Expired")); + break; + case 0x47: + dprintf(_("SM deleted by originating SME")); + break; + case 0x48: + dprintf(_("SM Deleted by SC Administration")); + break; + case 0x49: + dprintf(_("SM does not exist")); + break; + default: + dprintf(_("Reserved/Specific to SC: %x"), status); + break; + } + } + sms->Length = 6; + } else if (status & 0x20) { + strcpy(sms->MessageText, _("Pending")); + + /* more detailed reason only for debug */ + dprintf(_("Temporary error, SC still trying to transfer SM\n")); + switch (status) { + case 0x20: + dprintf(_("Congestion")); + break; + case 0x21: + dprintf(_("SME busy")); + break; + case 0x22: + dprintf(_("No response from SME")); + break; + case 0x23: + dprintf(_("Service rejected")); + break; + case 0x24: + dprintf(_("Quality of service not aviable")); + break; + case 0x25: + dprintf(_("Error in SME")); + break; + default: + dprintf(_("Reserved/Specific to SC: %x"), status); + break; + } + sms->Length = 7; + } else { + strcpy(sms->MessageText, _("Unknown")); + + /* more detailed reason only for debug */ + dprintf(_("Reserved/Specific to SC: %x"), status); + sms->Length = 8; + } + return GE_NONE; } -/* FIXME: we should allow for all validity formats */ -GSM_Error GSM_EncodeETSISMSSubmitValidity(GSM_SMSMessage *SMS,GSM_ETSISMSMessage *ETSI) +static GSM_Error DecodeData(char *message, char *output, int length, SMS_DataCodingScheme dcs, int udhlen, int size) { - /* GSM 03.40 section 9.2.3.3 (TP-Validity-Period-Format) */ - /* Bits 4 and 3: 10. TP-VP field present and integer represent (relative) */ - ETSI->firstbyte |= 0x10; - - /* GSM 03.40 section 9.2.3.12 (TP-Validity Period) */ - /* FIXME: error-checking for correct Validity - it should not be bigger then - 63 weeks and smaller then 5minutes. We should also test intervals because - the SMS->Validity to TP-VP is not continuos. I think that the simplest - solution will be an array of correct values. We should parse it and if we - find the closest TP-VP value we should use it. Or is it good to take - closest smaller TP-VP as we do now? I think it is :-) */ - - /* 5 minutes intervals up to 12 hours = 720 minutes */ - if (SMS->Validity <= 720) - ETSI->TPVP = (unsigned char) (SMS->Validity/5)-1; - - /* 30 minutes intervals up to 1 day */ - else if ((SMS->Validity > 720) && (SMS->Validity <= 1440)) - ETSI->TPVP = (unsigned char) ((SMS->Validity-720)/30)+143; - - /* 1 day intervals up to 30 days */ - else if ((SMS->Validity > 1440) && (SMS->Validity <= 43200)) - ETSI->TPVP = (unsigned char) (SMS->Validity/1440)+166; - - /* 1 week intervals up to 63 weeks */ - else if ((SMS->Validity > 43200) && (SMS->Validity <= 635040)) - ETSI->TPVP = (unsigned char) (SMS->Validity/10080)+192; - - return GE_NONE; + /* Unicode */ + if ((dcs.Type & 0x08) == 0x08) { + length = (length - udhlen)/2; + DecodeUnicode(output, message, length); + /* 8bit SMS */ + } else { + if ((dcs.Type & 0xf4) == 0xf4) { + memcpy(output, message, length); + /* 7bit SMS */ + } else { + length = length - (udhlen * 8 + ((7-udhlen)%7)) / 7; + Unpack7BitCharacters((7-udhlen)%7, size, length, message, output); + } + DecodeAscii(output, output, length); + } + dprintf("%s\n", output); + return GE_NONE; } -/* FIXME: do we need more than SMS_Submit and SMS_Deliver ? */ -GSM_Error GSM_EncodeETSISMS(GSM_SMSMessage *SMS, GSM_ETSISMSMessage *ETSI, SMS_MessageType PDU, int *length) +/* This function decodes UDH as described in: + - GSM 03.40 version 6.1.0 Release 1997, section 9.2.3.24 + - Smart Messaging Specification, Revision 1.0.0, September 15, 1997 +*/ +static GSM_Error DecodeUDH(char *SMSMessage, SMS_UDHInfo **UDHi, GSM_SMSMessage *sms) { - int size=0; - GSM_Error error; - - ETSI->firstbyte=0; - ETSI->TPPID=0; - ETSI->TPDCS=0; - ETSI->TPUDL=0; - ETSI->TPStatus=0; - ETSI->TPVP=0; - - switch (PDU) { - case SMS_Submit: - - /* GSM 03.40 section 9.2.3.1 (TP-Message-Type-Indicator) */ - /* Bits 1 and 0: 01. SMS-Submit */ - ETSI->firstbyte |= 0x01; - - /* GSM 03.40 section 9.2.3.5 (TP-Status-Raport-Request) */ - /* Mask for request for delivery report from SMSC */ - if (SMS->Type == GST_DR) ETSI->firstbyte |= 32; - - error=GSM_EncodeETSISMSSubmitHeader(SMS, ETSI); - if (error!=GE_NONE) return error; - error=GSM_EncodeETSISMSSubmitValidity(SMS, ETSI); - if (error!=GE_NONE) return error; - size=GSM_EncodeETSISMSSubmitData(SMS, ETSI); - - break; - case SMS_Deliver: - - /* GSM 03.40 section 9.2.3.1 (TP-Message-Type-Indicator) */ - /* Bits 1 and 0: 00. SMS-Deliver */ - ETSI->firstbyte |= 0x00; - - error=GSM_EncodeETSISMSSubmitHeader(SMS, ETSI); - if (error!=GE_NONE) return error; - GSM_EncodeSMSDateTime(&SMS->Time, ETSI->DeliveryDateTime); - size=GSM_EncodeETSISMSSubmitData(SMS, ETSI); - - break; - default: - break; - } - - /* size is the length of the data in octets including udh */ - *length=size; - - return GE_NONE; + unsigned char length, pos, nr; + + length = SMSMessage[0]; + pos = 1; + nr = 0; + while (length > 0) { + unsigned char udh_length; + + udh_length = SMSMessage[pos+1]; + switch (SMSMessage[pos]) { + case 0x00: // Concatenated short messages + dprintf("Concat UDH length: %d\n", udh_length); + UDHi[nr]->Type = SMS_ConcatenatedMessages; + UDHi[nr]->u.ConcatenatedShortMessage.ReferenceNumber = SMSMessage[pos + 3]; + UDHi[nr]->u.ConcatenatedShortMessage.MaximumNumber = SMSMessage[pos + 4]; + UDHi[nr]->u.ConcatenatedShortMessage.CurrentNumber = SMSMessage[pos + 5]; + break; + case 0x01: // Special SMS Message Indication + switch (SMSMessage[pos + 3] & 0x03) { + case 0x00: + UDHi[nr]->Type = SMS_VoiceMessage; + break; + case 0x01: + UDHi[nr]->Type = SMS_FaxMessage; + break; + case 0x02: + UDHi[nr]->Type = SMS_EmailMessage; + break; + default: + UDHi[nr]->Type = SMS_UnknownUDH; + break; + } + UDHi[nr]->u.SpecialSMSMessageIndication.Store = (SMSMessage[pos + 3] & 0x80) >> 7; + UDHi[nr]->u.SpecialSMSMessageIndication.MessageCount = SMSMessage[pos + 4]; + break; + case 0x04: // Application port addression scheme, 8 bit address + break; + case 0x05: // Application port addression scheme, 16 bit address + break; + case 0x06: // SMSC Control Parameters + break; + case 0x07: // UDH Source Indicator + break; + default: + break; + } + length -= (udh_length + 2); + pos += (udh_length + 2); + nr++; + } + sms->UDH_No = nr; + + return GE_NONE; } -/* This function decodes parts of SMS coded according to GSM 03.40 - (given in GSM_ETSISMSMessage) to GSM_SMSMessage */ -GSM_Error GSM_DecodeETSISMS(GSM_SMSMessage *SMS, GSM_ETSISMSMessage *ETSI) +static GSM_Error DecodeSMSSubmit() { - SMS_MessageType PDU=SMS_Deliver; - - /* See GSM 03.40 section 9.2.3.1 */ - if ((ETSI->firstbyte & 0x03) == 0x01) PDU=SMS_Submit; - if ((ETSI->firstbyte & 0x03) == 0x02) PDU=SMS_Status_Report; - - GSM_DecodeETSISMSHeader(SMS, ETSI); - - switch (PDU) { - case SMS_Submit: -#ifdef DEBUG - fprintf(stdout, _(" SMS submit ")); -#endif - SMS->SMSData=false; - GSM_DecodeETSISMSSubmitData(SMS,ETSI); - break; - case SMS_Deliver: -#ifdef DEBUG - fprintf(stdout, _(" SMS deliver ")); - fprintf(stdout, _(" Date: ")); -#endif - SMS->SMSData=true; - GSM_DecodeSMSDateTime(&SMS->Time, ETSI->DeliveryDateTime); - GSM_DecodeETSISMSSubmitData(SMS,ETSI); - break; - case SMS_Status_Report: -#ifdef DEBUG - fprintf(stdout, _(" SMS status report ")); - fprintf(stdout, _(" Date: ")); -#endif - SMS->SMSData=true; - GSM_DecodeSMSDateTime(&SMS->Time, ETSI->DeliveryDateTime); - GSM_DecodeETSISMSStatusReportData(SMS,ETSI); - break; - default: - break; - } - - SMS->MessageText[SMS->Length]=0; - - return GE_NONE; + return GE_NONE; } -void GSM_SetDefaultSMSData (GSM_SMSMessage *SMS) +static GSM_Error DecodeSMSDeliver() { - struct tm *now; - time_t nowh; - GSM_DateTime Date; - - /* Default settings for SMS message: - - no delivery report - - Class Message 1 - - no compression - - SMSC no. 1 - - validity 3 days */ - - SMS->folder = GST_OUTBOX; - SMS->Type = GST_SMS; - SMS->Class = -1; - SMS->Compression = false; - SMS->MessageCenter.No = 1; - SMS->Validity = 4320; /* 4320 minutes == 72 hours */ - SMS->ReplyViaSameSMSC = false; - SMS->UDHType = GSM_NoUDH; - SMS->Coding=GSM_Coding_Default; - strcpy(SMS->Destination,""); - - /* This part is required to save SMS */ - - SMS->Status = GSS_NOTSENTREAD; - SMS->Location = 0; - - nowh=time(NULL); - now=localtime(&nowh); - - Date.Year = now->tm_year; - Date.Month = now->tm_mon+1; - Date.Day = now->tm_mday; - Date.Hour = now->tm_hour; - Date.Minute = now->tm_min; - Date.Second = now->tm_sec; - - /* I have 100 (for 2000) Year now :-) */ - if (Date.Year>99 && Date.Year<1900) { - Date.Year=Date.Year+1900; - } - - /* We need to have only two last digits of year */ - if (Date.Year>1900) - { - if (Date.Year<2000) Date.Year = Date.Year-1900; - else Date.Year = Date.Year-2000; - } - - SMS->Time.Year=Date.Year; - SMS->Time.Month=Date.Month; - SMS->Time.Day=Date.Day; - SMS->Time.Hour=Date.Hour; - SMS->Time.Minute=Date.Minute; - SMS->Time.Second=Date.Second; - - SMS->Name[0]=0; + return GE_NONE; } -/* This function encodes the UserDataHeader as described in: - - GSM 03.40 version 6.1.0 Release 1997, section 9.2.3.24 - - Smart Messaging Specification, Revision 1.0.0, September 15, 1997 -*/ -GSM_Error EncodeUDHHeader(char *text, GSM_UDH UDHType) +static GSM_Error DecodeSMSHeader(unsigned char *message, GSM_SMSMessage *sms) { - int i=0; - - if (UDHType!=GSM_NoUDH) { - while (true) { - if (UDHHeaders[i].UDHType==GSM_NoUDH) { -#ifdef DEBUG - fprintf(stderr,_("Not supported User Data Header type\n")); -#endif + /* Short Message Type */ + switch (sms->Type = message[7]) { + case SMS_Deliver: + dprintf("Mobile Terminated message:\n"); break; - } - if (UDHHeaders[i].UDHType==UDHType) { - text[0] = UDHHeaders[i].Length; // UDH Length - memcpy(text+1, UDHHeaders[i].Text, UDHHeaders[i].Length); + case SMS_Delivery_Report: + dprintf("Delivery Report:\n"); + UnpackDateTime(message + 39 + DataOffset[sms->Type], &(sms->Time)); + dprintf("\tDelivery date: %s\n", PrintDateTime(message + 39 + DataOffset[sms->Type])); break; - } - i++; - } - } + case SMS_Submit: + dprintf("Mobile Originated message:\n"); + break; + default: + dprintf("Not supported message:\n"); + break; + } + /* Short Message status */ + sms->Status = message[4]; + dprintf("\tStatus: "); + switch (sms->Status) { + case SMS_Read: + dprintf("READ\n"); + break; + case SMS_Unread: + dprintf("UNREAD\n"); + break; + case SMS_Sent: + dprintf("SENT\n"); + break; + case SMS_Unsent: + dprintf("UNSENT\n"); + break; + default: + dprintf("UNKNOWN\n"); + break; + } + + /* Short Message location in memory */ + sms->Number = message[6]; + dprintf("\tLocation: %d\n", sms->Number); + + /* Short Message Center */ + strcpy(sms->MessageCenter.Number, GetBCDNumber(message)); + dprintf("\tSMS center number: %s\n", sms->MessageCenter.Number); + sms->ReplyViaSameSMSC = false; + if (sms->RemoteNumber.number[0] == 0 && (message[12] & 0x80)) { + sms->ReplyViaSameSMSC = true; + } + + /* Remote number */ + message[20+DataOffset[sms->Type]] = ((message[20+DataOffset[sms->Type]])+1)/2+1; + dprintf("\tRemote number (recipient or sender): %s\n", GSM_GetBCDNumber(message + 20 + DataOffset[sms->Type])); + strcpy(sms->RemoteNumber.number, GetBCDNumber(message + 20 + DataOffset[sms->Type])); + + UnpackDateTime(message + 24 + DataOffset[sms->Type], &(sms->Time)); + dprintf("\tDate: %s\n", PrintDateTime(message + 24 + DataOffset[sms->Type])); + + /* Data Coding Scheme */ + if (sms->Type != SMS_Delivery_Report) + sms->DCS.Type = message[18 + DataOffset[sms->Type]]; + else + sms->DCS.Type = 0; + + /* User Data Header */ + if (message[20] & 0x40) /* UDH header available */ + DecodeUDH(message + 31 + DataOffset[sms->Type], (SMS_UDHInfo **)sms->UDH, sms); + else /* No UDH */ + sms->UDH_No = 0; + return GE_NONE; } -int GSM_MakeSinglePartSMS2(GSM_SMSMessage *SMS, - unsigned char *MessageBuffer,int cur, GSM_UDH UDHType, GSM_Coding_Type Coding){ - - int j; - int current,smsudhlength; - - GSM_SetDefaultSMSData(SMS); - - EncodeUDHHeader(SMS->UDH, UDHType); - SMS->UDHType=UDHType; - - switch (UDHType) { - case GSM_EnableVoice: - case GSM_DisableVoice: - case GSM_EnableEmail: - case GSM_DisableEmail: - case GSM_EnableFax: - case GSM_DisableFax: - SMS->Class=1; - SMS->Coding=Coding; - break; - case GSM_NoUDH: - case GSM_ConcatenatedMessages: - case GSM_VoidSMS: - case GSM_HangSMS: - case GSM_BugSMS: - case GSM_PhonebookUDH: - case GSM_CalendarNoteUDH: //class=1? - SMS->Class=-1; - SMS->Coding=Coding; - break; - case GSM_OpLogo: - case GSM_CallerIDLogo: - case GSM_RingtoneUDH: - case GSM_WAPBookmarkUDH: - case GSM_WAPBookmarkUDHLong: - case GSM_WAPSettingsUDH: - case GSM_ProfileUDH: - SMS->Class=1; - SMS->Coding=GSM_Coding_8bit; - break; - default: - fprintf(stderr,_("Error in makesinglepartsms !\n\n\n")); - } - - current=cur; - - smsudhlength=0; - if (UDHType!=GSM_NoUDH) - smsudhlength=SMS->UDH[0]+1; - - j=0; - switch (SMS->Coding) { - case GSM_Coding_8bit: - j=(GSM_MAX_SMS_8_BIT_LENGTH-smsudhlength); //max=140 - break; - case GSM_Coding_Default: - j=(GSM_MAX_SMS_8_BIT_LENGTH-smsudhlength)*8/7; //max=160 - break; - case GSM_Coding_Unicode: - j=(GSM_MAX_SMS_8_BIT_LENGTH-smsudhlength)/2; //max=70 - break; - } - if (current>j) current=j; - - memcpy(SMS->MessageText,MessageBuffer,current); - SMS->MessageText[current]=0; - SMS->Length=current; - - return current; +/* This function decodes SMS as described in: + - GSM 03.40 version 6.1.0 Release 1997, section 9 +*/ +GSM_Error DecodePDUSMS(unsigned char *message, GSM_SMSMessage *SMS, int MessageLength) +{ + int i, udhlen = 0; + + DecodeSMSHeader(message, SMS); + for (i = 0; i < SMS->UDH_No; i++) { + udhlen += headers[SMS->UDH[i].Type].length; + } + if (SMS->Type == SMS_Delivery_Report) { + SMSStatus(message[22], SMS); + } else { + int size = MessageLength - + 39 - /* Header Length */ + DataOffset[SMS->Type] - /* offset */ + udhlen - /* UDH Length */ + 2; /* checksum */ + DecodeData(message + 39 + DataOffset[SMS->Type] + udhlen, + (unsigned char *)&(SMS->MessageText), + SMS->Length, SMS->DCS, + udhlen, size); + } + + return GE_NONE; } -void GSM_MakeMultiPartSMS2(GSM_MultiSMSMessage *SMS, - unsigned char *MessageBuffer,int MessageLength, GSM_UDH UDHType, GSM_Coding_Type Coding){ - - int i=0,j,pos=0,current=0; - - for (i=0;i<4;i++) { - if (pos==MessageLength) break; - - current=MessageLength-pos; - - pos=pos+GSM_MakeSinglePartSMS2(&SMS->SMS[i],MessageBuffer+pos,current,UDHType,Coding); - } - - for (j=0;jSMS[j].UDH[10]=i; - SMS->SMS[j].UDH[11]=j+1; - break; - case GSM_ConcatenatedMessages: - SMS->SMS[j].UDH[4]=i; - SMS->SMS[j].UDH[5]=j+1; - break; - default: - break; - } - } - - SMS->number=i; +/* This function does simple SMS decoding - no PDU coding */ +GSM_Error DecodeTextSMS(unsigned char *message, GSM_SMSMessage *sms) +{ +#if 0 + int w, tmp, i; + unsigned char output[161]; + + sms->EightBit = false; + w = (7 - off) % 7; + if (w < 0) w = (14 - off) % 14; + sms->Length = message[9 + 11 + offset] - (off * 8 + w) / 7; + offset += off; + w = (7 - off) % 7; + if (w < 0) w = (14 - off) % 14; + tmp = Unpack7BitCharacters(w, length-31-9-offset, sms->Length, message+9+31+offset, output); + dprintf(" 7 bit SMS, body is (length %i): ",sms->Length); + for (i = 0; i < tmp; i++) { + dprintf("%c", DecodeWithDefaultAlphabet(output[i])); + sms->MessageText[i] = DecodeWithDefaultAlphabet(output[i]); + } + dprintf("\n"); +#endif + return GE_NONE; } diff --git a/common/gsm-statemachine.c b/common/gsm-statemachine.c index a65583a..5f68d41 100644 --- a/common/gsm-statemachine.c +++ b/common/gsm-statemachine.c @@ -10,27 +10,55 @@ Released under the terms of the GNU GPL, see file COPYING for more details. + $Log$ + Revision 1.1.1.4 2002/04/03 00:07:57 short + Found in "gnokii-working" directory, some November-patches version + + Revision 1.5 2001/09/09 21:45:49 machek + Cleanups from Ladislav Michl : + + *) do *not* internationalize debug messages + + *) some whitespace fixes, do not use // + + *) break is unneccessary after return + + Revision 1.4 2001/07/27 00:02:20 pkot + Generic AT support for the new structure (Manfred Jonsson) + + Revision 1.3 2001/06/10 11:26:56 machek + Warn if Link.Loop is not defined. + + Revision 1.2 2001/05/07 14:01:51 machek + Warn when phone functions are missing, but do not segfault. + + Revision 1.1 2001/03/21 23:36:04 chris + Added the statemachine + This will break gnokii --identify and --monitor except for 6210/7110 + + */ #include "gsm-common.h" #include "gsm-statemachine.h" +#include "gsm-api.h" GSM_Error SM_Initialise(GSM_Statemachine *state) { - state->CurrentState = Initialised; - state->NumWaitingFor = 0; - state->NumReceived = 0; + state->CurrentState=Initialised; + state->NumWaitingFor=0; + state->NumReceived=0; return GE_NONE; } GSM_Error SM_SendMessage(GSM_Statemachine *state, u16 messagesize, u8 messagetype, void *message) { - if (state->CurrentState != Startup) { - state->LastMsgSize = messagesize; - state->LastMsgType = messagetype; - state->LastMsg = message; - state->CurrentState = MessageSent; + if (state->CurrentState!=Startup) { + state->LastMsgSize=messagesize; + state->LastMsgType=messagetype; + state->LastMsg=message; + state->CurrentState=MessageSent; /* FIXME - clear KeepAlive timer */ return state->Link.SendMessage(messagesize, messagetype, message); @@ -47,7 +75,7 @@ GSM_State SM_Loop(GSM_Statemachine *state, int timeout) loop_timeout.tv_usec = 100000; if (!state->Link.Loop) { - dprintf("No Loop function. Aborting.\n"); + fprintf(stderr, "No Loop function. Aborting.\n"); abort(); } for (i = 0; i < timeout; i++) { @@ -55,16 +83,18 @@ GSM_State SM_Loop(GSM_Statemachine *state, int timeout) } /* FIXME - add calling a KeepAlive function here */ + return state->CurrentState; } void SM_Reset(GSM_Statemachine *state) { /* Don't reset to initialised if we aren't! */ - if (state->CurrentState != Startup) { - state->CurrentState = Initialised; - state->NumWaitingFor = 0; - state->NumReceived = 0; + + if (state->CurrentState!=Startup) { + state->CurrentState=Initialised; + state->NumWaitingFor=0; + state->NumReceived=0; } } @@ -73,30 +103,30 @@ void SM_Reset(GSM_Statemachine *state) void SM_IncomingFunction(GSM_Statemachine *state, u8 messagetype, void *message, u16 messagesize) { int c; - int temp = 1; + int temp=1; GSM_Data emptydata; - GSM_Data *data = &emptydata; - GSM_Error res = GE_INTERNALERROR; - int waitingfor = -1; + GSM_Data *data=&emptydata; + GSM_Error res=GE_INTERNALERROR; + int waitingfor=-1; GSM_DataClear(&emptydata); /* See if we need to pass the function the data struct */ - if (state->CurrentState == WaitingForResponse) - for (c = 0; c < state->NumWaitingFor; c++) - if (state->WaitingFor[c] == messagetype) { - data = state->Data[c]; - waitingfor = c; + if (state->CurrentState==WaitingForResponse) + for (c=0; cNumWaitingFor; c++) + if (state->WaitingFor[c]==messagetype) { + data=state->Data[c]; + waitingfor=c; } /* Pass up the message to the correct phone function, with data if necessary */ - c = 0; + c=0; while (state->Phone.IncomingFunctions[c].Functions) { if (state->Phone.IncomingFunctions[c].MessageType == messagetype) { dprintf("Received message type %02x\n\r", messagetype); - res = state->Phone.IncomingFunctions[c].Functions(messagetype, message, messagesize, data); - temp = 0; + res=state->Phone.IncomingFunctions[c].Functions(messagetype, message, messagesize, data); + temp=0; } c++; } @@ -107,16 +137,17 @@ void SM_IncomingFunction(GSM_Statemachine *state, u8 messagetype, void *message, return; } - if (state->CurrentState == WaitingForResponse) { + if (state->CurrentState==WaitingForResponse) { + /* Check if we were waiting for a response and we received it */ - if (waitingfor != -1) { - state->ResponseError[waitingfor] = res; + if (waitingfor!=-1) { + state->ResponseError[waitingfor]=res; state->NumReceived++; } /* Check if all waitingfors have been received */ - if (state->NumReceived == state->NumWaitingFor) { - state->CurrentState = ResponseReceived; + if (state->NumReceived==state->NumWaitingFor) { + state->CurrentState=ResponseReceived; } } @@ -127,25 +158,25 @@ void SM_IncomingFunction(GSM_Statemachine *state, u8 messagetype, void *message, GSM_Error SM_GetError(GSM_Statemachine *state, unsigned char messagetype) { - int c, d; - GSM_Error error = GE_NOTREADY; + int c,d; + GSM_Error error=GE_NOTREADY; if (state->CurrentState==ResponseReceived) { - for(c = 0; c < state->NumReceived; c++) - if (state->WaitingFor[c] == messagetype) { - error = state->ResponseError[c]; - for(d = c + 1 ;d < state->NumReceived; d++){ - state->ResponseError[d-1] = state->ResponseError[d]; - state->WaitingFor[d-1] = state->WaitingFor[d]; - state->Data[d-1] = state->Data[d]; + for(c=0; c < state->NumReceived; c++) + if (state->WaitingFor[c]==messagetype) { + error=state->ResponseError[c]; + for( d=c+1 ; d < state->NumReceived; d++){ + state->ResponseError[d-1]=state->ResponseError[d]; + state->WaitingFor[d-1]=state->WaitingFor[d]; + state->Data[d-1]=state->Data[d]; } state->NumReceived--; state->NumWaitingFor--; c--; /* For neatness continue in the correct place */ } - if (state->NumReceived == 0) { - state->NumWaitingFor = 0; - state->CurrentState = Initialised; + if (state->NumReceived==0) { + state->NumWaitingFor=0; + state->CurrentState=Initialised; } } @@ -161,15 +192,15 @@ GSM_Error SM_WaitFor(GSM_Statemachine *state, GSM_Data *data, unsigned char mess { /* If we've received a response, we have to call SM_GetError first */ - if ((state->CurrentState == Startup) || (state->CurrentState == ResponseReceived)) + if ((state->CurrentState==Startup) || (state->CurrentState==ResponseReceived)) return GE_NOTREADY; - if (state->NumWaitingFor == SM_MAXWAITINGFOR) return GE_NOTREADY; - state->WaitingFor[state->NumWaitingFor] = messagetype; - state->Data[state->NumWaitingFor] = data; - state->ResponseError[state->NumWaitingFor] = GE_BUSY; + if (state->NumWaitingFor==SM_MAXWAITINGFOR) return GE_NOTREADY; +; + state->WaitingFor[state->NumWaitingFor]=messagetype; + state->Data[state->NumWaitingFor]=data; state->NumWaitingFor++; - state->CurrentState = WaitingForResponse; + state->CurrentState=WaitingForResponse; return GE_NONE; } @@ -185,21 +216,21 @@ GSM_Error SM_Block(GSM_Statemachine *state, GSM_Data *data, int waitfor) GSM_State s; GSM_Error err; - for (retry = 0; retry < 3; retry++) { - timeout = 30; - err = SM_WaitFor(state, data, waitfor); - if (err != GE_NONE) return err; + for (retry=0; retry<3; retry++) { + timeout=30; + err=SM_WaitFor(state,data,waitfor); + if (err!=GE_NONE) return err; do { /* ~3secs timeout */ - s = SM_Loop(state, 1); /* Timeout=100ms */ + s=SM_Loop(state, 1); /* Timeout=100ms */ timeout--; - } while ((timeout > 0) && (s == WaitingForResponse)); + } while ((timeout>0) && (s==WaitingForResponse)); - if (s == ResponseReceived) return SM_GetError(state, waitfor); + if (s==ResponseReceived) return SM_GetError(state, waitfor); dprintf("SM_Block Retry - %d\n\r", retry); SM_Reset(state); - if (retry < 2) SM_SendMessage(state, state->LastMsgSize, state->LastMsgType, state->LastMsg); + if (retry<2) SM_SendMessage(state, state->LastMsgSize, state->LastMsgType, state->LastMsg); } return GE_TIMEOUT; @@ -210,9 +241,13 @@ GSM_Error SM_Block(GSM_Statemachine *state, GSM_Data *data, int waitfor) GSM_Error SM_Functions(GSM_Operation op, GSM_Data *data, GSM_Statemachine *sm) { - if (!sm->Phone.Functions) { - dprintf("Sorry, phone has not yet been converted to new style. Phone.Functions == NULL!\n"); - return GE_INTERNALERROR; - } - return sm->Phone.Functions(op, data, sm); +GSM_Error err; + + if (!sm->Phone.Functions) + err=GE_NOTIMPLEMENTED; + else + err=sm->Phone.Functions(op, data, sm); + if (err==GE_NOTIMPLEMENTED) + err=compat_Phone_Functions(op, data, sm); + return(err); } diff --git a/common/links/Makefile b/common/links/Makefile index 560a695..329d0ed 100644 --- a/common/links/Makefile +++ b/common/links/Makefile @@ -17,11 +17,11 @@ TOPDIR=../.. include $(TOPDIR)/Makefile.global +CFLAGS += $(PTHREAD_CFLAGS) + OBJS = fbus.o \ fbus-phonet.o \ cbus.o \ - atbus.o \ - fbus-3110.o \ utils.o all: LINKS.o diff --git a/common/links/atbus.c b/common/links/atbus.c index 0af3d20..afe7916 100644 --- a/common/links/atbus.c +++ b/common/links/atbus.c @@ -11,11 +11,8 @@ Released under the terms of the GNU GPL, see file COPYING for more details. $Log$ - Revision 1.1.1.1 2001/11/25 21:59:09 short - :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001 - - Revision 1.5 2001/11/19 13:03:18 pkot - nk3110.c cleanup + Revision 1.1.1.2 2002/04/03 00:08:07 short + Found in "gnokii-working" directory, some November-patches version Revision 1.4 2001/09/09 21:45:49 machek Cleanups from Ladislav Michl : @@ -63,19 +60,14 @@ /* FIXME - win32 stuff! */ -/* FIXME - when sending an AT command while another one is still in */ -/* progress, the old command is aborted and the new ignored. */ -/* the result is _one_ error message from the phone. */ - /* Some globals */ -/* FIXME - if we use more than one phone these should be part of */ -/* a statemachine. */ - +static GSM_Link *glink; static GSM_Statemachine *statemachine; static int binlength = 0; static char reply_buf[1024]; static int reply_buf_pos = 0; + static int xwrite(unsigned char *d, int len) { int res; @@ -114,7 +106,7 @@ void ATBUS_RX_StateMachine(unsigned char rx_char) if (reply_buf_pos >= binlength) { if (((reply_buf_pos > 3) && (!strncmp(reply_buf+reply_buf_pos-4, "OK\r\n", 4))) || ((reply_buf_pos > 6) && (!strncmp(reply_buf+reply_buf_pos-7, "ERROR\r\n", 7)))) { - SM_IncomingFunction(statemachine, statemachine->LastMsgType, reply_buf, reply_buf_pos); + SM_IncomingFunction(statemachine, 1, reply_buf, reply_buf_pos); reply_buf_pos = 0; binlength = 0; return; @@ -131,10 +123,10 @@ void ATBUS_RX_StateMachine(unsigned char rx_char) } -bool ATBUS_OpenSerial(int hw_handshake, char *device) +bool ATBUS_OpenSerial(int hw_handshake) { int result; - result = device_open(device, false, false, hw_handshake, GCT_Serial); + result = device_open(glink->PortDevice, false, false, hw_handshake, GCT_Serial); if (!result) { perror(_("Couldn't open ATBUS device")); return (false); @@ -179,14 +171,15 @@ GSM_Error ATBUS_Initialise(GSM_Statemachine *state, int hw_handshake) setvbuf(stderr, NULL, _IONBF, 0); /* 'Copy in' the global structures */ + glink = &(state->Link); statemachine = state; /* Fill in the link functions */ - state->Link.Loop = &ATBUS_Loop; - state->Link.SendMessage = &AT_SendMessage; + glink->Loop = &ATBUS_Loop; + glink->SendMessage = &AT_SendMessage; - if (state->Link.ConnectionType == GCT_Serial) { - if (!ATBUS_OpenSerial(hw_handshake, state->Link.PortDevice)) + if (glink->ConnectionType == GCT_Serial) { + if (!ATBUS_OpenSerial(hw_handshake)) return GE_DEVICEOPENFAILED; } else { fprintf(stderr, "Device not supported by ATBUS"); diff --git a/common/links/atbus.c-REMOVE b/common/links/atbus.c-REMOVE new file mode 100644 index 0000000..e69de29 diff --git a/common/links/fbus-phonet.c b/common/links/fbus-phonet.c index 328fd09..d2f0b8b 100644 --- a/common/links/fbus-phonet.c +++ b/common/links/fbus-phonet.c @@ -17,8 +17,8 @@ The various routines are called PHONET_(whatever). $Log$ - Revision 1.1.1.1 2001/11/25 21:59:09 short - :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001 + Revision 1.1.1.2 2002/04/03 00:08:07 short + Found in "gnokii-working" directory, some November-patches version Revision 1.8 2001/08/20 23:27:37 pkot Add hardware shakehand to the link layer (Manfred Jonsson) @@ -80,9 +80,9 @@ /* Some globals */ -GSM_Link *glink; -GSM_Statemachine *statemachine; -PHONET_IncomingMessage imessage; +static GSM_Link *glink; +static GSM_Statemachine *PHONET_statemachine; +static PHONET_IncomingMessage imessage; /*--------------------------------------------*/ @@ -186,7 +186,7 @@ void PHONET_RX_StateMachine(unsigned char rx_byte) { /* Is that it? */ if (i->BufferCount == i->MessageLength) { - SM_IncomingFunction(statemachine, i->MessageType, i->MessageBuffer, i->MessageLength); + SM_IncomingFunction(PHONET_statemachine, i->MessageType, i->MessageBuffer, i->MessageLength); i->state = FBUS_RX_Sync; } break; @@ -288,7 +288,7 @@ GSM_Error PHONET_Initialise(GSM_Link *newlink, GSM_Statemachine *state) /* 'Copy in' the global structures */ glink = newlink; - statemachine = state; + PHONET_statemachine = state; /* Fill in the link functions */ glink->Loop = &PHONET_Loop; diff --git a/common/links/fbus.c b/common/links/fbus.c index 4b19e5f..7d20039 100644 --- a/common/links/fbus.c +++ b/common/links/fbus.c @@ -17,17 +17,8 @@ The various routines are called FBUS_(whatever). $Log$ - Revision 1.1.1.2 2001/11/27 22:01:16 short - :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Tue Nov 27 22:58 CET 2001 - - Revision 1.14 2001/11/27 12:19:01 pkot - Cleanup, indentation, ANSI complaint preprocesor symbols (Jan Kratochvil, me) - - Revision 1.13 2001/11/17 20:14:15 pkot - Nasty bug with counting message length. Workaround applied. Needs fixing. - - Revision 1.12 2001/11/15 12:04:05 pkot - Faster initialization for 6100 series (don't check for dlr3 cable) + Revision 1.1.1.3 2002/04/03 00:08:07 short + Found in "gnokii-working" directory, some November-patches version Revision 1.11 2001/09/09 21:45:49 machek Cleanups from Ladislav Michl : @@ -107,13 +98,13 @@ #include "links/utils.h" #ifndef WIN32 -# include "device.h" + #include "device.h" #else -# include "win32/winserial.h" -# define device_write(a, b) WriteCommBlock(a, b) -# define device_read(a, b) ReadCommBlock(a, b) -# define sleep(x) Sleep((x) * 1000) -# define usleep(x) Sleep(((x) < 1000) ? 1 : ((x) / 1000)) + #include "win32/winserial.h" + #define device_write(a, b) WriteCommBlock(a, b) + #define device_read(a, b) ReadCommBlock(a, b) + #define sleep(x) Sleep((x) * 1000) + #define usleep(x) Sleep(((x) < 1000) ? 1 : ((x) / 1000)) #endif #define __links_fbus_c @@ -126,7 +117,7 @@ /* Some globals */ static GSM_Link *glink; -static GSM_Statemachine *statemachine; +static GSM_Statemachine *FBUS_statemachine; static FBUS_Link flink; /* FBUS specific stuff, internal to this file */ @@ -166,9 +157,9 @@ void FBUS_RX_StateMachine(unsigned char rx_byte) #if 0 if (isprint(rx_byte)) - dprintf("[%02x%c]", (unsigned char) rx_byte, rx_byte); + fprintf(stderr, "[%02x%c]", (unsigned char) rx_byte, rx_byte); else - dprintf("[%02x ]", (unsigned char) rx_byte); + fprintf(stderr, "[%02x ]", (unsigned char) rx_byte); #endif /* XOR the byte with the current checksum */ @@ -319,11 +310,11 @@ void FBUS_RX_StateMachine(unsigned char rx_byte) m->Malloced = 0; m->MessageBuffer = NULL; } - m->Malloced = frm_num * m->MessageLength; + m->Malloced = frm_num *m->MessageLength; m->MessageBuffer = (char *) malloc(m->Malloced); } else if (m->FramesToGo != frm_num) { - dprintf("Missed a frame in a multiframe message.\n"); + fprintf(stdout, "Missed a frame in a multiframe message.\n"); /* FIXME - we should make sure we don't ack the rest etc */ } @@ -333,16 +324,16 @@ void FBUS_RX_StateMachine(unsigned char rx_byte) } memcpy(m->MessageBuffer + m->MessageLength, i->MessageBuffer, - i->FrameLength - 2);/* - (i->FrameLength % 2)); */ + i->FrameLength - 2 - (i->FrameLength % 2)); - m->MessageLength += i->FrameLength - 2;/* - (i->FrameLength % 2); */ + m->MessageLength += i->FrameLength - 2 - (i->FrameLength % 2); m->FramesToGo--; /* Finally dispatch if ready */ if (m->FramesToGo == 0) { - SM_IncomingFunction(statemachine, i->MessageType, m->MessageBuffer, m->MessageLength); + SM_IncomingFunction(FBUS_statemachine, i->MessageType, m->MessageBuffer, m->MessageLength); free(m->MessageBuffer); m->MessageBuffer = NULL; m->Malloced = 0; @@ -537,15 +528,17 @@ int FBUS_TX_SendAck(u8 message_type, u8 message_seq) /* newlink is actually part of state - but the link code should not anything about state */ /* state is only passed around to allow for muliple state machines (one day...) */ -GSM_Error FBUS_Initialise(GSM_Link *newlink, GSM_Statemachine *state, int type) +GSM_Error FBUS_Initialise(GSM_Link *newlink, GSM_Statemachine *state) { unsigned char init_char = 0x55; unsigned char count; + static int try = 0; - if (type > 2) return GE_DEVICEOPENFAILED; + try++; + if (try > 2) return GE_DEVICEOPENFAILED; /* 'Copy in' the global structures */ glink = newlink; - statemachine = state; + FBUS_statemachine = state; /* Fill in the link functions */ glink->Loop = &FBUS_Loop; @@ -564,7 +557,7 @@ GSM_Error FBUS_Initialise(GSM_Link *newlink, GSM_Statemachine *state, int type) } else { /* ConnectionType == GCT_Serial */ /* FBUS_OpenSerial(0) - try dau-9p * FBUS_OpenSerial(n != 0) - try dlr-3p */ - if (!FBUS_OpenSerial(type)) + if (!FBUS_OpenSerial(2 - try)) return GE_DEVICEOPENFAILED; } diff --git a/common/mbus-2110.c b/common/mbus-2110.c index 09e7208..8fcb02e 100644 --- a/common/mbus-2110.c +++ b/common/mbus-2110.c @@ -11,8 +11,8 @@ Released under the terms of the GNU GPL, see file COPYING for more details. $Log$ - Revision 1.1.1.1 2001/11/25 21:59:04 short - :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001 + Revision 1.1.1.2 2002/04/03 00:07:58 short + Found in "gnokii-working" directory, some November-patches version Revision 1.39 2001/09/14 12:15:28 pkot Cleanups from 0.3.3 (part1) @@ -1163,6 +1163,7 @@ GSM_Functions MB21_Functions = { UNIMPLEMENTED, UNIMPLEMENTED, UNIMPLEMENTED, + UNIMPLEMENTED, SendRLPFrame, UNIMPLEMENTED, EnableDisplayOutput, diff --git a/common/mbus-6160.c b/common/mbus-6160.c index 372bd7d..96e1723 100644 --- a/common/mbus-6160.c +++ b/common/mbus-6160.c @@ -13,8 +13,8 @@ This code contains the main part of the 5160/6160 code. $Log$ - Revision 1.1.1.1 2001/11/25 21:59:05 short - :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001 + Revision 1.1.1.2 2002/04/03 00:07:59 short + Found in "gnokii-working" directory, some November-patches version Revision 1.29 2001/08/20 23:27:37 pkot Add hardware shakehand to the link layer (Manfred Jonsson) @@ -101,7 +101,6 @@ GSM_Functions MB61_Functions = { UNIMPLEMENTED, UNIMPLEMENTED, UNIMPLEMENTED, - UNIMPLEMENTED, MB61_SendRLPFrame, UNIMPLEMENTED, UNIMPLEMENTED, diff --git a/common/mbus-640.c b/common/mbus-640.c index 8dc2171..3219525 100644 --- a/common/mbus-640.c +++ b/common/mbus-640.c @@ -13,8 +13,8 @@ This is the main part of 640 support. $Log$ - Revision 1.1.1.1 2001/11/25 21:59:06 short - :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001 + Revision 1.1.1.2 2002/04/03 00:07:59 short + Found in "gnokii-working" directory, some November-patches version Revision 1.22 2001/06/28 00:28:45 pkot Small docs updates (Pawel Kot) @@ -101,7 +101,6 @@ GSM_Functions MB640_Functions = { MB640_GetBitmap, MB640_SetBitmap, UNIMPLEMENTED, - UNIMPLEMENTED, MB640_Reset, UNIMPLEMENTED, UNIMPLEMENTED, diff --git a/common/misc.c b/common/misc.c index 1adf9c8..bf9887b 100644 --- a/common/misc.c +++ b/common/misc.c @@ -4,152 +4,175 @@ A Linux/Unix toolset and driver for Nokia mobile phones. + Copyright (C) 1999, 2000 Hugh Blemings & Pavel Janík ml. + Released under the terms of the GNU GPL, see file COPYING for more details. -*/ + $Id$ + + $Log$ + Revision 1.1.1.9 2002/04/03 00:07:59 short + Found in "gnokii-working" directory, some November-patches version + + Revision 1.18 2001/09/09 21:45:49 machek + Cleanups from Ladislav Michl : + + *) do *not* internationalize debug messages + + *) some whitespace fixes, do not use // + + *) break is unneccessary after return + + Revision 1.17 2001/08/09 12:34:34 pkot + 3330 and 6250 support - I have no idea if it does work (mygnokii) + + Revision 1.16 2001/03/21 23:36:04 chris + Added the statemachine + This will break gnokii --identify and --monitor except for 6210/7110 + + Revision 1.15 2001/03/06 10:38:52 machek + Dancall models added to the global list. + + Revision 1.14 2001/02/06 13:55:23 pkot + Enabled authentication in 51xx models + + Revision 1.13 2001/02/02 08:09:56 ja + New dialogs for 6210/7110 in xgnokii. Fixed the smsd for new capabilty code. -#include -#include -#include - -#ifndef WIN32 - #include - #include - #include - #include - #include - #include - #include -#endif -#include "misc.h" -#include "gsm-common.h" - -#ifndef HAVE_TIMEOPS - -/* FIXME: I have timersub defined in sys/time.h :-( PJ - FIXME: Jano wants this function too... PJ - -int timersub(struct timeval *a, struct timeval *b, struct timeval *result) { - do { - (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; - (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; - if ((result)->tv_usec < 0) { - --(result)->tv_sec; - (result)->tv_usec += 1000000; - } - } while (0); -} */ -#endif +#include +#include +#include "misc.h" -int GetLine(FILE *File, char *Line, int count) { - char *ptr; +int GetLine(FILE *File, char *Line, int count) +{ + char *ptr; - if (fgets(Line, count, File)) { - ptr=Line+strlen(Line)-1; + if (fgets(Line, count, File)) { + ptr = Line + strlen(Line) - 1; - while ( (*ptr == '\n' || *ptr == '\r') && ptr>=Line) *ptr--='\0'; + while ( (*ptr == '\n' || *ptr == '\r') && ptr>=Line) + *ptr--='\0'; - return strlen(Line); - } else return -1; + return strlen(Line); + } + else + return 0; } -/* - * like atoi, but of a non-null-terminated string of a specified portion +static PhoneModel models[] = { + {NULL, "", 0 }, + {"2711", "?????", PM_SMS }, /* Dancall */ + {"2731", "?????", PM_SMS }, + {"1611", "NHE-5", 0 }, + {"2110i", "NHE-4", PM_SMS }, + {"2148i", "NHK-4", 0 }, + {"3110", "0310" , PM_SMS | PM_DTMF | PM_DATA }, /* NHE-8 */ + {"3210", "NSE-8", PM_SMS | PM_DTMF }, + {"3210", "NSE-9", PM_SMS | PM_DTMF }, + {"3310", "NHM-5", PM_SMS | PM_DTMF }, + {"3330", "NHM-6", PM_SMS | PM_DTMF }, + {"3810", "0305" , PM_SMS | PM_DTMF | PM_DATA }, /* NHE-9 */ + {"5110", "NSE-1", PM_NETMONITOR | PM_KEYBOARD | PM_SMS | PM_DTMF | PM_DATA | PM_SPEEDDIAL | PM_AUTHENTICATION }, + {"5130", "NSK-1", PM_NETMONITOR | PM_KEYBOARD | PM_SMS | PM_DTMF | PM_DATA | PM_SPEEDDIAL | PM_AUTHENTICATION }, + {"5160", "NSW-1", PM_NETMONITOR | PM_KEYBOARD | PM_SMS | PM_DTMF | PM_DATA | PM_SPEEDDIAL | PM_AUTHENTICATION }, + {"5190", "NSB-1", PM_NETMONITOR | PM_KEYBOARD | PM_SMS | PM_DTMF | PM_DATA | PM_SPEEDDIAL | PM_AUTHENTICATION }, + {"6110", "NSE-3", PM_CALLERGROUP | PM_CALENDAR | PM_NETMONITOR | PM_KEYBOARD | PM_SMS | PM_DTMF | PM_DATA | PM_SPEEDDIAL | PM_AUTHENTICATION }, + {"6120", "NSC-3", PM_CALLERGROUP | PM_CALENDAR | PM_NETMONITOR | PM_KEYBOARD | PM_SMS | PM_DTMF | PM_DATA | PM_SPEEDDIAL | PM_AUTHENTICATION }, + {"6130", "NSK-3", PM_CALLERGROUP | PM_CALENDAR | PM_NETMONITOR | PM_KEYBOARD | PM_SMS | PM_DTMF | PM_DATA | PM_SPEEDDIAL | PM_AUTHENTICATION }, + {"6150", "NSM-1", PM_CALLERGROUP | PM_CALENDAR | PM_NETMONITOR | PM_KEYBOARD | PM_SMS | PM_DTMF | PM_DATA | PM_SPEEDDIAL | PM_AUTHENTICATION }, + {"616x", "NSW-3", PM_CALLERGROUP | PM_CALENDAR | PM_NETMONITOR | PM_KEYBOARD | PM_SMS | PM_DTMF | PM_DATA | PM_SPEEDDIAL | PM_AUTHENTICATION }, + {"6185", "NSD-3", PM_CALLERGROUP | PM_CALENDAR | PM_NETMONITOR | PM_KEYBOARD | PM_SMS | PM_DTMF | PM_DATA | PM_SPEEDDIAL | PM_AUTHENTICATION }, + {"6190", "NSB-3", PM_CALLERGROUP | PM_CALENDAR | PM_NETMONITOR | PM_KEYBOARD | PM_SMS | PM_DTMF | PM_DATA | PM_SPEEDDIAL | PM_AUTHENTICATION }, + {"6210", "NPE-3", PM_CALLERGROUP | PM_CALENDAR | PM_EXTPBK }, + {"6250", "NHM-3", PM_CALLERGROUP | PM_CALENDAR | PM_EXTPBK }, + {"7110", "NSE-5", PM_CALLERGROUP | PM_SPEEDDIAL | PM_EXTPBK }, + {"8810", "NSE-6", PM_SMS | PM_DTMF | PM_DATA }, + {"8110i", "0423", PM_SMS | PM_DTMF | PM_DATA }, /* Guess for NHE-6 */ + {"8110", "0423" , PM_SMS | PM_DTMF | PM_DATA }, /* NHE-6BX */ + {"9000i", "RAE-4", 0 }, + {"9110", "RAE-2", 0 }, + {"550", "THF-10", 0 }, + {"540", "THF-11", 0 }, + {"650", "THF-12", 0 }, + {"640", "THF-13", 0 }, +/* "AT" modele, all are prefixed by "AT-" to not to clash with FBUS interface to the same phone! */ -int mem_to_int(const char str[], int len) + {"M20", "AT-M20", PM_SMS }, + {"9110", "AT-RAE-2", PM_SMS }, + {"9210", "AT-Nokia Communicator GSM900/1800", PM_SMS }, + {NULL, NULL, 0 } +}; + +PhoneModel *GetPhoneModel (const char *num) { - char aux[81]; + register int i = 0; + + while (models[i].number != NULL) { + if (strcmp (num, models[i].number) == 0) { + dprintf("Found model\n"); + return (&models[i]); + } + else { + dprintf("comparing %s and %s\n", num, models[i].number); + } + i++; + } + + return (&models[0]); +} - strncpy(aux, str, len); - aux[len]=0; - return( atoi(aux) ); -} +inline char *GetModel (const char *num) +{ + return (GetPhoneModel(num)->model); +} -/* - * make hexdump of Message - */ -#ifdef DEBUG -void hexdump(u16 MessageLength, u8 *MessageBuffer) +#ifndef HAVE_VASPRINTF +/* Adapted from snprintf(3) man page: */ +int gvasprintf(char **destp,const char *fmt,va_list ap) { - - int count; - int n=0; - char string1[80]=""; - char string2[80]=""; - char hex1[10]; - char hex2[10]; - - for (count = 0; count < MessageLength; count ++) - { - n++; - - switch (MessageBuffer[count]) { - case 0x09: - sprintf(hex1,"%02x ",MessageBuffer[count]); - strcpy(hex2,"."); - break; - default: - if (isprint(MessageBuffer[count])) - sprintf(hex1,"%02x%c ",MessageBuffer[count],MessageBuffer[count]); - else - sprintf(hex1,"%02x ",MessageBuffer[count]); - - if (isprint(MessageBuffer[count])) sprintf(hex2,"%c",MessageBuffer[count]); - else strcpy(hex2,"."); - break; - } - - if ( n!=15 && count != MessageLength-1 ) hex1[3]='|'; - - strcat(string1,hex1); - strcat(string2,hex2); - - if ( n==15 || count == MessageLength-1 ) - { - fprintf(stdout,"%-60s%03x %s\n",string1,count+1,string2); - strcpy(string1,""); - strcpy(string2,""); - n=0; - } - }//for count - - if (n!=0) fprintf (stdout,_("\n")); - - fflush(stdout); +int n,size=0x100; +char *p,*pnew; + + if (!(p=malloc(size))) { + *destp=NULL; + return(-1); + } + for (;;) { + /* Try to print in the allocated space. */ + n=gvsprintf(p,size,fmt,ap); + /* If that worked, return the string. */ + if (n>-1 && n-1) /* glibc 2.1 */ + size=n+1; /* precisely what is needed */ + else /* glibc 2.0 */ + size*=2; /* twice the old size */ + if (!(pnew=realloc(p,size))) { + free(p); + *destp=NULL; + return(-1); + } + p=pnew; + } } +#endif + +#ifndef HAVE_ASPRINTF +int gasprintf(char **destp,const char *fmt,...) +{ +va_list ap; +int r; -void txhexdump(u16 MessageLength, u8 *MessageBuffer) -{ - int count; - int n=0; - - for (count = 0; count < MessageLength; count ++) - { - n++; - fprintf(stdout,_("%02x"),MessageBuffer[count]); - switch (MessageBuffer[count]) { - case 0x09: - fprintf(stdout,_(" |")); - break; - default: - if (isprint(MessageBuffer[count])) fprintf(stdout, _("%c|"),MessageBuffer[count]); - else fprintf(stdout,_(" |")); - break; - } - - if (n==18) - { - fprintf (stdout,_("\n")); - n=0; - } - }//for count - - if (n!=0) fprintf (stdout,_("\n")); - - fflush(stdout); + va_start(ap,fmt); + r=gvasprintf(destp,fmt,ap); + va_end(ap); + return(r); } #endif diff --git a/common/phones/Makefile b/common/phones/Makefile index a17632e..2c41a94 100644 --- a/common/phones/Makefile +++ b/common/phones/Makefile @@ -17,17 +17,12 @@ TOPDIR=../.. include $(TOPDIR)/Makefile.global +CFLAGS += $(PTHREAD_CFLAGS) + OBJS = generic.o \ nokia.o \ nk7110.o \ - nk6100.o \ - nk3110.o \ - nk2110.o \ - atgen.o \ - ateric.o \ - atnok.o \ - atsie.o -# dc2711.o + nk2110.o all: PHONES.o diff --git a/common/phones/atgen.c b/common/phones/atgen.c index 436523f..925f2db 100644 --- a/common/phones/atgen.c +++ b/common/phones/atgen.c @@ -13,6 +13,25 @@ This file provides functions specific to generic at command compatible phones. See README for more details on supported mobile phones. + $Log$ + Revision 1.1.1.4 2002/04/03 00:08:08 short + Found in "gnokii-working" directory, some November-patches version + + Revision 1.5 2001/11/08 16:49:19 pkot + Cleanups + + Revision 1.4 2001/08/20 23:36:27 pkot + More cleanup in AT code (Manfred Jonsson) + + Revision 1.3 2001/08/20 23:27:37 pkot + Add hardware shakehand to the link layer (Manfred Jonsson) + + Revision 1.2 2001/08/09 11:51:39 pkot + Generic AT support updates and cleanup (Manfred Jonsson) + + Revision 1.1 2001/07/27 00:02:21 pkot + Generic AT support for the new structure (Manfred Jonsson) + */ #include @@ -24,23 +43,15 @@ #include "gsm-statemachine.h" #include "gsm-encoding.h" #include "phones/generic.h" -#include "phones/atgen.h" -#include "phones/ateric.h" -#include "phones/atsie.h" -#include "phones/atnok.h" #include "links/atbus.h" #include "links/cbus.h" +#define ARRAY_LEN(x) (sizeof((x))/sizeof((x)[0])) + static GSM_Error Initialise(GSM_Data *setupdata, GSM_Statemachine *state); static GSM_Error Functions(GSM_Operation op, GSM_Data *data, GSM_Statemachine *state); static GSM_Error Reply(int messagetype, unsigned char *buffer, int length, GSM_Data *data); -static GSM_Error ReplyIdentify(int messagetype, unsigned char *buffer, int length, GSM_Data *data); -static GSM_Error ReplyGetRFLevel(int messagetype, unsigned char *buffer, int length, GSM_Data *data); -static GSM_Error ReplyGetBattery(int messagetype, unsigned char *buffer, int length, GSM_Data *data); -static GSM_Error ReplyReadPhonebook(int messagetype, unsigned char *buffer, int length, GSM_Data *data); -static GSM_Error ReplyMemoryStatus(int messagetype, unsigned char *buffer, int length, GSM_Data *data); -static GSM_Error ReplyCallDivert(int messagetype, unsigned char *buffer, int length, GSM_Data *data); static GSM_Error AT_Identify(GSM_Data *data, GSM_Statemachine *state); static GSM_Error AT_GetModel(GSM_Data *data, GSM_Statemachine *state); @@ -51,38 +62,45 @@ static GSM_Error AT_GetBattery(GSM_Data *data, GSM_Statemachine *state); static GSM_Error AT_GetRFLevel(GSM_Data *data, GSM_Statemachine *state); static GSM_Error AT_GetMemoryStatus(GSM_Data *data, GSM_Statemachine *state); static GSM_Error AT_ReadPhonebook(GSM_Data *data, GSM_Statemachine *state); -static GSM_Error AT_CallDivert(GSM_Data *data, GSM_Statemachine *state); + +typedef GSM_Error (*AT_FunctionType)(GSM_Data *d, GSM_Statemachine *s); typedef struct { int gop; - AT_SendFunctionType sfunc; - GSM_RecvFunctionType rfunc; + AT_FunctionType func; } AT_FunctionInitType; - -/* Mobile phone information */ -static AT_SendFunctionType AT_Functions[GOP_Max]; -static GSM_IncomingFunctionType IncomingFunctions[GOP_Max]; +static AT_FunctionType AT_Functions[GOP_Max]; static AT_FunctionInitType AT_FunctionInit[] = { - { GOP_Init, NULL, Reply }, - { GOP_GetModel, AT_GetModel, ReplyIdentify }, - { GOP_GetRevision, AT_GetRevision, ReplyIdentify }, - { GOP_GetImei, AT_GetIMEI, ReplyIdentify }, - { GOP_GetManufacturer, AT_GetManufacturer, ReplyIdentify }, - { GOP_Identify, AT_Identify, ReplyIdentify }, - { GOP_GetBatteryLevel, AT_GetBattery, ReplyGetBattery }, - { GOP_GetPowersource, AT_GetBattery, ReplyGetBattery }, - { GOP_GetRFLevel, AT_GetRFLevel, ReplyGetRFLevel }, - { GOP_GetMemoryStatus, AT_GetMemoryStatus, ReplyMemoryStatus }, - { GOP_ReadPhonebook, AT_ReadPhonebook, ReplyReadPhonebook }, - { GOP_CallDivert, AT_CallDivert, ReplyCallDivert } + { GOP_GetModel, AT_GetModel }, + { GOP_GetRevision, AT_GetRevision }, + { GOP_GetImei, AT_GetIMEI }, + { GOP_GetManufacturer, AT_GetManufacturer }, + { GOP_Identify, AT_Identify }, + { GOP_GetBatteryLevel, AT_GetBattery }, + { GOP_GetPowersource, AT_GetBattery }, + { GOP_GetRFLevel, AT_GetRFLevel }, + { GOP_GetMemoryStatus, AT_GetMemoryStatus }, + { GOP_ReadPhonebook, AT_ReadPhonebook }, }; +char *skipcrlf(char *str); +char *findcrlf(char *str, int test); + + #define REPLY_SIMPLETEXT(l1, l2, c, t) \ if ((0 == strcmp(l1, c)) && (NULL != t)) strcpy(t, l2) +/* Mobile phone information */ + +static GSM_IncomingFunctionType IncomingFunctions[] = { + { 1, Reply }, + { 0, NULL } +}; + + GSM_Phone phone_at = { IncomingFunctions, PGEN_IncomingDefault, @@ -127,70 +145,29 @@ static char *memorynames[] = { bool ATGEN_LinkOK = true; -GSM_RecvFunctionType AT_InsertRecvFunction(int type, GSM_RecvFunctionType func) -{ - static int pos = 0; - int i; - GSM_RecvFunctionType oldfunc; - - if (type >= GOP_Max) { - return (GSM_RecvFunctionType) -1; - } - if (pos == 0) { - IncomingFunctions[pos].MessageType = type; - IncomingFunctions[pos].Functions = func; - pos++; - return NULL; - } - for (i=0; i < pos; i++) { - if (IncomingFunctions[i].MessageType == type) { - oldfunc = IncomingFunctions[i].Functions; - IncomingFunctions[i].Functions = func; - return oldfunc; - } - } - if (pos < GOP_Max-1) { - IncomingFunctions[pos].MessageType = type; - IncomingFunctions[pos].Functions = func; - pos++; - } - return NULL; -} - - -AT_SendFunctionType AT_InsertSendFunction(int type, AT_SendFunctionType func) -{ - AT_SendFunctionType f; - - f = AT_Functions[type]; - AT_Functions[type] = func; - return f; -} - - static GSM_Error SetEcho(GSM_Data *data, GSM_Statemachine *state) { char req[128]; sprintf(req, "ATE1\r\n"); - if (SM_SendMessage(state, 6, GOP_Init, req) != GE_NONE) return GE_NOTREADY; - return SM_Block(state, data, GOP_Init); + if (SM_SendMessage(state, 6, 1, req) != GE_NONE) return GE_NOTREADY; + return SM_Block(state, data, 1); } -GSM_Error AT_SetMemoryType(GSM_MemoryType mt, GSM_Statemachine *state) +static GSM_Error SetMemoryType(GSM_MemoryType mt, GSM_Statemachine *state) { char req[128]; GSM_Error ret = GE_NONE; GSM_Data data; if (mt != memorytype) { - sprintf(req, "AT+CPBS=\"%s\"\r\n", memorynames[mt]); - ret = SM_SendMessage(state, 14, GOP_Init, req); + sprintf(req, "AT+CPBS=%s\r\n", memorynames[mt]); + ret = SM_SendMessage(state, 12, 1, req); if (ret != GE_NONE) return GE_NOTREADY; GSM_DataClear(&data); - ret = SM_Block(state, &data, GOP_Init); + ret = SM_Block(state, &data, 1); if (ret == GE_NONE) memorytype = mt; } @@ -206,11 +183,11 @@ static GSM_Error SetCharset(GSM_Statemachine *state) if (atcharset == 0) { sprintf(req, "AT+CSCS=\"GSM\"\r\n"); - ret = SM_SendMessage(state, 15, GOP_Init, req); + ret = SM_SendMessage(state, 15, 1, req); if (ret != GE_NONE) return GE_NOTREADY; GSM_DataClear(&data); - ret = SM_Block(state, &data, GOP_Init); + ret = SM_Block(state, &data, 1); if (ret == GE_NONE) atcharset = 1; } @@ -237,9 +214,8 @@ static GSM_Error AT_GetModel(GSM_Data *data, GSM_Statemachine *state) char req[128]; sprintf(req, "AT+CGMM\r\n"); - if (SM_SendMessage(state, 9, GOP_Identify, req) != GE_NONE) - return GE_NOTREADY; - return SM_Block(state, data, GOP_Identify); + if (SM_SendMessage(state, 9, 1, req) != GE_NONE) return GE_NOTREADY; + return SM_Block(state, data, 1); } @@ -248,9 +224,8 @@ static GSM_Error AT_GetManufacturer(GSM_Data *data, GSM_Statemachine *state) char req[128]; sprintf(req, "AT+CGMI\r\n"); - if (SM_SendMessage(state, 9, GOP_Identify, req) != GE_NONE) - return GE_NOTREADY; - return SM_Block(state, data, GOP_Identify); + if (SM_SendMessage(state, 9, 1, req) != GE_NONE) return GE_NOTREADY; + return SM_Block(state, data, 1); } @@ -259,9 +234,8 @@ static GSM_Error AT_GetRevision(GSM_Data *data, GSM_Statemachine *state) char req[128]; sprintf(req, "AT+CGMR\r\n"); - if (SM_SendMessage(state, 9, GOP_Identify, req) != GE_NONE) - return GE_NOTREADY; - return SM_Block(state, data, GOP_Identify); + if (SM_SendMessage(state, 9, 1, req) != GE_NONE) return GE_NOTREADY; + return SM_Block(state, data, 1); } @@ -270,9 +244,8 @@ static GSM_Error AT_GetIMEI(GSM_Data *data, GSM_Statemachine *state) char req[128]; sprintf(req, "AT+CGSN\r\n"); - if (SM_SendMessage(state, 9, GOP_Identify, req) != GE_NONE) - return GE_NOTREADY; - return SM_Block(state, data, GOP_Identify); + if (SM_SendMessage(state, 9, 1, req) != GE_NONE) return GE_NOTREADY; + return SM_Block(state, data, 1); } @@ -283,9 +256,8 @@ static GSM_Error AT_GetBattery(GSM_Data *data, GSM_Statemachine *state) char req[128]; sprintf(req, "AT+CBC\r\n"); - if (SM_SendMessage(state, 8, GOP_GetBatteryLevel, req) != GE_NONE) - return GE_NOTREADY; - return SM_Block(state, data, GOP_GetBatteryLevel); + if (SM_SendMessage(state, 8, 1, req) != GE_NONE) return GE_NOTREADY; + return SM_Block(state, data, 1); } @@ -294,9 +266,8 @@ static GSM_Error AT_GetRFLevel(GSM_Data *data, GSM_Statemachine *state) char req[128]; sprintf(req, "AT+CSQ\r\n"); - if (SM_SendMessage(state, 8, GOP_GetRFLevel, req) != GE_NONE) - return GE_NOTREADY; - return SM_Block(state, data, GOP_GetRFLevel); + if (SM_SendMessage(state, 8, 1, req) != GE_NONE) return GE_NOTREADY; + return SM_Block(state, data, 1); } @@ -305,19 +276,13 @@ static GSM_Error AT_GetMemoryStatus(GSM_Data *data, GSM_Statemachine *state) char req[128]; GSM_Error ret; - ret = AT_SetMemoryType(data->MemoryStatus->MemoryType, state); + ret = SetMemoryType(data->MemoryStatus->MemoryType, state); if (ret != GE_NONE) return ret; sprintf(req, "AT+CPBS?\r\n"); - if (SM_SendMessage(state, 10, GOP_GetMemoryStatus, req) != GE_NONE) - return GE_NOTREADY; - ret = SM_Block(state, data, GOP_GetMemoryStatus); - if (ret != GE_UNKNOWN) - return ret; - sprintf(req, "AT+CPBR=?\r\n"); - if (SM_SendMessage(state, 11, GOP_GetMemoryStatus, req) != GE_NONE) + if (SM_SendMessage(state, 10, 1, req) != GE_NONE) return GE_NOTREADY; - ret = SM_Block(state, data, GOP_GetMemoryStatus); + ret = SM_Block(state, data, 1); return ret; } @@ -330,59 +295,17 @@ static GSM_Error AT_ReadPhonebook(GSM_Data *data, GSM_Statemachine *state) ret = SetCharset(state); if (ret != GE_NONE) return ret; - ret = AT_SetMemoryType(data->PhonebookEntry->MemoryType, state); + ret = SetMemoryType(data->PhonebookEntry->MemoryType, state); if (ret != GE_NONE) return ret; sprintf(req, "AT+CPBR=%d\r\n", data->PhonebookEntry->Location); - if (SM_SendMessage(state, strlen(req), GOP_ReadPhonebook, req) != GE_NONE) + if (SM_SendMessage(state, strlen(req), 1, req) != GE_NONE) return GE_NOTREADY; - ret = SM_Block(state, data, GOP_ReadPhonebook); + ret = SM_Block(state, data, 1); return ret; } -static GSM_Error AT_CallDivert(GSM_Data *data, GSM_Statemachine *state) -{ - char req[64]; - - if (!data->CallDivert) return GE_UNKNOWN; - - sprintf(req, "AT+CCFC="); - - switch (data->CallDivert->DType) { - case GSM_CDV_AllTypes: - strcat(req, "4"); - break; - case GSM_CDV_Busy: - strcat(req, "1"); - break; - case GSM_CDV_NoAnswer: - strcat(req, "2"); - break; - case GSM_CDV_OutOfReach: - strcat(req, "3"); - break; - default: - dprintf("3. %d\n", data->CallDivert->DType); - return GE_NOTIMPLEMENTED; - } - if (data->CallDivert->Operation == GSM_CDV_Register) - sprintf(req, "%s,%d,\"%s\",%d,,,%d", req, - data->CallDivert->Operation, - data->CallDivert->Number.number, - data->CallDivert->Number.type, - data->CallDivert->Timeout); - else - sprintf(req, "%s,%d", req, data->CallDivert->Operation); - - strcat(req, "\r\n"); - - dprintf("%s", req); - if (SM_SendMessage(state, strlen(req), GOP_CallDivert, req) != GE_NONE) - return GE_NOTREADY; - return SM_WaitFor(state, data, GOP_CallDivert); -} - static GSM_Error Functions(GSM_Operation op, GSM_Data *data, GSM_Statemachine *state) { if (op == GOP_Init) @@ -394,23 +317,15 @@ static GSM_Error Functions(GSM_Operation op, GSM_Data *data, GSM_Statemachine *s } -static GSM_Error ReplyReadPhonebook(int messagetype, unsigned char *buffer, int length, GSM_Data *data) +static GSM_Error ReplyReadPhonebook(GSM_Data *data, char *line, int error, int len) { - AT_LineBuffer buf; char *pos, *endpos; int l; - buf.line1 = buffer; - buf.length= length; - splitlines(&buf); - if (buf.line1 == NULL) + if (error) { return GE_INVALIDPHBOOKLOCATION; - - if (strncmp(buffer, "AT+CPBR", 7)) { - return GE_NONE; /*FIXME*/ - } - - if (!strncmp(buf.line2, "OK", 2)) { + } + if (!strncmp(line, "OK", 2)) { if (data->PhonebookEntry) { *(data->PhonebookEntry->Number) = '\0'; *(data->PhonebookEntry->Name) = '\0'; @@ -422,7 +337,7 @@ static GSM_Error ReplyReadPhonebook(int messagetype, unsigned char *buffer, int if (data->PhonebookEntry) { data->PhonebookEntry->Group = 0; data->PhonebookEntry->SubEntriesCount = 0; - pos = strchr(buf.line2, '\"'); + pos = strchr(line, '\"'); endpos = NULL; if (pos) endpos = strchr(++pos, '\"'); @@ -434,13 +349,10 @@ static GSM_Error ReplyReadPhonebook(int messagetype, unsigned char *buffer, int if (endpos) pos = strchr(++endpos, '\"'); endpos = NULL; - if (pos) { - pos++; - l = pos - (char *)buffer; - endpos = memchr(pos, '\"', length - l); - } + if (pos) + endpos = memchr(++pos, '\"', len); if (endpos) { - l = endpos - pos; + l= endpos - pos; DecodeAscii(data->PhonebookEntry->Name, pos, l); *(data->PhonebookEntry->Name + l) = '\0'; } @@ -449,88 +361,57 @@ static GSM_Error ReplyReadPhonebook(int messagetype, unsigned char *buffer, int } -static GSM_Error ReplyMemoryStatus(int messagetype, unsigned char *buffer, int length, GSM_Data *data) +static GSM_Error ReplyMemoryStatus(GSM_Data *data, char *line, int error) { - AT_LineBuffer buf; char *pos; - buf.line1 = buffer; - buf.length= length; - splitlines(&buf); - if (buf.line1 == NULL) + if (error) return GE_INVALIDMEMORYTYPE; - if (data->MemoryStatus) { - if (strstr(buf.line2,"+CPBS")) { - pos = strchr(buf.line2, ','); - if (pos) { - data->MemoryStatus->Used = atoi(++pos); - } else { - data->MemoryStatus->Used = 100; - data->MemoryStatus->Free = 0; - return GE_UNKNOWN; - } - pos = strchr(pos, ','); - if (pos) { - data->MemoryStatus->Free = atoi(++pos) - data->MemoryStatus->Used; - } else { - return GE_UNKNOWN; - } - } + pos = strchr(line, ','); + if (pos) + data->MemoryStatus->Used = atoi(++pos); + pos = strchr(pos, ','); + if (pos) + data->MemoryStatus->Free = atoi(++pos) - data->MemoryStatus->Used; } return GE_NONE; } -static GSM_Error ReplyGetBattery(int messagetype, unsigned char *buffer, int length, GSM_Data *data) +static GSM_Error ReplyBattery(GSM_Data *data, char *line, int error) { - AT_LineBuffer buf; char *pos; - buf.line1 = buffer; - buf.length= length; - splitlines(&buf); - if ((buf.line1 == NULL) || (buf.line2 == NULL)) - return GE_NONE; - - if (!strncmp(buffer, "AT+CBC", 6)) { - if (data->BatteryLevel) { - *(data->BatteryUnits) = GBU_Percentage; - pos = strchr(buf.line2, ','); - if (pos) { - pos++; - *(data->BatteryLevel) = atoi(pos); - } else { - *(data->BatteryLevel) = 1; - } - } - if (data->PowerSource) { - *(data->PowerSource) = 0; - if (*buf.line2 == '1') *(data->PowerSource) = GPS_ACDC; - if (*buf.line2 == '0') *(data->PowerSource) = GPS_BATTERY; + if (data->BatteryLevel) { + *(data->BatteryUnits) = GBU_Percentage; + pos = strchr(line, ','); + if (pos) { + pos++; + *(data->BatteryLevel) = atoi(pos); + } else { + *(data->BatteryLevel) = 1; } } + if (data->PowerSource) { + *(data->PowerSource) = 0; + if (*line == '1') *(data->PowerSource) = GPS_ACDC; + if (*line == '0') *(data->PowerSource) = GPS_BATTERY; + } return GE_NONE; } -static GSM_Error ReplyGetRFLevel(int messagetype, unsigned char *buffer, int length, GSM_Data *data) +static GSM_Error ReplyRFLevel(GSM_Data *data, char *line, int error) { - AT_LineBuffer buf; - char *pos1, *pos2; - - buf.line1 = buffer; - buf.length= length; - splitlines(&buf); - if (buf.line1 == NULL) - return GE_NONE; + char *pos, *buf; - if ((!strncmp(buffer, "AT+CSQ", 6)) && (data->RFUnits)) { + if (data->RFUnits) { *(data->RFUnits) = GRF_CSQ; - pos1 = buf.line2 + 6; - pos2 = strchr(buf.line2, ','); - if (pos1 < pos2) { - *(data->RFLevel) = atoi(pos1); + pos = line + 6; + buf = strchr(line, ','); + if (pos < buf) { + *(data->RFLevel) = atoi(pos); } else { *(data->RFLevel) = 1; } @@ -539,45 +420,46 @@ static GSM_Error ReplyGetRFLevel(int messagetype, unsigned char *buffer, int len } -static GSM_Error ReplyIdentify(int messagetype, unsigned char *buffer, int length, GSM_Data *data) -{ - AT_LineBuffer buf; - - buf.line1 = buffer; - buf.length= length; - splitlines(&buf); - if (buf.line1 == NULL) - return GE_NONE; /* Fixme */ - if (!strncmp(buffer, "AT+CG", 5)) { - REPLY_SIMPLETEXT(buffer+5, buf.line2, "SN", data->Imei); - REPLY_SIMPLETEXT(buffer+5, buf.line2, "MM", data->Model); - REPLY_SIMPLETEXT(buffer+5, buf.line2, "MI", data->Manufacturer); - REPLY_SIMPLETEXT(buffer+5, buf.line2, "MR", data->Revision); - } - return GE_NONE; -} - -static GSM_Error ReplyCallDivert(int messagetype, unsigned char *buffer, int length, GSM_Data *data) -{ - int i; - for (i = 0; i < length; i++) { - dprintf("%02x ", buffer[i]); - } - dprintf("\n"); - return GE_NONE; -} - static GSM_Error Reply(int messagetype, unsigned char *buffer, int length, GSM_Data *data) { - AT_LineBuffer buf; + char *line2, *line3, *pos; int error = 0; - buf.line1 = buffer; - buf.length= length; - splitlines(&buf); - if (buf.line1 == NULL) + if ((length > 7) && (!strncmp(buffer+length-7, "ERROR", 5))) error = 1; + pos = findcrlf(buffer, 0); + if (pos) { + *pos = 0; + line2 = skipcrlf(++pos); + } else { + line2 = buffer; + } + pos = findcrlf(line2, 1); + if (pos) { + *pos = 0; + line3 = skipcrlf(++pos); + } else { + line3 = line2; + } + if (!strncmp(buffer, "AT+C", 4)) { + if (*(buffer+4) =='G') { + REPLY_SIMPLETEXT(buffer+5, line2, "SN", data->Imei); + REPLY_SIMPLETEXT(buffer+5, line2, "MM", data->Model); + REPLY_SIMPLETEXT(buffer+5, line2, "MI", data->Manufacturer); + REPLY_SIMPLETEXT(buffer+5, line2, "MR", data->Revision); + } else if (!strncmp(buffer+4, "SQ", 2)) { + ReplyRFLevel(data, line2, error); + } else if (!strncmp(buffer+4, "BC", 2)) { + ReplyBattery(data, line2, error); + } else if (!strncmp(buffer+4, "PB", 2)) { + if (*(buffer+6) == 'S') { + ReplyMemoryStatus(data, line2, error); + } else if (*(buffer+6) == 'R') { + ReplyReadPhonebook(data, line2, error, length); + } + } + } return GE_NONE; } @@ -595,15 +477,10 @@ static GSM_Error Initialise(GSM_Data *setupdata, GSM_Statemachine *state) /* Copy in the phone info */ memcpy(&(state->Phone), &phone_at, sizeof(GSM_Phone)); - for (i=0; iLink.ConnectionType) { case GCT_Serial: @@ -627,46 +504,21 @@ static GSM_Error Initialise(GSM_Data *setupdata, GSM_Statemachine *state) ret = state->Phone.Functions(GOP_GetModel, &data, state); if (ret != GE_NONE) return ret; GSM_DataClear(&data); - data.Manufacturer = manufacturer; + data.Model = manufacturer; ret = state->Phone.Functions(GOP_GetManufacturer, &data, state); if (ret != GE_NONE) return ret; - if (!strncasecmp(manufacturer, "ericsson", 8)) - AT_InitEricsson(state, model, setupdata->Model); - if (!strncasecmp(manufacturer, "siemens", 7)) - AT_InitSiemens(state, model, setupdata->Model); - if (!strncasecmp(manufacturer, "nokia", 5)) - AT_InitNokia(state, model, setupdata->Model); + /* + if (!strcasecmp(manufacturer, "siemens")) + AT_InitSiemens(state, model, setupdata->Model, AT_Functions); + if (!strcasecmp(manufacturer, "ericsson")) + AT_InitEricsson(state, model, setupdata->Model, AT_Functions); + */ return GE_NONE; } -void splitlines(AT_LineBuffer *buf) -{ - char *pos; - - if ((buf->length > 7) && (!strncmp(buf->line1+buf->length-7, "ERROR", 5))) { - buf->line1 = NULL; - return; - } - pos = findcrlf(buf->line1, 0, buf->length); - if (pos) { - *pos = 0; - buf->line2 = skipcrlf(++pos); - } else { - buf->line2 = buf->line1; - } - pos = findcrlf(buf->line2, 1, buf->length); - if (pos) { - *pos = 0; - buf->line3 = skipcrlf(++pos); - } else { - buf->line3 = buf->line2; - } -} - - /* * increments the argument until a char unequal to * or is found. returns the new position. @@ -686,19 +538,18 @@ char *skipcrlf(char *str) * searches for or and returns the first * occurrence. if test is set, the gsm char @ which * is 0x00 is not considered as end of string. - * return NULL if no or was found in the - * range of max bytes. + * return NULL if test is not set and no or + * was found. + * TODO should ask for maximum length. */ -char *findcrlf(char *str, int test, int max) +char *findcrlf(char *str, int test) { if (str == NULL) return str; - while ((*str != '\n') && (*str != '\r') && ((*str != '\0') || test) && (max > 0)) { + while ((*str != '\n') && (*str != '\r') && ((*str != '\0') || test)) str++; - max--; - } - if ((*str == '\0') || ((max == 0) && (*str != '\n') && (*str != '\r'))) + if (*str == '\0') return NULL; return str; } diff --git a/common/phones/atgen.c-REMOVE b/common/phones/atgen.c-REMOVE new file mode 100644 index 0000000..e69de29 diff --git a/common/phones/dc2711.c b/common/phones/dc2711.c index 7e86bd7..22f7d16 100644 --- a/common/phones/dc2711.c +++ b/common/phones/dc2711.c @@ -14,8 +14,8 @@ See README for more details on supported mobile phones. $Log$ - Revision 1.1.1.1 2001/11/25 21:59:11 short - :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001 + Revision 1.1.1.2 2002/04/03 00:08:08 short + Found in "gnokii-working" directory, some November-patches version Revision 1.5 2001/07/27 00:02:21 pkot Generic AT support for the new structure (Manfred Jonsson) @@ -257,7 +257,6 @@ GSM_Functions D2711_Functions = { UNIMPLEMENTED, /* GetBitmap */ UNIMPLEMENTED, /* SetBitmap */ UNIMPLEMENTED, /* SetRingtone */ - UNIMPLEMENTED, /* SendRingtone */ UNIMPLEMENTED, /* Reset */ UNIMPLEMENTED, /* GetProfile */ UNIMPLEMENTED, /* SetProfile */ diff --git a/common/phones/dc2711.c-REMOVE b/common/phones/dc2711.c-REMOVE new file mode 100644 index 0000000..e69de29 diff --git a/common/phones/nk2110.c b/common/phones/nk2110.c index 15e528a..bcf6e1b 100644 --- a/common/phones/nk2110.c +++ b/common/phones/nk2110.c @@ -10,6 +10,55 @@ Released under the terms of the GNU GPL, see file COPYING for more details. + $Log$ + Revision 1.1.1.3 2002/04/03 00:08:09 short + Found in "gnokii-working" directory, some November-patches version + + Revision 1.12 2001/10/21 22:23:56 machek + Use symbolic constants instead of numbers + + At least detect when we get other message than we asked for + + Provide option to passively wait for sms-es + + Revision 1.11 2001/08/20 23:27:37 pkot + Add hardware shakehand to the link layer (Manfred Jonsson) + + Revision 1.10 2001/07/17 22:46:27 pkot + Removed warning when compiling with --enable-debug (Pawel Kot) + + Revision 1.9 2001/06/17 16:42:59 machek + Created another level of error message (ddprintf), fixed code not to + exit on error condition. Now it is actualy usable on my Philips Velo. + + Revision 1.8 2001/06/16 10:00:41 machek + Implement timeouts on waiting for SMS. + + Revision 1.7 2001/06/10 23:49:49 pkot + Small fixes to hide compilation warnings and allow gnokii.c to compile + + Revision 1.6 2001/06/10 11:28:00 machek + Convert GetSMS/DeleteSMS to new structure. + + Revision 1.5 2001/06/06 09:05:56 machek + Convert Grab/Release display to new structure. + + Revision 1.4 2001/05/09 20:18:46 machek + Cleaned up code a bit. Made it use device_() interface. Reworked delay + system; now it is 4 times faster. 5 times faster if you hold * key on + phone (?!). + + Revision 1.3 2001/05/07 14:13:03 machek + nokia-2110 module converted to suit new API better. --identify now works. + + Revision 1.2 2001/04/27 16:00:01 machek + Better error messages. + + Revision 1.1 2001/04/25 12:54:47 machek + Partly converted nokia 2110 to "new" form, and moved it to phone + directory. + + Notice that this code was (partly) converted to "new" structure, but it does not have code for bus separated. I think that separating it would be waste of effort... --pavel @@ -38,7 +87,6 @@ #include "mbus-2110.h" #include "phones/nokia.h" #include "device.h" -#include "gsm-sms.h" #include #include @@ -309,7 +357,8 @@ SMS(GSM_SMSMessage *message, int command) PacketOK = false; pkt[1] = command; pkt[2] = 1; /* == LM_SMS_MEM_TYPE_DEFAULT or LM_SMS_MEM_TYPE_SIM or LM_SMS_MEM_TYPE_ME */ - pkt[3] = message->Number; + pkt[3] = message->Location; + message->MessageNumber = message->Location; SendCommand(pkt, LM_SMS_COMMAND, sizeof(pkt)); msleep_poll(300); /* We have to keep acknowledning phone's data */ @@ -321,8 +370,8 @@ SMS(GSM_SMSMessage *message, int command) eprintf("Something is very wrong with SMS\n"); return GE_BUSY; /* FIXME */ } - if ((SMSData[2]) && (SMSData[2] != message->Number)) { - eprintf("Wanted message @%d, got message at @%d!\n", message->Number, SMSData[2]); + if ((SMSData[2]) && (SMSData[2] != message->Location)) { + eprintf("Wanted message @%d, got message at @%d!\n", message->Location, SMSData[2]); return GE_BUSY; } return (GE_NONE); @@ -332,23 +381,28 @@ SMS(GSM_SMSMessage *message, int command) static GSM_Error DecodeIncomingSMS(GSM_SMSMessage *m) { - GSM_Error error; - int len, i; - - error = GE_NONE; -/* Should be moved to gsm-sms.c */ - + int i, len; ddprintf("Status: " ); switch (SMSData[3]) { - case 7: m->Type = SMS_Submit; /* m->Status = GSS_NOTSENTREAD; */ ddprintf("not sent\n"); break; - case 5: m->Type = SMS_Submit; /* m->Status = GSS_SENTREAD; */ ddprintf("sent\n"); break; - case 3: m->Type = SMS_Deliver; /* m->Status = GSS_NOTSENTREAD; */ ddprintf("not read\n"); break; - case 1: m->Type = SMS_Deliver; /* m->Status = GSS_SENTREAD; */ ddprintf("read\n"); break; + case 7: m->Type = GST_MO; m->Status = GSS_NOTSENTREAD; ddprintf("not sent\n"); break; + case 5: m->Type = GST_MO; m->Status = GSS_SENTREAD; ddprintf("sent\n"); break; + case 3: m->Type = GST_MT; m->Status = GSS_NOTSENTREAD; ddprintf("not read\n"); break; + case 1: m->Type = GST_MT; m->Status = GSS_SENTREAD; ddprintf("read\n"); break; } - UnpackDateTime(SMSData+7, &m->Time); + /* Date is at SMSData[7]; this code is copied from fbus-6110.c*/ + { + int offset = -32 + 7; + m->Time.Year=10*(SMSData[32+offset]&0x0f)+(SMSData[32+offset]>>4); + m->Time.Month=10*(SMSData[33+offset]&0x0f)+(SMSData[33+offset]>>4); + m->Time.Day=10*(SMSData[34+offset]&0x0f)+(SMSData[34+offset]>>4); + m->Time.Hour=10*(SMSData[35+offset]&0x0f)+(SMSData[35+offset]>>4); + m->Time.Minute=10*(SMSData[36+offset]&0x0f)+(SMSData[36+offset]>>4); + m->Time.Second=10*(SMSData[37+offset]&0x0f)+(SMSData[37+offset]>>4); + m->Time.Timezone=(10*(SMSData[38+offset]&0x07)+(SMSData[38+offset]>>4))/4; + } - m->Length = len = SMSData[14]; + len = SMSData[14]; ddprintf("%d bytes: ", len ); for (i = 0; i160) eprintf("Magic not allowed\n"); - memset(m->MessageText, 0, 161); + memset(m->MessageText, 0, sizeof(m->MessageText)); strncpy(m->MessageText, (void *) &SMSData[15], len); - + m->MessageTextLength = len; /* we currently do not support UDH & 8-bit so it is simple */ + m->EightBit = false; ddprintf("Text is %s\n", m->MessageText); - /* - Originator address is at 15+i, - followed by message center addres (?) - */ + /* Originator address is at 15+i, + followed by message center addres (?) */ { char *s = (char *) &SMSData[15+i]; /* We discard volatile. Make compiler quiet. */ - strcpy(m->RemoteNumber.number, s); + strcpy(m->Sender, s); s+=strlen(s)+1; strcpy(m->MessageCenter.Number, s); ddprintf("Sender = %s, MessageCenter = %s\n", m->Sender, m->MessageCenter.Name); @@ -375,15 +428,14 @@ DecodeIncomingSMS(GSM_SMSMessage *m) m->MessageCenter.No = 0; strcpy(m->MessageCenter.Name, "(unknown)"); - m->UDH_No = 0; - - return error; + m->UDHPresent = false; + return GE_NONE; } static GSM_Error GetSMSMessage(GSM_SMSMessage *m) { - if (m->Number > 10) + if (m->Location > 10) return GE_INVALIDSMSLOCATION; if (SMS(m, LM_SMS_READ_STORED_DATA) != GE_NONE) @@ -405,7 +457,7 @@ GetSMSMessage(GSM_SMSMessage *m) static GSM_Error SendSMSMessage(GSM_SMSMessage *m) { - if (m->Number > 10) + if (m->Location > 10) return GE_INVALIDSMSLOCATION; if (SMSData[0] != 0x0b) { @@ -609,7 +661,7 @@ HandlePacket(void) return ((PacketData[4] & 0xf) != 0); /* Make all but last fragment "secret" */ - default: dprintf("Unknown response %dx\n", PacketData[3]); + default: dprintf("Unknown response %x\n", (unsigned int)PacketData[3]); return 0; } } @@ -632,7 +684,7 @@ SigHandler(int status) // dprintf("(%x)", b, Index); if (!Index && b != MYID && b != 0xf8 && b != 0x00) /* MYID is code of computer */ { /* something strange goes from phone. Just ignore it */ - ddprintf("Get [%02X %c]\n", b, b >= 0x20 ? b : '.' ); + ddprintf( "Get [%02X %c]\n", b, b >= 0x20 ? b : '.' ); continue; } else { pkt[Index++] = b; @@ -643,7 +695,7 @@ SigHandler(int status) } if(Index >= Length) { if((pkt[0] == MYID || pkt[0]==0xf8) && pkt[1] == 0x00) /* packet from phone */ { - ddprintf("Phone: "); + ddprintf( _("Phone: ") ); for( j = 0; j < Length; j++ ) { b = pkt[j]; ddprintf( "[%02X %c]", b, b >= 0x20 ? b : '.' ); @@ -958,7 +1010,7 @@ static GSM_Error SMS_Reserve(GSM_Statemachine *sm) eprintf("Bad reply trying to reserve SMS-es\n"); if (SMSData[0] != LM_SMS_PP_RESERVE_COMPLETE) eprintf("Not okay trying to reserve SMS-es (%d)\n", SMSData[0]); - return GE_NONE; + } static GSM_Error SMS_Slave(GSM_Statemachine *sm) @@ -985,14 +1037,12 @@ static GSM_Error SMS_Slave(GSM_Statemachine *sm) eprintf("New message indicated @%d\n", SMSData[2]); msleep_poll(200); memset(&m, 0, sizeof(m)); - m.Number = SMSData[2]; + m.Location = SMSData[2]; m.MemoryType = GMT_ME; if (GetSMSMessage(&m) != GE_NONE) eprintf("Could not find promissed message?\n"); -#if 0 else - slave_process(&m, SMSData[2]); -#endif + /*slave_process(&m, SMSData[2])*/; } break; default: @@ -1118,10 +1168,11 @@ WritePhonebookLocation(GSM_PhonebookEntry *entry) } static GSM_Error -GetSMSStatus(GSM_SMSMemoryStatus *Status) +GetSMSStatus(GSM_SMSStatus *Status) { - Status->Unread = 0; - Status->Number = 5; + Status->UnRead = 0; + Status->Used = 0; + Status->Slots = 5; return GE_NONE; } @@ -1170,7 +1221,6 @@ GSM_Functions N2110_Functions = { NULL, NULL, NULL, - NULL, SendRLPFrame, NULL, EnableDisplayOutput, diff --git a/common/phones/nk3110.c b/common/phones/nk3110.c index df30204..9c74f34 100644 --- a/common/phones/nk3110.c +++ b/common/phones/nk3110.c @@ -15,26 +15,8 @@ See README for more details on supported mobile phones. $Log$ - Revision 1.1.1.2 2001/11/27 22:01:20 short - :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Tue Nov 27 22:58 CET 2001 - - Revision 1.7 2001/11/27 12:19:01 pkot - Cleanup, indentation, ANSI complaint preprocesor symbols (Jan Kratochvil, me) - - Revision 1.6 2001/11/20 16:22:22 pkot - First attempt to read Picture Messages. They should appear when you enable DEBUG. Nokia seems to break own standards. :/ (Markus Plail) - - Revision 1.5 2001/11/19 13:03:18 pkot - nk3110.c cleanup - - Revision 1.4 2001/11/17 16:42:47 pkot - Cleanup - - Revision 1.3 2001/11/09 14:25:04 pkot - DEBUG cleanups - - Revision 1.2 2001/11/09 13:47:58 pkot - Removed pthreads from 3110 support. It may break it. + Revision 1.1.1.3 2002/04/03 00:08:11 short + Found in "gnokii-working" directory, some November-patches version Revision 1.1 2001/11/08 16:39:09 pkot 3810/3110 support for the new structure (Tamas Bondar) @@ -55,10 +37,11 @@ #include "phones/nokia.h" #ifndef WIN32 -# include + #include + #include #else -# define snprintf _snprintf -# define usleep(x) Sleep(((x) < 1000) ? 1 : ((x) / 1000)) + #define snprintf _snprintf + #define usleep(x) Sleep(((x) < 1000) ? 1 : ((x) / 1000)) #endif /* Some globals */ @@ -173,6 +156,9 @@ static bool SimAvailable = false; static bool RequestTerminate; static bool DisableKeepAlive; static int KeepAliveTimer; +#ifndef WIN32 +pthread_t Thread; +#endif /* Initialise is the only function allowed to 'use' state */ static GSM_Error P3110_Initialise(GSM_Statemachine *state) @@ -213,6 +199,10 @@ static GSM_Error P3110_Initialise(GSM_Statemachine *state) KeepAliveTimer = P3110_KEEPALIVE_TIMEOUT; RequestTerminate = false; DisableKeepAlive = false; +#ifndef WIN32 + if (pthread_create(&Thread, NULL, (void *) P3110_KeepAliveLoop, state) != 0) + return (GE_INTERNALERROR); +#endif return GE_NONE; } @@ -253,7 +243,6 @@ static GSM_Error P3110_GetMemoryStatus(GSM_Data *data, GSM_Statemachine *state) if (P3110_MEMORY_SIZE_ME == 0) return GE_NOTREADY; return P3110_GetSMSInfo(data, state); default: - break; } return GE_NOTREADY; } @@ -568,7 +557,7 @@ static GSM_Error P3110_SendSMSMessage(GSM_Data *data, GSM_Statemachine *state) case 0x29: /* Got a retry response so try again! */ dprintf("SMS send attempt failed, trying again...\n"); - retry_count--; + retry_count --; /* After an empirically determined pause... */ usleep(500000); /* 0.5 seconds. */ break; @@ -602,16 +591,20 @@ static GSM_Error P3110_IncomingCall(int messagetype, unsigned char *message, int } buffer[count] = 0x00; +#ifdef DEBUG /* Now display incoming call message. */ dprintf("Incoming call - Type: %s. %02x, Number %s.\n", (message[2] == 0x05 ? "Voice":"Data?"), message[3], buffer); +#endif return GE_NONE; } static GSM_Error P3110_IncomingCallAnswered(int messagetype, unsigned char *message, int length, GSM_Data *data) { +#ifdef DEBUG dprintf("Incoming call answered from phone.\n"); +#endif return GE_NONE; } @@ -620,8 +613,10 @@ static GSM_Error P3110_IncomingCallAnswered(int messagetype, unsigned char *mess call message has three (unexplained) data bytes. */ static GSM_Error P3110_IncomingCallEstablished(int messagetype, unsigned char *message, int length, GSM_Data *data) { +#ifdef DEBUG dprintf("%s call established - status bytes %02x %02x.\n", (message[2] == 0x05 ? "voice":"data(?)"), message[3], message[4]); +#endif return GE_NONE; } @@ -630,7 +625,9 @@ static GSM_Error P3110_IncomingCallEstablished(int messagetype, unsigned char *m call terminates. */ static GSM_Error P3110_IncomingEndOfOutgoingCall(int messagetype, unsigned char *message, int length, GSM_Data *data) { +#ifdef DEBUG dprintf("Call terminated from phone (0x10 message).\n"); +#endif /* FIXME: Tell datapump code that the call has terminated. */ /*if (CallPassup) { CallPassup(' '); @@ -644,7 +641,9 @@ static GSM_Error P3110_IncomingEndOfOutgoingCall(int messagetype, unsigned char purpose as yet undertermined. */ static GSM_Error P3110_IncomingEndOfIncomingCall(int messagetype, unsigned char *message, int length, GSM_Data *data) { +#ifdef DEBUG dprintf("Call terminated from opposite end of line (or from network).\n"); +#endif /* FIXME: Tell datapump code that the call has terminated. */ /*if (CallPassup) { @@ -660,7 +659,9 @@ static GSM_Error P3110_IncomingEndOfIncomingCall(int messagetype, unsigned char yet undertermined. */ static GSM_Error P3110_IncomingEndOfOutgoingCall2(int messagetype, unsigned char *message, int length, GSM_Data *data) { +#ifdef DEBUG dprintf("Call terminated from phone (0x12 message).\n"); +#endif /* FIXME: Tell datapump code that the call has terminated. */ /*if (CallPassup) { @@ -701,7 +702,9 @@ static GSM_Error P3110_IncomingInitFrame_0x15(int messagetype, unsigned char *me static GSM_Error P3110_IncomingInitFrame_0x16(int messagetype, unsigned char *message, int length, GSM_Data *data) { SimAvailable = (message[2] == 0x02); +#ifdef DEBUG dprintf("SIM available: %s.\n", (SimAvailable ? "Yes" : "No")); +#endif return GE_NONE; } @@ -776,7 +779,7 @@ static GSM_Error P3110_IncomingSMSSendError(int messagetype, unsigned char *mess static GSM_Error P3110_IncomingSMSHeader(int messagetype, unsigned char *message, int length, GSM_Data *data) { - /* u8 sender_length, smsc_length, l; */ + u8 sender_length, smsc_length, l; if (!data->SMSMessage) return GE_INTERNALERROR; @@ -795,7 +798,6 @@ static GSM_Error P3110_IncomingSMSHeader(int messagetype, unsigned char *message break; default: data->SMSMessage->MemoryType = GMT_XX; - break; } Set location in memory @@ -870,8 +872,8 @@ static GSM_Error P3110_IncomingSMSHeader(int messagetype, unsigned char *message message[6], message[7], message[14], message[4], message[5]); dprintf("Message Read:\n"); - dprintf(" Location: %d. Type: %d Status: %d\n", data->SMSMessage->Number, data->SMSMessage->Type, data->SMSMessage->Status); - dprintf(" Sender: %s\n", data->SMSMessage->RemoteNumber.number); + dprintf(" Location: %d. Type: %d Status: %d\n", data->SMSMessage->Location, data->SMSMessage->Type, data->SMSMessage->Status); + dprintf(" Sender: %s\n", data->SMSMessage->Sender); dprintf(" Message Center: %s\n", data->SMSMessage->MessageCenter.Number); dprintf(" Time: %02d.%02d.%02d %02d:%02d:%02d\n", data->SMSMessage->Time.Day, data->SMSMessage->Time.Month, data->SMSMessage->Time.Year, data->SMSMessage->Time.Hour, data->SMSMessage->Time.Minute, data->SMSMessage->Time.Second); @@ -921,7 +923,7 @@ static GSM_Error P3110_IncomingSMSDeleteError(int messagetype, unsigned char *me static GSM_Error P3110_IncomingSMSDelivered(int messagetype, unsigned char *message, int length, GSM_Data *data) { static GSM_SMSMessage sms; -/* u8 dest_length, smsc_length, l;*/ + u8 dest_length, smsc_length, l; u8 U0, U1, U2; data->SMSMessage = &sms; @@ -957,8 +959,8 @@ static GSM_Error P3110_IncomingSMSDelivered(int messagetype, unsigned char *mess data->SMSMessage->MessageCenter.Number[l] = 0; */ - dprintf("Message [0x%02x] Delivered!\n", data->SMSMessage->Number); - dprintf(" Destination: %s\n", data->SMSMessage->RemoteNumber.number); + dprintf("Message [0x%02x] Delivered!\n", data->SMSMessage->MessageNumber); + dprintf(" Destination: %s\n", data->SMSMessage->Destination); dprintf(" Message Center: %s\n", data->SMSMessage->MessageCenter.Number); dprintf(" Unknowns: 0x%02x 0x%02x 0x%02x\n", U0, U1, U2); dprintf(" Discharge Time: %02d.%02d.%02d %02d:%02d:%02d\n", @@ -975,7 +977,9 @@ static GSM_Error P3110_IncomingSMSDelivered(int messagetype, unsigned char *mess static GSM_Error P3110_IncomingNoSMSInfo(int messagetype, unsigned char *message, int length, GSM_Data *data) { +#ifdef DEBUG dprintf("SMS Message Center Data not reachable.\n"); +#endif return GE_NOTREADY; } @@ -987,7 +991,9 @@ static GSM_Error P3110_IncomingSMSInfo(int messagetype, unsigned char *message, { u8 center_number_length; u8 option_number_length; +#ifdef DEBUG int count; +#endif if (!data) return GE_INTERNALERROR; @@ -997,6 +1003,8 @@ static GSM_Error P3110_IncomingSMSInfo(int messagetype, unsigned char *message, /* Get message center length */ center_number_length = message[13 + option_number_length]; + +#ifdef DEBUG dprintf("SMS Message Center Data:\n"); dprintf(" Selected memory: 0x%02x\n", message[2]); dprintf(" Messages in Phone: 0x%02x Unread: 0x%02x\n", message[3], message[4]); @@ -1017,6 +1025,7 @@ static GSM_Error P3110_IncomingSMSInfo(int messagetype, unsigned char *message, dprintf("%c", message[14 + option_number_length + count]); } dprintf("\n"); +#endif /* Get message center related info if upper layer wants to know */ if (data->MessageCenter) { @@ -1056,7 +1065,6 @@ static GSM_Error P3110_IncomingSMSInfo(int messagetype, unsigned char *message, data->MemoryStatus->Free = P3110_MEMORY_SIZE_ME - message[3]; break; default: - break; } } @@ -1071,7 +1079,9 @@ static GSM_Error P3110_IncomingSMSInfo(int messagetype, unsigned char *message, static GSM_Error P3110_IncomingPINEntered(int messagetype, unsigned char *message, int length, GSM_Data *data) { SimAvailable = true; +#ifdef DEBUG dprintf("PIN [possibly] entered.\n"); +#endif return GE_NONE; } @@ -1083,6 +1093,7 @@ static GSM_Error P3110_IncomingPINEntered(int messagetype, unsigned char *messag static GSM_Error P3110_IncomingStatusInfo(int messagetype, unsigned char *message, int length, GSM_Data *data) { /* Strings for the status byte received from phone. */ +#ifdef DEBUG char *StatusStr[] = { "Unknown", "Ready", @@ -1090,6 +1101,7 @@ static GSM_Error P3110_IncomingStatusInfo(int messagetype, unsigned char *messag "Call in progress", "No network access" }; +#endif /* There are three data bytes in the status message, two have been attributed to signal level, the third is presently unknown. @@ -1112,10 +1124,12 @@ static GSM_Error P3110_IncomingStatusInfo(int messagetype, unsigned char *messag *(data->BatteryLevel) = message[4]; } +#ifdef DEBUG /* Only output connection status byte now as the RF and Battery levels are displayed by the main gnokii code. */ dprintf("Status: %s, Battery level: %d, RF level: %d.\n", StatusStr[message[2]], message[4], message[3]); +#endif return GE_NONE; } @@ -1138,10 +1152,12 @@ static GSM_Error P3110_IncomingPhoneInfo(int messagetype, unsigned char *message if (data->Model) strcpy(data->Model, message + 4 + imei_length + rev_length); +#ifdef DEBUG dprintf("Mobile Phone Identification:\n"); dprintf(" IMEI: %s\n", message + 2); dprintf(" Model: %s\n", message + 4 + imei_length + rev_length); dprintf(" Revision: %s\n", message + 3 + imei_length); +#endif return GE_NONE; } diff --git a/common/phones/nk6100.c b/common/phones/nk6100.c index 582367e..f7f1d4c 100644 --- a/common/phones/nk6100.c +++ b/common/phones/nk6100.c @@ -1,5 +1,4 @@ /* - $Id$ G N O K I I @@ -14,6 +13,19 @@ This file provides functions specific to the 6100 series. See README for more details on supported mobile phones. + $Log$ + Revision 1.1.1.3 2002/04/03 00:08:09 short + Found in "gnokii-working" directory, some November-patches version + + Revision 1.3 2001/08/17 00:01:53 pkot + Fixed a typo in 6100.c (me) + + Revision 1.2 2001/08/09 12:34:34 pkot + 3330 and 6250 support - I have no idea if it does work (mygnokii) + + Revision 1.1 2001/07/09 23:55:35 pkot + Initial support for 6100 series in the new structure (me) + */ #include @@ -35,46 +47,11 @@ /* Some globals */ -static const SMSMessage_Layout nk6100_deliver = { - true, - 0, 11, 0, 0, 6, 0, 0, -1, 23, 22, 0, 20, - 8, true, 24, true, 36, -1, - 5, 4, - 43, true -}; - -static const SMSMessage_Layout nk6100_submit = { - true, - -1, 20, 20, 20, 6, 21, 22, -1, 24, 23, 20, 20, - 8, true, 25, true, 37, -1, - -1, -1, - 44, true -}; - -static const SMSMessage_Layout nk6100_delivery_report = { - true, - 0, 0, 0, 0, 6, 0, 0, 0, 22, 21, -1, 20, - 8, true, 24, true, 35, 42, - 5, 4, - 22, true -}; - -static const SMSMessage_Layout nk6100_picture = { - false, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, true, 0, true, 0, 0, - 0, 0, - 0, true -}; - -static SMSMessage_PhoneLayout nk6100_layout; - static unsigned char MagicBytes[4] = { 0x00, 0x00, 0x00, 0x00 }; static GSM_IncomingFunctionType IncomingFunctions[] = { { 0x64, IncomingPhoneInfo }, { 0xd2, IncomingModelInfo }, - { 0x14, IncomingSMS }, { 0x03, Incoming0x03 }, { 0x0a, Incoming0x0a }, { 0x17, Incoming0x17 }, @@ -108,28 +85,35 @@ static GSM_Error Functions(GSM_Operation op, GSM_Data *data, GSM_Statemachine *s switch (op) { case GOP_Init: return Initialise(state); + break; case GOP_GetModel: return GetModelName(data, state); + break; case GOP_GetRevision: return GetRevision(data, state); + break; case GOP_GetImei: return GetIMEI(data, state); + break; case GOP_Identify: return Identify(data, state); + break; case GOP_GetBatteryLevel: return GetBatteryLevel(data, state); + break; case GOP_GetRFLevel: return GetRFLevel(data, state); + break; case GOP_GetMemoryStatus: return GetMemoryStatus(data, state); - case GOP_GetSMS: - return GetSMSMessage(data, state); + break; default: return GE_NOTIMPLEMENTED; + break; } } -/* static bool LinkOK = true; */ +static bool LinkOK = true; /* Initialise is the only function allowed to 'use' state */ static GSM_Error Initialise(GSM_Statemachine *state) @@ -137,40 +121,40 @@ static GSM_Error Initialise(GSM_Statemachine *state) GSM_Data data; char model[10]; GSM_Error err; + int try = 0, connected = 0; /* Copy in the phone info */ memcpy(&(state->Phone), &phone_nokia_6100, sizeof(GSM_Phone)); - /* SMS Layout */ - nk6100_layout.Type = 7; - nk6100_layout.Deliver = nk6100_deliver; - nk6100_layout.Submit = nk6100_submit; - nk6100_layout.DeliveryReport = nk6100_delivery_report; - nk6100_layout.Picture = nk6100_picture; - layout = nk6100_layout; - - switch (state->Link.ConnectionType) { - case GCT_Serial: - err = FBUS_Initialise(&(state->Link), state, 0); - break; - case GCT_Infrared: - err = PHONET_Initialise(&(state->Link), state); - break; - default: - return GE_NOTSUPPORTED; - } + while (!connected) { + switch (state->Link.ConnectionType) { + case GCT_Serial: + if (try > 1) return GE_NOTSUPPORTED; + err = FBUS_Initialise(&(state->Link), state); + break; + case GCT_Infrared: + if (try > 0) return GE_NOTSUPPORTED; + err = PHONET_Initialise(&(state->Link), state); + break; + default: + return GE_NOTSUPPORTED; + break; + } - if (err != GE_NONE) { - dprintf("Error in link initialisation\n"); - return GE_NOTSUPPORTED; - } - - SM_Initialise(state); + if (err != GE_NONE) { + dprintf("Error in link initialisation\n"); + try++; + continue; + } + + SM_Initialise(state); - /* Now test the link and get the model */ - GSM_DataClear(&data); - data.Model = model; - if (state->Phone.Functions(GOP_GetModel, &data, state) != GE_NONE) return GE_NOTSUPPORTED; + /* Now test the link and get the model */ + GSM_DataClear(&data); + data.Model = model; + if (state->Phone.Functions(GOP_GetModel, &data, state) != GE_NONE) try++; + else connected = 1; + } return GE_NONE; } @@ -278,7 +262,7 @@ static GSM_Error Incoming0x03(int messagetype, unsigned char *message, int lengt if (message[5] != 0xff) { data->MemoryStatus->Used = (message[16] << 8) + message[17]; data->MemoryStatus->Free = ((message[14] << 8) + message[15]) - data->MemoryStatus->Used; - dprintf("Memory status - location = %d\n", (message[8] << 8) + message[9]); + dprintf(_("Memory status - location = %d\n"), (message[8] << 8) + message[9]); return GE_NONE; } else { dprintf("Unknown error getting mem status\n"); @@ -298,9 +282,8 @@ static GSM_Error Incoming0x03(int messagetype, unsigned char *message, int lengt static GSM_Error Identify(GSM_Data *data, GSM_Statemachine *state) { unsigned char req[] = { FBUS_FRAME_HEADER, 0x10 }; - + dprintf("Identifying...\n"); - PNOK_GetManufacturer(data->Manufacturer); if (SM_SendMessage(state, 4, 0x64, req) != GE_NONE) return GE_NOTREADY; SM_WaitFor(state, data, 0x64); SM_Block(state, data, 0x64); /* waits for all requests */ @@ -338,17 +321,17 @@ static GSM_Error IncomingPhoneInfo(int messagetype, unsigned char *message, int dprintf("Received revision %s\n", data->Revision); } - dprintf("Message: Mobile phone identification received:\n"); - dprintf("\tIMEI: %s\n", data->Imei); - dprintf("\tModel: %s\n", data->Model); - dprintf("\tProduction Code: %s\n", message + 31); - dprintf("\tHW: %s\n", message + 39); - dprintf("\tFirmware: %s\n", message + 44); + dprintf(_("Message: Mobile phone identification received:\n")); + dprintf(_(" IMEI: %s\n"), data->Imei); + dprintf(_(" Model: %s\n"), data->Model); + dprintf(_(" Production Code: %s\n"), message + 31); + dprintf(_(" HW: %s\n"), message + 39); + dprintf(_(" Firmware: %s\n"), message + 44); /* These bytes are probably the source of the "Accessory not connected" messages on the phone when trying to emulate NCDS... I hope.... UPDATE: of course, now we have the authentication algorithm. */ - dprintf("\tMagic bytes: %02x %02x %02x %02x\n", message[50], message[51], message[52], message[53]); + dprintf(_(" Magic bytes: %02x %02x %02x %02x\n"), message[50], message[51], message[52], message[53]); MagicBytes[0] = message[50]; MagicBytes[1] = message[51]; @@ -374,7 +357,7 @@ static GSM_Error IncomingModelInfo(int messagetype, unsigned char *message, int data->Revision[GSM_MAX_REVISION_LENGTH - 1] = 0; } #endif - dprintf("Phone info:\n%s\n", message + 4); + dprintf(_("Phone info:\n%s\n"), message + 4); return GE_NONE; } @@ -417,89 +400,3 @@ static int GetMemoryType(GSM_MemoryType memory_type) } return (result); } - -static GSM_Error GetSMSMessage(GSM_Data *data, GSM_Statemachine *state) -{ - unsigned char req[] = { FBUS_FRAME_HEADER, 0x07, 0x02 /* Unknown */, 0x00 /* Location */, 0x01, 0x64}; - - req[5] = data->SMSMessage->Number; - - if (SM_SendMessage(state, 8, 0x02, req) != GE_NONE) return GE_NOTREADY; - return SM_Block(state, data, 0x14); -} - -static GSM_Error IncomingSMS(int messagetype, unsigned char *message, int length, GSM_Data *data) -{ - int i; - - switch (message[3]) { - /* save sms succeeded */ - case 0x05: - dprintf("Message stored at %d\n", message[5]); - break; - /* save sms failed */ - case 0x06: - dprintf("SMS saving failed:\n"); - switch (message[4]) { - case 0x02: - dprintf("\tAll locations busy.\n"); - return GE_MEMORYFULL; - case 0x03: - dprintf("\tInvalid location!\n"); - return GE_INVALIDSMSLOCATION; - default: - dprintf("\tUnknown reason.\n"); - return GE_UNKNOWN; - } - /* read sms */ - case 0x08: - for (i = 0; i < length; i ++) - if (isprint(message[i])) - dprintf("[%02x%c]", message[i], message[i]); - else - dprintf("[%02x ]", message[i]); - dprintf("\n"); - - memset(data->SMSMessage, 0, sizeof(GSM_SMSMessage)); - - /* Short Message status */ - DecodePDUSMS(message, data->SMSMessage, length); - - break; - /* read sms failed */ - case 0x09: - dprintf("SMS reading failed:\n"); - switch (message[4]) { - case 0x02: - dprintf("\tInvalid location!\n"); - return GE_INVALIDSMSLOCATION; - case 0x07: - dprintf("\tEmpty SMS location.\n"); - return GE_EMPTYSMSLOCATION; - default: - dprintf("\tUnknown reason.\n"); - return GE_UNKNOWN; - } - /* delete sms succeeded */ - case 0x0b: - dprintf("Message: SMS deleted successfully.\n"); - break; - /* sms status succeded */ - case 0x37: - dprintf("Message: SMS Status Received\n"); - dprintf("\tThe number of messages: %d\n", message[10]); - dprintf("\tUnread messages: %d\n", message[11]); - data->SMSStatus->Unread = message[11]; - data->SMSStatus->Number = message[10]; - break; - /* sms status failed */ - case 0x38: - dprintf("Message: SMS Status error, probably not authorized by PIN\n"); - return GE_INTERNALERROR; - /* unknown */ - default: - dprintf("Unknown message.\n"); - return GE_UNKNOWN; - } - return GE_NONE; -} diff --git a/common/phones/nk7110.c b/common/phones/nk7110.c index bd3f164..4dd584d 100644 --- a/common/phones/nk7110.c +++ b/common/phones/nk7110.c @@ -7,8 +7,7 @@ A Linux/Unix toolset and driver for Nokia mobile phones. Copyright (C) 2000 Hugh Blemings & Pavel Janík ml. - Copyright (C) 2000 Chris Kemp - Copyright (C) 2001 Markus Plail, Pawe³ Kot + Copytight (C) 2000 Chris Kemp Released under the terms of the GNU GPL, see file COPYING for more details. @@ -17,6 +16,94 @@ The various routines are called P7110_(whatever). + $Log$ + Revision 1.1.1.5 2002/04/03 00:08:10 short + Found in "gnokii-working" directory, some November-patches version + + Revision 1.15 2001/11/08 16:47:48 pkot + Start fiddling with 7110 and SMS + + Revision 1.14 2001/09/09 21:45:49 machek + Cleanups from Ladislav Michl : + + *) do *not* internationalize debug messages + + *) some whitespace fixes, do not use // + + *) break is unneccessary after return + + Revision 1.13 2001/08/16 23:59:32 pkot + Fixed (hopefully) timezone mismash (Sheldon Hearn) + + Revision 1.12 2001/08/09 12:34:34 pkot + 3330 and 6250 support - I have no idea if it does work (mygnokii) + + Revision 1.11 2001/07/05 10:54:53 pkot + Solaris 2.7 fixes - should be harmless for other OSes (Michael Wiedmann) + + Revision 1.10 2001/06/27 23:52:49 pkot + 7110/6210 updates (Marian Jancar) + + Revision 1.9 2001/06/10 23:49:49 pkot + Small fixes to hide compilation warnings and allow gnokii.c to compile + + Revision 1.8 2001/05/24 20:47:30 chris + More updating of 7110 code and some of xgnokii_lowlevel changed over. + + Revision 1.7 2001/05/07 16:24:04 pkot + DLR-3P temporary fix. How should I do it better? + + Revision 1.6 2001/03/23 13:40:24 chris + Pavel's patch and a few fixes. + + Revision 1.5 2001/03/22 16:17:06 chris + Tidy-ups and fixed gnokii/Makefile and gnokii/ChangeLog which I somehow corrupted. + + Revision 1.4 2001/03/21 23:36:06 chris + Added the statemachine + This will break gnokii --identify and --monitor except for 6210/7110 + + Revision 1.3 2001/03/13 01:24:03 pkot + Code cleanup - no warnings during compilation + + Revision 1.2 2001/03/13 01:23:18 pkot + Windows updates (Manfred Jonsson) + + Revision 1.1 2001/02/21 19:57:07 chris + More fiddling with the directory layout + + Revision 1.1 2001/02/16 14:29:53 chris + Restructure of common/. Fixed a problem in fbus-phonet.c + Lots of dprintfs for Marcin + Any size xpm can now be loaded (eg for 7110 startup logos) + nk7110 code detects 7110/6210 and alters startup logo size to suit + Moved Marcin's extended phonebook code into gnokii.c + + Revision 1.7 2001/02/06 21:15:35 chris + Preliminary irda support for 7110 etc. Not well tested! + + Revision 1.6 2001/02/03 23:56:15 chris + Start of work on irda support (now we just need fbus-irda.c!) + Proper unicode support in 7110 code (from pkot) + + Revision 1.5 2001/02/01 15:17:31 pkot + Fixed --identify and added Manfred's manufacturer patch + + Revision 1.4 2001/01/29 17:14:42 chris + dprintf now in misc.h (and fiddling with 7110 code) + + Revision 1.3 2001/01/23 15:32:41 chris + Pavel's 'break' and 'static' corrections. + Work on logos for 7110. + + Revision 1.2 2001/01/17 02:54:54 chris + More 7110 work. Use with care! (eg it is not possible to delete phonebook entries) + I can now edit my phonebook in xgnokii but it is 'work in progress'. + + Revision 1.1 2001/01/14 22:46:59 chris + Preliminary 7110 support (dlr9 only) and the beginnings of a new structure + + */ #include @@ -39,40 +126,6 @@ /* Some globals */ -static const SMSMessage_Layout nk7110_deliver = { - true, - 0, 21, 0, 0, 7, 0, 0, -1, 24, 23, 0, 21, - 9, true, 25, true, 37, -1, - 5, 4, - 44, true -}; - -static const SMSMessage_Layout nk7110_submit = { - true, - -1, 18, 18, 18, -1, 19, 20, -1, 22, 21, 18, 18, - 6, true, 23, true, -1, -1, - -1, -1, - 42, true -}; - -static const SMSMessage_Layout nk7110_delivery_report = { - true, - 0, 0, 0, 0, 7, 0, 0, 0, 23, 22, -1, 21, - 9, true, 24, true, 36, 43, - 5, 4, - 23, true -}; - -static const SMSMessage_Layout nk7110_picture = { - true, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 9, true, 22, true, 34, -1, - 0, 0, - 47, true -}; - -static SMSMessage_PhoneLayout nk7110_layout; - static GSM_IncomingFunctionType P7110_IncomingFunctions[] = { { P7110_MSG_FOLDER, P7110_IncomingFolder }, { P7110_MSG_SMS, P7110_IncomingSMS }, @@ -83,7 +136,6 @@ static GSM_IncomingFunctionType P7110_IncomingFunctions[] = { { P7110_MSG_CLOCK, P7110_IncomingClock }, { P7110_MSG_IDENTITY, P7110_Incoming0x1b }, { P7110_MSG_STLOGO, P7110_IncomingStartup }, - { P7110_MSG_DIVERT, P7110_IncomingCallDivert }, { 0, NULL } }; @@ -92,7 +144,7 @@ GSM_Phone phone_nokia_7110 = { PGEN_IncomingDefault, /* Mobile phone information */ { - "7110|6210|6250", /* Supported models */ + "7110|6210|6250", /* Supported models */ 7, /* Max RF Level */ 0, /* Min RF Level */ GRF_Percentage, /* RF level units */ @@ -100,9 +152,9 @@ GSM_Phone phone_nokia_7110 = { 0, /* Min Battery Level */ GBU_Percentage, /* Battery level units */ GDT_DateTime, /* Have date/time support */ - GDT_TimeOnly, /* Alarm supports time only */ + GDT_TimeOnly, /* Alarm supports time only */ 1, /* Alarms available - FIXME */ - 60, 96, /* Startup logo size - 7110 is fixed at init */ + 60, 96, /* Startup logo size - 7110 is fixed at init*/ 21, 78, /* Op logo size */ 14, 72 /* Caller logo size */ }, @@ -152,11 +204,7 @@ static GSM_Error P7110_Functions(GSM_Operation op, GSM_Data *data, GSM_Statemach return P7110_GetCalendarNote(data, state); case GOP_GetSMS: return P7110_GetSMS(data, state); - case GOP_SendSMS: - return P7110_SendSMS(data, state); - case GOP_CallDivert: - return P7110_CallDivert(data, state); -/* I'm not sure yet if folder functions will be shared or local +/* I'm not suer yet if folder functions will be shared or local case GOP_GetSMSFolders: return P7110_GetSMSFolders(data, state); case GOP_GetSMSFolderStatus: @@ -180,22 +228,11 @@ static GSM_Error P7110_Initialise(GSM_Statemachine *state) /* Copy in the phone info */ memcpy(&(state->Phone), &phone_nokia_7110, sizeof(GSM_Phone)); - /* SMS Layout */ - nk7110_layout.Type = 8; /* Locate the Type of the mesage field */ - nk7110_layout.Deliver = nk7110_deliver; - nk7110_layout.Submit = nk7110_submit; - nk7110_layout.DeliveryReport = nk7110_delivery_report; - nk7110_layout.Picture = nk7110_picture; - layout = nk7110_layout; - - dprintf("Connecting\n"); while (!connected) { switch (state->Link.ConnectionType) { - case GCT_DAU9P: - if (try == 0) try = 1; case GCT_Serial: if (try > 1) return GE_NOTSUPPORTED; - err = FBUS_Initialise(&(state->Link), state, 1 - try); + err = FBUS_Initialise(&(state->Link), state); break; case GCT_Infrared: case GCT_Irda: @@ -208,7 +245,7 @@ static GSM_Error P7110_Initialise(GSM_Statemachine *state) } if (err != GE_NONE) { - dprintf("Error in link initialisation: %d\n", err); + dprintf("Error in link initialisation\n"); try++; continue; } @@ -274,12 +311,13 @@ static GSM_Error P7110_IncomingBattLevel(int messagetype, unsigned char *message *(data->BatteryLevel) = message[5]; dprintf("Battery level %f\n",*(data->BatteryLevel)); } + return GE_NONE; break; default: dprintf("Unknown subtype of type 0x17 (%d)\n", message[3]); return GE_UNKNOWN; + break; } - return GE_NONE; } static GSM_Error P7110_GetRFLevel(GSM_Data *data, GSM_Statemachine *state) @@ -354,6 +392,7 @@ static GSM_Error P7110_IncomingNetwork(int messagetype, unsigned char *message, } blockstart += blockstart[1]; } + return GE_NONE; break; case 0x82: if (data->RFLevel) { @@ -361,15 +400,16 @@ static GSM_Error P7110_IncomingNetwork(int messagetype, unsigned char *message, *(data->RFLevel) = message[4]; dprintf("RF level %f\n",*(data->RFLevel)); } + return GE_NONE; break; case 0xa4: dprintf("Op Logo Set OK\n"); - break; + return GE_NONE; default: dprintf("Unknown subtype of type 0x0a (%d)\n", message[3]); return GE_UNKNOWN; + break; } - return GE_NONE; } static GSM_Error P7110_GetMemoryStatus(GSM_Data *data, GSM_Statemachine *state) @@ -400,11 +440,14 @@ static GSM_Error P7110_IncomingPhonebook(int messagetype, unsigned char *message data->MemoryStatus->Used = (message[16] << 8) + message[17]; data->MemoryStatus->Free = ((message[14] << 8) + message[15]) - data->MemoryStatus->Used; dprintf("Memory status - location = %d\n", (message[8] << 8) + message[9]); + return GE_NONE; } else { dprintf("Unknown error getting mem status\n"); return GE_NOTIMPLEMENTED; + } } + return GE_NONE; break; case 0x08: /* Read Memory response */ if (data->PhonebookEntry) { @@ -553,19 +596,20 @@ static GSM_Error P7110_IncomingPhonebook(int messagetype, unsigned char *message } blockstart += blockstart[3]; } + return GE_NONE; break; case 0x0c: switch (message[6]) { - case 0x3d: return GE_PHBOOKWRITEFAILED; - case 0x3e: return GE_PHBOOKWRITEFAILED; - default: return GE_NONE; + case 0x3d: return GE_PHBOOKWRITEFAILED; break; + case 0x3e: return GE_PHBOOKWRITEFAILED; break; + default: return GE_NONE; break; } break; default: dprintf("Unknown subtype of type 0x03 (%d)\n", message[3]); return GE_UNKNOWN; + break; } - return GE_NONE; } /* Just as an example.... */ @@ -576,7 +620,6 @@ static GSM_Error P7110_Identify(GSM_Data *data, GSM_Statemachine *state) unsigned char req2[] = {FBUS_FRAME_HEADER, 0x03, 0x01, 0x32}; dprintf("Identifying...\n"); - PNOK_GetManufacturer(data->Manufacturer); if (SM_SendMessage(state, 4, 0x1b, req) != GE_NONE) return GE_NOTREADY; if (SM_SendMessage(state, 6, 0x1b, req2) != GE_NONE) return GE_NOTREADY; SM_WaitFor(state, data, 0x1b); @@ -596,6 +639,7 @@ static GSM_Error P7110_Incoming0x1b(int messagetype, unsigned char *message, int snprintf(data->Imei, GSM_MAX_IMEI_LENGTH, "%s", message + 4); dprintf("Received imei %s\n",data->Imei); } + return GE_NONE; break; case 04: if (data->Model) { @@ -606,201 +650,132 @@ static GSM_Error P7110_Incoming0x1b(int messagetype, unsigned char *message, int snprintf(data->Revision, GSM_MAX_REVISION_LENGTH, "%s", message + 7); dprintf("Received revision %s\n",data->Revision); } + return GE_NONE; break; default: dprintf("Unknown subtype of type 0x1b (%d)\n", message[3]); return GE_UNKNOWN; + break; } - return GE_NONE; } /* handle messages of type 0x14 (SMS Handling, Folders, Logos.. */ static GSM_Error P7110_IncomingFolder(int messagetype, unsigned char *message, int length, GSM_Data *data) { - int i, j; - int nextfolder = 0x10; - bool found; - +#if 0 + int off, offset; + int wc,i,j,tmp=0; switch (message[3]) { /* getfolders */ case 0x7B: i = 5; - memset(data->SMSFolderList, 0, sizeof(SMS_FolderList)); - dprintf("Message: %d SMS Folders received:\n", message[4]); - - strcpy(data->SMSFolderList->Folder[1].Name, " "); - data->SMSFolderList->number = message[4]; + data->SMSFolders->number = message[4]; + dprintf("Message: %d SMS Folders received:\n", data->SMSFolders->number); for (j = 0; j < message[4]; j++) { - int len; - strcpy(data->SMSFolderList->Folder[j].Name, " "); - data->SMSFolderList->FolderID[j] = message[i]; - dprintf("Folder Index: %d", data->SMSFolderList->FolderID[j]); - i += 2; + strcpy(data->SMSFolders->Folder[j].Name, " "); + data->SMSFolders->FoldersID[j] = message[i]; + dprintf("Folder Index: %d", data->SMSFolders->FoldersID[j]); + i = i + 2; dprintf(" Folder name: "); - len = 0; - /* search for next folder's index number, i.e. length of folder name */ - while (message[i+1] != nextfolder && i < length) { - i += 2; - len++; - } - /* see nk7110.txt */ - nextfolder += 0x08; - if (nextfolder == 0x28) nextfolder++; - i -= 2 * len +1; - DecodeUnicode(data->SMSFolderList->Folder[j].Name, message + i, len); - dprintf("%s\n", data->SMSFolderList->Folder[j].Name); - i += 2 * len + 2; + tmp = 0; + while ((message[i] != 0x00) & (message[i+1] == 0x00)) { + wc = message[i] | (message[i+1] << 8); + data->SMSFolders->Folder[j].Name[tmp] = DecodeWithUnicodeAlphabet(wc); + dprintf("%c", data->SMSFolders->Folder[j].Name[tmp]); + tmp++; + i = i + 2; + } + dprintf("\n"); + tmp = 0; + i = i + 1; } break; /* getfolderstatus */ case 0x6C: - memset(data->SMSFolder, 0, sizeof(SMS_Folder)); dprintf("Message: SMS Folder status received: \n" ); - data->SMSFolder->FolderID = data->SMSMessage->MemoryType; - data->SMSFolder->number = (message[5] * 256) + message[5]; - dprintf("Message: Number of Entries: %i\n" , data->SMSFolder->number); + data->OneSMSFolder->number = (message[5] * 256) + message[5]; + dprintf("Message: Number of Entries: %i\n" , data->OneSMSFolder->number); dprintf("Message: IDs of Entries : "); - for (i = 0; i < message[4] * 256 + message[5]; i++) { - data->SMSFolder->locations[i] = message[6+(i*2)] * 256 + message[(i*2)+7]; - dprintf("%d, ", data->SMSFolder->locations[i]); + for (i=0;iOneSMSFolder->locations[i]=message[6+(i*2)]*256+message[(i*2)+7]; + dprintf("%d, ", data->OneSMSFolder->locations[i]); } dprintf("\n"); break; /* getsms */ case 0x08: - for (i = 0; i < length; i ++) + for (i = 0; i < length-2; i ++) if (isprint(message[i])) dprintf("[%02x%c]", message[i], message[i]); else dprintf("[%02x ]", message[i]); dprintf("\n"); - memset(data->SMSMessage, 0, sizeof(GSM_SMSMessage)); - - /* Number of SMS in folder */ - data->SMSMessage->Number = message[7]; - - /* MessageType/FolderID */ - data->SMSMessage->MemoryType = message[5]; + dprintf("Message: Getting SMS %i " , data->SMSMessage->Location); + dprintf("in Folder %i\n", data->SMSMessage->Destination); + if (message[5] != data->SMSMessage->Destination) { + dprintf("Invalid SMS location (Folder)\n"); + return GE_INVALIDSMSLOCATION; + } + if ((message[6] * 256 + message[7]) != data->SMSMessage->Location) { + dprintf("Invalid SMS location (ID)\n"); + return GE_INVALIDSMSLOCATION; + } - /* Short Message status */ - data->SMSMessage->Status = message[4]; - dprintf("\tStatus: "); - switch (data->SMSMessage->Status) { - case SMS_Read: - dprintf("READ\n"); - break; - case SMS_Unread: - dprintf("UNREAD\n"); - break; - case SMS_Sent: - dprintf("SENT\n"); - break; - case SMS_Unsent: - dprintf("UNSENT\n"); - break; - default: - dprintf("UNKNOWN\n"); - break; - } - /* See if message# is given back by phone. If not and status is unread */ - /* we want it, if status is not unread it's a "random" message given back */ - /* by the phone because we want a message of which the # doesn't exist */ - found = false; - for (i = 0; i < data->SMSFolder->number; i++) { - if (data->SMSMessage->Number == data->SMSFolder->locations[i]) - found = true; - } - if (found==false && data->SMSMessage->Status != SMS_Unread) return GE_INVALIDSMSLOCATION; + /* Status see nk7110.txt */ + data->SMSMessage->Status = message[4]; - DecodePDUSMS(message, data->SMSMessage, length); + if (message[8]==0x01) data->SMSMessage->Type = SMS_Deliver_Report; + offset=4; + if (data->SMSMessage->Status == SMS_MO_SENT) offset=5; + off = 0; + if (message[9+12] & 0x40) { /* UDH header available */ + off = (message[9+31+offset] + 1); /* Length of UDH header */ + + dprintf(" UDH header available (length %i)\n",off); + } + + DecodeSMSHeader(message, length, data->SMSMessage, 9, offset); + DecodeTextSMS(message, length, data->SMSMessage, 9, offset, off); + break; - - /* get list of SMS pictures */ - case 0x97: - dprintf("Getting list of SMS pictures...\n"); - for (i = 0; i < length; i ++) - if (isprint(message[i])) - dprintf("[%02x%c]", message[i], message[i]); - else - dprintf("[%02x ]", message[i]); - dprintf("\n"); - break; + default: - for (i = 0; i < length; i ++) + for (i = 0; i < length-2; i ++) if (isprint(message[i])) dprintf("[%02x%c]", message[i], message[i]); else dprintf("[%02x ]", message[i]); dprintf("\n"); dprintf("Message: Unknown message of type 14 : %d length: %d\n", message[3], length); - return GE_UNKNOWN; + break; } +#endif return GE_NONE; } static GSM_Error P7110_GetSMS(GSM_Data *data, GSM_Statemachine *state) { - unsigned char req_folders[] = {FBUS_FRAME_HEADER, 0x7a, 0x00, 0x00}; - unsigned char req_status[] = {FBUS_FRAME_HEADER, 0x6b, - 0x08, // Folder ID - 0x0f, 0x01}; - unsigned char req_sms[] = {FBUS_FRAME_HEADER, 0x07, + unsigned char req[] = {FBUS_FRAME_HEADER, 0x07, 0x08, // FolderID 0x00, 0x01, // Location 0x01, 0x65, 0x01}; - unsigned char req_list[] = {FBUS_FRAME_HEADER, 0x96, - 0x09, /* location */ - 0x0f, 0x07}; - GSM_Error error; - - /* just testiung picture listing */ - req_list[4] = data->SMSMessage->MemoryType; - if (SM_SendMessage(state, 7, 0x14, req_list) != GE_NONE) return GE_NOTREADY; - error = SM_Block(state, data, 0x14); - - /* see if the message we want is from the last read folder, i.e. */ - /* we don't have to get folder status again */ - if (data->SMSMessage->MemoryType != data->SMSFolder->FolderID) { - - dprintf("Getting list of SMS folders...\n"); - if (SM_SendMessage(state, 6, 0x14, req_folders) != GE_NONE) return GE_NOTREADY; - error = SM_Block(state, data, 0x14); - - if (data->SMSMessage->MemoryType > data->SMSFolderList->FolderID[data->SMSFolderList->number-1]) - return GE_INVALIDMEMORYTYPE; - data->SMSFolder->FolderID = data->SMSMessage->MemoryType; - req_status[4] = data->SMSMessage->MemoryType; - - dprintf("Getting entries for SMS folder %i...\n", data->SMSMessage->MemoryType); - if (SM_SendMessage(state, 7, 0x14, req_status) != GE_NONE) return GE_NOTREADY; - error = SM_Block(state, data, 0x14); - } - + dprintf("Getting SMS...\n"); - req_sms[4] = data->SMSMessage->MemoryType; - req_sms[6] = data->SMSMessage->Number; - if (SM_SendMessage(state, 10, 0x14, req_sms) != GE_NONE) return GE_NOTREADY; + req[4] = data->SMSMessage->MemoryType; + req[6] = data->SMSMessage->Location; + if (SM_SendMessage(state, 10, 0x14, req) != GE_NONE) return GE_NOTREADY; return SM_Block(state, data, 0x14); } -static GSM_Error P7110_GetPicture(GSM_Data *data, GSM_Statemachine *state) -{ - unsigned char req_list[] = {FBUS_FRAME_HEADER, 0x96, - 0x09, /* location */ - 0x0f, 0x07}; - if (SM_SendMessage(state, 7, 0x14, req_list) != GE_NONE) return GE_NOTREADY; - return SM_Block(state, data, 0x14); -} -#if 0 static GSM_Error P7110_GetSMSFolders(GSM_Data *data, GSM_Statemachine *state) { unsigned char req[] = {FBUS_FRAME_HEADER, 0x7A, 0x00, 0x00}; @@ -812,67 +787,39 @@ static GSM_Error P7110_GetSMSFolders(GSM_Data *data, GSM_Statemachine *state) static GSM_Error P7110_GetSMSFolderStatus(GSM_Data *data, GSM_Statemachine *state) { +#if 0 unsigned char req[] = {FBUS_FRAME_HEADER, 0x6B, 0x08, // Folder ID 0x0F, 0x01}; - req[4] = data->SMSFolder->FolderID; + req[4] = data->OneSMSFolder->FolderID; dprintf("Getting SMS Folder Status...\n"); if (SM_SendMessage(state, 7, 0x14, req) != GE_NONE) return GE_NOTREADY; return SM_Block(state, data, 0x14); -} #endif - -static GSM_Error P7110_SendSMS(GSM_Data *data, GSM_Statemachine *state) -{ - GSM_Error e = GE_NONE; - unsigned char req[256] = {FBUS_FRAME_HEADER, 0x01, 0x02, 0x00}; - int length, i; - - if (data->SMSMessage->MessageCenter.No) { - data->MessageCenter = &data->SMSMessage->MessageCenter; - P7110_GetSMSCenter(data, state); - } - - length = EncodePDUSMS(data->SMSMessage, req); - if (!length) return GE_SMSWRONGFORMAT; - dprintf("Sending SMS...(%d)\n", length); - for (i = 0; i < length; i++) { - dprintf("%02x ", req[i]); - } - dprintf("\n"); - if (SM_SendMessage(state, length, 0x02, req) != GE_NONE) return GE_NOTREADY; - while (1) { - e = SM_Block(state, data, 0x02); - if (e == GE_SMSSENDOK || e == GE_SMSSENDFAILED) break; - } - return e; + return GE_NONE; } static GSM_Error P7110_IncomingSMS(int messagetype, unsigned char *message, int length, GSM_Data *data) { GSM_Error e = GE_NONE; int digits, bytes; - - if (!data) return GE_INTERNALERROR; + + if (!data || !data->MessageCenter) return GE_INTERNALERROR; switch (message[3]) { case P7110_SUBSMS_SMSC_RCVD: - dprintf("SMSC Received\n"); /* FIXME: Implement all these in gsm-sms.c */ data->MessageCenter->No = message[4]; data->MessageCenter->Format = message[6]; data->MessageCenter->Validity = message[8]; /* due to changes in format */ + digits = message[9]; bytes = message[21] - 1; sprintf(data->MessageCenter->Name, "%s", message + 33); - strcpy(data->MessageCenter->Recipient, GetBCDNumber(message+9)); - strcpy(data->MessageCenter->Number, GetBCDNumber(message+21)); - data->MessageCenter->Type = message[22]; - if (strlen(data->MessageCenter->Recipient) == 0) { sprintf(data->MessageCenter->Recipient, "(none)"); } @@ -884,17 +831,8 @@ static GSM_Error P7110_IncomingSMS(int messagetype, unsigned char *message, int } break; - case P7110_SUBSMS_SMS_SENT: - dprintf("SMS sent\n"); - e = GE_SMSSENDOK; - break; - case P7110_SUBSMS_SEND_FAIL: - dprintf("SMS sending failed\n"); - e = GE_SMSSENDFAILED; - break; - case P7110_SUBSMS_SMS_RCVD: case P7110_SUBSMS_CELLBRD_OK: case P7110_SUBSMS_CELLBRD_FAIL: @@ -905,7 +843,6 @@ static GSM_Error P7110_IncomingSMS(int messagetype, unsigned char *message, int dprintf("Subtype 0x%02x of type 0x%02x (SMS handling) not implemented\n", message[3], P7110_MSG_SMS); e = GE_NOTIMPLEMENTED; break; - default: dprintf("Unknown subtype of type 0x%02x (SMS handling): 0x%02x\n", P7110_MSG_SMS, message[3]); e = GE_UNKNOWN; @@ -1112,80 +1049,6 @@ static GSM_Error P7110_IncomingCalendar(int messagetype, unsigned char *message, return e; } -static GSM_Error P7110_CallDivert(GSM_Data *data, GSM_Statemachine *state) -{ - unsigned short length = 0x09; - char req[55] = { FBUS_FRAME_HEADER, 0x01, 0x00, /* operation */ - 0x00, - 0x00, /* divert type */ - 0x00, /* call type */ - 0x00 }; - if (!data->CallDivert) return GE_UNKNOWN; - switch (data->CallDivert->Operation) { - case GSM_CDV_Query: - req[4] = 0x05; - break; - case GSM_CDV_Register: - req[4] = 0x03; - length = 0x16; - req[8] = 0x01; - req[9] = SemiOctetPack(data->CallDivert->Number.number, req + 10, data->CallDivert->Number.type); - req[21] = data->CallDivert->Timeout; - break; - case GSM_CDV_Erasure: - req[4] = 0x04; - break; - default: - return GE_NOTIMPLEMENTED; - } - switch (data->CallDivert->CType) { - case GSM_CDV_AllCalls: - break; - case GSM_CDV_VoiceCalls: - req[7] = 0x0b; - break; - case GSM_CDV_FaxCalls: - req[7] = 0x0d; - break; - case GSM_CDV_DataCalls: - req[7] = 0x19; - break; - default: - return GE_NOTIMPLEMENTED; - } - switch (data->CallDivert->DType) { - case GSM_CDV_AllTypes: - req[6] = 0x15; - break; - case GSM_CDV_Busy: - req[6] = 0x43; - break; - case GSM_CDV_NoAnswer: - req[6] = 0x3d; - break; - case GSM_CDV_OutOfReach: - req[6] = 0x3e; - break; - default: - return GE_NOTIMPLEMENTED; - } - if ((data->CallDivert->DType == GSM_CDV_AllTypes) && (data->CallDivert->CType == GSM_CDV_AllCalls)) - req[6] = 0x02; - - if (SM_SendMessage(state, length, P7110_MSG_DIVERT, req) != GE_NONE) return GE_NOTREADY; - return SM_WaitFor(state, data, P7110_MSG_DIVERT); -} - -static GSM_Error P7110_IncomingCallDivert(int messagetype, unsigned char *message, int length, GSM_Data *data) -{ - int i; - for (i = 0; i < length; i++) { - dprintf("%02x ", message[i]); - } - dprintf("\n"); - return GE_NONE; -} - static int GetMemoryType(GSM_MemoryType memory_type) { int result; @@ -1591,7 +1454,7 @@ static GSM_Error P7110_GetSpeedDial(GSM_Data *data, GSM_Statemachine *state) static GSM_Error P7110_GetSMSCenter(GSM_Data *data, GSM_Statemachine *state) { GSM_Error error; - unsigned char req[] = {FBUS_FRAME_HEADER, P7110_SUBSMS_GET_SMSC, 0x64, 0x00}; + unsigned char req[2000] = {FBUS_FRAME_HEADER, P7110_SUBSMS_GET_SMSC, 0x64, 0x00}; req[5] = data->MessageCenter->No; @@ -1604,7 +1467,7 @@ static GSM_Error P7110_GetSMSCenter(GSM_Data *data, GSM_Statemachine *state) static GSM_Error P7110_GetClock(char req_type, GSM_Data *data, GSM_Statemachine *state) { GSM_Error error; - unsigned char req[] = {FBUS_FRAME_HEADER, req_type}; + unsigned char req[2000] = {FBUS_FRAME_HEADER, req_type}; if (SM_SendMessage(state, 4, P7110_MSG_CLOCK, req) != GE_NONE) return GE_NOTREADY; error = SM_Block(state, data, P7110_MSG_CLOCK); @@ -1615,8 +1478,8 @@ static GSM_Error P7110_GetClock(char req_type, GSM_Data *data, GSM_Statemachine static GSM_Error P7110_GetCalendarNote(GSM_Data *data, GSM_Statemachine *state) { GSM_Error error = GE_NOTREADY; - unsigned char req[] = {FBUS_FRAME_HEADER, P7110_SUBCAL_GET_NOTE, 0x00, 0x00}; - unsigned char date[] = {FBUS_FRAME_HEADER, P7110_SUBCLO_GET_DATE}; + unsigned char req[2000] = {FBUS_FRAME_HEADER, P7110_SUBCAL_GET_NOTE, 0x00, 0x00}; + unsigned char date[2000] = {FBUS_FRAME_HEADER, P7110_SUBCLO_GET_DATE}; GSM_Data tmpdata; GSM_DateTime tmptime; diff --git a/common/phones/nokia.c b/common/phones/nokia.c index 5987a30..d026171 100644 --- a/common/phones/nokia.c +++ b/common/phones/nokia.c @@ -17,11 +17,8 @@ The various routines are called PNOK_(whatever). $Log$ - Revision 1.1.1.1 2001/11/25 21:59:13 short - :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001 - - Revision 1.2 2001/11/15 12:12:34 pkot - 7110 and 6110 series phones introduce as Nokia + Revision 1.1.1.2 2002/04/03 00:08:10 short + Found in "gnokii-working" directory, some November-patches version Revision 1.1 2001/02/21 19:57:07 chris More fiddling with the directory layout @@ -53,6 +50,6 @@ GSM_Error PNOK_GetManufacturer(char *manufacturer) { - strcpy (manufacturer, "Nokia"); + strncpy (manufacturer, "Nokia", PNOK_MAX_MANUFACTURER_LENGTH); return (GE_NONE); } diff --git a/configure.in b/configure.in index 87ea315..e755049 100644 --- a/configure.in +++ b/configure.in @@ -16,7 +16,7 @@ AC_PREFIX_DEFAULT("/usr/local") dnl ======================== Default setting CFLAGS="-O2 -Wall" -ALL_LINGUAS="cs de et fi nl sk pl it" +ALL_LINGUAS="cs de et fi nl sk pl it sl" dnl ======================== Checks for programs. AC_PROG_CC @@ -32,7 +32,7 @@ test x"$prefix" = xNONE && prefix="$ac_default_prefix" AC_ARG_ENABLE(debug, [ --enable-debug compile with debug code], - [ CFLAGS="-g -Wall" + [ CFLAGS="-ggdb3 -Wall" AC_DEFINE(DEBUG) debug="yes" ], [ debug="no" ] @@ -437,7 +437,7 @@ AC_PROG_GCC_TRADITIONAL AC_FUNC_MEMCMP AC_TYPE_SIGNAL AC_FUNC_STRFTIME -AC_CHECK_FUNCS(mktime select strdup strstr strtol strtok strsep snprintf) +AC_CHECK_FUNCS(mktime select strdup strstr strtol strtok strsep snprintf vsnprintf asprintf vasprintf) CFLAGS="$CFLAGS $NLS_CFLAGS" LIBS="$LIBS $NLS_LIBS" @@ -520,9 +520,7 @@ echo " Win32: $win32 Prefix: $prefix - Type '${MAKE}' for compilation or '${MAKE} makelib' when want to compile - all binaries with one shared library - - After it '${MAKE} install', '${MAKE} install-suid', '${MAKE} install-strip' - or '${MAKE} install-ss' to install gnokii. + Type '${MAKE}' for compilation and then '${MAKE} install', + '${MAKE} install-suid', '${MAKE} install-strip' or '${MAKE} install-ss' to + install gnokii. " diff --git a/do b/do new file mode 100755 index 0000000..742b7e9 --- /dev/null +++ b/do @@ -0,0 +1,13 @@ +#! /bin/sh + +enable_debug=1 + +exec 2>&1 +set -ex +rm -f config.cache +autoconf +# rm -f config.cache +./configure --without-x \ + `if [ -n "$enable_debug" ];then echo "--enable-debug --enable-xdebug";fi` +make clean +make diff --git a/getopt/Makefile b/getopt/Makefile index 037269d..02def81 100644 --- a/getopt/Makefile +++ b/getopt/Makefile @@ -20,7 +20,7 @@ distclean clean:: ##### # DO NOT DELETE THIS LINE -- make depend depends on it. - + ifeq (depend,$(wildcard depend)) include depend endif diff --git a/gnokii/Makefile b/gnokii/Makefile index 2018e7d..4719cc8 100644 --- a/gnokii/Makefile +++ b/gnokii/Makefile @@ -2,16 +2,20 @@ # # Makefile for the GNOKII tool suite. # +# Copyright (C) 1999 Hugh Blemings & Pavel Janík ml. +# 2000 Karel Zak +# TOPDIR=.. include $(TOPDIR)/Makefile.global CFLAGS += $(PTHREAD_CFLAGS) -LDLIBS += $(PTHREAD_LIBS) +LDFLAGS += $(PTHREAD_LIBS) ifdef XPM_LIBS - LDLIBS += $(XPM_LIBS) + LDFLAGS +=$(XPM_LIBS) + LDLIBS +=$(XPM_LIBS) endif OBJS = gnokii.o @@ -22,38 +26,27 @@ endif all: gnokii -gnokii: $(OBJS) $(TOPDIR)/common/COMMON.o $(TOPDIR)/common/gsm-filetypes.o - $(CC) $(LDFLAGS) $(TARGET_ARCH) $^ $(LOADLIBES) $(LDLIBS) -o $@ +gnokii: $(OBJS) $(TOPDIR)/common/libgnokii.a $(TOPDIR)/common/gsm-filetypes.o -$(TOPDIR)/common/COMMON.o: - $(MAKE) -C $(TOPDIR)/common COMMON.o +$(TOPDIR)/common/COMMON.o: + $(MAKE) -C $(TOPDIR)/common libgnokii.a -$(TOPDIR)/common/gsm-filetypes.o: +$(TOPDIR)/common/gsm-filetypes.o: $(MAKE) -C $(TOPDIR)/common gsm-filetypes.o $(TOPDIR)/getopt/libgetopt.a: $(MAKE) -C $(TOPDIR)/getopt -$(TOPDIR)/common/libmygnokii.so: - $(MAKE) -C $(TOPDIR)/common makelib - -gnokiilib: $(OBJS) $(TOPDIR)/common/libmygnokii.so - $(CC) $(LDFLAGS) $(TARGET_ARCH) $(OBJS) -L$(TOPDIR)/common -lmygnokii $(LOADLIBES) $(LDLIBS) -o $@ - -makelib: gnokiilib - clean: - $(RM) $(OBJS) *~ depend gnokii gnokiilib *.exe core *.bak + $(RM) $(OBJS) *~ depend gnokii *.exe core *.bak install: all $(INSTALL) -d $(bindir) $(INSTALL) gnokii $(bindir) - $(INSTALL) gnokiilib $(bindir)/gnokii install-strip: all $(INSTALL) -d $(bindir) $(INSTALL) -s gnokii $(bindir) - $(INSTALL) -s gnokiilib $(bindir)/gnokii @echo "done" install-suid: all @@ -62,7 +55,6 @@ install-suid: all fi $(INSTALL) -d $(bindir) $(INSTALL) -o root -g gnokii -m 0750 gnokii $(bindir) - $(INSTALL) -o root -g gnokii -m 0750 gnokiilib $(bindir)/gnokii @echo install-ss: all @@ -71,7 +63,6 @@ install-ss: all fi $(INSTALL) -d $(bindir) $(INSTALL) -o root -g gnokii -m 0750 -s gnokii $(bindir) - $(INSTALL) -o root -g gnokii -m 0750 -s gnokiilib $(bindir)/gnokii @echo depend dep: diff --git a/gnokii/gnokii.c b/gnokii/gnokii.c index 65d8227..472f4e5 100644 --- a/gnokii/gnokii.c +++ b/gnokii/gnokii.c @@ -1,699 +1,292 @@ /* + $Id$ + G N O K I I A Linux/Unix toolset and driver for Nokia mobile phones. + Copyright (C) 1999, 2000 Hugh Blemings & Pavel Janík ml. + Copyright (C) 2001 Pavel Machek + Copyright (C) 2001 Pawe³ Kot + Released under the terms of the GNU GPL, see file COPYING for more details. Mainline code for gnokii utility. Handles command line parsing and reading/writing phonebook entries and other stuff. -*/ - -#include -#include -#include -#include -#include -#include -#include - -#ifndef VC6 - #if defined(__svr4__) || defined(__FreeBSD__) - # include /* for bzero */ - #endif -#else - /* for VC6 make scripts save VERSION constant in mversion.h file */ - #include "mversion.h" -#endif - -#ifdef WIN32 - - #include + WARNING: this code is the test tool. Well, our test tool is now + really powerful and useful :-) - #include "misc_win32.h" - #include "getopt.h" + $Log$ + Revision 1.1.1.11 2002/04/03 00:08:17 short + Found in "gnokii-working" directory, some November-patches version - #define DEV_CONSOLE "CON:" + Revision 1.143 2001/09/14 13:30:07 pkot + Fixed bugs introduced during 0.3.3 merge -#else - - #include - #include - #include - #include - #include - #include + Revision 1.142 2001/09/14 13:02:03 pkot + Gnokii calendar changes from 0.3.3 - #define DEV_CONSOLE "/dev/tty" -#endif + Revision 1.141 2001/09/14 12:53:00 pkot + New preview logos. + Localization fixes. + Set valid operator on logos xgnokii screen. -#include "misc.h" -#include "gsm-common.h" -#include "gsm-api.h" -#include "gsm-networks.h" -#include "gsm-ringtones.h" -#include "gsm-bitmaps.h" -#include "gsm-wap.h" -#include "gsm-sms.h" -#include "gsm-datetime.h" -#include "gsm-phonebook.h" -#include "gsm-calendar.h" -#include "gsm-coding.h" -#include "newmodules/n6110.h" -#include "files/cfgreader.h" -#include "files/gsm-filetypes.h" -#include "gnokii.h" + Revision 1.140 2001/07/27 00:02:21 pkot + Generic AT support for the new structure (Manfred Jonsson) -#ifdef USE_NLS - #include -#endif + Revision 1.139 2001/07/01 23:16:45 pkot + Fixed a typo in gnokii.c avoiding saving logo (Jan Havelka) -char *model; /* Model from .gnokiirc file. */ -char *Port; /* Port from .gnokiirc file */ -char *Initlength; /* Init length from .gnokiirc file */ -char *Connection; /* Connection type from .gnokiirc file */ -char *SynchronizeTime; /* If we set date and time from computer to phone (from .gnokiirc file) */ -char *BinDir; /* Binaries directory from .gnokiirc file - not used here yet */ + Revision 1.138 2001/06/28 00:28:45 pkot + Small docs updates (Pawel Kot) -GSM_SMSMessage SMS[4]; - -char *GetProfileCallAlertString(int code) { - - switch (code) { - case PROFILE_CALLALERT_RINGING : return "Ringing"; - case PROFILE_CALLALERT_ASCENDING : return "Ascending"; - case PROFILE_CALLALERT_RINGONCE : return "Ring once"; - case PROFILE_CALLALERT_BEEPONCE : return "Beep once"; - case PROFILE_CALLALERT_CALLERGROUPS: return "Caller groups"; - case PROFILE_CALLALERT_OFF : return "Off"; - default : return "Unknown"; - } -} + Revision 1.137 2001/06/27 23:52:50 pkot + 7110/6210 updates (Marian Jancar) -char *GetProfileVolumeString(int code) { + Revision 1.136 2001/06/10 23:49:49 pkot + Small fixes to hide compilation warnings and allow gnokii.c to compile - switch (code) { - case PROFILE_VOLUME_LEVEL1 : return "Level 1"; - case PROFILE_VOLUME_LEVEL2 : return "Level 2"; - case PROFILE_VOLUME_LEVEL3 : return "Level 3"; - case PROFILE_VOLUME_LEVEL4 : return "Level 4"; - case PROFILE_VOLUME_LEVEL5 : return "Level 5"; - default : return "Unknown"; - } -} + Revision 1.135 2001/06/10 11:42:26 machek + Cleanup: some formating, made Statemachine global, converted to new + structure w.r.t. SMS-es -char *GetProfileKeypadToneString(int code) { + Revision 1.134 2001/05/24 20:47:30 chris + More updating of 7110 code and some of xgnokii_lowlevel changed over. - switch (code) { - case PROFILE_KEYPAD_OFF : return "Off"; - case PROFILE_KEYPAD_LEVEL1 : return "Level 1"; - case PROFILE_KEYPAD_LEVEL2 : return "Level 2"; - case PROFILE_KEYPAD_LEVEL3 : return "Level 3"; - default : return "Unknown"; - } -} + Revision 1.133 2001/04/23 17:20:01 pkot + Added possibility for viewing logos (currently nol and ngg) on console (Bartek Klepacz) -char *GetProfileMessageToneString(int code) { + Revision 1.132 2001/03/21 23:36:06 chris + Added the statemachine + This will break gnokii --identify and --monitor except for 6210/7110 - switch (code) { - case PROFILE_MESSAGE_NOTONE : return "No tone"; - case PROFILE_MESSAGE_STANDARD : return "Standard"; - case PROFILE_MESSAGE_SPECIAL : return "Special"; - case PROFILE_MESSAGE_BEEPONCE : return "Beep once"; - case PROFILE_MESSAGE_ASCENDING : return "Ascending"; - default : return "Unknown"; - } -} + Revision 1.131 2001/03/19 23:43:46 pkot + Solaris / BSD '#if defined' cleanup -char *GetProfileWarningToneString(int code) { + Revision 1.130 2001/03/13 01:23:18 pkot + Windows updates (Manfred Jonsson) - switch (code) { - case PROFILE_WARNING_OFF : return "Off"; - case PROFILE_WARNING_ON : return "On"; - default : return "Unknown"; - } -} + Revision 1.129 2001/03/13 01:21:39 pkot + *BSD updates (Bert Driehuis) -char *GetProfileOnOffString(int code) { + Revision 1.128 2001/03/08 00:49:06 pkot + Fixed bug (introduced by me) in getmemory function. Now gnokii.c should compile - switch (code) { - case 0x00 : return "Off"; - case 0x01 : return "On"; - default : return "Unknown"; - } -} + Revision 1.127 2001/03/08 00:18:13 pkot + Fixed writephonebook once again. Someone kick me please... -static char *GetProfileVibrationString(int code) -{ - switch (code) { - case PROFILE_VIBRATION_OFF: return "Off"; - case PROFILE_VIBRATION_ON: return "On"; - case PROFILE_VIBRATION_FIRST: return "Vibrate first"; - default: return "Unknown"; - } -} + Revision 1.126 2001/03/07 21:46:12 pkot + Fixed writephonebook patch -char BufferProfileGroups[90]; + Revision 1.125 2001/03/06 22:19:14 pkot + Cleanups and fixes in gnokii.c: + - reindenting + - fixed bug reported by Gabriele Zappi + - fixed small bugs introduced by Pavel Machek -char *GetProfileCallerGroups(int code) -{ - static char az_group_name[5][MAX_BITMAP_TEXT_LENGTH]; - static bool enteronce=false; - register int i; - GSM_Bitmap bitmap; + Revision 1.124 2001/02/28 21:42:00 machek + Possibility to force overwrite in --getsms (-F). Possibility to get + multiple files (use --getsms -f xyzzy%d), cleanup. - if( code == PROFILE_CALLERGROUPS_ALL ) - return _("All calls alert"); + Revision 1.123 2001/02/20 21:55:11 pkot + Small #include updates - if( !enteronce ) { - for(i=0;i<5;i++) az_group_name[i][0]='\0'; - enteronce=true; - } + Revision 1.122 2001/02/16 14:29:53 chris + Restructure of common/. Fixed a problem in fbus-phonet.c + Lots of dprintfs for Marcin + Any size xpm can now be loaded (eg for 7110 startup logos) + nk7110 code detects 7110/6210 and alters startup logo size to suit + Moved Marcin's extended phonebook code into gnokii.c - BufferProfileGroups[0]=0; - - for(i=0;i<5;i++) - { - int code2test; - char z_gtype[12]; - - code2test=(i==0) ? 1 : 2<<(i-1); - - if( code & code2test ) - { - if (!strcmp(az_group_name[i],"")) - { - if (GetModelFeature (FN_CALLERGROUPS)!=0) { - bitmap.type=GSM_CallerLogo; - bitmap.number=i; - strcpy(z_gtype,_("unknown")); - if (GSM->GetBitmap(&bitmap)==GE_NONE) - strcpy( az_group_name[i], bitmap.text ); - } - if ((!strcmp(az_group_name[i],""))) { - switch(i) { - case 0:strcpy(az_group_name[i],_("Family"));break; - case 1:strcpy(az_group_name[i],_("VIP"));break; - case 2:strcpy(az_group_name[i],_("Friends"));break; - case 3:strcpy(az_group_name[i],_("Colleagues"));break; - case 4:strcpy(az_group_name[i],_("Other"));break; - default:break; - } - } - } - strcpy(z_gtype,az_group_name[i]); - - if( strlen(BufferProfileGroups) ) strcat(BufferProfileGroups,"+"); - strcat(BufferProfileGroups, z_gtype); - } - - } + Revision 1.121 2001/02/06 21:15:35 chris + Preliminary irda support for 7110 etc. Not well tested! - return BufferProfileGroups; -} + Revision 1.120 2001/02/06 08:13:32 pkot + One more include in gnokii.c needed -char *print_error(GSM_Error e) -{ + Revision 1.119 2001/02/05 12:29:37 pkot + Changes needed to let unicode work -// case GE_DEVICEOPENFAILED: return "Couldn't open specified serial device."; -// case GE_UNKNOWNMODEL: return "Model specified isn't known/supported."; -// case GE_NOLINK: return "Couldn't establish link with phone."; -// case GE_TRYAGAIN: return "Try again."; -// case GE_INVALIDSMSLOCATION: return "Invalid SMS location."; -// case GE_INVALIDPHBOOKLOCATION: return "Invalid phonebook location."; -// case GE_INVALIDMEMORYTYPE: return "Invalid type of memory."; -// case GE_INVALIDSPEEDDIALLOCATION: return "Invalid speed dial location."; -// case GE_INVALIDCALNOTELOCATION: return "Invalid calendar note location."; -// case GE_INVALIDDATETIME: return "Invalid date, time or alarm specification."; -// case GE_EMPTYSMSLOCATION: return "SMS location is empty."; -// case GE_PHBOOKNAMETOOLONG: return "Phonebook name is too long."; -// case GE_PHBOOKNUMBERTOOLONG: return "Phonebook number is too long."; -// case GE_PHBOOKWRITEFAILED: return "Phonebook write failed."; -// case GE_SMSSENDOK: return "SMS was send correctly."; -// case GE_SMSSENDFAILED: return "SMS send fail."; -// case GE_SMSTOOLONG: return "SMS message too long."; -// case GE_NONEWCBRECEIVED: return "Attempt to read CB when no new CB received"; -// case GE_INTERNALERROR: return "Problem occured internal to model specific code."; -// case GE_NOTSUPPORTED: return "Function not supported by the phone"; -// case GE_BUSY: return "Command is still being executed."; -// case GE_USERCANCELED: return "User has cancelled the action."; -// case GE_UNKNOWN: return "Unknown error - well better than nothing!!"; -// case GE_MEMORYFULL: return "Memory is full"; -// case GE_LINEBUSY: return "Outgoing call requested reported line busy"; -// case GE_NOCARRIER: return "No Carrier error during data call setup ?"; - - switch (e) { - case GE_NONE: return "No error, done OK"; - case GE_INVALIDSECURITYCODE: return "Invalid Security code."; - case GE_NOTIMPLEMENTED: return "Called command is not implemented for the used model. Please contact marcin-wiacek@topnet.pl, if you want to help in implementing it"; - case GE_TIMEOUT: return "Command timed out."; - case GE_CANTOPENFILE: return "Can't open file with bitmap/ringtone"; - case GE_SUBFORMATNOTSUPPORTED: return "Subformat of file not supported"; - case GE_WRONGNUMBEROFCOLORS: return "Wrong number of colors in specified bitmap file (only 2 colors files supported)"; - case GE_WRONGCOLORS: return "Wrong colors in bitmap file"; - case GE_INVALIDIMAGESIZE: return "Invalid size of bitmap (in file, sms etc.)"; - case GE_INVALIDFILEFORMAT: return "Invalid format of file"; - case GE_TOOSHORT: return "File too short"; - case GE_INSIDEBOOKMARKSMENU: return "Inside WAP Bookmarks menu. Please leave it and try again"; - case GE_INVALIDBOOKMARKLOCATION: return "Invalid or empty WAP bookmark location"; - case GE_INSIDESETTINGSMENU: return "Inside WAP Settings menu. Please leave it and try again"; - case GE_INVALIDSETTINGSLOCATION: return "Invalid or empty WAP settings location"; - case GE_EMPTYSMSC: return "Empty SMSC number. Use --smsc"; - default: return "Unknown error."; - } -} + Revision 1.118 2001/02/01 15:17:33 pkot + Fixed --identify and added Manfred's manufacturer patch + Revision 1.117 2001/01/31 23:45:27 pkot + --identify should work ok now -GSM_Error GSM_ReadRingtoneFileOnConsole(char *FileName, GSM_Ringtone *ringtone) -{ - GSM_Error error; - - error=GSM_ReadRingtoneFile(FileName, ringtone); - - switch (error) { - case GE_CANTOPENFILE: - case GE_SUBFORMATNOTSUPPORTED: - fprintf(stderr, _("File \"%s\"\nError: %s\n"),FileName,print_error(error)); - break; - default: - break; - } - - return error; -} + Revision 1.116 2001/01/24 20:19:55 machek + Do not retry identification, if it is not implemented, it is bad idea. -GSM_Error GSM_SaveRingtoneFileOnConsole(char *FileName, GSM_Ringtone *ringtone) -{ - int confirm,confirm2; - char ans[4]; - struct stat buf; - GSM_Error error; + Revision 1.115 2001/01/22 01:25:10 hugh + Tweaks for 3810 series, datacalls seem to be broken so need to do + some more debugging... - /* Ask before overwriting */ - while (stat(FileName, &buf) == 0) { - - confirm=-1; - confirm2=-1; - - while (confirm < 0) { - fprintf(stderr, _("Saving ringtone. File \"%s\" exists. (O)verwrite, create (n)ew or (s)kip ? "),FileName); - GetLine(stdin, ans, 4); - if (!strcmp(ans, "O") || !strcmp(ans, "o")) confirm = 1; - if (!strcmp(ans, "N") || !strcmp(ans, "n")) confirm = 2; - if (!strcmp(ans, "S") || !strcmp(ans, "s")) return GE_USERCANCELED; - } - if (confirm==1) break; - if (confirm==2) { - while (confirm2 < 0) { - fprintf(stderr, _("Enter name of new file: ")); - GetLine(stdin, FileName, 50); - if (&FileName[0]==0) return GE_USERCANCELED; - confirm2=1; - } - } - } - - error=GSM_SaveRingtoneFile(FileName,ringtone); - - switch (error) { - case GE_CANTOPENFILE: fprintf(stderr, _("Failed to write file \"%s\"\n"),FileName); - break; - default: break; - } - - return error; -} + Revision 1.114 2001/01/17 02:54:55 chris + More 7110 work. Use with care! (eg it is not possible to delete phonebook entries) + I can now edit my phonebook in xgnokii but it is 'work in progress'. -GSM_Error GSM_ReadBitmapFileOnConsole(char *FileName, GSM_Bitmap *bitmap) -{ - GSM_Error error; - - error=GSM_ReadBitmapFile(FileName, bitmap); - - switch (error) { - case GE_CANTOPENFILE: - case GE_WRONGNUMBEROFCOLORS: - case GE_WRONGCOLORS: - case GE_INVALIDFILEFORMAT: - case GE_SUBFORMATNOTSUPPORTED: - case GE_TOOSHORT: - case GE_INVALIDIMAGESIZE: - fprintf(stderr, _("File \"%s\"\nError: %s\n"),FileName,print_error(error)); - break; - default: - break; - } - - return error; -} + Revision 1.113 2001/01/15 17:00:49 pkot + Initial keypress sequence support. Disable compilation warning -GSM_Error GSM_SaveBitmapFileOnConsole(char *FileName, GSM_Bitmap *bitmap) -{ - int confirm,confirm2; - char ans[4]; - struct stat buf; - GSM_Error error; + Revision 1.112 2001/01/12 14:09:13 pkot + More cleanups. This time mainly in the code. - /* Ask before overwriting */ - while (stat(FileName, &buf) == 0) { - - confirm=-1; - confirm2=-1; - - while (confirm < 0) { - fprintf(stderr, _("Saving logo. File \"%s\" exists. (O)verwrite, create (n)ew or (s)kip ? "),FileName); - GetLine(stdin, ans, 4); - if (!strcmp(ans, "O") || !strcmp(ans, "o")) confirm = 1; - if (!strcmp(ans, "N") || !strcmp(ans, "n")) confirm = 2; - if (!strcmp(ans, "S") || !strcmp(ans, "s")) return GE_USERCANCELED; - } - if (confirm==1) break; - if (confirm==2) { - while (confirm2 < 0) { - fprintf(stderr, _("Enter name of new file: ")); - GetLine(stdin, FileName, 50); - if (&FileName[0]==0) return GE_USERCANCELED; - confirm2=1; - } - } - } - - error=GSM_SaveBitmapFile(FileName,bitmap); - - switch (error) { - case GE_CANTOPENFILE: fprintf(stderr, _("Failed to write file \"%s\"\n"),FileName); - break; - default: break; - } - - return error; -} + Revision 1.111 2001/01/10 16:32:18 pkot + Documentation updates. + FreeBSD fix for 3810 code. + Added possibility for deleting SMS just after reading it in gnokii. + 2110 code updates. + Many cleanups. -/* mode == 0 -> overwrite - * mode == 1 -> ask - * mode == 2 -> append - */ -int GSM_SaveTextFileOnConsole(char *FileName, char *text, int mode) -{ - int confirm, confirm2; - char ans[4]; - struct stat buf; - int error; - - /* Ask before overwriting */ - if (mode==1) { - while (stat(FileName, &buf) == 0 && mode==1) { - - confirm=-1; - confirm2=-1; - - while (confirm < 0) { - fprintf(stderr, _("File \"%s\" exists. (O)verwrite, (a)ppend, create (n)ew or (s)kip ? "),FileName); - GetLine(stdin, ans, 4); - if (!strcmp(ans, "O") || !strcmp(ans, "o")) { - mode = 0; - confirm = 1; - } - if (!strcmp(ans, "A") || !strcmp(ans, "a")) { - mode = 2; - confirm = 1; - } - if (!strcmp(ans, "N") || !strcmp(ans, "n")) confirm=2; - if (!strcmp(ans, "S") || !strcmp(ans, "s")) return -1; - } - - if (confirm==2) { - while (confirm2 < 0) { - fprintf(stderr, _("Enter name of new file: ")); - GetLine(stdin, FileName, 50); - if (&FileName[0]==0) return -1; - mode=1; - confirm2=1; - } - } - - } - } - - error=GSM_SaveTextFile(FileName, text, mode); - - switch (error) { - case -1: fprintf(stderr, _("Failed to write file \"%s\"\n"), FileName); - break; - default: break; - } + Revision 1.110 2001/01/08 15:11:37 pkot + Documentation updates. + Fixed some bugs and removed FIXMEs. + We need to move some stuff from configure.in to aclocal.m4 - return error; -} + Revision 1.109 2000/12/29 15:39:07 pkot + Reverted a change in fbus-3810.c which broke compling with --enable-debug. + Small fixes in gnokii.c -int GSM_SendMultiPartSMSOnConsole(GSM_MultiSMSMessage *MultiSMS, int argnum, int argc, char *argv[], - bool unicode, bool profile, bool scale) { + Revision 1.108 2000/12/19 16:18:16 pkot + configure script updates and added shared function for configfile reading - int w,i; - struct option options[] = { - { "smscno", required_argument, NULL, '2'}, - { "smsc", required_argument, NULL, '1'}, - { "name", required_argument, NULL, '3'}, - { "unicode", no_argument, NULL, '4'}, - { "profilestyle", no_argument, NULL, '5'}, - { "scale", no_argument, NULL, '6'}, - { NULL, 0, NULL, 0 } - }; - - GSM_Error error; - - for (w=0;wnumber;w++) { - - if (argnum!=0) { - optarg = NULL; - - /* We check optional parameters from ... */ - optind = argnum; - - while ((i = getopt_long(argc, argv, "v:ds", options, NULL)) != -1) { - switch (i) { - - case '1': /* SMSC number */ - MultiSMS->SMS[w].MessageCenter.No = 0; - strcpy(MultiSMS->SMS[w].MessageCenter.Number,optarg); - break; - - case '2': /* SMSC number index in phone memory */ - MultiSMS->SMS[w].MessageCenter.No = atoi(optarg); - - if (MultiSMS->SMS[w].MessageCenter.No < 1 || MultiSMS->SMS[w].MessageCenter.No > 5) { - fprintf(stderr, _("Incorrect SMSC number with \"smscno\" option (can't be <1 and >5) !\n")); - GSM->Terminate(); - return -1; - } - break; - - case '3': /* Receiver/recipient */ - strncpy(MultiSMS->SMS[w].Destination,optarg,11); break; - - case '4': /* Unicode */ - if (unicode) break; - - case '5': /* Profile */ - if (profile) break; +*/ - case '6': /* Scale */ - if (scale) break; +#include "config.h" +#include "misc.h" - case 'v': /* Set validaty of SMS */ - MultiSMS->SMS[w].Validity = atoi(optarg); - break; +#include +#include +#include +#include +#if __unices__ +# include /* for memset */ +#endif +#include +#include +#include - case 'd': /* delivery report */ - MultiSMS->SMS[w].Type=GST_DR; - break; +#ifdef WIN32 - case 's': /* Set replying via the same SMSC */ - MultiSMS->SMS[w].ReplyViaSameSMSC = true; break; +#include +#define sleep(x) Sleep((x) * 1000) +#define usleep(x) Sleep(((x) < 1000) ? 1 : ((x) / 1000)) +#define stat _stat +#include "win32/getopt.h" - default: - fprintf(stderr,_("Unknown option number %i\n"),argc); - GSM->Terminate(); - return -1; +#else - } - } - } +#include +#include +#include +#include - error=GSM->SendSMSMessage(&MultiSMS->SMS[w]); +#endif - if (error == GE_SMSSENDOK) { - fprintf(stdout, _("SMS %i/%i sent OK !\n"),w+1,MultiSMS->number); - } else { - fprintf(stdout, _("SMS %i/%i, sending failed (%d, %s)\n"),w+1,MultiSMS->number, error,print_error(error)); - } +#ifdef USE_NLS +#include +#endif - } +#include "gsm-common.h" +#include "gsm-api.h" +#include "gsm-networks.h" +#include "cfgreader.h" +#include "gnokii.h" +#include "gsm-filetypes.h" +#include "gsm-bitmaps.h" +#include "gsm-ringtones.h" +#include "gsm-statemachine.h" - GSM->Terminate(); +char *model; /* Model from .gnokiirc file. */ +char *Port; /* Serial port from .gnokiirc file */ +char *Initlength; /* Init length from .gnokiirc file */ +char *Connection; /* Connection type from .gnokiirc file */ +char *BinDir; /* Binaries directory from .gnokiirc file - not used here yet */ +/* Local variables */ - return 0; +char *GetProfileCallAlertString(int code) +{ + switch (code) { + case PROFILE_CALLALERT_RINGING: return "Ringing"; + case PROFILE_CALLALERT_ASCENDING: return "Ascending"; + case PROFILE_CALLALERT_RINGONCE: return "Ring once"; + case PROFILE_CALLALERT_BEEPONCE: return "Beep once"; + case PROFILE_CALLALERT_CALLERGROUPS: return "Caller groups"; + case PROFILE_CALLALERT_OFF: return "Off"; + default: return "Unknown"; + } } -int GSM_SaveMultiPartSMSOnConsole(GSM_MultiSMSMessage *MultiSMS, int argnum, int argc, char *argv[], - bool inter, bool unicode, bool profile, bool scale) { - - int w,i; - - GSM_SMSMessage SMSold; - - struct option options[] = { - { "smscno", required_argument, NULL, '2'}, - { "smsc", required_argument, NULL, '1'}, - { "name", required_argument, NULL, '3'}, - { "unicode", no_argument, NULL, '4'}, - { "profilestyle", no_argument, NULL, '5'}, - { "scale", no_argument, NULL, '6'}, - { NULL, 0, NULL, 0 } - }; - - int interactive; - int confirm = -1; - char ans[8]; - - GSM_Error error; - - interactive = inter; - - for (w=0;wnumber;w++) { - - if (argnum!=0) { - optarg = NULL; - - /* We check optional parameters from ... */ - optind = argnum; - - while ((i = getopt_long(argc, argv, "risal:", options, NULL)) != -1) { - switch (i) { - - case '1': /* SMSC number */ - MultiSMS->SMS[w].MessageCenter.No = 0; - strcpy(MultiSMS->SMS[w].MessageCenter.Number,optarg); - break; - - case '2': /* SMSC number index in phone memory */ - MultiSMS->SMS[w].MessageCenter.No = atoi(optarg); - - if (MultiSMS->SMS[w].MessageCenter.No < 1 || MultiSMS->SMS[w].MessageCenter.No > 5) { - fprintf(stderr, _("Incorrect SMSC number with \"smscno\" option (can't be <1 and >5) !\n")); - GSM->Terminate(); - return -1; - } - break; - - case '3': /* Receiver/recipient */ - strncpy(MultiSMS->SMS[w].Destination,optarg,11); break; - - case '4': /* Unicode */ - if (unicode) break; - - case '5': /* Profile */ - if (profile) break; - - case '6': /* Scale */ - if (scale) break; - - case 'r': /* mark as read */ - MultiSMS->SMS[w].Status = GSS_SENTREAD; break; - - case 'i': /* Save into Inbox */ - MultiSMS->SMS[w].folder = GST_INBOX; break; - - case 's': /* Set replying via the same SMSC */ - MultiSMS->SMS[w].ReplyViaSameSMSC = true; break; - - case 'a': /* Ask before overwriting */ - interactive=true;break; - - case 'l': /* Specify location */ - MultiSMS->SMS[0].Location = atoi(optarg); break; - - default: - fprintf(stderr,_("Unknown option number %i\n"),argc); - GSM->Terminate(); - return -1; - } - } - } - - if (interactive && MultiSMS->SMS[0].Location!=0 && w==0) { - SMSold.Location=MultiSMS->SMS[0].Location; - error = GSM->GetSMSMessage(&SMSold); - switch (error) { - case GE_NONE: - fprintf(stderr, _("Message at specified location exists. ")); - while (confirm < 0) { - fprintf(stderr, _("Overwrite? (yes/no) ")); - GetLine(stdin, ans, 7); - if (!strcmp(ans, "yes")) confirm = 1; - if (!strcmp(ans, "no")) confirm = 0; - } - if (!confirm) { GSM->Terminate(); return 0; } - else break; - case GE_INVALIDSMSLOCATION: - fprintf(stderr, _("Invalid location\n")); - GSM->Terminate(); - return -1; - default: -/* FIXME: Remove this fprintf when the function is thoroughly tested */ -#ifdef DEBUG - fprintf(stderr, _("Location %d empty. Saving\n"), SMS[w].Location); -#endif - break; - } - } - - error=GSM->SaveSMSMessage(&MultiSMS->SMS[w]); - - if (error == GE_NONE) - fprintf(stdout, _("SMS %i/%i saved at location %i !\n"),w+1,MultiSMS->number,MultiSMS->SMS[w].MessageNumber); - else - fprintf(stdout, _("SMS %i/%i saving failed (%d, %s, location=%i)\n"), w+1, MultiSMS->number,error,print_error(error),MultiSMS->SMS[w].Location); - } +char *GetProfileVolumeString(int code) +{ + switch (code) { + case PROFILE_VOLUME_LEVEL1: return "Level 1"; + case PROFILE_VOLUME_LEVEL2: return "Level 2"; + case PROFILE_VOLUME_LEVEL3: return "Level 3"; + case PROFILE_VOLUME_LEVEL4: return "Level 4"; + case PROFILE_VOLUME_LEVEL5: return "Level 5"; + default: return "Unknown"; + } +} - GSM->Terminate(); +char *GetProfileKeypadToneString(int code) +{ + switch (code) { + case PROFILE_KEYPAD_OFF: return "Off"; + case PROFILE_KEYPAD_LEVEL1: return "Level 1"; + case PROFILE_KEYPAD_LEVEL2: return "Level 2"; + case PROFILE_KEYPAD_LEVEL3: return "Level 3"; + default: return "Unknown"; + } +} - return 0; +char *GetProfileMessageToneString(int code) +{ + switch (code) { + case PROFILE_MESSAGE_NOTONE: return "No tone"; + case PROFILE_MESSAGE_STANDARD: return "Standard"; + case PROFILE_MESSAGE_SPECIAL: return "Special"; + case PROFILE_MESSAGE_BEEPONCE: return "Beep once"; + case PROFILE_MESSAGE_ASCENDING: return "Ascending"; + default: return "Unknown"; + } } -void GSM_PlayRingtoneOnConsole(GSM_Ringtone *ringtone) +char *GetProfileWarningToneString(int code) { - int i; -#ifdef VC6 - char mychar; -#endif + switch (code) { + case PROFILE_WARNING_OFF: return "Off"; + case PROFILE_WARNING_ON: return "On"; + default: return "Unknown"; + } +} - for (i=0;iNrNotes;i++) { -#ifdef VC6 - if (_kbhit()) { - mychar=_getch(); - break; - } -#endif - GSM_PlayOneNote (ringtone->notes[i]); - } - GSM->PlayTone(255*255,0); +char *GetProfileVibrationString(int code) +{ + switch (code) { + case PROFILE_VIBRATION_OFF: return "Off"; + case PROFILE_VIBRATION_ON: return "On"; + default: return "Unknown"; + } } /* This function shows the copyright and some informations usefull for debugging. */ + int version(void) { - - fprintf(stdout, _("GNOKII Version %s\n" -"Copyright (C) Hugh Blemings , 1999, 2000\n" -"Copyright (C) Pavel Janík ml. , 1999, 2000\n" -"Built %s %s for %s on %s \n"), VERSION, __TIME__, __DATE__, model, Port); - - return 0; + fprintf(stdout, _("GNOKII Version %s\n" + "Copyright (C) Hugh Blemings , 1999, 2000\n" + "Copyright (C) Pavel Janík ml. , 1999, 2000\n" + "Copyright (C) Pavel Machek , 2001\n" + "Copyright (C) Pawe³ Kot , 2001\n" + "gnokii is free software, covered by the GNU General Public License, and you are\n" + "welcome to change it and/or distribute copies of it under certain conditions.\n" + "There is absolutely no warranty for gnokii. See GPL for details.\n" + "Built %s %s for %s on %s \n"), VERSION, __TIME__, __DATE__, model, Port); + return 0; } /* The function usage is only informative - it prints this program's usage and @@ -701,6780 +294,1824 @@ int version(void) int usage(void) { - - fprintf(stdout, _(" usage: gnokii [--help|--monitor [-noloop|-nl]|--version]\n" -" gnokii --getmemory memory_type [start [end]] [-short|-v30|-v21|-v]\n" -" gnokii --writephonebook [-i]\n" -" gnokii --sendphonebookentry destination memory_type location\n" -" [--smsc message_center_number] [--smscno message_center_index]\n" -" [-s] [-v n] [-d]\n" -" gnokii --savephonebookentry memory_type location\n" -" [--smsc message_center_number] [--smscno message_center_index]\n" -" [-r] [-i] [-s] [-a] [--name name]\n" -" gnokii --getvoicemailbox\n" -" gnokii --getspeeddial number\n" -" gnokii --setspeeddial number memory_type location\n\n" - -" gnokii --getsms memory_type start [end] [-f file]\n" -" gnokii --getsmsstatus\n" -" gnokii --getsmsfolders\n" -" gnokii --deletesms memory_type start [end]\n" -" gnokii --sendsms destination [--smsc message_center_number |\n" -" --smscno message_center_index] [--long n] [-s] [-C n]\n" -" [--enablevoice|--disablevoice|--enablefax|--disablefax|\n" -" --enableemail|--disableemail|--void][--unicode][-v n][-d]\n" -" gnokii --savesms destination|\"\" [--smsc \n" -" message_center_number] [--smscno message_center_index]\n" -" [--long n] [-r] [-i] [-s][-C n][-a][-l][F n][--smsname name]\n" -" [--enablevoice|--disablevoice|--enablefax|--disablefax|\n" -" --enableemail|--disableemail|--void|--hang|--bug][--unicode]\n" -" gnokii --receivesms\n" -" gnokii --getsmsc message_center_number\n" -" gnokii --renamesmsc number new_name\n\n" - -" gnokii --setdatetime [YYYY [MM [DD [HH [MM]]]]]\n" -" gnokii --getdatetime\n" -" gnokii --setalarm HH MM\n" -" gnokii --getalarm\n\n" - -" gnokii --getcalendarnote { start end [-v30|-v10] | --short|-s }\n" -" gnokii --writecalendarnote vcardfile number\n" -" gnokii --deletecalendarnote index\n" -" gnokii --sendcalendarnote destination vcardfile number\n" -" [--smsc message_center_number] [--smscno message_center_index]\n" -" [-s] [-v n] [-d]\n" -" gnokii --savecalendarnote vcardfile number\n" -" [--smsc message_center_number] [--smscno message_center_index]\n" -" [-r] [-i] [-s] [-a] [--name name]\n\n" - -" gnokii --netmonitor {reset|off|field|devel|next|nr}\n" -" gnokii --nm_collect screen1|-d [screen2|-d]...\n" -" gnokii --netmonitordata [-S file] [-I file] [-h] [-n n] [-ts n][-tm n]\n" -" [-fs str] [-ls str] FLD1:FLD2:FLDn:... \n" -" (see files netmonitordata_????_??? for details)\n\n" - -" gnokii --bitmapconvert source destination\n" -" gnokii --bitmapconvert source destination op|7110op [network code]\n" -" gnokii --bitmapconvert source destination caller [caller group number]\n" -" gnokii --bitmapconvert source destination\n" -" startup|7110startup|6210startup\n" -" gnokii --bitmapconvert source destination picture\n" -" gnokii --showbitmap logofile\n" -" gnokii --sendlogo op destination logofile network_code\n" -" [--smsc message_center_number] [--smscno message_center_index]\n" -" [-s] [-v n] [-d]\n" -" gnokii --sendlogo picture destination logofile text\n" -" [--smsc message_center_number] [--smscno message_center_index]\n" -" [-s] [-v n] [-d] [--unicode]\n" -" gnokii --sendlogo screensaver destination logofile\n" -" [--smsc message_center_number] [--smscno message_center_index]\n" -" [-s] [-v n] [-d]\n" -" gnokii --sendlogo caller destination logofile\n" -" [--smsc message_center_number] [--smscno message_center_index]\n" -" [-s] [-v n] [-d]\n" -" gnokii --savelogo op logofile network_code\n" -" [--smsc message_center_number] [--smscno message_center_index]\n" -" [-r] [-i] [-s] [-a] [-l] [--name name]\n" -" gnokii --savelogo picture logofile text\n" -" [--smsc message_center_number] [--smscno message_center_index]\n" -" [-r] [-i] [-s] [-a] [-l] [--name name] [--unicode]\n" -" gnokii --savelogo screensaver logofile\n" -" [--smsc message_center_number] [--smscno message_center_index]\n" -" [-r] [-i] [-s] [-a] [-l] [--name name]\n" -" gnokii --savelogo caller logofile\n" -" [--smsc message_center_number] [--smscno message_center_index]\n" -" [-r] [-i] [-s] [-a] [-l] [--name name]\n" -" gnokii --setlogo op|7110op [logofile] [network code]\n" -" gnokii --setlogo startup|7110startup|6210startup [logofile]\n" -" gnokii --setlogo startup 1|2|3\n" -" gnokii --setlogo caller [logofile] [caller group number] [group name]\n" -" gnokii --setlogo picture [logofile] [number] [text] [sender]\n" -" gnokii --setlogo {dealer|text} [text]\n" -" gnokii --getlogo op|7110op [logofile] [network code]\n" -" gnokii --getlogo startup|7110startup|6210startup [logofile]\n" -" gnokii --getlogo caller [logofile][caller group number]\n" -" gnokii --getlogo picture [logofile][number]\n" -" gnokii --getlogo {dealer|text}\n\n" - -" gnokii --sendringtone destination ringtonefile\n" -" [--smsc message_center_number] [--smscno message_center_index]\n" -" [-s] [-v n] [-d] [--scale] [--profilestyle]\n" -" gnokii --saveringtone ringtonefile\n" -" [--smsc message_center_number] [--smscno message_center_index]\n" -" [-r] [-i] [-s] [-a] [--name name] [--scale] [--profilestyle]\n" -" gnokii --setringtone ringtonefile [location]\n" -" gnokii --getringtone ringtonefile [location]\n" -" gnokii --ringtoneconvert source destination\n" -" gnokii --binringtoneconvert source destination\n" -" gnokii --playringtone ringtonefile\n" -" gnokii --composer ringtonefile\n" -" gnokii --allringtones\n\n" - -" gnokii --getprofile [number]\n" -" gnokii --setprofile number feature value\n" -" gnokii --sendprofile destination profile_name ringtonefile\n" -" picturefile [--smsc message_center_number]\n" -" [--smscno message_center_index] [-s] [-v n] [-d] [--scale]\n\n" - -" gnokii --reset [soft|hard]\n" -" gnokii --dialvoice number\n" -" gnokii --cancelcall\n" -" gnokii --displayoutput\n" -" gnokii --presskeysequence sequence\n" -" gnokii --backupsettings file\n" -" gnokii --restoresettings file\n" -" gnokii --getphoneprofile\n" -" gnokii --setphoneprofile feature value\n" -" gnokii --getoperatorname\n" -" gnokii --setoperatorname code name\n" -" gnokii --senddtmf string\n" -" gnokii --divert register|enable|query|disable|erasure\n" -" all|busy|noans|outofreach all|voice|fax|data\n" -" [number timeout]\n\n" - -" gnokii --phonetests\n" -" gnokii --simlock\n" -" gnokii --getdisplaystatus\n" -" gnokii --identify\n\n" - -" gnokii --getwapbookmark location\n" -" gnokii --setwapbookmark title url [location]\n" -" gnokii --sendwapbookmark location destination\n" -" [--smsc message_center_number] [--smscno message_center_index]\n" -" [-s] [-v n] [-d]\n" -" gnokii --savewapbookmark location\n" -" [--smsc message_center_number] [--smscno message_center_index]\n" -" [-r] [-i] [-s] [-a] [-l] [--name name]\n" -" gnokii --getwapsettings location\n" -" gnokii --savewapsettings location\n" -" [--smsc message_center_number] [--smscno message_center_index]\n" -" [-r] [-i] [-s] [-a] [-l] [--name name]\n" -" gnokii --sendwapsettings location destination\n" -" [--smsc message_center_number] [--smscno message_center_index]\n" -" [-s] [-v n] [-d]\n" - )); - + fprintf(stdout, _(" usage: gnokii [--help|--monitor|--version]\n" + " gnokii --getmemory memory_type start [end]\n" + " gnokii --writephonebook [-i]\n" + " gnokii --getspeeddial number\n" + " gnokii --setspeeddial number memory_type location\n" + " gnokii --getsms memory_type start [end] [-f file] [-F file] [-d]\n" + " gnokii --deletesms memory_type start [end]\n" + " gnokii --sendsms destination [-r] [-C n] [-v n]\n" + " [--longtext|--longudh] [--udh] [-8]\n" + " [--smsc message_center_number | --smscno message_center_index]\n" + " gnokii --savesms [-m] [-l n] [-i]\n" + " gnokii --getsmsc message_center_number\n" + " gnokii --setdatetime [YYYY [MM [DD [HH [MM]]]]]\n" + " gnokii --getdatetime\n" + " gnokii --setalarm HH MM\n" + " gnokii --getalarm\n" + " gnokii --dialvoice number\n" + " gnokii --getcalendarnote start [end] [-v]\n" + " gnokii --writecalendarnote vcardfile number\n" + " gnokii --deletecalendarnote start [end]\n" + " gnokii --getdisplaystatus\n" + " gnokii --netmonitor {reset|off|field|devel|next|nr}\n" + " gnokii --identify\n" + " gnokii --senddtmf string\n" + " gnokii --sendlogo {caller|op} destination logofile [network code]\n" + " [--smsc message_center_number | --smscno message_center_index]\n" + " gnokii --sendringtone destination rtttlfile\n" + " [--smsc message_center_number | --smscno message_center_index]\n" + " gnokii --setlogo op [logofile] [network code]\n" + " gnokii --setlogo startup [logofile]\n" + " gnokii --setlogo caller [logofile] [caller group number] [group name]\n" + " gnokii --setlogo {dealer|text} [text]\n" + " gnokii --getlogo op [logofile] [network code]\n" + " gnokii --getlogo startup [logofile] [network code]\n" + " gnokii --getlogo caller [logofile][caller group number][network code]\n" + " gnokii --getlogo {dealer|text}\n" + " gnokii --viewlogo logofile\n" + " gnokii --setringtone rtttlfile\n" + " gnokii --reset [soft|hard]\n" + " gnokii --getprofile [number]\n" + " gnokii --displayoutput\n" + " gnokii --keysequence\n" + )); #ifdef SECURITY - fprintf(stdout, _( -"\n gnokii --entersecuritycode PIN|PIN2|PUK|PUK2\n" -" gnokii --getsecuritycodestatus\n" -" gnokii --getsecuritycode PIN|PIN2|PUK|PUK2|SecurityCode\n" -" gnokii --geteeprom\n" -" gnokii --resetphonesettings\n" - )); + fprintf(stdout, _( + " gnokii --entersecuritycode PIN|PIN2|PUK|PUK2\n" + " gnokii --getsecuritycodestatus\n" + )); #endif - -#ifdef DEBUG - fprintf(stdout, _( -" gnokii --sniff [port]\n" -" gnokii --decodefile file\n" -" gnokii --getbinringfromfile file name offset file2\n" - )); -#endif - - return 0; + exit(-1); } /* fbusinit is the generic function which waits for the FBUS link. The limit is 10 seconds. After 10 seconds we quit. */ +static GSM_Statemachine State; +static GSM_Data data; + void fbusinit(void (*rlp_handler)(RLP_F96Frame *frame)) { + int count=0; + GSM_Error error; + GSM_ConnectionType connection=GCT_Serial; - int count=0; - GSM_Error error; + GSM_DataClear(&data); -#ifndef WIN32 - if (strcmp(GetMygnokiiVersion(),VERSION)!=0) - fprintf(stderr,_("WARNING: version of installed libmygnokii.so (%s) is different to version of gnokii (%s)\n"),GetMygnokiiVersion(),VERSION); -#endif + if (!strcmp(Connection, "infrared")) connection=GCT_Infrared; + if (!strcmp(Connection, "irda")) connection=GCT_Irda; + + /* Initialise the code for the GSM interface. */ + + error = GSM_Initialise(model, Port, Initlength, connection, rlp_handler, &State); - /* Initialise the code for the GSM interface. */ - error = GSM_Initialise(model, Port, Initlength, GetConnectionTypeFromString(Connection), rlp_handler, SynchronizeTime); + if (error != GE_NONE) { + fprintf(stderr, _("GSM/FBUS init failed! (Unknown model ?). Quitting.\n")); + exit(-1); + } - if (error != GE_NONE) { - fprintf(stderr, _("GSM/FBUS init failed! (Unknown model ?). Quitting.\n")); - exit(-1); - } + /* First (and important!) wait for GSM link to be active. We allow 10 + seconds... */ - /* First (and important!) wait for GSM link to be active. We allow 10 - seconds... */ - while (count++ < 200 && *GSM_LinkOK == false) - usleep(50000); + while (count++ < 200 && *GSM_LinkOK == false) + usleep(50000); - if (*GSM_LinkOK == false) { - fprintf (stderr, _("Hmmm... GSM_LinkOK never went true. Quitting.\n")); - exit(-1); - } + if (*GSM_LinkOK == false) { + fprintf (stderr, _("Hmmm... GSM_LinkOK never went true. Quitting.\n")); + exit(-1); + } } /* This function checks that the argument count for a given options is withing an allowed range. */ - int checkargs(int opt, struct gnokii_arg_len gals[], int argc) { + int i; - int i; - - /* Walk through the whole array with options requiring arguments. */ - - for(i = 0;!(gals[i].gal_min == 0 && gals[i].gal_max == 0); i++) { - - /* Current option. */ - - if(gals[i].gal_opt == opt) { - - /* Argument count checking. */ - - if(gals[i].gal_flags == GAL_XOR) { - if(gals[i].gal_min == argc || gals[i].gal_max == argc) return 0; - } - else { - if(gals[i].gal_min <= argc && gals[i].gal_max >= argc) return 0; - } - - return 1; + /* Walk through the whole array with options requiring arguments. */ + for (i = 0; !(gals[i].gal_min == 0 && gals[i].gal_max == 0); i++) { - } + /* Current option. */ + if (gals[i].gal_opt == opt) { - } + /* Argument count checking. */ + if (gals[i].gal_flags == GAL_XOR) { + if (gals[i].gal_min == argc || gals[i].gal_max == argc) + return 0; + } else { + if (gals[i].gal_min <= argc && gals[i].gal_max >= argc) + return 0; + } - /* We do not have options without arguments in the array, so check them. */ + return 1; + } + } - if (argc==0) return 0; - else return 1; + /* We do not have options without arguments in the array, so check them. */ + if (argc == 0) return 0; + else return 1; } /* Main function - handles command line arguments, passes them to separate functions accordingly. */ - int main(int argc, char *argv[]) { + int c, i, rc = -1; + int nargc = argc-2; + char **nargv; - int c, i, rc = -1; - int nargc = argc-2; - char **nargv; - - /* Every option should be in this array. */ - - static struct option long_options[] = - { - - { "help", no_argument, NULL, OPT_HELP },// Display usage. - { "version", no_argument, NULL, OPT_VERSION },// Display version and build information. - { "getsmsfolders", no_argument, NULL, OPT_GETSMSFOLDERS },// Gets SMS folders - { "getsmsstatus", no_argument, NULL, OPT_GETSMSSTATUS },// Get SMS Folder Status - { "identify", no_argument, NULL, OPT_IDENTIFY },// Identify - { "pmon", no_argument, NULL, OPT_PMON },// For development purposes: run in passive monitoring mode - { "foogle", no_argument, NULL, OPT_FOOGLE },// For development purposes: insert you function calls here - { "getdatetime", no_argument, NULL, OPT_GETDATETIME },// Get date and time mode - { "getalarm", no_argument, NULL, OPT_GETALARM },// Get alarm - { "cancelcall", no_argument, NULL, OPT_CANCELCALL },// Cancel Call - { "getdisplaystatus", no_argument, NULL, OPT_GETDISPLAYSTATUS },// Get display status mode - { "allringtones", no_argument, NULL, OPT_ALLRINGTONES },/* Displays names of available ringtones */ - { "displayoutput", no_argument, NULL, OPT_DISPLAYOUTPUT },/* Show texts from phone's display */ - { "getphoneprofile", no_argument, NULL, OPT_GETPHONEPROFILE },/* Get/Set phone profile settings */ - { "getoperatorname", no_argument, NULL, OPT_GETOPERATORNAME },/* Get downloaded operator name */ - { "getvoicemailbox", no_argument, NULL, OPT_GETVOICEMAILBOX },/* Gets voice mailbox number */ - { "phonetests", no_argument, NULL, OPT_PHONETESTS }, - { "simlockinfo", no_argument, NULL, OPT_SIMLOCKINFO }, - { "receivesms", no_argument, NULL, OPT_RECEIVESMS }, - { "setoperatorname", optional_argument, NULL, OPT_SETOPERATORNAME },/* Set downloaded operator name */ - { "setdatetime", optional_argument, NULL, OPT_SETDATETIME },// Set date and time - { "writephonebook", optional_argument, NULL, OPT_WRITEPHONEBOOK },// Write phonebook (memory) mode - { "reset", optional_argument, NULL, OPT_RESET },// Resets the phone - { "monitor", optional_argument, NULL, OPT_MONITOR },// Monitor mode - { "setlogo", optional_argument, NULL, OPT_SETLOGO },// Set logo - { "getprofile", optional_argument, NULL, OPT_GETPROFILE },// Show profile - { "setalarm", required_argument, NULL, OPT_SETALARM },// Set alarm - { "dialvoice", required_argument, NULL, OPT_DIALVOICE },// Voice call mode - { "getcalendarnote", required_argument, NULL, OPT_GETCALENDARNOTE },// Get calendar note mode - { "writecalendarnote", required_argument, NULL, OPT_WRITECALENDARNOTE},// Write calendar note mode - { "sendcalendarnote", required_argument, NULL, OPT_SENDCALENDARNOTE }, - { "savecalendarnote", required_argument, NULL, OPT_SAVECALENDARNOTE }, - { "sendphonebookentry", required_argument, NULL, OPT_SENDPHONEBOOKENTRY}, - { "savephonebookentry", required_argument, NULL, OPT_SAVEPHONEBOOKENTRY}, - { "deletecalendarnote", required_argument, NULL, OPT_DELCALENDARNOTE },// Delete calendar note mode - { "getmemory", required_argument, NULL, OPT_GETMEMORY },// Get memory mode - { "getspeeddial", required_argument, NULL, OPT_GETSPEEDDIAL },// Get speed dial mode - { "setspeeddial", required_argument, NULL, OPT_SETSPEEDDIAL },// Set speed dial mode - { "getsms", required_argument, NULL, OPT_GETSMS },// Get SMS message mode - { "deletesms", required_argument, NULL, OPT_DELETESMS },// Delete SMS message mode - { "sendsms", required_argument, NULL, OPT_SENDSMS },// Send SMS message mode - { "savesms", required_argument, NULL, OPT_SAVESMS },// Save SMS message mode - { "sendlogo", required_argument, NULL, OPT_SENDLOGO },// Send logo as SMS message mode - { "savelogo", required_argument, NULL, OPT_SAVELOGO },// Save logo on SIM - { "sendringtone", required_argument, NULL, OPT_SENDRINGTONE },// Send ringtone as SMS message - { "saveringtone", required_argument, NULL, OPT_SAVERINGTONE },// Saves ringtone on SIM - { "setringtone", required_argument, NULL, OPT_SETRINGTONE },// Set ringtone - { "getringtone", required_argument, NULL, OPT_GETRINGTONE },// Get bin/normal ringtone - { "presskeysequence", required_argument, NULL, OPT_PRESSKEYSEQUENCE },/* Presses keys in phone's display */ - { "getsmsc", required_argument, NULL, OPT_GETSMSC },// Get SMS center number mode - { "renamesmsc", required_argument, NULL, OPT_RENAMESMSC },// Rename SMSC - { "netmonitor", required_argument, NULL, OPT_NETMONITOR },// NetMonitor mode - { "senddtmf", required_argument, NULL, OPT_SENDDTMF },// Send DTMF sequence - { "getlogo", required_argument, NULL, OPT_GETLOGO },// Get logo - { "setprofile", required_argument, NULL, OPT_SETPROFILE },// Set profile feature - { "sendprofile", required_argument, NULL, OPT_SENDPROFILE },// Send profile via SMS - { "setphoneprofile", required_argument, NULL, OPT_SETPHONEPROFILE },/* Get/Set phone profile settings */ - { "restoresettings", required_argument, NULL, OPT_RESTORESETTINGS },//Restore various settings from one file - { "backupsettings", required_argument, NULL, OPT_BACKUPSETTINGS },//Backup various settings to one file - { "playringtone", required_argument, NULL, OPT_PLAYRINGTONE },/* Plays ringtones */ - { "composer", required_argument, NULL, OPT_COMPOSER },/* Shows ringtone like in Nokia Composer */ - { "ringtoneconvert", required_argument, NULL, OPT_RINGTONECONVERT },/* Convert ringtone files */ - { "binringtoneconvert", required_argument, NULL, OPT_BINRINGTONECONVERT},/* Convert binary ringtone files */ - { "bitmapconvert", required_argument, NULL, OPT_BITMAPCONVERT },/* Convert bitmap files */ - { "showbitmap", required_argument, NULL, OPT_SHOWBITMAP }, - { "nm_collect", required_argument, NULL, OPT_NM_COLLECT },// NetMonitor periodical data collection mode (newbiee) - { "netmonitordata", required_argument, NULL, OPT_NETMONITORDATA },// NetMonitor periodical data collection mode (advanced) - { "getwapbookmark", required_argument, NULL, OPT_GETWAPBOOKMARK }, - { "setwapbookmark", required_argument, NULL, OPT_SETWAPBOOKMARK }, - { "savewapbookmark", required_argument, NULL, OPT_SAVEWAPBOOKMARK }, - { "savewapsettings", required_argument, NULL, OPT_SAVEWAPSETTINGS }, - { "sendwapsettings", required_argument, NULL, OPT_SENDWAPSETTINGS }, - { "sendwapbookmark", required_argument, NULL, OPT_SENDWAPBOOKMARK }, - { "getwapsettings", required_argument, NULL, OPT_GETWAPSETTINGS }, - { "divert", required_argument, NULL, OPT_DIVERT }, - -#ifdef SECURITY - { "entersecuritycode", required_argument, NULL, OPT_ENTERSECURITYCODE },// Enter Security Code mode - { "getsecuritycode", required_argument, NULL, OPT_GETSECURITYCODE },// Get Security Code - { "getsecuritycodestatus",no_argument, NULL, OPT_GETSECURITYCODESTATUS},// Get Security Code status - { "geteeprom", no_argument, NULL, OPT_GETEEPROM },// Gets EEPROM - { "resetphonesettings", no_argument, NULL, OPT_RESETPHONESETTINGS },// Reset phone settings - { "setsimlock", no_argument, NULL, OPT_SETSIMLOCK },// Sets simlock -#endif - -#ifdef DEBUG - { "sniff", optional_argument, NULL, OPT_SNIFFER },// Will show datas from port - { "decodefile", required_argument, NULL, OPT_DECODEFILE },//decode input file - { "getbinringfromfile", required_argument, NULL, OPT_GETBINRINGFROMFILE }, -#endif - - { 0, 0, 0, 0}, - }; + /* Every option should be in this array. */ + static struct option long_options[] = + { + /* FIXME: these comments are nice, but they would be more usefull as docs for the user */ + // Display usage. + { "help", no_argument, NULL, OPT_HELP }, - /* Every command which requires arguments should have an appropriate entry - in this array. */ - - struct gnokii_arg_len gals[] = - { + // Display version and build information. + { "version", no_argument, NULL, OPT_VERSION }, - { OPT_MONITOR, 0, 1, 0 }, + // Monitor mode + { "monitor", no_argument, NULL, OPT_MONITOR }, #ifdef SECURITY - { OPT_ENTERSECURITYCODE, 1, 1, 0 }, - { OPT_GETSECURITYCODE, 1, 1, 0 }, -#endif -#ifdef DEBUG - { OPT_SNIFFER, 0, 1, 0 }, - { OPT_DECODEFILE, 1, 1, 0 }, - { OPT_GETBINRINGFROMFILE,4, 4, 0 }, -#endif + // Enter Security Code mode + { "entersecuritycode", required_argument, NULL, OPT_ENTERSECURITYCODE }, - { OPT_SETDATETIME, 0, 5, 0 }, - { OPT_BACKUPSETTINGS, 1, 1, 0 }, - { OPT_RESTORESETTINGS, 1, 1, 0 }, - { OPT_SETALARM, 2, 2, 0 }, - { OPT_DIALVOICE, 1, 1, 0 }, - { OPT_GETCALENDARNOTE, 1, 3, 0 }, - { OPT_WRITECALENDARNOTE, 2, 2, 0 }, - { OPT_SAVECALENDARNOTE, 2, 9, 0 }, - { OPT_SENDCALENDARNOTE, 3, 9, 0 }, - { OPT_SAVEPHONEBOOKENTRY,2, 9, 0 }, - { OPT_SENDPHONEBOOKENTRY,3, 9, 0 }, - { OPT_DELCALENDARNOTE, 1, 1, 0 }, - { OPT_GETMEMORY, 2, 4, 0 }, - { OPT_GETSPEEDDIAL, 1, 1, 0 }, - { OPT_SETSPEEDDIAL, 3, 3, 0 }, - { OPT_GETSMS, 2, 5, 0 }, - { OPT_DELETESMS, 2, 3, 0 }, - { OPT_SENDSMS, 1,10, 0 }, - { OPT_SAVESMS, 1,11, 0 }, - { OPT_SENDLOGO, 3, 9, 0 }, - { OPT_SAVELOGO, 2,10, 0 }, - { OPT_SENDRINGTONE, 2, 7, 0 }, - { OPT_SAVERINGTONE, 1, 9, 0 }, - { OPT_GETSMSC, 1, 1, 0 }, - { OPT_RENAMESMSC, 2, 2, 0 }, - { OPT_NETMONITOR, 1, 1, 0 }, - { OPT_SENDDTMF, 1, 1, 0 }, - { OPT_SETLOGO, 1, 5, 0 }, - { OPT_GETLOGO, 1, 4, 0 }, - { OPT_SETRINGTONE, 1, 3, 0 }, - { OPT_GETRINGTONE, 1, 2, 0 }, - { OPT_PRESSKEYSEQUENCE, 1, 1, 0 }, - { OPT_RESET, 0, 1, 0 }, - { OPT_GETPROFILE, 0, 1, 0 }, - { OPT_SETPROFILE, 3, 3, 0 }, - { OPT_SENDPROFILE, 4,10, 0 }, - { OPT_WRITEPHONEBOOK, 0, 1, 0 }, - { OPT_PLAYRINGTONE, 1, 1, 0 }, - { OPT_COMPOSER, 1, 1, 0 }, - { OPT_RINGTONECONVERT, 2, 2, 0 }, - { OPT_BINRINGTONECONVERT,2, 2, 0 }, - { OPT_BITMAPCONVERT, 2, 4, 0 }, - { OPT_SHOWBITMAP, 1, 1, 0 }, - { OPT_SETOPERATORNAME, 0, 2, 0 }, - { OPT_SETPHONEPROFILE, 2, 2, 0 }, - { OPT_NM_COLLECT, 1, MAX_NM_COLLECT, 0 }, - { OPT_NETMONITORDATA, 0,99, 0 }, - { OPT_GETWAPBOOKMARK, 1, 1, 0 }, - { OPT_SETWAPBOOKMARK, 2, 3, 0 }, - { OPT_SAVEWAPBOOKMARK, 1, 9, 0 }, - { OPT_SENDWAPBOOKMARK, 2, 9, 0 }, - { OPT_GETWAPSETTINGS, 1, 1, 0 }, - { OPT_SAVEWAPSETTINGS, 1, 9, 0 }, - { OPT_SENDWAPSETTINGS, 2, 9, 0 }, - { OPT_DIVERT, 3, 5, 0 }, - - { 0, 0, 0, 0 }, - }; - - opterr = 0; - - /* For GNU gettext */ - -#ifdef USE_NLS -#ifndef VC6 - textdomain("gnokii"); - setlocale(LC_ALL, "pl_PL"); //here is string for Polish localisation -#else - setlocale(LC_ALL, ".852"); //Polish codepage for console, not "real" WIN CP -#endif + // Get Security Code status + { "getsecuritycodestatus", no_argument, NULL, OPT_GETSECURITYCODESTATUS }, #endif - /* Read config file */ - if (CFG_ReadConfig(&model, &Port, &Initlength, &Connection, &BinDir, &SynchronizeTime,false) < 0) { - exit(-1); - } - - /* Handle command line arguments. */ + // Set date and time + { "setdatetime", optional_argument, NULL, OPT_SETDATETIME }, - c = getopt_long(argc, argv, "", long_options, NULL); + // Get date and time mode + { "getdatetime", no_argument, NULL, OPT_GETDATETIME }, - if (c == -1) { + // Set alarm + { "setalarm", required_argument, NULL, OPT_SETALARM }, - /* No argument given - we should display usage. */ - usage(); - exit(-1); - } + // Get alarm + { "getalarm", no_argument, NULL, OPT_GETALARM }, - /* We have to build an array of the arguments which will be passed to the - functions. Please note that every text after the --command will be - passed as arguments. A syntax like gnokii --cmd1 args --cmd2 args will - not work as expected; instead args --cmd2 args is passed as a - parameter. */ + // Voice call mode + { "dialvoice", required_argument, NULL, OPT_DIALVOICE }, - if((nargv = malloc(sizeof(char *) * argc)) != NULL) { + // Get calendar note mode + { "getcalendarnote", required_argument, NULL, OPT_GETCALENDARNOTE }, - for(i = 2; i < argc; i++) - nargv[i-2] = argv[i]; - - if(checkargs(c, gals, nargc)) { - - free(nargv); + // Write calendar note mode + { "writecalendarnote", required_argument, NULL, OPT_WRITECALENDARNOTE }, - /* Wrong number of arguments - we should display usage. */ - usage(); - exit(-1); - } - -#ifndef VC6 -#if defined(__svr4__) - /* have to ignore SIGALARM */ - sigignore(SIGALRM); -#endif -#endif + // Delete calendar note mode + { "deletecalendarnote", required_argument, NULL, OPT_DELCALENDARNOTE }, - switch(c) { + // Get display status mode + { "getdisplaystatus", no_argument, NULL, OPT_GETDISPLAYSTATUS }, - // First, error conditions - case '?': - fprintf(stderr, _("Use '%s --help' for usage informations.\n"), argv[0]); - break; - - // Then, options with no arguments - case OPT_HELP: rc = usage(); break; - case OPT_VERSION: rc = version(); break; - case OPT_MONITOR: rc = monitormode(nargc, nargv); break; - case OPT_GETSMSFOLDERS: rc = getsmsfolders(); break; - case OPT_GETDATETIME: rc = getdatetime(); break; - case OPT_GETALARM: rc = getalarm(); break; - case OPT_GETDISPLAYSTATUS: rc = getdisplaystatus(); break; - case OPT_PMON: rc = pmon(); break; - case OPT_WRITEPHONEBOOK: rc = writephonebook(nargc, nargv);break; + // Get memory mode + { "getmemory", required_argument, NULL, OPT_GETMEMORY }, -#ifdef SECURITY - case OPT_ENTERSECURITYCODE: rc = entersecuritycode(optarg); break; - case OPT_GETSECURITYCODESTATUS: rc = getsecuritycodestatus(); break; - case OPT_GETSECURITYCODE: rc = getsecuritycode(optarg); break; - case OPT_GETEEPROM: rc = geteeprom(); break; - case OPT_RESETPHONESETTINGS: rc = resetphonesettings(); break; - case OPT_SETSIMLOCK: rc = setsimlock(); break; -#endif + // Write phonebook (memory) mode + { "writephonebook", optional_argument, NULL, OPT_WRITEPHONEBOOK }, -#ifdef DEBUG - case OPT_SNIFFER: rc = sniff(nargc, nargv); break; - case OPT_DECODEFILE: rc = decodefile(nargc, nargv); break; - case OPT_GETBINRINGFROMFILE: rc = getbinringfromfile(nargc, nargv);break; -#endif - - // Now, options with arguments - case OPT_SETDATETIME: rc = setdatetime(nargc, nargv); break; - case OPT_SETALARM: rc = setalarm(nargv); break; - case OPT_DIALVOICE: rc = dialvoice(optarg); break; - case OPT_CANCELCALL: rc = cancelcall(); break; - case OPT_GETCALENDARNOTE: rc = getcalendarnote(nargc, nargv);break; - case OPT_DELCALENDARNOTE: rc = deletecalendarnote(optarg);break; - case OPT_SAVECALENDARNOTE: rc = savecalendarnote(nargc, nargv);break; - case OPT_SENDCALENDARNOTE: rc = sendcalendarnote(nargc, nargv);break; - case OPT_SAVEPHONEBOOKENTRY: rc = savephonebookentry(nargc, nargv);break; - case OPT_SENDPHONEBOOKENTRY: rc = sendphonebookentry(nargc, nargv);break; - case OPT_WRITECALENDARNOTE: rc = writecalendarnote(nargv); break; - case OPT_GETMEMORY: rc = getmemory(nargc, nargv); break; - case OPT_GETSPEEDDIAL: rc = getspeeddial(optarg); break; - case OPT_SETSPEEDDIAL: rc = setspeeddial(nargv); break; - case OPT_GETSMS: rc = getsms(argc, argv); break; - case OPT_GETSMSSTATUS: rc = getsmsstatus(argc, argv); break; - case OPT_DELETESMS: rc = deletesms(nargc, nargv); break; - case OPT_SENDSMS: rc = sendsms(nargc, nargv); break; - case OPT_SAVESMS: rc = savesms(nargc, nargv); break; - case OPT_DIVERT: rc = divert(nargc, nargv); break; - case OPT_SENDLOGO: rc = sendlogo(nargc, nargv); break; - case OPT_SAVELOGO: rc = savelogo(nargc, nargv); break; - case OPT_GETSMSC: rc = getsmsc(optarg); break; - case OPT_RENAMESMSC: rc = renamesmsc(nargc,nargv); break; - case OPT_NETMONITOR: rc = netmonitor(optarg); break; - case OPT_IDENTIFY: rc = identify(); break; - case OPT_SETLOGO: rc = setlogo(nargc, nargv); break; - case OPT_GETLOGO: rc = getlogo(nargc, nargv); break; - case OPT_RECEIVESMS: rc = receivesms(nargc, nargv); break; - case OPT_SETRINGTONE: rc = setringtone(nargc, nargv); break; - case OPT_GETRINGTONE: rc = getringtone(nargc, nargv); break; - case OPT_PRESSKEYSEQUENCE: rc = presskeysequence(nargv); break; - case OPT_SENDRINGTONE: rc = sendringtone(nargc, nargv);break; - case OPT_SAVERINGTONE: rc = saveringtone(nargc, nargv);break; - case OPT_GETPROFILE: rc = getprofile(nargc, nargv); break; - case OPT_SETPROFILE: rc = setprofile(nargc, nargv); break; - case OPT_SENDPROFILE: rc = sendprofile(nargc, nargv); break; - case OPT_DISPLAYOUTPUT: rc = displayoutput(); break; - case OPT_RESTORESETTINGS: rc = restoresettings(nargv); break; - case OPT_BACKUPSETTINGS: rc = backupsettings(nargv); break; - case OPT_RINGTONECONVERT: rc = ringtoneconvert(nargc, nargv);break; - case OPT_BINRINGTONECONVERT: rc = binringtoneconvert(nargc, nargv);break; - case OPT_BITMAPCONVERT: rc = bitmapconvert(nargc, nargv);break; - case OPT_SHOWBITMAP: rc = showbitmap(nargc, nargv); break; - case OPT_PLAYRINGTONE: rc = playringtone(nargc, nargv);break; - case OPT_COMPOSER: rc = composer(nargc, nargv); break; - case OPT_FOOGLE: rc = foogle(nargv); break; - case OPT_PHONETESTS: rc = phonetests(); break; - case OPT_SIMLOCKINFO: rc = simlockinfo(); break; - case OPT_SENDDTMF: rc = senddtmf(optarg); break; - case OPT_RESET: rc = reset(nargc,nargv); break; - case OPT_GETOPERATORNAME: rc = getoperatorname(); break; - case OPT_SETOPERATORNAME: rc = setoperatorname(nargc,nargv);break; - case OPT_GETWAPBOOKMARK: rc = getwapbookmark(nargc,nargv);break; - case OPT_SETWAPBOOKMARK: rc = setwapbookmark(nargc,nargv);break; - case OPT_SAVEWAPBOOKMARK: rc = savewapbookmark(nargc,nargv);break; - case OPT_SENDWAPBOOKMARK: rc = sendwapbookmark(nargc,nargv);break; - case OPT_GETWAPSETTINGS: rc = getwapsettings(nargc,nargv);break; - case OPT_SAVEWAPSETTINGS: rc = savewapsettings(nargc,nargv);break; - case OPT_SENDWAPSETTINGS: rc = sendwapsettings(nargc,nargv);break; - case OPT_ALLRINGTONES: rc = allringtones(); break; - case OPT_GETPHONEPROFILE: rc = getphoneprofile(); break; - case OPT_SETPHONEPROFILE: rc = setphoneprofile(nargc,nargv);break; - case OPT_GETVOICEMAILBOX: rc = getvoicemailbox(); break; - case OPT_NM_COLLECT: rc = nm_collect(nargc, nargv); break; - case OPT_NETMONITORDATA: rc = netmonitordata(nargc, nargv);break; - - default: fprintf(stderr, _("Unknown option: %d\n"), c); break; - - } - - free(nargv); - - return(rc); - } - - fprintf(stderr, _("Wrong number of arguments\n")); - - exit(-1); -} + // Get speed dial mode + { "getspeeddial", required_argument, NULL, OPT_GETSPEEDDIAL }, -/* Restores various phone settings from one file */ -int restoresettings(char *argv[]) -{ - GSM_Backup Backup; - GSM_PhonebookEntry pbk; - - int confirm; - char ans[4]; - - int i,pos; - - GSM_MemoryStatus SIMMemoryStatus = {GMT_SM, 0, 0}; - GSM_MemoryStatus PhoneMemoryStatus = {GMT_ME, 0, 0}; - - if (GSM_ReadBackupFile(argv[0], &Backup)!=GE_NONE) return 1; - - fbusinit(NULL); - - if (Backup.SIMPhonebookUsed!=0) { - confirm=-1; - while (confirm < 0) { - fprintf(stderr, _("Restore SIM phonebook ? ")); - GetLine(stdin, ans, 99); - if (!strcmp(ans, "yes")) confirm = 1; - if (!strcmp(ans, "no" )) confirm = 0; - } - if (confirm==1) { - if (GSM->GetMemoryStatus(&SIMMemoryStatus) != GE_NONE) { - fprintf(stderr,_("Error getting memory status !\n")); - GSM->Terminate(); - } - i=0;pos=1; - - while ((pos-1)!=SIMMemoryStatus.Used+SIMMemoryStatus.Free) { - pbk.Location=pos; - pbk.MemoryType=GMT_SM; - pbk.Name[0]=0; - pbk.Number[0]=0; - pbk.SubEntriesCount = 0; - if (iWritePhonebookLocation(&pbk); - fprintf(stderr,_(".")); - pos++; - } - fprintf(stderr,_("\n")); - } - } - if (Backup.PhonePhonebookUsed!=0) { - confirm=-1; - while (confirm < 0) { - fprintf(stderr, _("Restore phone phonebook ? ")); - GetLine(stdin, ans, 99); - if (!strcmp(ans, "yes")) confirm = 1; - if (!strcmp(ans, "no" )) confirm = 0; - } - if (confirm==1) { - if (GSM->GetMemoryStatus(&PhoneMemoryStatus) != GE_NONE) { - fprintf(stderr,_("Error getting memory status !\n")); - GSM->Terminate(); - } - - i=0;pos=1; - - while ((pos-1)!=PhoneMemoryStatus.Used+PhoneMemoryStatus.Free) { - pbk.Location=pos; - pbk.MemoryType=GMT_ME; - pbk.Name[0]=0; - pbk.Number[0]=0; - pbk.SubEntriesCount = 0; - if (iWritePhonebookLocation(&pbk); - fprintf(stderr,_(".")); - pos++; - } - fprintf(stderr,_("\n")); - } - } - if (Backup.CallerAvailable==true) { - confirm=-1; - while (confirm < 0) { - fprintf(stderr, _("Restore caller groups ? ")); - GetLine(stdin, ans, 99); - if (!strcmp(ans, "yes")) confirm = 1; - if (!strcmp(ans, "no" )) confirm = 0; - } - if (confirm==1) { - for (i=0;i<5;i++) GSM->SetBitmap(&Backup.CallerGroups[i]); - } - } - if (Backup.OperatorLogoAvailable==true) { - confirm=-1; - while (confirm < 0) { - fprintf(stderr, _("Restore operator logo ? ")); - GetLine(stdin, ans, 99); - if (!strcmp(ans, "yes")) confirm = 1; - if (!strcmp(ans, "no" )) confirm = 0; - } - if (confirm==1) { - GSM->SetBitmap(&Backup.OperatorLogo); - } - } - if (Backup.StartupLogoAvailable==true) { - confirm=-1; - while (confirm < 0) { - fprintf(stderr, _("Restore startup logo ? ")); - GetLine(stdin, ans, 99); - if (!strcmp(ans, "yes")) confirm = 1; - if (!strcmp(ans, "no" )) confirm = 0; - } - if (confirm==1) { - GSM->SetBitmap(&Backup.StartupLogo); - } - } - - GSM->Terminate(); - - return 0; -} + // Set speed dial mode + { "setspeeddial", required_argument, NULL, OPT_SETSPEEDDIAL }, -/* Backup various phone settings from one file */ -int backupsettings(char *argv[]) -{ - GSM_PhonebookEntry PbkEntry; - GSM_Error error; - GSM_Backup Backup; - int i; + // Get SMS message mode + { "getsms", required_argument, NULL, OPT_GETSMS }, - GSM_MemoryStatus SIMMemoryStatus = {GMT_SM, 0, 0}; - GSM_MemoryStatus PhoneMemoryStatus = {GMT_ME, 0, 0}; + // Delete SMS message mode + { "deletesms", required_argument, NULL, OPT_DELETESMS }, - fbusinit(NULL); + // Send SMS message mode + { "sendsms", required_argument, NULL, OPT_SENDSMS }, - fprintf(stderr,_("Backup phonebook from SIM...")); - Backup.SIMPhonebookUsed=0; - if (GSM->GetMemoryStatus(&SIMMemoryStatus) == GE_NONE) { - Backup.SIMPhonebookSize=SIMMemoryStatus.Used+SIMMemoryStatus.Free; + // Save SMS message mode + { "savesms", optional_argument, NULL, OPT_SAVESMS }, - PbkEntry.MemoryType=GMT_SM; + // Send logo as SMS message mode + { "sendlogo", required_argument, NULL, OPT_SENDLOGO }, - for (i=0;iGetMemoryLocation(&PbkEntry); - switch (error) { - case GE_NONE: - Backup.SIMPhonebook[Backup.SIMPhonebookUsed]=PbkEntry; - Backup.SIMPhonebookUsed++; - fprintf(stderr,_(".")); - break; - default: - break; - } - } - fprintf(stderr,_("Done\n")); - } else fprintf(stderr,_("ERROR\n")); - - fprintf(stderr,_("Backup phonebook from phone...")); - Backup.PhonePhonebookUsed=0; - if (GSM->GetMemoryStatus(&PhoneMemoryStatus) == GE_NONE) { - Backup.PhonePhonebookSize=PhoneMemoryStatus.Used+PhoneMemoryStatus.Free; - - PbkEntry.MemoryType=GMT_ME; - - for (i=0;iGetMemoryLocation(&PbkEntry); - switch (error) { - case GE_NONE: - Backup.PhonePhonebook[Backup.PhonePhonebookUsed]=PbkEntry; - Backup.PhonePhonebookUsed++; - fprintf(stderr,_(".")); - break; - default: - break; - } - } - fprintf(stderr,_("Done\n")); - } else fprintf(stderr,_("ERROR\n")); - - if( GetModelFeature (FN_CALLERGROUPS)!=0) { - fprintf(stderr,_("Backup caller logos...")); - Backup.CallerAvailable=true; - for (i=0;i<5;i++) { - Backup.CallerGroups[i].number=i; - Backup.CallerGroups[i].type=GSM_CallerLogo; - if (GSM->GetBitmap(&Backup.CallerGroups[i])!=GE_NONE) return 1; - } - fprintf(stderr,_("Done\n")); - } else Backup.CallerAvailable=false; - -// fprintf(stderr,_("Backup speed dials...")); - Backup.SpeedAvailable=false; -// for (i=0;i<8;i++) { -// Backup.SpeedDials[i].Number=i+1; -// if (GSM->GetSpeedDial(&Backup.SpeedDials[i])!=GE_NONE) return 1; -// } -// fprintf(stderr,_("Done\n")); - - fprintf(stderr,_("Backup operator logo...")); - Backup.OperatorLogoAvailable=true; - Backup.OperatorLogo.type=GSM_7110OperatorLogo; - if (GSM->GetBitmap(&Backup.OperatorLogo)!=GE_NONE) { - Backup.OperatorLogo.type=GSM_OperatorLogo; - if (GSM->GetBitmap(&Backup.OperatorLogo)!=GE_NONE) { - Backup.OperatorLogoAvailable=false; - fprintf(stderr,_("Error\n")); - } else fprintf(stderr,_("Done\n")); - } else fprintf(stderr,_("Done\n")); - - Backup.StartupLogoAvailable=false; - if( GetModelFeature (FN_STARTUP)!=0) { - fprintf(stderr,_("Backup startup logo...")); - Backup.StartupLogoAvailable=true; - switch (GetModelFeature (FN_STARTUP)) { - case F_STA62: Backup.StartupLogo.type=GSM_6210StartupLogo;break; - case F_STA71: Backup.StartupLogo.type=GSM_7110StartupLogo;break; - default : Backup.StartupLogo.type=GSM_StartupLogo;break; - } - if (GSM->GetBitmap(&Backup.StartupLogo)!=GE_NONE) { - Backup.StartupLogoAvailable=false; - fprintf(stderr,_("Error\n")); - } else fprintf(stderr,_("Done\n")); - } - - fprintf(stderr,_("Backup welcome note...")); - Backup.StartupText.type=GSM_WelcomeNoteText; - if (GSM->GetBitmap(&Backup.StartupText)!=GE_NONE) { - fprintf(stderr,_("Error\n")); - } else fprintf(stderr,_("Done\n")); - - GSM->Terminate(); - - GSM_SaveBackupFile(argv[0], &Backup); - - return 0; -} + // Set ringtone + { "setringtone", required_argument, NULL, OPT_SETRINGTONE }, -/* Presses keys on phone's keyboard */ + // Get SMS center number mode + { "getsmsc", required_argument, NULL, OPT_GETSMSC }, -int presskeysequence(char *argv[]) -{ - int i,j; - int keycode; - char key; - - sleep(1); + // For development purposes: run in passive monitoring mode + { "pmon", no_argument, NULL, OPT_PMON }, - fbusinit(NULL); - - for (i=0;iTerminate(); - return -1; - } - - if (GSM->PressKey(keycode,PRESSPHONEKEY)!=GE_NONE) - { - fprintf(stderr,_("Can't press key !\n")); - GSM->Terminate(); - return -1; - } - if (GSM->PressKey(keycode,RELEASEPHONEKEY)!=GE_NONE) - { - fprintf(stderr,_("Can't release key !\n")); - GSM->Terminate(); - return -1; - } - } else - { - sleep(2); - } - } - - GSM->Terminate(); + // NetMonitor mode + { "netmonitor", required_argument, NULL, OPT_NETMONITOR }, - return 0; -} + // Identify + { "identify", no_argument, NULL, OPT_IDENTIFY }, -/* Send SMS messages. */ -int sendsms(int argc, char *argv[]) -{ - GSM_MultiSMSMessage MultiSMS; - char message_buffer[GSM_MAX_CONCATENATED_SMS_LENGTH]; - int input_len, chars_read,i,msgnum; - - GSM_SMSMessageType SMSType=GST_SMS; - int SMSValidity= 4320; /* 4320 minutes == 72 hours */ - bool SMSReply=false; - int SMSClass=-1,SMSCenter=1; - char SMSCNumber[100]; - GSM_Coding_Type SMSCoding=GSM_Coding_Default; - GSM_UDH SMSUDHType=GSM_NoUDH; - - struct option options[] = { - { "smscno", required_argument, NULL, '2'}, - { "smsc", required_argument, NULL, '1'}, - { "long", required_argument, NULL, '3'}, - { "enablevoice", no_argument, NULL, '4'}, - { "disablevoice", no_argument, NULL, '5'}, - { "enableemail", no_argument, NULL, '6'}, - { "disableemail", no_argument, NULL, '7'}, - { "enablefax", no_argument, NULL, '8'}, - { "disablefax", no_argument, NULL, '9'}, - { "unicode", no_argument, NULL, '-'}, - { "void", no_argument, NULL, '+'}, - { "hang", no_argument, NULL, '('}, - { "bug", no_argument, NULL, ')'}, - { NULL, 0, NULL, 0} - }; - - input_len = GSM_MAX_SMS_LENGTH; - - if (argc!=0) { - - optarg = NULL; - optind = 0; - - while ((i = getopt_long(argc, argv, "v:dsC:", options, NULL)) != -1) { - switch (i) { - - case '1': /* SMSC number */ - SMSCenter = 0; - strcpy(SMSCNumber,optarg); - break; - - case '2': /* SMSC number index in phone memory */ - SMSCenter = atoi(optarg); - - if (SMSCenter < 1 || SMSCenter > 5) { - fprintf(stderr, _("Incorrect SMSC number with \"smscno\" option (can't be <1 and >5) !\n")); - GSM->Terminate(); - return -1; - } - break; - - case '3': /* we send long message */ - SMSUDHType=GSM_ConcatenatedMessages; - input_len = atoi(optarg); - if (input_len > GSM_MAX_CONCATENATED_SMS_LENGTH) { - fprintf(stderr, _("Input too long, max %i!\n"),GSM_MAX_CONCATENATED_SMS_LENGTH); - exit(-1); - } - break; - - case '4': /* SMS enables voice indicator */ - SMSUDHType=GSM_EnableVoice; break; - - case '5': /* SMS disables voice indicator */ - SMSUDHType=GSM_DisableVoice; break; - - case '6': /* SMS enables email indicator */ - SMSUDHType=GSM_EnableEmail; break; - - case '7': /* SMS disables email indicator */ - SMSUDHType=GSM_DisableEmail; break; - - case '8': /* SMS enables fax indicator */ - SMSUDHType=GSM_EnableFax; break; - - case '9': /* SMS disables fax indicator */ - SMSUDHType=GSM_DisableFax; break; - - case '-': /* SMS coding type */ - SMSCoding=GSM_Coding_Unicode; break; - - case '+': /* SMS ghost */ - SMSUDHType=GSM_VoidSMS; break; - - case '(': /* SMS hanging phone, when saved to Outbox */ - SMSUDHType=GSM_HangSMS; break; - - case ')': /* SMS showed incorrectly in phone */ - SMSUDHType=GSM_BugSMS; break; - - case 'v': /* Set validaty of SMS */ - SMSValidity = atoi(optarg); break; - - case 'd': /* delivery report */ - SMSType=GST_DR; break; - - case 's': /* Set replying via the same SMSC */ - SMSReply = true; break; - - case 'C': /* class Message */ - - if (SMSUDHType!=GSM_NoUDH) { - fprintf(stderr, _("Can't specify SMS Class with --enablevoice, --disablevoice, --enableemail, --disableemail, --enablefax, --disablefax options !\n")); - return -1; - } - - switch (*optarg) { - case '0': SMSClass = 0; break; - case '1': SMSClass = 1; break; - case '2': SMSClass = 2; break; - case '3': SMSClass = 3; break; - default: - fprintf(stderr, _("SMS Class (\"C\" option) can be 0, 1, 2 or 3 only !\n")); - return -1; - } - break; - - default: - fprintf(stderr,_("Unknown option number %i\n"),argc); - return -1; - } - } - } - - /* Get message text from stdin. */ - chars_read = fread(message_buffer, 1, input_len, stdin); - - if (chars_read == 0) { - fprintf(stderr, _("Couldn't read from stdin!\n")); - return -1; - } - if (chars_read > input_len) { - fprintf(stderr, _("Input too long!\n")); - return -1; - } - - /* Null terminate. */ - message_buffer[chars_read] = 0x00; - - GSM_MakeMultiPartSMS2(&MultiSMS,message_buffer,chars_read,SMSUDHType,SMSCoding); - msgnum=MultiSMS.number; - - switch (SMSUDHType) { - case GSM_NoUDH: - case GSM_BugSMS: - case GSM_VoidSMS: - case GSM_HangSMS: - case GSM_EnableVoice: - case GSM_DisableVoice: - case GSM_EnableFax: - case GSM_DisableFax: - case GSM_EnableEmail: - case GSM_DisableEmail: - fprintf(stdout,_("Warning: saving %i chars\n"),strlen(MultiSMS.SMS[0].MessageText)); - msgnum=1; - break; - default: - break; - } - - for (i=0;i 5) { - fprintf(stderr, _("Incorrect SMSC number with \"smscno\" option (can't be <1 and >5) !\n")); - GSM->Terminate(); - return -1; - } - break; + // Simulate pressing the keys + { "keysequence", no_argument, NULL, OPT_KEYPRESS }, + + // For development purposes: insert you function calls here + { "foogle", no_argument, NULL, OPT_FOOGLE }, - case '3': /* we send long message */ - SMSUDHType=GSM_ConcatenatedMessages; - input_len = atoi(optarg); - if (input_len > GSM_MAX_CONCATENATED_SMS_LENGTH) { - fprintf(stderr, _("Input too long, max %i!\n"),GSM_MAX_CONCATENATED_SMS_LENGTH); - exit(-1); - } - break; + { 0, 0, 0, 0}, + }; - case '4': /* SMS enables voice indicator */ - SMSUDHType=GSM_EnableVoice; break; + /* Every command which requires arguments should have an appropriate entry + in this array. */ + struct gnokii_arg_len gals[] = + { - case '5': /* SMS disables voice indicator */ - SMSUDHType=GSM_DisableVoice; break; +#ifdef SECURITY + { OPT_ENTERSECURITYCODE, 1, 1, 0 }, +#endif - case '6': /* SMS enables email indicator */ - SMSUDHType=GSM_EnableEmail; break; + { OPT_SETDATETIME, 0, 5, 0 }, + { OPT_SETALARM, 2, 2, 0 }, + { OPT_DIALVOICE, 1, 1, 0 }, + { OPT_GETCALENDARNOTE, 1, 3, 0 }, + { OPT_WRITECALENDARNOTE, 2, 2, 0 }, + { OPT_DELCALENDARNOTE, 1, 2, 0 }, + { OPT_GETMEMORY, 2, 3, 0 }, + { OPT_GETSPEEDDIAL, 1, 1, 0 }, + { OPT_SETSPEEDDIAL, 3, 3, 0 }, + { OPT_GETSMS, 2, 5, 0 }, + { OPT_DELETESMS, 2, 3, 0 }, + { OPT_SENDSMS, 1, 10, 0 }, + { OPT_SAVESMS, 0, 6, 0 }, + { OPT_SENDLOGO, 3, 6, 0 }, + { OPT_SENDRINGTONE, 2, 6, 0 }, + { OPT_GETSMSC, 1, 1, 0 }, + { OPT_GETWELCOMENOTE, 1, 1, 0 }, + { OPT_SETWELCOMENOTE, 1, 1, 0 }, + { OPT_NETMONITOR, 1, 1, 0 }, + { OPT_SENDDTMF, 1, 1, 0 }, + { OPT_SETLOGO, 1, 4, 0 }, + { OPT_GETLOGO, 1, 4, 0 }, + { OPT_VIEWLOGO, 1, 1, 0 }, + { OPT_SETRINGTONE, 1, 1, 0 }, + { OPT_RESET, 0, 1, 0 }, + { OPT_GETPROFILE, 0, 1, 0 }, + { OPT_WRITEPHONEBOOK, 0, 1, 0 }, + + { 0, 0, 0, 0 }, + }; + + opterr = 0; + + /* For GNU gettext */ +#ifdef USE_NLS + textdomain("gnokii"); + setlocale(LC_ALL, ""); +#endif - case '7': /* SMS disables email indicator */ - SMSUDHType=GSM_DisableEmail; break; + /* Read config file */ + if (readconfig(&model, &Port, &Initlength, &Connection, &BinDir) < 0) { + exit(-1); + } - case '8': /* SMS enables fax indicator */ - SMSUDHType=GSM_EnableFax; break; + /* Handle command line arguments. */ + c = getopt_long(argc, argv, "", long_options, NULL); + if (c == -1) /* No argument given - we should display usage. */ + usage(); - case '9': /* SMS disables fax indicator */ - SMSUDHType=GSM_DisableFax; break; + switch(c) { + // First, error conditions + case '?': + case ':': + fprintf(stderr, _("Use '%s --help' for usage informations.\n"), argv[0]); + exit(0); + // Then, options with no arguments + case OPT_HELP: + usage(); + case OPT_VERSION: + return version(); + } + + /* We have to build an array of the arguments which will be passed to the + functions. Please note that every text after the --command will be + passed as arguments. A syntax like gnokii --cmd1 args --cmd2 args will + not work as expected; instead args --cmd2 args is passed as a + parameter. */ + if ((nargv = malloc(sizeof(char *) * argc)) != NULL) { + for (i = 2; i < argc; i++) + nargv[i-2] = argv[i]; + + if (checkargs(c, gals, nargc)) { + free(nargv); /* Wrong number of arguments - we should display usage. */ + usage(); + } - case '-': /* SMS coding type */ - SMSCoding=GSM_Coding_Unicode; break; +#ifdef __svr4__ + /* have to ignore SIGALARM */ + sigignore(SIGALRM); +#endif - case '+': /* SMS ghost */ - SMSUDHType=GSM_VoidSMS; break; + /* Initialise the code for the GSM interface. */ + fbusinit(NULL); - case '(': /* SMS hanging phone, when saved to Outbox */ - SMSUDHType=GSM_HangSMS; break; + switch(c) { + case OPT_MONITOR: + rc = monitormode(); + break; +#ifdef SECURITY + case OPT_ENTERSECURITYCODE: + rc = entersecuritycode(optarg); + break; + case OPT_GETSECURITYCODESTATUS: + rc = getsecuritycodestatus(); + break; +#endif + case OPT_GETDATETIME: + rc = getdatetime(); + break; + case OPT_GETALARM: + rc = getalarm(); + break; + case OPT_GETDISPLAYSTATUS: + rc = getdisplaystatus(); + break; + case OPT_PMON: + rc = pmon(); + break; + case OPT_WRITEPHONEBOOK: + rc = writephonebook(nargc, nargv); + break; + // Now, options with arguments + case OPT_SETDATETIME: + rc = setdatetime(nargc, nargv); + break; + case OPT_SETALARM: + rc = setalarm(nargv); + break; + case OPT_DIALVOICE: + rc = dialvoice(optarg); + break; + case OPT_GETCALENDARNOTE: + rc = getcalendarnote(nargc, nargv); + break; + case OPT_DELCALENDARNOTE: + rc = deletecalendarnote(nargc, nargv); + break; + case OPT_WRITECALENDARNOTE: + rc = writecalendarnote(nargv); + break; + case OPT_GETMEMORY: + rc = getmemory(nargc, nargv); + break; + case OPT_GETSPEEDDIAL: + rc = getspeeddial(optarg); + break; + case OPT_SETSPEEDDIAL: + rc = setspeeddial(nargv); + break; + case OPT_GETSMS: + rc = getsms(argc, argv); + break; + case OPT_DELETESMS: + rc = deletesms(nargc, nargv); + break; + case OPT_SENDSMS: + rc = sendsms(nargc, nargv); + break; + case OPT_SAVESMS: + rc = savesms(argc, argv); + break; + case OPT_SENDLOGO: + rc = sendlogo(nargc, nargv); + break; + case OPT_GETSMSC: + rc = getsmsc(optarg); + break; + case OPT_NETMONITOR: + rc = netmonitor(optarg); + break; + case OPT_IDENTIFY: + rc = identify(); + break; + case OPT_SETLOGO: + rc = setlogo(nargc, nargv); + break; + case OPT_GETLOGO: + rc = getlogo(nargc, nargv); + break; + case OPT_VIEWLOGO: + rc = viewlogo(optarg); + break; + case OPT_SETRINGTONE: + rc = setringtone(nargc, nargv); + break; + case OPT_SENDRINGTONE: + rc = sendringtone(argc, argv); + break; + case OPT_GETPROFILE: + rc = getprofile(nargc, nargv); + break; + case OPT_DISPLAYOUTPUT: + rc = displayoutput(); + break; + case OPT_KEYPRESS: + rc = presskeysequence(); + break; +#ifndef WIN32 + case OPT_FOOGLE: + rc = foogle(nargv); + break; +#endif + case OPT_SENDDTMF: + rc = senddtmf(optarg); + break; + case OPT_RESET: + rc = reset(optarg); + break; + default: + fprintf(stderr, _("Unknown option: %d\n"), c); + break; - case ')': /* SMS showed incorrectly in phone */ - SMSUDHType=GSM_BugSMS; break; + } + return(rc); + } - case 'r': /* mark as read */ - SMSStatus = GSS_SENTREAD; break; - - case 'i': /* Save into Inbox */ - SMSFolder = GST_INBOX; break; - - case 's': /* Set replying via the same SMSC */ - SMSReply = true; break; - - case 'a': /* Ask before overwriting */ - interactive=true;break; - - case 'l': /* Specify location */ - SMSLocation = atoi(optarg); break; - - case '/': /* Name */ - strncpy(SMSName,optarg,25);break; - - case 'C': /* class Message */ - - if (SMSUDHType!=GSM_NoUDH) { - fprintf(stderr, _("Can't specify SMS Class with --enablevoice, --disablevoice, --enableemail, --disableemail, --enablefax, --disablefax options !\n")); - return -1; - } - - switch (*optarg) { - case '0': SMSClass = 0; break; - case '1': SMSClass = 1; break; - case '2': SMSClass = 2; break; - case '3': SMSClass = 3; break; - default: - fprintf(stderr, _("SMS Class (\"C\" option) can be 0, 1, 2 or 3 only !\n")); - return -1; - } - break; - - case 'F': /* save into folder n */ - SMSFolder = atoi(optarg); - break; - - default: - fprintf(stderr,_("Unknown option number %i\n"),argc); - return -1; - } - } - } - - /* Get message text from stdin. */ - chars_read = fread(message_buffer, 1, input_len, stdin); - - if (chars_read == 0) { - fprintf(stderr, _("Couldn't read from stdin!\n")); - return -1; - } - if (chars_read > input_len) { - fprintf(stderr, _("Input too long!\n")); - return -1; - } - - /* Null terminate. */ - message_buffer[chars_read] = 0x00; - - GSM_MakeMultiPartSMS2(&MultiSMS,message_buffer,chars_read,SMSUDHType,SMSCoding); - msgnum=MultiSMS.number; - - switch (SMSUDHType) { - case GSM_NoUDH: - case GSM_BugSMS: - case GSM_VoidSMS: - case GSM_HangSMS: - case GSM_EnableVoice: - case GSM_DisableVoice: - case GSM_EnableFax: - case GSM_DisableFax: - case GSM_EnableEmail: - case GSM_DisableEmail: - fprintf(stdout,_("Warning: saving %i chars\n"),strlen(MultiSMS.SMS[0].MessageText)); - msgnum=1; - break; - default: - break; - } - - for (i=0;irerun getopt_long()) + */ +static bool smsc_options_parse(int option,GSM_SMSMessage *SMS) { + switch (option) { - GSM_MessageCenter MessageCenter; + case SMSC_SHORTCHAR_SMSC: /* SMSC number */ + SMS->MessageCenter.No = 0; + strcpy(SMS->MessageCenter.Number,optarg); + break; - MessageCenter.No=atoi(MessageCenterNumber); + case SMSC_SHORTCHAR_SMSCNO: /* SMSC number index in phone memory */ + SMS->MessageCenter.No = atoi(optarg); - fbusinit(NULL); + if (SMS->MessageCenter.No < 1 || SMS->MessageCenter.No > 5) + usage(); + break; - if (GSM->GetSMSCenter(&MessageCenter) == GE_NONE) { + default: + return(false); /* option not recognized */ + } - fprintf(stdout, _("%d. SMS center ("),MessageCenter.No); - - if (!strcmp(MessageCenter.Name,"")) - fprintf(stdout,_("Set %d"),MessageCenter.No); - else fprintf(stdout,_("%s"),MessageCenter.Name); - - fprintf(stdout,_(") number is ")); + return(true); /* option was successfuly processed */ +} - if (!strcmp(MessageCenter.Number,"")) fprintf(stdout,_("not set\n")); - else fprintf(stdout,_("%s\n"),MessageCenter.Number); +/* RETURNS: Success + */ +bool sendsms_deconcatenated(GSM_SMSMessage *sms,char *buf,size_t buflen,bool useudh) +{ + GSM_Deconcatenate_state SMS_Deconcatenate_state; + GSM_Error error; - fprintf(stdout,_("Default recipient number is ")); + SMS_Deconcatenate_state.first=true; + while (SMS_Deconcatenate(&SMS_Deconcatenate_state,sms,buf,buflen,useudh)) { + /* Send the message. */ + error = GSM->SendSMSMessage(sms); - if (!strcmp(MessageCenter.DefaultRecipient,"")) - fprintf(stdout,_("not set\n")); - else fprintf(stdout,_("%s\n"),MessageCenter.DefaultRecipient); + if (error == GE_SMSSENDOK) { + fprintf(stdout, _("Send succeeded!\n")); + } else { + fprintf(stdout, _("SMS Send failed (error=%d)\n"), error); + return(false); + } + /* Here the sleep have no meaning. + * If it is required by some backend phone driver, it should be done THERE! + */ + /* sleep(10); */ + } + return(true); +} - fprintf(stdout, _("Messages sent as ")); +/* Send SMS messages. */ +int sendsms(int argc, char *argv[]) +{ + GSM_SMSMessage SMS; + /* The maximum length of an uncompressed concatenated short message is + 255 * 153 = 39015 default alphabet characters */ + char message_buffer[GSM_MAX_CONCATENATED_SMS_LENGTH]; + int input_len, chars_read; + int i; + bool useudh = false; + + struct option options[] = { + SMSC_OPTIONS, + { "longtext", no_argument, NULL, '3'}, + { "longudh", no_argument, NULL, '4'}, + { "udh", no_argument, NULL, '5'}, + { NULL, 0, NULL, 0} + }; + + input_len = GSM_MAX_SMS_LENGTH; + + /* Default settings: + - no delivery report + - no Class Message + - no compression + - 7 bit data + - SMSC no. 1 + - message validity for 3 days + - unset user data header indicator + */ + + SMS.Type = GST_MO; + SMS.Class = -1; + SMS.Compression = false; + SMS.EightBit = false; + SMS.MessageCenter.No = 1; + SMS.Validity = 4320; /* 4320 minutes == 72 hours */ + SMS.UDHPresent = false; + + strcpy(SMS.Destination, argv[0]); + + optarg = NULL; + optind = 0; + + while ((i = getopt_long(argc, argv, "r8cC:v:", options, NULL)) != -1) { + if (smsc_options_parse(i,&SMS)) + continue; + switch (i) { // -c for compression. not yet implemented. + case '3': /* we send long message in text format */ + input_len = GSM_MAX_CONCATENATED_SMS_LENGTH; + useudh = false; + break; + case '4': /* we send long message in UDH format */ + input_len = GSM_MAX_CONCATENATED_SMS_LENGTH; + useudh = true; + break; + case '5': /* UDH indication requested */ + SMS.UDHPresent = true; + break; + case 'r': /* request for delivery report */ + SMS.Type = GST_DR; + break; + case 'C': /* class Message */ + switch (*optarg) { + case '0': + SMS.Class = 0; + break; + case '1': + SMS.Class = 1; + break; + case '2': + SMS.Class = 2; + break; + case '3': + SMS.Class = 3; + break; + default: + usage(); + } + break; + case '8': /* 8-bit data */ + SMS.EightBit = true; + break; + case 'v': + SMS.Validity = atoi(optarg); + break; + default: + usage(); /* Would be better to have an sendsms_usage() here. */ + } + } - switch (MessageCenter.Format) { - case GSMF_Text :fprintf(stdout, _("Text"));break; - case GSMF_Paging:fprintf(stdout, _("Paging"));break; - case GSMF_Fax :fprintf(stdout, _("Fax"));break; - case GSMF_Email : - case GSMF_UCI :fprintf(stdout, _("Email"));break; - case GSMF_ERMES :fprintf(stdout, _("ERMES"));break; - case GSMF_X400 :fprintf(stdout, _("X.400"));break; - default :fprintf(stdout, _("Unknown")); - } + /* Get message text from stdin. */ + chars_read = fread(message_buffer, 1, input_len, stdin); - printf("\n"); + if (chars_read == 0) { + fprintf(stderr, _("Couldn't read from stdin!\n")); + return -1; + } else if (chars_read > input_len) { + fprintf(stderr, _("Input too long!\n")); + return -1; + } - fprintf(stdout, _("Message validity is ")); + if (SMS.UDHPresent) { +u8 UDHlen = 1 + message_buffer[0]; /* designifify */ - switch (MessageCenter.Validity) { - case GSMV_1_Hour :fprintf(stdout, _("1 hour"));break; - case GSMV_6_Hours :fprintf(stdout, _("6 hours"));break; - case GSMV_24_Hours:fprintf(stdout, _("24 hours"));break; - case GSMV_72_Hours:fprintf(stdout, _("72 hours"));break; - case GSMV_1_Week :fprintf(stdout, _("1 week"));break; - case GSMV_Max_Time:fprintf(stdout, _("Maximum time"));break; - default :fprintf(stdout, _("Unknown")); - } + if (chars_read < UDHlen || sizeof(SMS.UDH) < UDHlen) { + fprintf(stderr, _("Input too short to satisfy UDH!\n")); + return -1; + } + memcpy(SMS.UDH, message_buffer, UDHlen); + chars_read-=UDHlen; + memmove(message_buffer, message_buffer + UDHlen, chars_read); + } - fprintf(stdout, "\n"); + /* Null terminate. */ + message_buffer[chars_read] = 0x00; - } - else - fprintf(stdout, _("SMS center can not be found :-(\n")); + sendsms_deconcatenated(&SMS,message_buffer,chars_read,useudh); - GSM->Terminate(); + GSM->Terminate(); - return 0; + return 0; } -/* Get SMS messages. */ -int getsms(int argc, char *argv[]) +int savesms(int argc, char *argv[]) { + GSM_SMSMessage SMS; + GSM_Error error; + /* The maximum length of an uncompressed concatenated short message is + 255 * 153 = 39015 default alphabet characters */ + char message_buffer[GSM_MAX_CONCATENATED_SMS_LENGTH]; + int input_len, chars_read; + int i, confirm = -1; + int interactive = 0; + char ans[8]; + + /* Defaults */ + SMS.Type = GST_MO; + SMS.Destination[0] = '\0'; + SMS.Class = -1; + SMS.Compression = false; + SMS.EightBit = false; + SMS.MessageCenter.No = 1; + SMS.Validity = 4320; /* 4320 minutes == 72 hours */ + SMS.UDHPresent = false; + SMS.Status = GSS_NOTSENTREAD; + SMS.Location = 0; + SMS.MemoryType = GMT_SM; + + input_len = GSM_MAX_SMS_LENGTH; + + /* Option parsing */ + while ((i = getopt(argc, argv, "ml:in:s:c:")) != -1) { + switch (i) { + case 'm': /* mark the message as sent */ + SMS.Status = GSS_SENTREAD; + break; + case 'l': /* Specify the location */ + SMS.Location = atoi(optarg); + break; + case 'i': /* Ask before overwriting */ + interactive = 1; + break; + case 'n': /* Specify the from number */ + break; + case 's': /* Specify the smsc number */ + break; + case 'c': /* Specify the smsc location */ + break; + default: + usage(); + return -1; + } + } - GSM_SMSMessage message; - GSM_WAPBookmark bookmark; - char memory_type_string[20]; - int start_message, end_message, count, mode = 1; - char filename[64]; - GSM_Error error; - GSM_Bitmap bitmap; - GSM_Ringtone ringtone; - GSM_SMSFolders folders; - - int confirm = -1, i; - char ans[8]; - - /* Handle command line args that set type, start and end locations. */ - if (!GetMemoryTypeID(argv[2], &message.MemoryType)) - { - fprintf(stderr, _("Unknown memory type %s!\n"), argv[2]); - return (-1); - } - GetMemoryTypeString(memory_type_string, &message.MemoryType); - - for (i=0;i<64;i++) filename[i]=0; - - start_message = atoi(argv[3]); - if (argc > 4) { - int i; - - /* [end] can be only argv[4] */ - if (argv[4][0] == '-') { end_message = start_message; } - else { end_message = atoi(argv[4]); } - - /* parse all options (beginning with '-' */ - while ((i = getopt(argc, argv, "f:")) != -1) { - switch (i) { - case 'f': - if (optarg) { + if (interactive) { + GSM_SMSMessage aux; + + aux.Location = SMS.Location; + data.SMSMessage = &aux; + error = SM_Functions(GOP_GetSMS, &data, &State); + switch (error) { + case GE_NONE: + fprintf(stderr, _("Message at specified location exists. ")); + while (confirm < 0) { + fprintf(stderr, _("Overwrite? (yes/no) ")); + GetLine(stdin, ans, 7); + if (!strcmp(ans, "yes")) confirm = 1; + else if (!strcmp(ans, "no")) confirm = 0; + } + if (!confirm) { GSM->Terminate(); return 0; } + else break; + case GE_INVALIDSMSLOCATION: + fprintf(stderr, _("Invalid location\n")); + GSM->Terminate(); + return -1; + default: +/* FIXME: Remove this fprintf when the function is thoroughly tested */ #ifdef DEBUG - fprintf(stderr, _("Saving into file \"%s\"\n"), optarg); -#endif /* DEBUG */ - strncpy(filename, optarg, 64); - if (strlen(optarg) > 63) { - fprintf(stderr, _("Filename too long - will be truncated to 63 characters.\n")); - filename[63] = 0; - } else { - filename[strlen(optarg)] = 0; - } - } else { - usage(); - exit(1); - } - break; - default: - usage(); - exit(1); + fprintf(stderr, _("Location %d empty. Saving\n"), SMS.Location); +#endif + break; + } } - } - } else { - end_message = start_message; - } - - /* Initialise the code for the GSM interface. */ - - fbusinit(NULL); + chars_read = fread(message_buffer, 1, input_len, stdin); - GSM->GetSMSFolders(&folders); + if (chars_read == 0) { - - /* Now retrieve the requested entries. */ + fprintf(stderr, _("Couldn't read from stdin!\n")); + return -1; - for (count = start_message; count <= end_message; count ++) { + } else if (chars_read > input_len) { - message.Location = count; + fprintf(stderr, _("Input too long!\n")); + return -1; - error = GSM->GetSMSMessage(&message); + } - switch (error) { + strncpy (SMS.MessageText, message_buffer, chars_read); + SMS.MessageText[chars_read] = 0; + SMS.MessageTextLength=chars_read; - case GE_NONE: + error = GSM->SaveSMSMessage(&SMS); - switch (message.Type) { + if (error == GE_NONE) { + fprintf(stdout, _("Saved!\n")); + } else { + fprintf(stdout, _("Saving failed (error=%d)\n"), error); + } + sleep(10); + GSM->Terminate(); - case GST_DR: + return 0; +} - /* RTH FIXME: Test that out ! */ - fprintf(stdout, _("%d. Delivery Report "), message.MessageNumber); - switch (message.Status) - { - case GSS_SENTREAD: - if (message.folder==0) fprintf(stdout, _("(read)\n")); //GST_INBOX - else fprintf(stdout, _("(sent)\n")); - break; - case GSS_NOTSENTREAD: - if (message.folder==0) fprintf(stdout, _("(unread)\n")); //GST_INBOX - else fprintf(stdout, _("(not sent)\n")); - break; - case GSS_UNKNOWN: - fprintf(stdout, _("(not known :-()\n")); - break; - case GSS_TEMPLATE: - fprintf(stdout, _("(template)\n")); - break; - default: - fprintf(stdout, _("(unknown: %d)\n"),message.Status); +/* Get SMSC number */ +int getsmsc(char *MessageCenterNumber) +{ + GSM_MessageCenter MessageCenter; + GSM_Data data; + GSM_Error error; + + memset(&MessageCenter, 0, sizeof(MessageCenter)); + MessageCenter.No=atoi(MessageCenterNumber); + + if (GSM && GSM->GetSMSCenter && GSM->Terminate) { + error = GSM->GetSMSCenter(&MessageCenter); + GSM->Terminate(); + } else { + GSM_DataClear(&data); + data.MessageCenter = &MessageCenter; + error = SM_Functions(GOP_GetSMSCenter, &data, &State); + } + + switch (error) { + case GE_NONE: + fprintf(stdout, _("%d. SMS center (%s) number is %s\n"), MessageCenter.No, MessageCenter.Name, MessageCenter.Number); + fprintf(stdout, _("Default recipient number is %s\n"), MessageCenter.Recipient); + fprintf(stdout, _("Messages sent as ")); + + switch (MessageCenter.Format) { + case GSMF_Text: + fprintf(stdout, _("Text")); + break; + case GSMF_Paging: + fprintf(stdout, _("Paging")); + break; + case GSMF_Fax: + fprintf(stdout, _("Fax")); + break; + case GSMF_Email: + case GSMF_UCI: + fprintf(stdout, _("Email")); + break; + case GSMF_ERMES: + fprintf(stdout, _("ERMES")); + break; + case GSMF_X400: + fprintf(stdout, _("X.400")); + break; + default: + fprintf(stdout, _("Unknown")); + break; + } + + printf("\n"); + fprintf(stdout, _("Message validity is ")); + + switch (MessageCenter.Validity) { + case GSMV_1_Hour: + fprintf(stdout, _("1 hour")); + break; + case GSMV_6_Hours: + fprintf(stdout, _("6 hours")); + break; + case GSMV_24_Hours: + fprintf(stdout, _("24 hours")); + break; + case GSMV_72_Hours: + fprintf(stdout, _("72 hours")); + break; + case GSMV_1_Week: + fprintf(stdout, _("1 week")); + break; + case GSMV_Max_Time: + fprintf(stdout, _("Maximum time")); + break; + default: + fprintf(stdout, _("Unknown")); + break; + } + + fprintf(stdout, "\n"); + break; - } - - fprintf(stdout, _("Sending date/time : %s %02d/%02d/%02d %d:%02d:%02d "), \ - DayOfWeek(message.Time.Year, message.Time.Month, message.Time.Day), \ - message.Time.Day, message.Time.Month, message.Time.Year, \ - message.Time.Hour, message.Time.Minute, message.Time.Second); - - if (message.Time.Timezone) { - if (message.Time.Timezone > 0) - fprintf(stdout,_("+%02d00"), message.Time.Timezone); - else - fprintf(stdout,_("%02d00"), message.Time.Timezone); - } - - fprintf(stdout, "\n"); - - fprintf(stdout, _("Response date/time: %s %02d/%02d/%02d %d:%02d:%02d "), \ - DayOfWeek(message.SMSCTime.Year, message.SMSCTime.Month, message.SMSCTime.Day), \ - message.SMSCTime.Day, message.SMSCTime.Month, message.SMSCTime.Year, \ - message.SMSCTime.Hour, message.SMSCTime.Minute, message.SMSCTime.Second); - - if (message.SMSCTime.Timezone) { - if (message.SMSCTime.Timezone > 0) - fprintf(stdout,_("+%02d00"),message.SMSCTime.Timezone); - else - fprintf(stdout,_("%02d00"),message.SMSCTime.Timezone); - } - - fprintf(stdout, "\n"); - - fprintf(stdout, _("Receiver: %s Msg Center: %s\n"), message.Sender, message.MessageCenter.Number); - fprintf(stdout, _("Text: %s\n\n"), message.MessageText); - - break; - - case GST_SMS: - fprintf(stdout, _("%d. %s Message "), message.MessageNumber, - folders.Folder[message.folder].Name); - - switch (message.Status) - { - case GSS_SENTREAD: - if (message.folder==0) fprintf(stdout, _("(read)\n")); //GST_INBOX - else fprintf(stdout, _("(sent)\n")); + case GE_NOTIMPLEMENTED: + fprintf(stderr, _("Function not implemented in %s model!\n"), model); break; - case GSS_NOTSENTREAD: - if (message.folder==0) fprintf(stdout, _("(unread)\n")); //GST_INBOX - else fprintf(stdout, _("(not sent)\n")); + default: + fprintf(stdout, _("SMS center can not be found :-(\n")); break; - case GSS_UNKNOWN: - fprintf(stdout, _("(not known :-()\n")); - break; - case GSS_TEMPLATE: - fprintf(stdout, _("(template)\n")); - break; - default: - fprintf(stdout, _("(unknown: %d)\n"),message.Status); - break; - } - - /* RTH FIXME: date for other status ok ? */ - if (message.SMSData) { - - fprintf(stdout, _("Date/time: %s %02d/%02d/%02d %d:%02d:%02d "), \ - DayOfWeek(message.Time.Year, message.Time.Month, message.Time.Day), \ - message.Time.Day, message.Time.Month, message.Time.Year, \ - message.Time.Hour, message.Time.Minute, message.Time.Second); - - if (message.Time.Timezone) { - if (message.Time.Timezone > 0) - fprintf(stdout,_("+%02d00"),message.Time.Timezone); - else - fprintf(stdout,_("%02d00"),message.Time.Timezone); - } - - fprintf(stdout, "\n"); - - fprintf(stdout, _("Msg Center: %s "), message.MessageCenter.Number); - - if (message.ReplyViaSameSMSC) - fprintf(stdout, _("(centre set for reply) ")); - } - - if (strcmp(message.Sender,"")) { - if (message.folder==1) { //GST_OUTBOX - fprintf(stdout, _("Recipient: %s"),message.Sender); - } else { - fprintf(stdout, _("Sender: %s"),message.Sender); - } - } - - if (strcmp(message.Sender,"") || message.folder==0) - fprintf(stdout, "\n"); - - switch (message.UDHType) { - - case GSM_OpLogo: + } + + return error; +} - /* put bitmap into bitmap structure */ - switch (GSM_ReadBitmap(&message, &bitmap)) { - case GE_INVALIDIMAGESIZE: - fprintf(stdout,_("Image size not supported\n")); - break; - case GE_NONE: - fprintf(stdout, _("GSM operator logo for %s (%s) network.\n"), bitmap.netcode, GSM_GetNetworkName(bitmap.netcode)); - - GSM_PrintBitmap(&bitmap); +/* Get SMS messages. */ +int getsms(int argc, char *argv[]) +{ + int del = 0; + GSM_SMSMessage message; + char *memory_type_string; + int start_message, end_message, count, mode = 1; + char filename[64]; + GSM_Error error; + GSM_Bitmap bitmap; + char ans[5]; + struct stat buf; + + /* Handle command line args that set type, start and end locations. */ + memory_type_string = argv[2]; + message.MemoryType = StrToMemoryType(memory_type_string); + if (message.MemoryType == GMT_XX) { + fprintf(stderr, _("Unknown memory type %s (use ME, SM, ...)!\n"), argv[2]); + return (-1); + } - if (filename[0]!=0) { - GSM_SaveBitmapFileOnConsole(filename, &bitmap); - } + memset(&filename, 0, 64); - break; - default: - fprintf(stdout,_("Error reading image\n")); - break; - } + start_message = end_message = atoi(argv[3]); + if (argc > 4) { + int i; -#ifdef DEBUG - if (message.folder==0) { //GST_INBOX - if (!strcmp(message.Sender, "+998000005") && - !strcmp(message.MessageCenter.Number, "+886935074443") && - message.Time.Day==27 && - message.Time.Month==7 && - message.Time.Year==99 && - message.Time.Hour==0 && - message.Time.Minute==10 && - message.Time.Second==48) fprintf(stdout, _("Saved by Logo Express\n")); - - /* Is it changed in next versions ? Or what ? */ - if (!strcmp(message.Sender, "+998000002") || - !strcmp(message.Sender, "+998000003") || - !strcmp(message.Sender, "+998000004")) fprintf(stdout, _("Saved by Operator Logo Uploader by Thomas Kessler\n")); - } else { - if (!strcmp(message.Sender, "+8861234567890") && - !strcmp(message.MessageCenter.Number, "+886935074443")) fprintf(stdout, _("Saved by Logo Express\n")); - } - if (!strncmp(message.Sender, "OpLogo",6) && - strlen(message.Sender)==11) - fprintf(stdout, _("Saved by gnokii\n")); -#endif + /* [end] can be only argv[4] */ + if (argv[4][0] != '-') { + end_message = atoi(argv[4]); + } - break; + /* parse all options (beginning with '-' */ + while ((i = getopt(argc, argv, "f:F:d")) != -1) { + switch (i) { + case 'd': + del = 1; + break; + case 'F': + mode = 0; + case 'f': + if (optarg) { + dprintf(_("Saving into %s\n"), optarg); + strncpy(filename, optarg, 64); + if (strlen(optarg) > 63) { + fprintf(stderr, _("Filename too long - will be truncated to 63 characters.\n")); + filename[63] = 0; + } else { + filename[strlen(optarg)] = 0; + } + } else usage(); + break; + default: + usage(); + } + } + } - case GSM_WAPBookmarkUDH: + /* Now retrieve the requested entries. */ + for (count = start_message; count <= end_message; count ++) { - /* put bookmark into bookmark structure */ - switch (GSM_ReadWAPBookmark(&message, &bookmark)) { - case GE_NONE: - fprintf(stdout, ("WAP Bookmark\n")); + message.Location = count; + data.SMSMessage = &message; + error = SM_Functions(GOP_GetSMS, &data, &State); - fprintf(stdout,_("Address: \"%s\"\n"),bookmark.address); + switch (error) { + case GE_NONE: + switch (message.Type) { + case GST_MO: + fprintf(stdout, _("%d. Outbox Message "), message.MessageNumber); + if (message.Status) + fprintf(stdout, _("(sent)\n")); + else + fprintf(stdout, _("(not sent)\n")); + fprintf(stdout, _("Text: %s\n\n"), message.MessageText); + break; + case GST_DR: + fprintf(stdout, _("%d. Delivery Report "), message.MessageNumber); + if (message.Status) + fprintf(stdout, _("(read)\n")); + else + fprintf(stdout, _("(not read)\n")); + fprintf(stdout, _("Sending date/time: %d/%d/%d %d:%02d:%02d "), \ + message.Time.Day, message.Time.Month, message.Time.Year, \ + message.Time.Hour, message.Time.Minute, message.Time.Second); + if (message.Time.Timezone) { + if (message.Time.Timezone > 0) + fprintf(stdout,_("+%02d00"), message.Time.Timezone); + else + fprintf(stdout,_("%02d00"), message.Time.Timezone); + } + fprintf(stdout, "\n"); + fprintf(stdout, _("Response date/time: %d/%d/%d %d:%02d:%02d "), \ + message.SMSCTime.Day, message.SMSCTime.Month, message.SMSCTime.Year, \ + message.SMSCTime.Hour, message.SMSCTime.Minute, message.SMSCTime.Second); + if (message.SMSCTime.Timezone) { + if (message.SMSCTime.Timezone > 0) + fprintf(stdout,_("+%02d00"),message.SMSCTime.Timezone); + else + fprintf(stdout,_("%02d00"),message.SMSCTime.Timezone); + } + fprintf(stdout, "\n"); + fprintf(stdout, _("Receiver: %s Msg Center: %s\n"), message.Sender, message.MessageCenter.Number); + fprintf(stdout, _("Text: %s\n\n"), message.MessageText); + break; + default: + fprintf(stdout, _("%d. Inbox Message "), message.MessageNumber); + if (message.Status) + fprintf(stdout, _("(read)\n")); + else + fprintf(stdout, _("(not read)\n")); + fprintf(stdout, _("Date/time: %d/%d/%d %d:%02d:%02d "), \ + message.Time.Day, message.Time.Month, message.Time.Year, \ + message.Time.Hour, message.Time.Minute, message.Time.Second); + if (message.Time.Timezone) { + if (message.Time.Timezone > 0) + fprintf(stdout,_("+%02d00"),message.Time.Timezone); + else + fprintf(stdout,_("%02d00"),message.Time.Timezone); + } + fprintf(stdout, "\n"); + fprintf(stdout, _("Sender: %s Msg Center: %s\n"), message.Sender, message.MessageCenter.Number); + switch (SMS_DetectUDH(&message)) { + case GSM_OpLogo: + fprintf(stdout, _("GSM operator logo for %s (%s) network.\n"), bitmap.netcode, GSM_GetNetworkName(bitmap.netcode)); + if (!strcmp(message.Sender, "+998000005") && !strcmp(message.MessageCenter.Number, "+886935074443")) dprintf(_("Saved by Logo Express\n")); + if (!strcmp(message.Sender, "+998000002") || !strcmp(message.Sender, "+998000003")) dprintf(_("Saved by Operator Logo Uploader by Thomas Kessler\n")); + case GSM_CallerIDLogo: + fprintf(stdout, ("Logo:\n")); + /* put bitmap into bitmap structure */ + GSM_ReadSMSBitmap(&message, &bitmap); + GSM_PrintBitmap(&bitmap); + if (*filename) { + error = GE_NONE; + if ((stat(filename, &buf) == 0)) { + fprintf(stdout, _("File %s exists.\n"), filename); + fprintf(stderr, _("Overwrite? (yes/no) ")); + GetLine(stdin, ans, 4); + if (!strcmp(ans, "yes")) { + error = GSM_SaveBitmapFile(filename, &bitmap); + } + } else error = GSM_SaveBitmapFile(filename, &bitmap); + if (error!=GE_NONE) fprintf(stderr, _("Couldn't save logofile %s!\n"), filename); + } + break; + case GSM_RingtoneUDH: + fprintf(stdout, ("Ringtone\n")); + break; + case GSM_ConcatenatedMessages: + fprintf(stdout, _("Linked (%d/%d):\n"),message.UDH[5],message.UDH[4]); + case GSM_NoUDH: + fprintf(stdout, _("Text:\n%s\n\n"), message.MessageText); + if ((mode != -1) && *filename) { + char buf[1024]; + sprintf(buf, "%s%d", filename, count); + mode = GSM_SaveTextFile(buf, message.MessageText, mode); + } + break; + default: + fprintf(stderr, _("Unknown\n")); + break; + } + break; + } + if (del) { + data.SMSMessage = &message; + if (GE_NONE != SM_Functions(GOP_DeleteSMS, &data, &State)) + fprintf(stdout, _("(delete failed)\n")); + else + fprintf(stdout, _("(message deleted)\n")); + } + break; + case GE_NOTIMPLEMENTED: + fprintf(stderr, _("Function not implemented in %s model!\n"), model); + if (GSM && GSM->Terminate) GSM->Terminate(); + return -1; + case GE_INVALIDSMSLOCATION: + fprintf(stderr, _("Invalid location: %s %d\n"), memory_type_string, count); + break; + case GE_EMPTYSMSLOCATION: + fprintf(stderr, _("SMS location %s %d empty.\n"), memory_type_string, count); + break; + default: + fprintf(stdout, _("GetSMS %s %d failed!(%d)\n\n"), memory_type_string, count, error); + break; + } + } + + if (GSM && GSM->Terminate) GSM->Terminate(); + + return 0; +} - if (bookmark.title[0]==0) - fprintf(stdout,_("Title: \"%s\"\n"),bookmark.address); - else - fprintf(stdout,_("Title: \"%s\"\n"),bookmark.title); +/* Delete SMS messages. */ +int deletesms(int argc, char *argv[]) +{ + GSM_SMSMessage message; + char *memory_type_string; + int start_message, end_message, count; + GSM_Error error; - break; - default: - fprintf(stdout,_("Error reading WAP Bookmark\n")); - break; - } + /* Handle command line args that set type, start and end locations. */ + memory_type_string = argv[0]; + message.MemoryType = StrToMemoryType(memory_type_string); + if (message.MemoryType == GMT_XX) { + fprintf(stderr, _("Unknown memory type %s (use ME, SM, ...)!\n"), argv[0]); + return (-1); + } + + start_message = end_message = atoi (argv[1]); + if (argc > 2) end_message = atoi (argv[2]); + + /* Now delete the requested entries. */ + for (count = start_message; count <= end_message; count ++) { + + message.Location = count; + data.SMSMessage = &message; + error = SM_Functions(GOP_DeleteSMS, &data, &State); + + if (error == GE_NONE) + fprintf(stdout, _("Deleted SMS %s %d\n"), memory_type_string, count); + else { + if (error == GE_NOTIMPLEMENTED) { + fprintf(stderr, _("Function not implemented in %s model!\n"), model); + GSM->Terminate(); + return -1; + } + fprintf(stdout, _("DeleteSMS %s %d failed!(%d)\n\n"), memory_type_string, count, error); + } + } -#ifdef DEBUG - if (!strcmp(message.Sender, "WAPBookmark")) - fprintf(stdout, _("Saved by gnokii\n")); -#endif + GSM->Terminate(); - break; + return 0; +} - case GSM_CallerIDLogo: +static volatile bool bshutdown = false; - /* put bitmap into bitmap structure */ - switch (GSM_ReadBitmap(&message, &bitmap)) { - case GE_INVALIDIMAGESIZE: - fprintf(stdout,_("Image size not supported\n")); - break; - case GE_NONE: - fprintf(stdout, ("Caller Logo\n")); - - GSM_PrintBitmap(&bitmap); +/* SIGINT signal handler. */ +static void interrupted(int sig) +{ + signal(sig, SIG_IGN); + bshutdown = true; +} - if (filename[0]!=0) { - GSM_SaveBitmapFileOnConsole(filename, &bitmap); - } +#ifdef SECURITY - break; - default: - fprintf(stdout,_("Error reading image\n")); - break; - } +/* In this mode we get the code from the keyboard and send it to the mobile + phone. */ +int entersecuritycode(char *type) +{ + GSM_Error test; + GSM_SecurityCode SecurityCode; + + if (!strcmp(type,"PIN")) + SecurityCode.Type=GSCT_Pin; + else if (!strcmp(type,"PUK")) + SecurityCode.Type=GSCT_Puk; + else if (!strcmp(type,"PIN2")) + SecurityCode.Type=GSCT_Pin2; + else if (!strcmp(type,"PUK2")) + SecurityCode.Type=GSCT_Puk2; + // FIXME: Entering of SecurityCode does not work :-( + // else if (!strcmp(type,"SecurityCode")) + // SecurityCode.Type=GSCT_SecurityCode; + else + usage(); -#ifdef DEBUG - if (message.folder==0) { //GST_INBOX - if (!strcmp(message.Sender, "+998000005") && - !strcmp(message.MessageCenter.Number, "+886935074443") && - message.Time.Day==27 && - message.Time.Month==7 && - message.Time.Year==99 && - message.Time.Hour==0 && - message.Time.Minute==10 && - message.Time.Second==48) fprintf(stdout, _("Saved by Logo Express\n")); - } else { - if (!strcmp(message.Sender, "+8861234567890") && - !strcmp(message.MessageCenter.Number, "+886935074443")) fprintf(stdout, _("Saved by Logo Express\n")); - } - if (!strcmp(message.Sender, "GroupLogo")) - fprintf(stdout, _("Saved by gnokii\n")); +#ifdef WIN32 + printf("Enter your code: "); + gets(SecurityCode.Code); +#else + strcpy(SecurityCode.Code,getpass(_("Enter your code: "))); #endif - break; + test = GSM->EnterSecurityCode(SecurityCode); + if (test == GE_INVALIDSECURITYCODE) + fprintf(stdout, _("Error: invalid code.\n")); + else if (test == GE_NONE) + fprintf(stdout, _("Code ok.\n")); + else if (test == GE_NOTIMPLEMENTED) + fprintf(stderr, _("Function not implemented in %s model!\n"), model); + else + fprintf(stdout, _("Other error.\n")); - case GSM_ProfileUDH: - fprintf(stdout, ("Profile SMS, part %i/%i\n"),message.UDH[11],message.UDH[10]); - break; + GSM->Terminate(); - case GSM_WAPBookmarkUDHLong: - fprintf(stdout, ("WAP Bookmark, part %i/%i\n"),message.UDH[11],message.UDH[10]); - break; + return 0; +} - case GSM_WAPSettingsUDH: - fprintf(stdout, ("WAP Settings, part %i/%i\n"),message.UDH[11],message.UDH[10]); - break; - - case GSM_RingtoneUDH: +int getsecuritycodestatus(void) +{ + int Status; - /* put ringtone into ringtone structure */ - switch (GSM_ReadRingtone(&message, &ringtone)) { - case GE_NONE: + if (GSM->GetSecurityCodeStatus(&Status) == GE_NONE) { - fprintf(stdout, ("Ringtone \"%s\"\n"),ringtone.name); + fprintf(stdout, _("Security code status: ")); - while (confirm < 0) { - fprintf(stderr, _("Do you want to play it ? (yes/no) ")); - GetLine(stdin, ans, 7); - if (!strcmp(ans, "yes")) confirm = 1; - if (!strcmp(ans, "no")) confirm = 0; - } + switch(Status) { + case GSCT_SecurityCode: + fprintf(stdout, _("waiting for Security Code.\n")); + break; + case GSCT_Pin: + fprintf(stdout, _("waiting for PIN.\n")); + break; + case GSCT_Pin2: + fprintf(stdout, _("waiting for PIN2.\n")); + break; + case GSCT_Puk: + fprintf(stdout, _("waiting for PUK.\n")); + break; + case GSCT_Puk2: + fprintf(stdout, _("waiting for PUK2.\n")); + break; + case GSCT_None: + fprintf(stdout, _("nothing to enter.\n")); + break; + default: + fprintf(stdout, _("Unknown!\n")); + break; + } + } - if (confirm==1) GSM_PlayRingtoneOnConsole(&ringtone); - - if (filename[0]!=0) GSM_SaveRingtoneFileOnConsole(filename, &ringtone); - - break; - - default: - fprintf(stdout,_("Gnokii can't read this ringtone - there is probably error inside\n")); - break; - } - - break; - - case GSM_CalendarNoteUDH: - fprintf(stdout, ("Calendar note SMS, part %i/%i\n"),message.UDH[11],message.UDH[10]); - fprintf(stdout, _("Text:\n%s\n\n"), message.MessageText); - if (filename[0]!=0 && mode != -1) mode = GSM_SaveTextFileOnConsole(filename, message.MessageText, mode); - break; - - case GSM_ConcatenatedMessages: - fprintf(stdout, _("Linked (%d/%d)\nText:\n%s\n\n"),message.UDH[5],message.UDH[4], message.MessageText); - if (filename[0]!=0 && mode != -1) mode = GSM_SaveTextFileOnConsole(filename, message.MessageText, mode); - break; - - case GSM_EnableVoice: - fprintf(stdout, _("Enables voice indicator\nText:\n%s\n\n"), message.MessageText); - if (filename[0]!=0 && mode != -1) mode = GSM_SaveTextFileOnConsole(filename, message.MessageText, mode); - break; - - case GSM_DisableVoice: - fprintf(stdout, _("Disables voice indicator\nText:\n%s\n\n"), message.MessageText); - if (filename[0]!=0 && mode != -1) mode = GSM_SaveTextFileOnConsole(filename, message.MessageText, mode); - break; - - case GSM_EnableFax: - fprintf(stdout, _("Enables fax indicator\nText:\n%s\n\n"), message.MessageText); - if (filename[0]!=0 && mode != -1) mode = GSM_SaveTextFileOnConsole(filename, message.MessageText, mode); - break; - - case GSM_DisableFax: - fprintf(stdout, _("Disables fax indicator\nText:\n%s\n\n"), message.MessageText); - if (filename[0]!=0 && mode != -1) mode = GSM_SaveTextFileOnConsole(filename, message.MessageText, mode); - break; - - case GSM_EnableEmail: - fprintf(stdout, _("Enables email indicator\nText:\n%s\n\n"), message.MessageText); - if (filename[0]!=0 && mode != -1) mode = GSM_SaveTextFileOnConsole(filename, message.MessageText, mode); - break; - - case GSM_DisableEmail: - fprintf(stdout, _("Disables email indicator\nText:\n%s\n\n"), message.MessageText); - if (filename[0]!=0 && mode != -1) mode = GSM_SaveTextFileOnConsole(filename, message.MessageText, mode); - break; - - case GSM_VoidSMS: - fprintf(stdout, _("Void SMS\nText:\n%s\n\n"), message.MessageText); - if (filename[0]!=0 && mode != -1) mode = GSM_SaveTextFileOnConsole(filename, message.MessageText, mode); - break; - - case GSM_NoUDH: - if (message.Coding!=GSM_Coding_8bit) { - fprintf(stdout, _("Text:\n%s\n\n"), message.MessageText); - if (filename[0]!=0 && mode != -1) mode = GSM_SaveTextFileOnConsole(filename, message.MessageText, mode); - } else { - fprintf(stdout, _("Message cannot be displayed here\n")); // like in phone :-) - } - break; - - default: //GSM_UnknownUDH and other - fprintf(stderr, _("Unknown\n")); - } - - break; - - default: - fprintf(stdout,_("Unknown SMS type. Report it\n")); - break; - } - - break; - - case GE_NOTIMPLEMENTED: - - fprintf(stderr, _("Function not implemented in %s model!\n"), model); - GSM->Terminate(); - return -1; - - case GE_INVALIDSMSLOCATION: - - fprintf(stderr, _("Invalid location: %s %d\n"), memory_type_string, count); - - break; - - case GE_EMPTYSMSLOCATION: - - fprintf(stderr, _("SMS location %s %d empty.\n"), memory_type_string, count); - - break; - - case GE_NOACCESS: - - fprintf(stderr, _("No access to %s memory.\n"), memory_type_string); - - break; - - default: - - fprintf(stderr, _("GetSMS %s %d failed!(%d)\n\n"), memory_type_string, count, error); - } - } - - GSM->Terminate(); - - return 0; -} - -int getsmsstatus(int argc, char *argv[]) -{ - GSM_SMSStatus SMSStatus; - GSM_SMSFolders folders; - GSM_Error error; - GSM_SMSMessage SMS; - - int i,j; - - /* Initialise the code for the GSM interface. */ - fbusinit(NULL); - - error = GSM->GetSMSStatus(&SMSStatus); - if (error!=GE_NONE) return error; - - fprintf(stdout, _("SMS Messages: UnRead %d, Number %d\n"),SMSStatus.UnRead, SMSStatus.Number); - - error=GSM->GetSMSFolders(&folders); - if (error!=GE_NONE) return error; - - /* For not 7110 compatible phones we have to read all SMS and prepare sms table */ - if( GetModelFeature (FN_SMS)!=F_SMS71 ) - { - i=1;j=0; - while (true) { - if (j==SMSStatus.Number) break; - SMS.Location=i; - if (GSM->GetSMSMessage(&SMS)==GE_NONE) { - SMSStatus.foldertable[j].smsnum=i; - - /* We set such folders ID like in 7110 compatible phones */ - if (SMS.Status==GSS_NOTSENTREAD && SMS.folder==0) //GST_INBOX - SMSStatus.foldertable[j].folder=0; - else { - switch (SMS.folder) { - case 0://GST_INBOX - SMSStatus.foldertable[j].folder=GST_7110_INBOX; - break; - case 1://GST_OUTBOX - SMSStatus.foldertable[j].folder=GST_7110_OUTBOX; - break; - } - } - j++; - } - i++; - } - } - - printf("0.Unread : "); - for(j=0; jTerminate(); - - return 0; -} - -/* Delete SMS messages. */ -int deletesms(int argc, char *argv[]) -{ - - GSM_SMSMessage message; - char memory_type_string[20]; - int start_message, end_message, count; - GSM_Error error; - - /* Handle command line args that set type, start and end locations. */ - if (!GetMemoryTypeID(argv[0], &message.MemoryType)) - { - fprintf(stderr, _("Unknown memory type %s!\n"), argv[0]); - return (-1); - } - GetMemoryTypeString(memory_type_string, &message.MemoryType); - - start_message = atoi (argv[1]); - if (argc > 2) end_message = atoi (argv[2]); - else end_message = start_message; - - /* Initialise the code for the GSM interface. */ - - fbusinit(NULL); - - /* Now delete the requested entries. */ - - for (count = start_message; count <= end_message; count ++) { - - message.Location = count; - - error = GSM->DeleteSMSMessage(&message); - - if (error == GE_NONE) - fprintf(stdout, _("Deleted SMS %s %d\n"), memory_type_string, count); - else { - if (error == GE_NOTIMPLEMENTED) { - fprintf(stderr, _("Function not implemented in %s model!\n"), model); GSM->Terminate(); - return -1; - } - fprintf(stdout, _("DeleteSMS %s %d failed!(%d)\n\n"), memory_type_string, count, error); - } - } - - GSM->Terminate(); - - return 0; -} - -static volatile bool bshutdown = false; - -/* SIGINT signal handler. */ - -static void interrupted(int sig) -{ - - signal(sig, SIG_IGN); - bshutdown = true; - -} - -#ifdef SECURITY - -/* In this mode we get the code from the keyboard and send it to the mobile - phone. */ - -int entersecuritycode(char *type) -{ - GSM_Error test; - GSM_SecurityCode SecurityCode; - - if (!strcmp(type,"PIN")) SecurityCode.Type=GSCT_Pin; - else if (!strcmp(type,"PUK")) SecurityCode.Type=GSCT_Puk; - else if (!strcmp(type,"PIN2"))SecurityCode.Type=GSCT_Pin2; - else if (!strcmp(type,"PUK2"))SecurityCode.Type=GSCT_Puk2; - - // FIXME: Entering of SecurityCode does not work :-( - // else if (!strcmp(type,"SecurityCode")) - // SecurityCode.Type=GSCT_SecurityCode; - - else { - fprintf(stdout, _("Wrong code in second parameter (allowed: PIN,PUK,PIN2,PUK2,SecurityCode)\n")); - return -1; - } - -#ifdef WIN32 - printf("Enter your code: "); - gets(SecurityCode.Code); -#else - strcpy(SecurityCode.Code,getpass(_("Enter your code: "))); -#endif - - fbusinit(NULL); - - test = GSM->EnterSecurityCode(SecurityCode); - if (test==GE_NONE) - fprintf(stdout,_("Code OK !\n")); - else - fprintf(stderr,_("%s\n"),print_error(test)); - - GSM->Terminate(); - - return 0; -} - -int getsecuritycodestatus(void) -{ - - int Status; - - fbusinit(NULL); - - if (GSM->GetSecurityCodeStatus(&Status) == GE_NONE) { - - fprintf(stdout, _("Security code status: ")); - - switch(Status) { - case GSCT_SecurityCode:fprintf(stdout, _("waiting for Security Code.\n"));break; - case GSCT_Pin: fprintf(stdout, _("waiting for PIN.\n")); break; - case GSCT_Pin2: fprintf(stdout, _("waiting for PIN2.\n")); break; - case GSCT_Puk: fprintf(stdout, _("waiting for PUK.\n")); break; - case GSCT_Puk2: fprintf(stdout, _("waiting for PUK2.\n")); break; - case GSCT_None: fprintf(stdout, _("nothing to enter.\n")); break; - default: fprintf(stdout, _("Unknown!\n")); - } - } - GSM->Terminate(); - - return 0; + return 0; } -int getsecuritycode(char *type) -{ - - GSM_SecurityCode SecurityCode; - GSM_Error error; - - if (!strcmp(type,"PIN")) SecurityCode.Type=GSCT_Pin; - else if (!strcmp(type,"PUK")) SecurityCode.Type=GSCT_Puk; - else if (!strcmp(type,"PIN2")) SecurityCode.Type=GSCT_Pin2; - else if (!strcmp(type,"PUK2")) SecurityCode.Type=GSCT_Puk2; - else if (!strcmp(type,"SecurityCode"))SecurityCode.Type=GSCT_SecurityCode; - else { - fprintf(stdout, _("Wrong code in second parameter (allowed: PIN,PUK,PIN2,PUK2,SecurityCode)\n")); - return -1; - } - - fbusinit(NULL); - - error=GSM->GetSecurityCode(&SecurityCode); - - switch (error) { - case GE_INVALIDSECURITYCODE: - fprintf(stdout, _("Error: getting ")); - switch (SecurityCode.Type) { - case GSCT_SecurityCode:fprintf(stdout, _("security code"));break; - case GSCT_Pin :fprintf(stdout, _("PIN"));break; - case GSCT_Pin2:fprintf(stdout, _("PIN2"));break; - case GSCT_Puk :fprintf(stdout, _("PUK"));break; - case GSCT_Puk2:fprintf(stdout, _("PUK2"));break; - default:break; - } - fprintf(stdout, _(" not allowed\n")); - break; - case GE_NONE: - switch (SecurityCode.Type) { - case GSCT_SecurityCode:fprintf(stdout, _("Security code"));break; - case GSCT_Pin :fprintf(stdout, _("PIN"));break; - case GSCT_Pin2:fprintf(stdout, _("PIN2"));break; - case GSCT_Puk :fprintf(stdout, _("PUK"));break; - case GSCT_Puk2:fprintf(stdout, _("PUK2"));break; - default:break; - } - fprintf(stdout, _(" is %s\n"),SecurityCode.Code); - break; - default: - fprintf(stderr, _("%s\n"),print_error(error)); - break; - } - - GSM->Terminate(); - - return 0; -} #endif /* Voice dialing mode. */ - int dialvoice(char *Number) { - fbusinit(NULL); - - if (GSM->DialVoice(Number)!=GE_NONE) fprintf(stdout,_("Error!\n")); + GSM->DialVoice(Number); - GSM->Terminate(); + GSM->Terminate(); - return 0; + return 0; } -/* Cancel a call */ -int cancelcall(void) +/* The following function allows to send logos using SMS */ +int sendlogo(int argc, char *argv[]) { - fbusinit(NULL); - - if (GSM->CancelCall()!=GE_NONE) fprintf(stdout,_("Error!\n")); - - GSM->Terminate(); + GSM_SMSMessage SMS; + GSM_Bitmap bitmap; + + char Data[sizeof(bitmap.bitmap) +64/*headers safety*/]; + + int current=0, i; + + struct option options[] = { + SMSC_OPTIONS, + { NULL, 0, NULL, 0} + }; + + /* Default settings for SMS message: + - no delivery report + - Class Message 1 + - no compression + - 8 bit data + - SMSC no. 1 + - validity 3 days + - set UserDataHeaderIndicator + */ + + SMS.Type = GST_MO; + SMS.Class = 1; + SMS.Compression = false; + SMS.EightBit = true; + SMS.MessageCenter.No = 1; + SMS.Validity = 4320; /* 4320 minutes == 72 hours */ + + optarg = NULL; + optind = 0; + while ((i = getopt_long(argc, argv, "", options, NULL)) != -1) { + if (smsc_options_parse(i,&SMS)) + continue; + switch (i) { + default: + usage(); /* Would be better to have an sendsms_usage() here. */ + } + } - return 0; -} +/* + if (argc!=3 && argc!=4) + usage(); +*/ -int savelogo(int argc, char *argv[]) -{ - GSM_Bitmap bitmap; - GSM_NetworkInfo NetworkInfo; - GSM_MultiSMSMessage MultiSMS; - - /* Operator logos will be saved with this number */ - char oplogonumber[]={'O','p','L','o','g','o', - '0','0','0','0','0', /* MMC+MNC */ - '\0'}; - int i=0; - - bool UnicodeText=false; - - /* The first argument is the type of the logo. */ - if (!strcmp(argv[0], "op")) { - fprintf(stdout, _("Saving operator logo.\n")); - } else if (!strcmp(argv[0], "caller")) { - fprintf(stdout, _("Saving caller line identification logo.\n")); - } else if (!strcmp(argv[0], "startup")) { - fprintf(stderr, _("It isn't possible to save startup logo!\n")); - return (-1); - } else if (!strcmp(argv[0], "7110startup")) { - fprintf(stderr, _("It isn't possible to save startup logo!\n")); - return (-1); - } else if (!strcmp(argv[0], "6210startup")) { - fprintf(stderr, _("It isn't possible to save startup logo!\n")); - return (-1); - } else if (!strcmp(argv[0], "7110op")) { - fprintf(stderr, _("It isn't possible to save big operator logos!\n")); - return (-1); - } else if (!strcmp(argv[0], "picture")) { - fprintf(stderr, _("Saving picture image.\n")); - } else if (!strcmp(argv[0], "screensaver")) { - fprintf(stderr, _("Saving screen saver.\n")); - } else { - fprintf(stderr, _("You should specify what kind of logo to save!\n")); - return (-1); - } - - /* The second argument is the bitmap file. */ - if (GSM_ReadBitmapFileOnConsole(argv[1], &bitmap)!=GE_NONE) return -1; - - /* Initialise the GSM interface. */ - fbusinit(NULL); - - /* We check optional parameters from 2'rd */ - optind = 2; - - if (!strcmp(argv[0], "op")) { - GSM_ResizeBitmap(&bitmap,GSM_CallerLogo); - - /* The third argument, if present, is the Network code of the operator. - * Network code is in this format: "xxx yy" */ - if (argc > 2) { - strcpy(bitmap.netcode, argv[2]); -#ifdef DEBUG - fprintf(stdout, _("Operator code: %s\n"), argv[2]); -#endif - if (!strcmp(GSM_GetNetworkName(bitmap.netcode),"unknown")) { - fprintf(stderr,"Sorry, gnokii doesn't know \"%s\" network !\n",bitmap.netcode); - GSM->Terminate(); - return -1; - } - optind++; - } else - { - if (GSM->GetNetworkInfo(&NetworkInfo) == GE_NONE) strncpy(bitmap.netcode,NetworkInfo.NetworkCode,7); - } - bitmap.type=GSM_OperatorLogo; - - /* Put bitmap into SMS structure */ - GSM_SaveBitmapToSMS(&MultiSMS,&bitmap,false,false); - - oplogonumber[6]=bitmap.netcode[0]; - oplogonumber[7]=bitmap.netcode[1]; - oplogonumber[8]=bitmap.netcode[2]; - oplogonumber[9]=bitmap.netcode[4]; - oplogonumber[10]=bitmap.netcode[5]; - for(i=0;i2) { - optind++; - if (strlen(argv[2])>121) { - fprintf(stdout,_("Sorry: length of text (parameter \"%s\") can be 121 chars or shorter only !\n"),argv[2]); - return -1; - } - strcpy(bitmap.text,argv[2]); - } - - /* Put bitmap into SMS structure */ - GSM_SaveBitmapToSMS(&MultiSMS,&bitmap,false,UnicodeText); + /* The first argument is the type of the logo. */ + if (!strcmp(argv[0], "op")) { + SMS_SetupUDH(&SMS,GSM_OpLogo); /* error ignored */ + fprintf(stdout, _("Sending operator logo.\n")); + } else if (!strcmp(argv[0], "caller")) { /* error ignored */ + SMS_SetupUDH(&SMS,GSM_CallerIDLogo); + fprintf(stdout, _("Sending caller line identification logo.\n")); + } else { + fprintf(stderr, _("You should specify what kind of logo to send!\n")); + return (-1); + } - for(i=0;i 3) { - strcpy(bitmap.netcode, argv[3]); + /* If we are sending op logo we can rewrite network code. */ + if (!strcmp(argv[0], "op")) { + /* + * The fourth argument, if present, is the Network code of the operator. + * Network code is in this format: "xxx yy". + */ + if (argc > 3) { + strcpy(bitmap.netcode, argv[3]); #ifdef DEBUG - fprintf(stdout, _("Operator code: %s\n"), argv[3]); + fprintf(stdout, _("Operator code: %s\n"), argv[3]); #endif - if (!strcmp(GSM_GetNetworkName(bitmap.netcode),"unknown")) { - fprintf(stderr,"Sorry, gnokii doesn't know \"%s\" network !\n",bitmap.netcode); - GSM->Terminate(); - return -1; - } - optind++; - } else - { - if (GSM->GetNetworkInfo(&NetworkInfo) == GE_NONE) strncpy(bitmap.netcode,NetworkInfo.NetworkCode,7); - } - bitmap.type=GSM_OperatorLogo; - } - if (!strcmp(argv[0], "caller")) { - GSM_ResizeBitmap(&bitmap,GSM_CallerLogo); - - bitmap.type=GSM_CallerLogo; - } - if (!strcmp(argv[0], "screensaver")) { - GSM_ResizeBitmap(&bitmap,GSM_PictureImage); - - bitmap.text[0]=0; - - for(i=0;i3) { - optind++; - if (strlen(argv[3])>121) { - fprintf(stdout,_("Sorry: length of text (parameter \"%s\") can be 121 chars or shorter only !\n"),argv[3]); - return -1; - } - strcpy(bitmap.text,argv[3]); - } - } - - /* Put bitmap into SMS structure */ - GSM_SaveBitmapToSMS(&MultiSMS,&bitmap,ScreenSaver,UnicodeText); - - /* The second argument is the destination, ie the phone number of recipient. */ - for(i=0;i9)) num=1; - bitmap.number=num; - } else - { - bitmap.number=1; - } - bitmap.number--; - bitmap.type=GSM_CallerLogo; - } - - if (!strcmp(argv[0],"picture")) { - /* There is a number missing in argument list. */ - if (argc==3) { - if (strlen(argv[2])==2) { - num=(argv[2][0]-'0')*10+(argv[2][1]-'0'); - } else { - num=argv[2][0]-'0'; - } - if (num<1) num=1; - bitmap.number=num; - } else - { - bitmap.number=1; - } - bitmap.number--; - bitmap.type=GSM_PictureImage; - } - - if (!strcmp(argv[0],"startup")) - bitmap.type=GSM_StartupLogo; - - if (!strcmp(argv[0],"7110startup")) - bitmap.type=GSM_7110StartupLogo; - - if (!strcmp(argv[0],"6210startup")) - bitmap.type=GSM_6210StartupLogo; - - if (!strcmp(argv[0],"dealer")) - bitmap.type=GSM_DealerNoteText; - - if (!strcmp(argv[0],"text")) - bitmap.type=GSM_WelcomeNoteText; + Data[current++] = 0x01; /* depth=number of grayscales */ - if (bitmap.type!=GSM_None) { - - fbusinit(NULL); - - fprintf(stdout, _("Getting Logo\n")); - - error=GSM->GetBitmap(&bitmap); + memcpy(Data+current,bitmap.bitmap,bitmap.size); + current+=bitmap.size; + + /* Send the message. */ + sendsms_deconcatenated(&SMS,Data,current,true/*useudh*/); - GSM->Terminate(); - - switch (error) - { - case GE_NONE: - if (bitmap.type==GSM_DealerNoteText) fprintf(stdout, _("Dealer welcome note ")); - if (bitmap.type==GSM_WelcomeNoteText) fprintf(stdout, _("Welcome note ")); - if (bitmap.type==GSM_DealerNoteText || bitmap.type==GSM_WelcomeNoteText) - { - if (bitmap.text[0]!=0) - { - fprintf(stdout, _("currently set to \"%s\"\n"), bitmap.text); - } else { - fprintf(stdout, _("currently empty\n")); - } - } else - { - if (bitmap.width!=0) - { - if (bitmap.type==GSM_OperatorLogo || bitmap.type==GSM_7110OperatorLogo) - { - fprintf(stdout,"Operator logo for %s (%s) network got succesfully\n",bitmap.netcode,GSM_GetNetworkName(bitmap.netcode)); - } - if (bitmap.type==GSM_StartupLogo || bitmap.type==GSM_7110StartupLogo || bitmap.type==GSM_6210StartupLogo) - { - fprintf(stdout,"Startup logo got successfully\n"); - } - if (bitmap.type==GSM_CallerLogo) - { - fprintf(stdout,"Caller logo got successfully\n"); - } - if (bitmap.type==GSM_PictureImage) - { - fprintf(stdout,"Picture Image got successfully"); - if (strcmp(bitmap.text,"")) - fprintf(stdout,_(", text \"%s\""),bitmap.text); - if (strcmp(bitmap.Sender,"")) - fprintf(stdout,_(", sender \"%s\""),bitmap.Sender); - fprintf(stdout,"\n"); - } - if (argc>1) - { - if (GSM_SaveBitmapFileOnConsole(argv[1], &bitmap)!=GE_NONE) return(-1); - } - } else - { - fprintf(stdout,"Your phone doesn't have logo uploaded !\n"); - return -1; - } - } - break; - case GE_NOTIMPLEMENTED: - fprintf(stderr, _("Function not implemented !\n")); - return -1; - case GE_NOTSUPPORTED: - fprintf(stderr, _("This kind of logo is not supported !\n")); - return -1; - default: - fprintf(stderr, _("Error getting logo (wrong location ?) !\n")); - return -1; - } - } else - { - fprintf(stderr, _("What kind of logo do you want to get ?\n")); - return -1; - } - - return 0; + GSM->Terminate(); + return 0; } -/* Setting logos. */ - -int setlogo(int argc, char *argv[]) +/* Getting logos. */ +GSM_Error SaveBitmapFileOnConsole(char *FileName, GSM_Bitmap *bitmap) { + int confirm; + char ans[4]; + struct stat buf; + GSM_Error error; - GSM_Bitmap bitmap,oldbit; - GSM_NetworkInfo NetworkInfo; - GSM_Error error; - char model[64]; - int num; - - bool ok=true; - - int i; - - fbusinit(NULL); - - if (!strcmp(argv[0],"text") || !strcmp(argv[0],"dealer")) - { - if (!strcmp(argv[0],"text")) bitmap.type=GSM_WelcomeNoteText; - else bitmap.type=GSM_DealerNoteText; - bitmap.text[0]=0x00; - if (argc>1) strncpy(bitmap.text,argv[1],255); - } else - { - if (!strcmp(argv[0],"op") || !strcmp(argv[0],"startup") || !strcmp(argv[0],"caller") || - !strcmp(argv[0],"7110op") || !strcmp(argv[0],"6210startup") || !strcmp(argv[0],"7110startup") || - !strcmp(argv[0],"picture")) - { - if (argc>1) - { - if (!strcmp(argv[0],"startup")) - { - bitmap.type=GSM_StartupLogo; - bitmap.width=84; - bitmap.height=48; - bitmap.size=GSM_GetBitmapSize(&bitmap); - num=argv[1][0]-'0'; - if (num>=1 && num<=3) { - bitmap.number=num; - } else { - if (GSM_ReadBitmapFileOnConsole(argv[1], &bitmap)!=GE_NONE) { - GSM->Terminate(); - return(-1); - } - bitmap.number=0; - GSM_ResizeBitmap(&bitmap,GSM_StartupLogo); - } - } else { - if (GSM_ReadBitmapFileOnConsole(argv[1], &bitmap)!=GE_NONE) { - GSM->Terminate(); - return(-1); - } - } - if (!strcmp(argv[0],"op")) - { - if (bitmap.type!=GSM_OperatorLogo || argc<3) - { - if (GSM->GetNetworkInfo(&NetworkInfo) == GE_NONE) strncpy(bitmap.netcode,NetworkInfo.NetworkCode,7); - } - GSM_ResizeBitmap(&bitmap,GSM_OperatorLogo); - if (argc==3) - { - strncpy(bitmap.netcode,argv[2],7); - if (!strcmp(GSM_GetNetworkName(bitmap.netcode),"unknown")) - { - fprintf(stderr,"Sorry, gnokii doesn't know \"%s\" network !\n",bitmap.netcode); - return -1; - } - } - } - if (!strcmp(argv[0],"7110op")) - { - if (bitmap.type!=GSM_7110OperatorLogo || argc<3) - { - if (GSM->GetNetworkInfo(&NetworkInfo) == GE_NONE) strncpy(bitmap.netcode,NetworkInfo.NetworkCode,7); - } - GSM_ResizeBitmap(&bitmap,GSM_7110OperatorLogo); - if (argc==3) - { - strncpy(bitmap.netcode,argv[2],7); - if (!strcmp(GSM_GetNetworkName(bitmap.netcode),"unknown")) - { - fprintf(stderr,"Sorry, gnokii doesn't know \"%s\" network !\n",bitmap.netcode); - return -1; - } - } - } - if (!strcmp(argv[0],"picture")) - { - GSM_ResizeBitmap(&bitmap,GSM_PictureImage); - bitmap.number=1; - if (argc>2) - { - if (strlen(argv[2])==2) { - num=(argv[2][0]-'0')*10+(argv[2][1]-'0'); - } else { - num=argv[2][0]-'0'; - } - if (num<1) num=1; - bitmap.number=num; - } - bitmap.number--; - bitmap.text[0]=0; - if (argc>3) - strncpy(bitmap.text,argv[3],121); - strcpy(bitmap.Sender,"\0"); - if (argc>4) - strncpy(bitmap.Sender,argv[4],GSM_MAX_SENDER_LENGTH); - } - if (!strcmp(argv[0],"7110startup")) - { - GSM_ResizeBitmap(&bitmap,GSM_7110StartupLogo); - } - if (!strcmp(argv[0],"6210startup")) - { - GSM_ResizeBitmap(&bitmap,GSM_6210StartupLogo); - } - if (!strcmp(argv[0],"caller")) - { - GSM_ResizeBitmap(&bitmap,GSM_CallerLogo); - if (argc>2) - { - num=argv[2][0]-'0'; - if ((num<0)||(num>9)) num=0; - bitmap.number=num; - } else - { - bitmap.number=0; - } - oldbit.type=GSM_CallerLogo; - oldbit.number=bitmap.number; - if (GSM->GetBitmap(&oldbit)==GE_NONE) - { - /* We have to get the old name and ringtone!! */ - bitmap.ringtone=oldbit.ringtone; - strncpy(bitmap.text,oldbit.text,255); - } - if (argc>3) strncpy(bitmap.text,argv[3],255); - } - fprintf(stdout, _("Setting Logo.\n")); - } else - { - /* FIX ME: is it possible to permanently remove op logo ? */ - if (!strcmp(argv[0],"op")) - { - bitmap.type=GSM_OperatorLogo; - strncpy(bitmap.netcode,"000 00",7); - bitmap.width=72; - bitmap.height=14; - bitmap.size=GSM_GetBitmapSize(&bitmap); - GSM_ClearBitmap(&bitmap); - } - if (!strcmp(argv[0],"7110op")) - { - bitmap.type=GSM_7110OperatorLogo; - strncpy(bitmap.netcode,"000 00",7); - bitmap.width=78; - bitmap.height=21; - bitmap.size=GSM_GetBitmapSize(&bitmap); - GSM_ClearBitmap(&bitmap); + /* Ask before overwriting */ + while (stat(FileName, &buf) == 0) { + confirm = 0; + while (!confirm) { + fprintf(stderr, _("Saving logo. File \"%s\" exists. (O)verwrite, create (n)ew or (s)kip ? "), FileName); + GetLine(stdin, ans, 4); + if (!strcmp(ans, "O") || !strcmp(ans, "o")) confirm = 1; + if (!strcmp(ans, "N") || !strcmp(ans, "n")) confirm = 2; + if (!strcmp(ans, "S") || !strcmp(ans, "s")) return GE_USERCANCELED; + } + if (confirm == 1) break; + if (confirm == 2) { + fprintf(stderr, _("Enter name of new file: ")); + GetLine(stdin, FileName, 50); + if (!FileName || (*FileName == 0)) return GE_USERCANCELED; + } } - /* FIX ME: how to remove startup and group logos ? */ - fprintf(stdout, _("Removing Logo.\n")); - } - } else - { - fprintf(stderr, _("What kind of logo do you want to set ?\n")); - GSM->Terminate(); - return -1; - } - } - - while (GSM->GetModel(model) != GE_NONE) - sleep(1); - /* For Nokia 6110/6130/6150 we use different method of uploading. - Phone will display menu, when received it */ - if (!strcmp(model,"NSE-3") || !strcmp(model,"NSK-3") || !strcmp(model,"NSM-1")) - { - if (!strcmp(argv[0],"caller") && argc<3) - bitmap.number=255; - if (!strcmp(argv[0],"op") && argc<3) - bitmap.number=255; - } - - error=GSM->SetBitmap(&bitmap); + error = GSM_SaveBitmapFile(FileName, bitmap); - switch (error) - { - case GE_NONE: oldbit.type=bitmap.type; - oldbit.number=bitmap.number; - if (GSM->GetBitmap(&oldbit)==GE_NONE) { - if (bitmap.type==GSM_WelcomeNoteText || - bitmap.type==GSM_DealerNoteText) { - if (strcmp(bitmap.text,oldbit.text)) { - fprintf(stderr, _("Error setting")); - if (bitmap.type==GSM_DealerNoteText) fprintf(stderr, _(" dealer")); - fprintf(stderr, _(" welcome note - ")); - - /* I know, it looks horrible, but... */ - /* I set it to the short string - if it won't be set */ - /* it means, PIN is required. If it will be correct, previous */ - /* (user) text was too long */ - - /* Without it, I could have such thing: */ - /* user set text to very short string (for example, "Marcin") */ - /* then enable phone without PIN and try to set it to the very long (too long for phone) */ - /* string (which start with "Marcin"). If we compare them as only length different, we could think, */ - /* that phone accepts strings 6 chars length only (length of "Marcin") */ - /* When we make it correct, we don't have this mistake */ - - strcpy(oldbit.text,"!\0"); - GSM->SetBitmap(&oldbit); - GSM->GetBitmap(&oldbit); - if (oldbit.text[0]!='!') { - fprintf(stderr, _("SIM card and PIN is required\n")); - } else { - GSM->SetBitmap(&bitmap); - GSM->GetBitmap(&oldbit); - fprintf(stderr, _("too long, truncated to \"%s\" (length %i)\n"),oldbit.text,strlen(oldbit.text)); - } - ok=false; - } - } else { - if (bitmap.type==GSM_StartupLogo) { - for (i=0;iTerminate(); - - return 0; + return error; } -/* Calendar notes receiving. */ - -int getcalendarnote(int argc, char *argv[]) +int getlogo(int argc, char *argv[]) { - GSM_CalendarNote CalendarNote; - GSM_NotesInfo NotesInfo; - GSM_Error error; - int i; - int vCalVer=0; - bool vInfo=false; - int start, stop; - bool was_note=false; - char z_text[MAX_CALENDAR_TEXT_LENGTH+11]; - - /* Hopefully is 64 larger as FB38_MAX* / FB61_MAX* */ - char model[64]; - - struct tm *now; - time_t nowh; - GSM_DateTime Date; - - nowh=time(NULL); - now=localtime(&nowh); - - Date.Year = now->tm_year; - - /* I have 100 (for 2000) Year now :-) */ - if (Date.Year>99 && Date.Year<1900) { - Date.Year=Date.Year+1900; - } - - start=atoi(argv[0]); - stop=start; - - switch (argc) { - case 2: - if (!strcmp(argv[argc-1],"-v10")) { - vCalVer=10; - } else { - if (!strcmp(argv[argc-1],"-v30")) { - vCalVer=30; - } else { - stop=atoi(argv[1]); - } - } - break; - case 3: - stop=atoi(argv[1]); - if (!strcmp(argv[argc-1],"-v10")) { - vCalVer=10; - } else { - if (!strcmp(argv[argc-1],"-v30")) { - vCalVer=30; - } else { - usage(); - return -1; - } - } - break; - } - - fbusinit(NULL); + GSM_Bitmap bitmap; + GSM_Error error; + GSM_Statemachine *sm = &State; - while (GSM->GetModel(model) != GE_NONE) - sleep(1); + bitmap.type=GSM_None; - if (!strcmp(argv[0],"-s") || !strcmp(argv[0],"--short")) - vInfo=true; - else if (!isdigit(argv[0][0])) { - usage(); - return -1; - } + if (!strcmp(argv[0], "op")) + bitmap.type = GSM_OperatorLogo; - error=GSM->GetCalendarNotesInfo(&NotesInfo); - if ( error == GE_NONE ) { - if( NotesInfo.HowMany == 0 ) { - fprintf(stderr, _("Sorry! No Calendar Notes present on phone.\n")); - start=0; stop=(-1); /* This for skipping next 'for' loop ;-> */ - } -#ifdef DEBUG - fprintf(stdout, _(" CALENDAR NOTES INFO \n")); - fprintf(stdout, _("---------------------\n")); - fprintf(stdout, _("How Many Locations :%d\n"), NotesInfo.HowMany); - - /* For 6210 (NPE-3) and 7110 (NSE-5), Locations have a different behaviour */ - if ( GetModelFeature (FN_CALENDAR)==F_CAL71 ) { - fprintf(stdout, _("Locations are :\n")); - for(i=0;i */ - } - } - - if (GetModelFeature (FN_CALENDAR)!=F_CAL71) { - error=GE_NONE; - NotesInfo.HowMany=200; - for (i=0;i<200;i++) { - NotesInfo.Location[i]=i+1; - } - } - - if( vInfo && stop!=(-1) && error==GE_NONE ) - { - /* Info datas (for 7110 and comp.) */ - fprintf(stdout, _(" CALENDAR NOTES SUMMARY INFORMATION \n")); - fprintf(stdout, _(" ==================================\n")); - if (GetModelFeature (FN_CALENDAR)==F_CAL71) { - fprintf(stdout, _("Calendar notes present on phone: %d\n"), NotesInfo.HowMany); - fprintf(stdout, _("Locations are :\n")); - } - fprintf(stdout, "----------------------------------------------------------------------------\n"); - fprintf(stdout,_(" Loc Phys Type Summary description Dt start Alarm Recurs\n") ); - fprintf(stdout, "----------------------------------------------------------------------------\n"); - - for(i=0;iGetCalendarNote(&CalendarNote) == GE_NONE) { - char z_type[11]; - char z_recur[15]; - switch (CalendarNote.Type) { - case GCN_REMINDER:strcpy(z_type, "REMIND"); break; - case GCN_CALL: strcpy(z_type, "CALL"); break; - case GCN_MEETING: strcpy(z_type, "MEETING"); break; - case GCN_BIRTHDAY:strcpy(z_type, "BDAY"); break; - default: strcpy(z_type, "UNKNOWN"); break; - } - - if( CalendarNote.Recurrance ) { - sprintf( z_recur,"%d ", CalendarNote.Recurrance/24 ); - strcat( z_recur, CalendarNote.Recurrance == 1 ? "day" : "days" ); - } - else - strcpy( z_recur, "No" ); - - strcpy(z_text,""); - - if( CalendarNote.Type == GCN_CALL ) - sprintf(z_text, "\"%s\"", CalendarNote.Phone ); - - if (CalendarNote.Text[0]!=0) - sprintf(z_text, "\"%s\"", CalendarNote.Text ); - - if(CalendarNote.Type == GCN_BIRTHDAY) { - int i_age; - i_age = Date.Year - CalendarNote.Time.Year; - sprintf(z_text, "\"%s (%d %s)\"", CalendarNote.Text, - i_age, (i_age==1)?"year":"years"); - strcpy( z_recur, "-" ); - if (GetModelFeature (FN_CALENDAR)==F_CAL71) - fprintf(stdout, - _("%4d %4d %-7.7s %-32.32s %04d-%02d-%02d %s %s\n"), - i+1,NotesInfo.Location[i], z_type, z_text, - CalendarNote.Time.Year, - CalendarNote.Time.Month, - CalendarNote.Time.Day, - (CalendarNote.AlarmType==0x00) ? "Tone " : "Silent", - " " ); - else - fprintf(stdout, - _("%4d %4d %-7.7s %-32.32s %04d-%02d-%02d %s %s\n"), - i+1,NotesInfo.Location[i], z_type, z_text, - CalendarNote.Time.Year, - CalendarNote.Time.Month, - CalendarNote.Time.Day, - (CalendarNote.Alarm.Year) ? "Yes" : "No ", - " " ); - } else - if (GetModelFeature (FN_CALENDAR)==F_CAL71) - fprintf(stdout, - _("%4d %4d %-7.7s %-32.32s %04d-%02d-%02d %s %s\n"), - i+1,NotesInfo.Location[i], z_type, z_text, - CalendarNote.Time.Year, - CalendarNote.Time.Month, - CalendarNote.Time.Day, - (CalendarNote.Alarm.Year) ? "Yes" : "No ", - z_recur ); - else - fprintf(stdout, - _("%4d %4d %-7.7s %-32.32s %04d-%02d-%02d %s\n"), - i+1,NotesInfo.Location[i], z_type, z_text, - CalendarNote.Time.Year, - CalendarNote.Time.Month, - CalendarNote.Time.Day, - (CalendarNote.Alarm.Year) ? "Yes" : "No "); - } else { - if (GetModelFeature (FN_CALENDAR)!=F_CAL71) break; - } - } - } - else - for (i=start;i<=stop;i++) { - if (error==GE_NONE) { - if( i>NotesInfo.HowMany ) { - fprintf(stderr, _("Only %d Calendar Notes present on phone!\n"),NotesInfo.HowMany); - break; - } - if( i==0 ) { - fprintf(stderr, _("Calendar Notes location can't be zero... skipping.\n")); - continue; + if (!strcmp(argv[0], "caller")) { + /* There is caller group number missing in argument list. */ + if (argc == 3) { + bitmap.number=argv[2][0]-'0'; + if ((bitmap.number < 0) || (bitmap.number > 9)) bitmap.number = 0; + } else { + bitmap.number = 0; + } + bitmap.type = GSM_CallerLogo; } - } - CalendarNote.Location=i; - CalendarNote.ReadNotesInfo=false; - - if (GSM->GetCalendarNote(&CalendarNote) == GE_NONE) { - - if (vCalVer!=0) { - if (!was_note) { - fprintf(stdout, GSM_GetVCALENDARStart(vCalVer)); - was_note=true; - } - - fprintf(stdout, GSM_GetVCALENDARNote(&CalendarNote,vCalVer)); - - } else { /* not vCal */ - - if (was_note) { - fprintf(stdout, "\n"); - } else { - was_note=true; - } - - fprintf(stdout, _(" Type of the note: ")); - - switch (CalendarNote.Type) { - - case GCN_REMINDER:fprintf(stdout, _("Reminder\n"));break; - case GCN_CALL :fprintf(stdout, _("Call\n")); break; - case GCN_MEETING :fprintf(stdout, _("Meeting\n")); break; - case GCN_BIRTHDAY:fprintf(stdout, _("Birthday\n"));break; - default: fprintf(stdout, _("Unknown\n")); - - } - - /* For 3310: set date to 2090! */ - if (GetModelFeature (FN_CALENDAR)==F_CAL33) { - fprintf(stdout, _(" Date: xxxx-%02d-%02d\n"), CalendarNote.Time.Month, - CalendarNote.Time.Day); + if (!strcmp(argv[0],"startup")) + bitmap.type = GSM_StartupLogo; + else if (!strcmp(argv[0], "dealer")) + bitmap.type = GSM_DealerNoteText; + else if (!strcmp(argv[0], "text")) + bitmap.type=GSM_WelcomeNoteText; + + if (bitmap.type != GSM_None) { + + fprintf(stdout, _("Getting Logo\n")); + + data.Bitmap=&bitmap; + error=SM_Functions(GOP_GetBitmap, &data, sm); + + switch (error) { + case GE_NONE: + if (bitmap.type == GSM_DealerNoteText) fprintf(stdout, _("Dealer welcome note ")); + if (bitmap.type == GSM_WelcomeNoteText) fprintf(stdout, _("Welcome note ")); + if (bitmap.type == GSM_DealerNoteText || bitmap.type==GSM_WelcomeNoteText) { + if (bitmap.text[0]) { + fprintf(stdout, _("currently set to \"%s\"\n"), bitmap.text); + } else { + fprintf(stdout, _("currently empty\n")); + } + } else { + if (bitmap.width) { + switch (bitmap.type) { + case GSM_OperatorLogo: + fprintf(stdout,"Operator logo for %s (%s) network got succesfully\n",bitmap.netcode,GSM_GetNetworkName(bitmap.netcode)); + if (argc==3) { + strncpy(bitmap.netcode,argv[2], 7); + if (!strcmp(GSM_GetNetworkName(bitmap.netcode), "unknown")) { + fprintf(stderr, "Sorry, gnokii doesn't know %s network !\n", bitmap.netcode); + return -1; + } + } + break; + case GSM_StartupLogo: + fprintf(stdout, "Startup logo got successfully\n"); + if (argc == 3) { + strncpy(bitmap.netcode,argv[2], 7); + if (!strcmp(GSM_GetNetworkName(bitmap.netcode), "unknown")) { + fprintf(stderr, "Sorry, gnokii doesn't know %s network !\n", bitmap.netcode); + return -1; + } + } + break; + case GSM_CallerLogo: + fprintf(stdout,"Caller logo got successfully\n"); + if (argc == 4) { + strncpy(bitmap.netcode,argv[3],7); + if (!strcmp(GSM_GetNetworkName(bitmap.netcode), "unknown")) { + fprintf(stderr, "Sorry, gnokii doesn't know %s network !\n", bitmap.netcode); + return -1; + } + } + break; + default: + fprintf(stdout,"Unknown bitmap type.\n"); + break; + } + if (argc > 1) { + if (SaveBitmapFileOnConsole(argv[1], &bitmap) != GE_NONE) return (-1); + } + } else { + fprintf(stdout,"Your phone doesn't have logo uploaded !\n"); + return -1; + } + } + break; + case GE_NOTIMPLEMENTED: + fprintf(stderr, _("Function not implemented !\n")); + return -1; + case GE_NOTSUPPORTED: + fprintf(stderr, _("This kind of logo is not supported !\n")); + return -1; + default: + fprintf(stderr, _("Error getting logo !\n")); + return -1; + } } else { - fprintf(stdout, _(" Date: %s %d-%02d-%02d\n"), - DayOfWeek(CalendarNote.Time.Year, CalendarNote.Time.Month, CalendarNote.Time.Day), - CalendarNote.Time.Year, - CalendarNote.Time.Month, - CalendarNote.Time.Day); - } - - fprintf(stdout, _(" Time: %02d:%02d:%02d\n"), CalendarNote.Time.Hour, - CalendarNote.Time.Minute, - CalendarNote.Time.Second); - - if (CalendarNote.Alarm.Year!=0) { - fprintf(stdout, _(" Alarm date: %s %d-%02d-%02d\n"), - DayOfWeek(CalendarNote.Alarm.Year, CalendarNote.Alarm.Month, CalendarNote.Alarm.Day), - CalendarNote.Alarm.Year, - CalendarNote.Alarm.Month, - CalendarNote.Alarm.Day); - - fprintf(stdout, _(" Alarm time: %02d:%02d:%02d\n"), CalendarNote.Alarm.Hour, - CalendarNote.Alarm.Minute, - CalendarNote.Alarm.Second); - if ( GetModelFeature (FN_CALENDAR)==F_CAL71 ) - fprintf(stdout, _(" Alarm type: %s\n"), (CalendarNote.AlarmType==0x00) ? - "With Tone" : "Silent" ); - } - - if ( GetModelFeature (FN_CALENDAR)==F_CAL71 && CalendarNote.Recurrance!= 0 ) - fprintf(stdout, " It repeat every %d day%s\n", CalendarNote.Recurrance/24, - ((CalendarNote.Recurrance/24)>1) ? "s":"" ); - - if (CalendarNote.Type == GCN_BIRTHDAY) - { - int i_age; - i_age = Date.Year - CalendarNote.Time.Year; - fprintf(stdout, _(" Text: %s (%d %s)\n"), CalendarNote.Text, - i_age, (i_age==1)?"year":"years"); - } else { - if (CalendarNote.Text[0]!=0) - fprintf(stdout, _(" Text: %s\n"), CalendarNote.Text); + fprintf(stderr, _("What kind of logo do you want to get ?\n")); + return -1; } - if (CalendarNote.Type == GCN_CALL) - fprintf(stdout, _(" Phone: %s\n"), CalendarNote.Phone); - } - } else { - fprintf(stderr, _("The calendar note %i can not be read\n"),i); - } - } - - if (was_note && vCalVer!=0) { - fprintf(stdout, GSM_GetVCALENDAREnd(vCalVer)); - } - - GSM->Terminate(); - - return 0; + return 0; } -/* Writing calendar notes. */ -int writecalendarnote(char *argv[]) +/* Sending logos. */ +GSM_Error ReadBitmapFileOnConsole(char *FileName, GSM_Bitmap *bitmap) { - GSM_CalendarNote CalendarNote; - GSM_Error error; - int number; - - number=atoi(argv[1]); + GSM_Error error; - if (number<1) { - fprintf(stdout, _("Number of calendar note must be 1 or higher\n")); - return -1; - } + error = GSM_ReadBitmapFile(FileName, bitmap); - switch ( GSM_ReadVCalendarFile(argv[0], &CalendarNote, &number) ) { - case GE_NONE: - break; - case GE_CANTOPENFILE: - fprintf(stdout, _("Failed to open vCalendar file \"%s\"\n"),argv[0]); - return -1; - case GE_TOOSHORT: - fprintf(stdout, _("Number of given calendar note is too high (max=%i)\n"),number); - return(-1); - default: - fprintf(stdout, _("Failed to parse vCalendar file \"%s\"\n"),argv[0]); - return -1; - } - - fbusinit(NULL); - - /* Error 22=Calendar full ;-) */ - - error=GSM->WriteCalendarNote(&CalendarNote); - switch (error) { - case GE_NONE: - fprintf(stdout, _("Succesfully written!\n"));break; - case GE_TOOLONG: - fprintf(stdout, _("Too long text in calendar note!\n"));break; - default: - fprintf(stdout, _("Failed to write calendar note!\n"));break; - } - - GSM->Terminate(); - - return 0; -} - -/* Calendar note deleting. */ - -int deletecalendarnote(char *Index) -{ - - GSM_CalendarNote CalendarNote; - - CalendarNote.Location=atoi(Index); - - fbusinit(NULL); - - if (GSM->DeleteCalendarNote(&CalendarNote) == GE_NONE) { - fprintf(stdout, _(" Calendar note deleted.\n")); - } - else { - fprintf(stderr, _("The calendar note can not be deleted\n")); - - GSM->Terminate(); - return -1; - } - - GSM->Terminate(); - - return 0; -} - -/* Setting the date and time. */ - -int setdatetime(int argc, char *argv[]) -{ - struct tm *now; - time_t nowh; - GSM_DateTime Date; - - fbusinit(NULL); - - nowh=time(NULL); - now=localtime(&nowh); - - Date.Year = now->tm_year; - Date.Month = now->tm_mon+1; - Date.Day = now->tm_mday; - Date.Hour = now->tm_hour; - Date.Minute = now->tm_min; - Date.Second = now->tm_sec; - - if (argc>0) Date.Year = atoi (argv[0]); - if (argc>1) Date.Month = atoi (argv[1]); - if (argc>2) Date.Day = atoi (argv[2]); - if (argc>3) Date.Hour = atoi (argv[3]); - if (argc>4) Date.Minute = atoi (argv[4]); - - if (Date.Year<1900) - { - - /* Well, this thing is copyrighted in U.S. This technique is known as - Windowing and you can read something about it in LinuxWeekly News: - http://lwn.net/1999/features/Windowing.phtml. This thing is beeing - written in Czech republic and Poland where algorithms are not allowed - to be patented. */ - - if (Date.Year>90) - Date.Year = Date.Year+1900; - else - Date.Year = Date.Year+2000; - } - - /* FIXME: Error checking should be here. */ - GSM->SetDateTime(&Date); - - GSM->Terminate(); - - return 0; -} - -/* In this mode we receive the date and time from mobile phone. */ - -int getdatetime(void) { - - GSM_DateTime date_time; - - fbusinit(NULL); - - if (GSM->GetDateTime(&date_time)==GE_NONE) { - if (date_time.IsSet) { - fprintf(stdout, _("Date: %s %4d/%02d/%02d\n"), - DayOfWeek(date_time.Year, date_time.Month, date_time.Day), - date_time.Year, date_time.Month, date_time.Day); - fprintf(stdout, _("Time: %02d:%02d:%02d\n"), date_time.Hour, date_time.Minute, date_time.Second); - } else { - fprintf(stdout, _("Date and time not set in phone\n")); - } - } else { - fprintf(stdout,_("Error!\n")); - } - - GSM->Terminate(); - - return 0; -} - -/* Setting the alarm. */ - -int setalarm(char *argv[]) -{ - - GSM_DateTime Date; - - fbusinit(NULL); - - Date.Hour = atoi(argv[0]); - Date.Minute = atoi(argv[1]); - - GSM->SetAlarm(1, &Date); - - GSM->Terminate(); - - return 0; -} - -/* Getting the alarm. */ - -int getalarm(void) { - - GSM_DateTime date_time; - - fbusinit(NULL); - - if (GSM->GetAlarm(0, &date_time)==GE_NONE) { - fprintf(stdout, _("Alarm: %s\n"), (date_time.IsSet)?"on":"off"); - fprintf(stdout, _("Time: %02d:%02d\n"), date_time.Hour, date_time.Minute); - } else { - fprintf(stdout,_("Error!\n")); - } - - GSM->Terminate(); - - return 0; -} - -/* In monitor mode we don't do much, we just initialise the fbus code. - Note that the fbus code no longer has an internal monitor mode switch, - instead compile with DEBUG enabled to get all the gumpf. */ - -int monitormode(int argc, char *argv[]) -{ - - float rflevel=-1, batterylevel=-1; - unsigned char loop=1; - - GSM_PowerSource powersource=-1; - GSM_RFUnits rf_units = GRF_Arbitrary; - GSM_BatteryUnits batt_units = GBU_Arbitrary; - - GSM_NetworkInfo NetworkInfo; - GSM_CBMessage CBMessage; - - GSM_MemoryStatus SIMMemoryStatus = {GMT_SM, 0, 0}; - GSM_MemoryStatus PhoneMemoryStatus = {GMT_ME, 0, 0}; - GSM_MemoryStatus DC_MemoryStatus = {GMT_DC, 0, 0}; - GSM_MemoryStatus EN_MemoryStatus = {GMT_EN, 0, 0}; - GSM_MemoryStatus FD_MemoryStatus = {GMT_FD, 0, 0}; - GSM_MemoryStatus LD_MemoryStatus = {GMT_LD, 0, 0}; - GSM_MemoryStatus MC_MemoryStatus = {GMT_MC, 0, 0}; - GSM_MemoryStatus ON_MemoryStatus = {GMT_ON, 0, 0}; - GSM_MemoryStatus RC_MemoryStatus = {GMT_RC, 0, 0}; - - GSM_SMSStatus SMSStatus = {0, 0}; - - char Number[20]; - - /* evaluate for presence of "-noloop" argument in parameter */ - if(argc>0) - { - if( strcmp(argv[0],"-noloop" ) && strcmp(argv[0],"-nl" )) - { - usage(); - return -1; - } - else - loop=0; - } - - /* We do not want to monitor serial line forever - press Ctrl+C to stop the - monitoring mode. */ - - signal(SIGINT, interrupted); - - fprintf (stderr, _("Entering monitor mode...\n")); - fprintf (stderr, _("Initialising GSM interface...\n")); - - /* Initialise the code for the GSM interface. */ - - fbusinit(NULL); - - sleep(1); - GSM->EnableCellBroadcast(); - - /* Loop here indefinitely - allows you to see messages from GSM code in - response to unknown messages etc. The loops ends after pressing the - Ctrl+C. */ - while (!bshutdown) { - if (GSM->GetRFLevel(&rf_units, &rflevel) == GE_NONE) - fprintf(stdout, _("RFLevel: %d\n"), (int)rflevel); - - if (GSM->GetBatteryLevel(&batt_units, &batterylevel) == GE_NONE) - fprintf(stdout, _("Battery: %d\n"), (int)batterylevel); - - if (GSM->GetPowerSource(&powersource) == GE_NONE) - fprintf(stdout, _("Power Source: %s\n"), (powersource==GPS_ACDC)?_("AC/DC"):_("battery")); - - if (GSM->GetMemoryStatus(&SIMMemoryStatus) == GE_NONE) - fprintf(stdout, _("SIM: Used %d, Free %d\n"), SIMMemoryStatus.Used, SIMMemoryStatus.Free); - - if (GSM->GetMemoryStatus(&PhoneMemoryStatus) == GE_NONE) - fprintf(stdout, _("Phone: Used %d, Free %d\n"), PhoneMemoryStatus.Used, PhoneMemoryStatus.Free); - - if (GSM->GetMemoryStatus(&DC_MemoryStatus) == GE_NONE) - fprintf(stdout, _("DC: Used %d, Free %d\n"), DC_MemoryStatus.Used, DC_MemoryStatus.Free); - - if (GSM->GetMemoryStatus(&EN_MemoryStatus) == GE_NONE) - fprintf(stdout, _("EN: Used %d, Free %d\n"), EN_MemoryStatus.Used, EN_MemoryStatus.Free); - - if (GSM->GetMemoryStatus(&FD_MemoryStatus) == GE_NONE) - fprintf(stdout, _("FD: Used %d, Free %d\n"), FD_MemoryStatus.Used, FD_MemoryStatus.Free); - - if (GSM->GetMemoryStatus(&LD_MemoryStatus) == GE_NONE) - fprintf(stdout, _("LD: Used %d, Free %d\n"), LD_MemoryStatus.Used, LD_MemoryStatus.Free); - - if (GSM->GetMemoryStatus(&MC_MemoryStatus) == GE_NONE) - fprintf(stdout, _("MC: Used %d, Free %d\n"), MC_MemoryStatus.Used, MC_MemoryStatus.Free); - - if (GSM->GetMemoryStatus(&ON_MemoryStatus) == GE_NONE) - fprintf(stdout, _("ON: Used %d, Free %d\n"), ON_MemoryStatus.Used, ON_MemoryStatus.Free); - - if (GSM->GetMemoryStatus(&RC_MemoryStatus) == GE_NONE) - fprintf(stdout, _("RC: Used %d, Free %d\n"), RC_MemoryStatus.Used, RC_MemoryStatus.Free); - - if (GSM->GetSMSStatus(&SMSStatus) == GE_NONE) - fprintf(stdout, _("SMS Messages: UnRead %d, Number %d\n"), SMSStatus.UnRead, SMSStatus.Number); - - if (GSM->GetIncomingCallNr(Number) == GE_NONE) - fprintf(stdout, _("Incoming call: %s\n"), Number); - - if (GSM->GetNetworkInfo(&NetworkInfo) == GE_NONE) - fprintf(stdout, _("Network: %s (%s), LAC: %s, CellID: %s\n"), GSM_GetNetworkName (NetworkInfo.NetworkCode), GSM_GetCountryName(NetworkInfo.NetworkCode), NetworkInfo.LAC, NetworkInfo.CellID); - - if (GSM->ReadCellBroadcast(&CBMessage) == GE_NONE) - fprintf(stdout, _("Cell broadcast received on channel %d: %s\n"), CBMessage.Channel, CBMessage.Message); - - if( !loop ) break; - - sleep(1); - } - - if( loop ) fprintf (stderr, _("Leaving monitor mode...\n")); - - GSM->Terminate(); - - return 0; -} - -/* Shows texts from phone's display */ - -int displayoutput() -{ - - GSM_Error error; - - fbusinit(NULL); - - error=GSM->EnableDisplayOutput(); - - if (error == GE_NONE) - { - - /* We do not want to see texts forever - press Ctrl+C to stop. */ - - signal(SIGINT, interrupted); - - fprintf (stderr, _("Entering display monitoring mode...\n")); - - /* Loop here indefinitely - allows you to read texts from phone's - display. The loops ends after pressing the Ctrl+C. */ - - while (!bshutdown) - sleep(1); - - fprintf (stderr, _("Leaving display monitor mode...\n")); - - error=GSM->DisableDisplayOutput(); - if (error!=GE_NONE) - fprintf (stderr, _("Error!\n")); - } else - fprintf (stderr, _("Error!\n")); - - GSM->Terminate(); - - return 0; -} - -/* Displays names of available ringtones */ -int allringtones() -{ - char model[64], rev[64]; - int i; - - fbusinit(NULL); - - while (GSM->GetRevision(rev) != GE_NONE) - sleep(1); - - while (GSM->GetModel(model) != GE_NONE) - sleep(1); - - strncpy(rev,rev+2,5); - rev[5]=0; - PrepareRingingTones(model,rev); - - for (i=1;i<=NumberOfRingtones();i++) - { - fprintf(stdout,_("%i. %s\n"),i,RingingToneName(0,i)); - } - - GSM->Terminate(); - - return 0; - -} - -/* Reads profile from phone and displays its' settings */ - -int getprofile(int argc, char *argv[]) -{ - - int max_profiles; - int start, stop, i; - GSM_Profile profile; - GSM_Error error; - - /* Hopefully is 64 larger as FB38_MAX* / FB61_MAX* */ - char model[64], rev[64]; - - /* Initialise the code for the GSM interface. */ - - fbusinit(NULL); - - profile.Number = 0; - error=GSM->GetProfile(&profile); - - if (error == GE_NONE) - { - - while (GSM->GetModel(model) != GE_NONE) sleep(1); - - while (GSM->GetRevision(rev) != GE_NONE) sleep(1); - - strncpy(rev,rev+2,5); - rev[5]=0; - PrepareRingingTones(model,rev); - - switch(GetModelFeature (FN_PROFILES)) { - case F_PROF33:max_profiles=6;break; - case F_PROF51:max_profiles=3;break; - default :max_profiles=7;break; - } - - if (argc>0) - { - profile.Number=atoi(argv[0])-1; - start=profile.Number; - stop=start+1; - - if (profile.Number < 0) - { - fprintf(stderr, _("Profile number must be value from 1 to %d!\n"), max_profiles); - GSM->Terminate(); - return -1; - } - - if (profile.Number >= max_profiles) - { - fprintf(stderr, _("This phone supports only %d profiles!\n"), max_profiles); - GSM->Terminate(); - return -1; - } - } else { - start=0; - stop=max_profiles; - } - - i=start; - while (iGetProfile(&profile); - - printf("%d. \"%s\"", (profile.Number+1), profile.Name); - if (profile.DefaultName==-1) printf(" (name defined)"); - printf("\n"); - -#ifdef DEBUG - printf("Incoming call alert: %d\n", profile.CallAlert); - printf("Ringtone ID: %d\n", profile.Ringtone); - printf("Ringing volume: %d\n", profile.Volume); - printf("Message alert tone: %d\n", profile.MessageTone); - printf("Keypad tones: %d\n", profile.KeypadTone); - printf("Warning and game tones: %d\n", profile.WarningTone); - printf("Lights: %d\n", profile.Lights); - printf("Vibration: %d\n", profile.Vibration); - printf("Caller groups: 0x%02x\n", profile.CallerGroups); - printf("Automatic answer: %d\n", profile.AutomaticAnswer); - printf("Screen saver: %d\n", profile.ScreenSaver); - printf("\n"); -#endif - - printf("Incoming call alert: %s\n", GetProfileCallAlertString(profile.CallAlert)); - - /* For different phones different ringtones names */ - if (strcmp(RingingToneName(profile.Ringtone,0),"")) - printf(_("Ringing tone: %s (number %d in phone menu)\n"), - RingingToneName(profile.Ringtone,0), RingingToneMenu(profile.Ringtone)); - else - printf(_("Ringtone number: %d\n"), profile.Ringtone); - - printf(_("Ringing volume: %s\n"), GetProfileVolumeString(profile.Volume)); - - printf(_("Message alert tone: %s\n"), GetProfileMessageToneString(profile.MessageTone)); - - printf(_("Keypad tones: %s\n"), GetProfileKeypadToneString(profile.KeypadTone)); - - printf(_("Warning and game tones: %s\n"), GetProfileWarningToneString(profile.WarningTone)); - - if (GetModelFeature (FN_SCREENSAVER)!=0) - printf(_("Screen saver: %s\n"), GetProfileOnOffString(profile.ScreenSaver)); - - printf(_("Vibration: %s\n"), GetProfileVibrationString(profile.Vibration)); - - /* It has been nice to add here reading caller group name. ;^) */ - if (GetModelFeature (FN_CALENDAR)==F_CAL71) - printf(_("Caller groups: %s\n"), - GetProfileCallerGroups(profile.CallerGroups) ); - - /* FIXME: need make investigation for 3310 for these features. For now unknown */ - if (GetModelFeature (FN_PROFILES)!=F_PROF33) { - /* FIXME: Light settings is only used for Car */ - if (profile.Number==(max_profiles-2)) printf(_("Lights: %s\n"), profile.Lights ? _("On") : _("Automatic")); - - /* FIXME: Automatic answer is only used for Car and Headset. */ - if (profile.Number>=(max_profiles-2)) printf(_("Automatic answer: %s\n"), GetProfileOnOffString(profile.AutomaticAnswer)); - } - - printf("\n"); - - i++; - } - } else { - if (error == GE_NOTIMPLEMENTED) { - fprintf(stderr, _("Function not implemented in %s model!\n"), model); - GSM->Terminate(); - return -1; - } else - { - fprintf(stderr, _("Unspecified error\n")); - GSM->Terminate(); - return -1; - } - } - - GSM->Terminate(); - - return 0; - -} - -/* Sets profile feature */ - -int setprofile(int argc, char *argv[]) -{ - -/* Hopefully is 64 larger as FB38_MAX* / FB61_MAX* */ - char model[64], rev[64]; - - int max_profiles; - GSM_Profile profile; - GSM_Profile profile2, profile3; - GSM_Error error; - bool correct_arg1; - bool correct_arg2; - -/* Initialise the code for the GSM interface. */ - - fbusinit(NULL); - - profile.Number = 0; - - error = GSM->GetProfile(&profile); - - if (error == GE_NONE) - { - - while (GSM->GetModel(model) != GE_NONE) sleep(1); - - while (GSM->GetRevision(rev) != GE_NONE) sleep(1); - - strncpy(rev,rev+2,5); - rev[5]=0; - PrepareRingingTones(model,rev); - - switch(GetModelFeature (FN_PROFILES)) { - case F_PROF33:max_profiles=6;break; - case F_PROF51:max_profiles=3;break; - default :max_profiles=7;break; - } - - profile.Number=atoi (argv[0]); - profile.Number=profile.Number-1; - - if (profile.Number < 0) - { - fprintf(stderr, _("Profile number must be value from 1 to %i!\n"), max_profiles); - GSM->Terminate(); - return -1; - } - - if (profile.Number >= max_profiles) - { - fprintf(stderr, _("This phone supports only %i profiles!\n"), max_profiles); - GSM->Terminate(); - return -1; - } - - if (profile.Number!=0) GSM->GetProfile(&profile); - - correct_arg1=false; - correct_arg2=false; - - if (strcmp(argv[1], "callalert")==0) - { - if (strcmp(argv[2], "ringing")==0) {profile.CallAlert=PROFILE_CALLALERT_RINGING;correct_arg2=true;} - if (strcmp(argv[2], "ascending")==0) {profile.CallAlert=PROFILE_CALLALERT_ASCENDING;correct_arg2=true;} - if (strcmp(argv[2], "ringonce")==0) {profile.CallAlert=PROFILE_CALLALERT_RINGONCE;correct_arg2=true;} - if (strcmp(argv[2], "beeponce")==0) {profile.CallAlert=PROFILE_CALLALERT_BEEPONCE;correct_arg2=true;} - if (strcmp(argv[2], "groups")==0) - { - profile.CallAlert=PROFILE_CALLALERT_CALLERGROUPS; - correct_arg2=true; - /*Ignored by N5110*/ - /*FIX ME: it's ignored by N5130 and 3210 too*/ - if (max_profiles==3) fprintf(stdout, _("Warning: value \"groups\" for profile feature \"callalert\" will be ignored in this phone model !\n")); - } - if (strcmp(argv[2], "off")==0 || strcmp(argv[2], "0")==0) {profile.CallAlert=PROFILE_CALLALERT_OFF;correct_arg2=true;} - if (!correct_arg2) - { - fprintf(stderr, _("Correct parameters for profile feature \"callalert\" are ringing|ascending|ringonce|beeponce|groups|off|0 !\n")); - GSM->Terminate(); - return -1; - } - correct_arg1=true; - } - if (strcmp(argv[1], "volume")==0) - { - if (strcmp(argv[2], "1")==0) {profile.Volume=PROFILE_VOLUME_LEVEL1;correct_arg2=true;} - if (strcmp(argv[2], "2")==0) {profile.Volume=PROFILE_VOLUME_LEVEL2;correct_arg2=true;} - if (strcmp(argv[2], "3")==0) {profile.Volume=PROFILE_VOLUME_LEVEL3;correct_arg2=true;} - if (strcmp(argv[2], "4")==0) {profile.Volume=PROFILE_VOLUME_LEVEL4;correct_arg2=true;} - if (strcmp(argv[2], "5")==0) {profile.Volume=PROFILE_VOLUME_LEVEL5;correct_arg2=true;} - if (!correct_arg2) - { - fprintf(stderr, _("Correct parameters for profile feature \"volume\" are 0|1|2|3|4|5 !\n")); - GSM->Terminate(); - return -1; - } - correct_arg1=true; - } - if (strcmp(argv[1], "keypad")==0 || strcmp(argv[1], "keypadtone")==0) - { - if (strcmp(argv[2], "0")==0 || strcmp(argv[2], "off")==0) {profile.KeypadTone=PROFILE_KEYPAD_OFF;correct_arg2=true;} - if (strcmp(argv[2], "1")==0) {profile.KeypadTone=PROFILE_KEYPAD_LEVEL1;correct_arg2=true;} - if (strcmp(argv[2], "2")==0) {profile.KeypadTone=PROFILE_KEYPAD_LEVEL2;correct_arg2=true;} - if (strcmp(argv[2], "3")==0) {profile.KeypadTone=PROFILE_KEYPAD_LEVEL3;correct_arg2=true;} - if (!correct_arg2) - { - fprintf(stderr, _("Correct parameters for profile feature \"keypad|keypadtone\" are off|0|1|2|3 !\n")); - GSM->Terminate(); - return -1; - } - correct_arg1=true; - } - if (strcmp(argv[1], "messagetone")==0 || strcmp(argv[1], "smstone")==0 || strcmp(argv[1], "sms")==0 || strcmp(argv[1], "message")==0) - { - if (strcmp(argv[2], "0")==0 || strcmp(argv[2], "off")==0) {profile.MessageTone=PROFILE_MESSAGE_NOTONE;correct_arg2=true;} - if (strcmp(argv[2], "standard")==0) {profile.MessageTone=PROFILE_MESSAGE_STANDARD;correct_arg2=true;} - if (strcmp(argv[2], "special")==0) {profile.MessageTone=PROFILE_MESSAGE_SPECIAL;correct_arg2=true;} - if (strcmp(argv[2], "beeponce")==0 || strcmp(argv[2], "once")==0) {profile.MessageTone=PROFILE_MESSAGE_BEEPONCE;correct_arg2=true;} - if (strcmp(argv[2], "ascending")==0) {profile.MessageTone=PROFILE_MESSAGE_ASCENDING;correct_arg2=true;} - if (!correct_arg2) - { - fprintf(stderr, _("Correct parameters for profile feature \"messagetone|smstone|message|sms\" are 0|off|standard|special|beeponce|once|ascending !\n")); - GSM->Terminate(); - return -1; - } - correct_arg1=true; - } - if (strcmp(argv[1], "warningtone")==0 || strcmp(argv[1], "warning")==0) - { - if (strcmp(argv[2], "0")==0 || strcmp(argv[2], "off")==0) {profile.WarningTone=PROFILE_WARNING_OFF;correct_arg2=true;} - if (strcmp(argv[2], "1")==0 || strcmp(argv[2], "on")==0) {profile.WarningTone=PROFILE_WARNING_ON;correct_arg2=true;} - if (!correct_arg2) - { - fprintf(stderr, _("Correct parameters for profile feature \"warningtone|warning\" are 0|off|1|on !\n")); - GSM->Terminate(); - return -1; - } - correct_arg1=true; - } - if (strcmp(argv[1], "vibra")==0 || strcmp(argv[1], "vibration")==0) - { - if (strcmp(argv[2], "0")==0 || strcmp(argv[2], "off")==0) {profile.Vibration=PROFILE_VIBRATION_OFF;correct_arg2=true;} - if (strcmp(argv[2], "1")==0 || strcmp(argv[2], "on")==0) {profile.Vibration=PROFILE_VIBRATION_ON;correct_arg2=true;} - if (!correct_arg2) - { - fprintf(stderr, _("Correct parameters for profile feature \"vibration|vibra\" are 0|off|1|on !\n")); - GSM->Terminate(); - return -1; - } - correct_arg1=true; - } - if (strcmp(argv[1], "lights")==0) - { - if (strcmp(argv[2], "0")==0 || strcmp(argv[2], "off")==0) {profile.Lights=-1;correct_arg2=true;} - if (strcmp(argv[2], "1")==0 || strcmp(argv[2], "on")==0) {profile.Lights=0;correct_arg2=true;} - if (!correct_arg2) - { - fprintf(stderr, _("Correct parameters for profile feature \"lights\" are 0|off|1|on !\n")); - GSM->Terminate(); - return -1; - } - if (profile.Number!=(max_profiles-2)) - { - profile2.Number=max_profiles-2; - if (GSM->GetProfile(&profile2)==GE_NONE) - { - fprintf(stdout, _("Warning: \"Lights\" feature is ignored in this profile (only setting it for \"%s\" profile get some results) !\n"), profile2.Name); - } - } - correct_arg1=true; - } - if (strcmp(argv[1], "answer")==0) - { - if (strcmp(argv[2], "0")==0 || strcmp(argv[2], "off")==0) {profile.AutomaticAnswer=-1;correct_arg2=true;} - if (strcmp(argv[2], "1")==0 || strcmp(argv[2], "on")==0) {profile.AutomaticAnswer=0;correct_arg2=true;} - if (!correct_arg2) - { - fprintf(stderr, _("Correct parameters for profile feature \"answer\" are 0|off|1|on !\n")); - GSM->Terminate(); - return -1; - } - if (profile.Number<(max_profiles-2)) - { - profile2.Number=max_profiles-2; - if (GSM->GetProfile(&profile2)==GE_NONE) - { - profile3.Number=max_profiles-1; - if (GSM->GetProfile(&profile3)==GE_NONE) - { - fprintf(stdout, _("Warning: \"Automatic Answer\" feature is ignored in this profile (only setting it for \"%s\" and \"%s\" profiles get some results) !\n"), profile2.Name, profile3.Name); - } - } - } - correct_arg1=true; - } - if (strcmp(argv[1], "name")==0) - { - strcpy(profile.Name,argv[2]); - /*Ignored by N5110*/ - /*FIX ME: it's ignored by N5130 and 3210 too*/ - if (max_profiles==3) fprintf(stdout, _("Warning: this phone model doesn't allow to change profile name !\n")); - correct_arg1=true; - } - if (strcmp(argv[1], "ringtone")==0) - { - profile.Ringtone=atoi(argv[2]); - if (profile.Ringtone<1) - { - /*With value 0 results are interesting in N5110, but can't be used for anything*/ - fprintf(stderr, _("Ringtone number must be higher than 0 !\n")); - GSM->Terminate(); - return -1; - } else - { - if (profile.Ringtone>NumberOfRingtones()) - { - fprintf(stderr, _("Ringtone number too high (max %i) !\n"),NumberOfRingtones()); - GSM->Terminate(); - return -1; - } - profile.Ringtone=RingingToneCode(profile.Ringtone); - if (profile.Ringtone==0) - { - fprintf(stderr, _("Warning: we don't know ringtones codes for this model ! Can you contact with gnokii authors to add it into source ?\n")); - GSM->Terminate(); - return -1; - } - if (max_profiles==3) fprintf(stdout, _("Warning: ringtone is changed for all profiles. You must reset phone or select profile in phone againg to see result.\n")); - } - correct_arg1=true; - } - if (strcmp(argv[1], "groups")==0) - { - /*Ignored by N5110*/ - /*FIX ME: it's ignored by N5130 and 3210 too*/ - if (max_profiles==3) fprintf(stdout, _("Warning: this phone model doesn't allow to change caller group name !\n")); - profile.CallerGroups=atoi(argv[2]); - correct_arg1=true; - } - - if (!correct_arg1) - { - fprintf(stderr, _("Correct profile feature names are callalert|volume|keypad|keypadtone|messagetone|smstone|message|sms|warningtone|warning|vibra|vibration|lights|answer|name|groups !\n")); - GSM->Terminate(); - return -1; - } - - GSM->SetProfile(&profile); - - } else { - if (error == GE_NOTIMPLEMENTED) { - fprintf(stderr, _("Function not implemented in %s model!\n"), model); - GSM->Terminate(); - return -1; - } else - { - fprintf(stderr, _("Unspecified error\n")); - GSM->Terminate(); - return -1; - } - } - - GSM->Terminate(); - - return 0; - -} - -/* Get requested range of memory storage entries and output to stdout in - easy-to-parse format */ - -int getmemory(int argc, char *argv[]) -{ - - GSM_PhonebookEntry entry; - int count; - register int i; - GSM_Error error; - GSM_Bitmap bitmap; - char memory_type_string[20]; - int start_entry; - int end_entry; - int i_used = 0, n_used=0; - int do_all; - char *output_opt = NULL; - bool wasdate=false; - char az_group_name[5][MAX_BITMAP_TEXT_LENGTH]; - bool formatdone=false; - char buf[64]; - - /* group names init */ - for(i=0;i<5;i++) az_group_name[i][0]='\0'; - - /* Handle command line args that set type, start and end locations. */ - if (!GetMemoryTypeID(argv[0], &entry.MemoryType)) - { - fprintf(stderr, _("Unknown memory type %s!\n"), argv[0]); - return (-1); - } - GetMemoryTypeString(memory_type_string, &entry.MemoryType); - - if (argv[argc-1][0] == '-') - output_opt = argv[--argc]; - - /* Do generic initialisation routine */ - - fbusinit(NULL); - - while ((error = GSM->GetModel(buf)) != GE_NONE && i++ < 15) - sleep(1); - - if (argc > 1) { - do_all = 0; - start_entry = atoi (argv[1]); - end_entry = argc > 2 ? atoi( argv[2]) : start_entry; - } else { - GSM_MemoryStatus stats = {entry.MemoryType, 0, 0}; - - do_all = 1; - start_entry = 1; - if (GSM->GetMemoryStatus( &stats) != GE_NONE) { - fprintf( stderr, _("Error reading memory status.\n")); - GSM->Terminate(); - return -1; - } - n_used = stats.Used; - end_entry = stats.Used + stats.Free; - } - - - /* Now retrieve the requested entries. */ - - for (count = start_entry; - count <= end_entry && (!do_all || i_used < n_used); - count++) { - - entry.Location=count; - - error=GSM->GetMemoryLocation(&entry); - - switch (error) { - case GE_NONE: - if (entry.SubEntriesCount || strcmp( entry.Number, "")) - i_used++; - else if (do_all) - break; - if (output_opt && !strcmp( output_opt,"-v30")) { - semicolon_pipe_substitution( &entry, 0 ); - fprintf(stdout,_("%s"),GSM_GetVCARD(&entry,30)); - formatdone=true; - } - if (output_opt && !strcmp(output_opt,"-v21")) { - semicolon_pipe_substitution( &entry, 0 ); - fprintf(stdout,_("%s"),GSM_GetVCARD(&entry,21)); - formatdone=true; - } - if (output_opt && !strcmp(output_opt,"-v")) { - semicolon_pipe_substitution( &entry, 0 ); - fprintf(stdout,_("%s"),GSM_GetVCARD(&entry,10)); - formatdone=true; - } - if (output_opt && !strcmp(output_opt,"-short")) { - semicolon_pipe_substitution( &entry, 0 ); - fprintf(stdout, "%s;%s;%s;%d;%d;", entry.Name, entry.Number, memory_type_string, entry.Location, entry.Group); - for( i = 0; i < entry.SubEntriesCount; i++ ) - { - if( entry.SubEntries[i].EntryType == GSM_Date ) - fprintf(stdout,_("%u;%u;%u;%02u.%02u.%04u;%02u:%02u:%02u;"), - entry.SubEntries[i].EntryType, - entry.SubEntries[i].NumberType, - entry.SubEntries[i].BlockNumber, - entry.SubEntries[i].data.Date.Day, - entry.SubEntries[i].data.Date.Month, - entry.SubEntries[i].data.Date.Year, - entry.SubEntries[i].data.Date.Hour, - entry.SubEntries[i].data.Date.Minute, - entry.SubEntries[i].data.Date.Second ); - else - fprintf(stdout,_("%u;%u;%u;%s;"), - entry.SubEntries[i].EntryType, - entry.SubEntries[i].NumberType, - entry.SubEntries[i].BlockNumber, - entry.SubEntries[i].data.Number ); - } - fprintf(stdout,_("\n")); - formatdone=true; - } - if (!formatdone) { - char z_gtype[12]; - wasdate=false; - fprintf(stdout, "Memory %s, location %d\n",memory_type_string, entry.Location); - - // check if some info in subentries - for( i = 0; i < entry.SubEntriesCount; i++ ) - if( entry.SubEntries[i].EntryType != GSM_Date && - strcmp(entry.SubEntries[i].data.Number,"") ) - break; - - if (strcmp(entry.Number,"") || i < entry.SubEntriesCount) { - if (strcmp(entry.Name,"")) fprintf(stdout,_(" Name: %s\n"),entry.Name); - if (strcmp(entry.Number,"")) fprintf(stdout,_(" Number: %s\n"),entry.Number); - bitmap.type=GSM_CallerLogo; - bitmap.number=entry.Group; - strcpy(z_gtype,"unknown"); - if (entry.Group==5) strcpy(z_gtype,"No group"); - if (entry.Group<5 && entry.Group>=0) { - if (!strcmp(az_group_name[entry.Group],"")) { - if (GetModelFeature (FN_CALLERGROUPS)!=0) { - if (GSM->GetBitmap(&bitmap)==GE_NONE) - strcpy( az_group_name[entry.Group], bitmap.text ); - } - if ((!strcmp(az_group_name[entry.Group],""))) { - switch(entry.Group) { - case 0:strcpy(az_group_name[entry.Group],"Family");break; - case 1:strcpy(az_group_name[entry.Group],"VIP");break; - case 2:strcpy(az_group_name[entry.Group],"Friends");break; - case 3:strcpy(az_group_name[entry.Group],"Colleagues");break; - case 4:strcpy(az_group_name[entry.Group],"Other");break; - default:break; - } - } - } - strcpy(z_gtype,az_group_name[entry.Group]); - } - fprintf(stdout,_(" Group: %d (%s)\n"),entry.Group+1,z_gtype); - for( i = 0; i < entry.SubEntriesCount; i++ ) - { - if( entry.SubEntries[i].EntryType == GSM_Date ) { - fprintf(stdout, " Date and time: %s %02u.%02u.%04u %02u:%02u:%02u\n", - DayOfWeek(entry.SubEntries[i].data.Date.Year, - entry.SubEntries[i].data.Date.Month, - entry.SubEntries[i].data.Date.Day), - entry.SubEntries[i].data.Date.Day, - entry.SubEntries[i].data.Date.Month, - entry.SubEntries[i].data.Date.Year, - entry.SubEntries[i].data.Date.Hour, - entry.SubEntries[i].data.Date.Minute, - entry.SubEntries[i].data.Date.Second); - wasdate=true; - } else { - if( strcmp(entry.SubEntries[i].data.Number,"") ) { - char z_etype[19]; - switch( entry.SubEntries[i].EntryType ) { - case GSM_Number: - switch( entry.SubEntries[i].NumberType ) { - case GSM_General: strcpy(z_etype,"General "); break; - case GSM_Home: strcpy(z_etype,"Home "); break; - case GSM_Mobile: strcpy(z_etype,"Mobile "); break; - case GSM_Work: strcpy(z_etype,"Work "); break; - case GSM_Fax: strcpy(z_etype,"Fax "); break; - default: strcpy(z_etype,""); break; - } - strcat(z_etype,"Number"); break; - case GSM_Note: - strcpy(z_etype,"Note"); break; - case GSM_Postal: - strcpy(z_etype,"Postal"); break; - case GSM_Email: - strcpy(z_etype,"E-Mail"); break; - default: - strcpy(z_etype,"unknown data"); break; - } -#ifdef DEBUG - fprintf(stdout,_(" ---> Subentry: %u\n"),i+1); - fprintf(stdout,_(" Entry type: %u (%s)\n"),entry.SubEntries[i].EntryType,z_etype); - fprintf(stdout,_(" Number type: %u\n"),entry.SubEntries[i].NumberType); - fprintf(stdout,_(" Block Number: %u\n"),entry.SubEntries[i].BlockNumber); -#endif - fprintf(stdout,_(" %s: %s\n"),z_etype,entry.SubEntries[i].data.Number); - } - } - } - if ((entry.MemoryType==GMT_DC || - entry.MemoryType==GMT_RC || - entry.MemoryType==GMT_MC) && !wasdate) - fprintf(stdout,_(" Date and time not available\n")); - } else - fprintf(stdout,_(" Location empty\n")); - } - break; - case GE_NOTIMPLEMENTED: - fprintf( stderr, _("Function not implemented in %s model!\n"), model); - GSM->Terminate(); - return -1; - case GE_INVALIDMEMORYTYPE: - fprintf( stderr, _("Memory type %s not supported!\n"), - memory_type_string); - GSM->Terminate(); - return -1; - default: - fprintf(stdout, _("%s|%d|Bad location or other error!(%d)\n"), - memory_type_string, count, error); - } - } - - GSM->Terminate(); - - return 0; -} - -/* Read data from stdin, parse and write to phone. The parsing is relatively - crude and doesn't allow for much variation from the stipulated format. */ - -int writephonebook(int argc, char *args[]) -{ - - GSM_PhonebookEntry entry; - GSM_Error error; - char *memory_type_string; - int line_count=0,current,i; - int subentry; - - char *Line, OLine[1024], BackLine[1024]; - char *ptr; - - /* Check argument */ - if (argc) { - if (strcmp("-i", args[0])) { - usage(); - return 0; - } - } - /* Initialise fbus code */ - - fbusinit(NULL); - - Line = OLine; - - /* Go through data from stdin. */ - - while (GetLine(stdin, Line, sizeof(OLine))!=-1) { - - current=0;BackLine[current++]=Line[0]; - for (i=1;iGetMemoryLocation(&tmp_entry); - if (error == GE_NONE) { - if (!tmp_entry.Empty) { - int confirm = -1; - char ans[8]; - FILE *input_flow; //for reading from console, even when input redir. - - input_flow = fopen(DEV_CONSOLE, "r"); - - if (!input_flow) { - fprintf(stderr, _("Can't open \"%s\" for input !\n"),DEV_CONSOLE); - return(-1); - } - - fprintf(stderr, _("Location busy. ")); - while (confirm < 0) { - fprintf(stderr, _("Overwrite? (yes/no) ")); - GetLine(input_flow, ans, 7); - if (!strcmp(ans, "yes")) confirm = 1; - else if (!strcmp(ans, "no")) confirm = 0; - } - if (!confirm) continue; - } - } else { - fprintf(stderr, _("Unknown error (%d)\n"), error); - GSM->Terminate(); - return 0; - } - } - - /* Do write and report success/failure. */ - semicolon_pipe_substitution( &entry, 1 ); - - error = GSM->WritePhonebookLocation(&entry); - - if (error == GE_NONE) - fprintf (stdout, _("Write Succeeded: memory type: %s, loc: %d, name: %s, number: %s\n"), memory_type_string, entry.Location, entry.Name, entry.Number); - else - fprintf (stdout, _("Write FAILED(%d): memory type: %s, loc: %d, name: %s, number: %s\n"), error, memory_type_string, entry.Location, entry.Name, entry.Number); - - } - - GSM->Terminate(); - - return 0; -} - -/* Getting speed dials. */ - -int getspeeddial(char *Number) { - - GSM_SpeedDial entry; - GSM_Error error; - GSM_PhonebookEntry pbentry; - - entry.Number = atoi(Number); - - fbusinit(NULL); - - if (GSM->GetSpeedDial(&entry)==GE_NONE) { - pbentry.Location=entry.Location; - if (pbentry.Location==0) pbentry.Location=entry.Number; - pbentry.MemoryType=entry.MemoryType; - - error=GSM->GetMemoryLocation(&pbentry); - - if (error == GE_NONE) - { - fprintf(stdout, _("SpeedDial nr. %d: %d:%d (%s)\n"), entry.Number, entry.MemoryType, entry.Location,pbentry.Name); - } else - fprintf(stdout, _("Error\n")); - } else { - fprintf(stdout, _("Error\n")); - } - - GSM->Terminate(); - - return 0; -} - -/* Setting speed dials. */ - -int setspeeddial(char *argv[]) { - - GSM_SpeedDial entry; - - char *memory_type_string; - - /* Handle command line args that set type, start and end locations. */ - - if (strcmp(argv[1], "ME") == 0) { - entry.MemoryType = GMT_ME; - memory_type_string = "ME"; - } - else if (strcmp(argv[1], "SM") == 0) { - entry.MemoryType = GMT_SM; - memory_type_string = "SM"; - } - else { - fprintf(stderr, _("Unknown memory type %s!\n"), argv[1]); - - return -1; - } - - entry.Number = atoi(argv[0]); - entry.Location = atoi(argv[2]); - - fbusinit(NULL); - - if (GSM->SetSpeedDial(&entry) == GE_NONE) { - fprintf(stdout, _("Succesfully written!\n")); - } - - GSM->Terminate(); - - return 0; -} - -/* Getting the status of the display. */ - -int getdisplaystatus() -{ - - int Status; - - /* Initialise the code for the GSM interface. */ - - fbusinit(NULL); - - if (GSM->GetDisplayStatus(&Status)==GE_NONE) { - - printf(_("Call in progress: %s\n"), Status & (1<Terminate(); - - return 0; -} - -int netmonitor(char *Mode) -{ - - unsigned char mode=atoi(Mode); - char Screen[NM_MAX_SCREEN_WIDTH]; - int i; - - fbusinit(NULL); - - if (!strcmp(Mode,"reset")) mode=0xf0; - else if (!strcmp(Mode,"off")) mode=0xf1; - else if (!strcmp(Mode,"field"))mode=0xf2; - else if (!strcmp(Mode,"devel"))mode=0xf3; - else if (!strcmp(Mode,"next")) mode=0x00; - - /* We clear it */ - for (i=0;iNetMonitor(mode, Screen); - - if (Screen) - printf("%s\n", Screen); - - GSM->Terminate(); - - return 0; -} - -int identify( void ) -{ - /* Hopefully is 64 larger as FB38_MAX* / FB61_MAX* */ - char imei[64], model[64], rev[64], manufacturer[64]; - - fbusinit(NULL); - - while (GSM->GetIMEI(imei) != GE_NONE) sleep(1); - while (GSM->GetRevision(rev) != GE_NONE) sleep(1); - while (GSM->GetModel(model) != GE_NONE) sleep(1); - - strcpy(manufacturer, "(unknown)"); - GSM->GetManufacturer(manufacturer); - - fprintf(stdout, _("IMEI: %s\n"), imei); - fprintf(stdout, _("Model: %s %s (%s)\n"), manufacturer, GetModelName (model), model); - fprintf(stdout, _("Revision: %s\n"), rev); - - GSM->Terminate(); - - return 0; -} - -int senddtmf(char *String) -{ - - fbusinit(NULL); - - if (GSM->SendDTMF(String)!=GE_NONE) fprintf(stdout,_("Error!\n")); - - GSM->Terminate(); - - return 0; -} - -/* Resets the phone */ -int reset(int argc, char *argv[]) -{ - - unsigned char _type=0x03; - - if (argc>0) { - _type=0x10; - - if (!strcmp(argv[0],"soft")) _type = 0x03; - - /* Doesn't work with 5110 */ - if (!strcmp(argv[0],"hard")) _type = 0x04; - - if (_type==0x10) { - fprintf(stderr, _("What kind of reset do you want (second parameter can be \"soft\" or \"hard\") ?\n")); - return -1; - } - } - - fbusinit(NULL); - - GSM->Reset(_type); - - GSM->Terminate(); - - return 0; -} - -/* This is a "convenience" function to allow quick test of new API stuff which - doesn't warrant a "proper" command line function. */ - -int foogle(char *argv[]) -{ - /* Initialise the code for the GSM interface. */ - - fbusinit(NULL); - - // Fill in what you would like to test here... - - sleep(5); - - GSM->Terminate(); - - return 0; -} - -int phonetests() -{ - /* Initialise the code for the GSM interface. */ - - fbusinit(NULL); - - if (GSM->PhoneTests()!=GE_NONE) fprintf(stderr,_("Error\n")); - - GSM->Terminate(); - - return 0; -} - -/* pmon allows fbus code to run in a passive state - it doesn't worry about - whether comms are established with the phone. A debugging/development - tool. */ - -int pmon() -{ - - GSM_Error error; - GSM_ConnectionType connection=GCT_FBUS; - - /* Initialise the code for the GSM interface. */ - - error = GSM_Initialise(model, Port, Initlength, connection, RLP_DisplayF96Frame, SynchronizeTime); - - if (error != GE_NONE) { - fprintf(stderr, _("GSM/FBUS init failed! (Unknown model ?). Quitting.\n")); - return -1; - } - - - while (1) { - usleep(50000); - } - - return 0; -} - -int setringtone(int argc, char *argv[]) -{ - GSM_Ringtone ringtone; - GSM_BinRingtone binringtone,binringtone2; - - GSM_Error error; - - int current=0; //number of packed notes or location - int i; - - char model[64]; - - /* If not binary ringtone */ - if (GSM_ReadBinRingtoneFile(argv[0],&binringtone2)!=GE_NONE) { - fprintf(stdout,_("Not binary ringtone, trying RTTL\n")); - - if (GSM_ReadRingtoneFileOnConsole(argv[0], &ringtone)!=GE_NONE) return(-1); - - ringtone.location=1; - if (argc>1) ringtone.location=atoi(argv[1]); - - ringtone.allnotesscale=false; - - /* Initialise the GSM interface. */ - fbusinit(NULL); - - while (GSM->GetModel(model) != GE_NONE) - sleep(1); - - /* For Nokia 6110/6130/6150/6210 we use different method of uploading. - Phone will display menu, when received it */ - if ( !strcmp(model,"NSE-3") || !strcmp(model,"NSK-3") || - !strcmp(model,"NSM-1") || !strcmp(model,"NPE-3") ) { - if (argc==1) ringtone.location=255; - } - - error=GSM->SetRingtone(&ringtone,¤t); - - if (current!=ringtone.NrNotes) { - if (current>FB61_MAX_RINGTONE_NOTES) { - fprintf(stderr,_("Warning: due to phone limitation")); - } else { - fprintf(stderr,_("Warning: ringtone was too long to be saved into frame,")); - } - fprintf(stderr, _(" only %i first notes were packed (%i cut)\n"),current,ringtone.NrNotes-current); - } - - if (error==GE_NONE) - fprintf(stdout, _("Set succeeded!\n")); - else - fprintf(stdout, _("Setting failed\n")); - - } else { /* This IS binary ringtone */ - fprintf(stdout,_("Binary ringtone format\n")); - - if (argc==3) { - binringtone.frame[current++]=0x00; - binringtone.frame[current++]=0x00; - binringtone.frame[current++]=0x0c; - binringtone.frame[current++]=0x01; - binringtone.frame[current++]=0x2c; - - //copy new name - memcpy(binringtone.frame+current,argv[2],strlen(argv[2])); - current=current+strlen(argv[2]); - - /*don't use old*/ - i=2; - while(binringtone2.frame[i]!=0x00) { - if (i==binringtone.length) break; - i++; - } - - //copy binringtone - memcpy(binringtone.frame+current,binringtone2.frame+i,binringtone2.length-i); - binringtone.length=binringtone2.length-i+current; - } else - { - memcpy(binringtone.frame+current,binringtone2.frame,binringtone2.length); - binringtone.length=binringtone2.length; - } - - binringtone.location=1; - if (argc>1) binringtone.location=atoi(argv[1]); - - /* Initialise the GSM interface. */ - fbusinit(NULL); - - error=GSM->SetBinRingtone(&binringtone); - - switch (error) { - case GE_NONE: - fprintf(stdout, _("Set succeeded!\n")); - break; - case GE_INVALIDRINGLOCATION: - fprintf(stdout, _("Invalid location %i!\n"),binringtone.location); - break; - case GE_UNKNOWNMODEL: - fprintf(stdout, _("Mygnokii doesn't know format for this model!\n")); - break; - case GE_NOTIMPLEMENTED: - fprintf(stdout, _("Not implemented for this model!\n")); - break; - default: - fprintf(stdout, _("Not supported by this model!\n")); - break; - } - } - - GSM->Terminate(); - - return 0; -} - -int ringtoneconvert(int argc, char *argv[]) -{ - GSM_Ringtone ringtone; - - if (!strcmp(argv[0],argv[1])) - { - fprintf(stderr, _("Files can't have the same names !\n")); - return -1; - } - - if (GSM_ReadRingtoneFileOnConsole(argv[0], &ringtone)!=GE_NONE) return(-1); - - ringtone.allnotesscale=false; - - GSM_SaveRingtoneFileOnConsole(argv[1], &ringtone); - - return 0; -} - -int playringtone(int argc, char *argv[]) -{ - GSM_Ringtone ringtone; - - GSM_BinRingtone binringtone; - - int i,j,z; - int Hz; - bool isok; - -//{ "c", "c#", "d", "d#", "e", "f", "f#", "g", "g#", "a", "a#", "h" }; - int binary_notes[12] = - { 0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11 , 12}; - - if (GSM_ReadBinRingtoneFile(argv[0],&binringtone)!=GE_NONE) { - fprintf(stdout,_("Not binary ringtone, trying RTTL\n")); - - if (GSM_ReadRingtoneFileOnConsole(argv[0], &ringtone)!=GE_NONE) return(-1); - - /* Initialise the GSM interface. */ - fbusinit(NULL); - - fprintf(stdout,_("Playing \"%s\" (%i notes)\n"),ringtone.name,ringtone.NrNotes); - - GSM_PlayRingtoneOnConsole(&ringtone); - - } else { - - fprintf(stdout,_("Binary ringtone format\n")); - - /* Initialise the GSM interface. */ - fbusinit(NULL); - - i=5; - while (true) { //skipping name - if (binringtone.frame[i]==0) break; - i++; - } - - i=i+5;j=0;z=0; - while (true) { - if (binringtone.frame[i]!=j) { - if (j!=0) { -//#ifdef DEBUG - fprintf(stdout,_("Block in binary ringtone %i %i\n"),j,z); -//#endif - isok=false; - if (j==64) { - j=255;//Pause - isok=true; - } - if (!isok && j>=114 && j<=125) { - j=14*3+binary_notes[j-114]; - isok=true; - } - if (!isok && j>=126 && j<=137) { - j=14*1+binary_notes[j-126]; - isok=true; - } - if (!isok && j>=138 && j<=149) { - j=14*2+binary_notes[j-138]; - isok=true; - } - if (!isok && j>=150 && j<=161) { - j=14*4+binary_notes[j-150]; - isok=true; - } - if (!isok) { -//#ifdef DEBUG - fprintf(stdout,_("Unknown block in binary ringtone %i %i\n"),j,z); -//#endif - } else { - Hz=GSM_GetFrequency(j); - if (GSM->PlayTone(Hz,5)!=GE_NONE) fprintf(stdout,_("error during playing\n")); - usleep(z*5000); - } - } - j=binringtone.frame[i]; - z=binringtone.frame[i+1]; - } else { - z=z+binringtone.frame[i+1]; - } - i=i+2; - if (i>=binringtone.length) break; - } - - GSM->PlayTone(0,0); - } - - GSM->Terminate(); - - return 0; -} - -int composer(int argc, char *argv[]) -{ - GSM_Ringtone ringtone; - int i; - bool unknown; - int oldnoteslen=4,nownoteslen,oldnoteslen2; - int oldnotesscale=1,nownotesscale; - bool firstnote=true; - int DefNoteTempo=63; - - if (GSM_ReadRingtoneFileOnConsole(argv[0], &ringtone)!=GE_NONE) return(-1); - - if (ringtone.NrNotes!=0) - DefNoteTempo=ringtone.notes[0].tempo; - - fprintf(stdout,_("Ringtone \"%s\" (tempo = %i Beats Per Minute)\n\n"),ringtone.name,GSM_GetTempo(DefNoteTempo)); - - for (i=0;i50) - fprintf(stdout,_("WARNING: LENGTH=%i, BUT YOU WILL ENTER ONLY FIRST 50 TONES. TO ENTER FULL RINGTONE MUST SEND IT (--sendringtone) OR DOWNLOAD (--setringtone)\n\n"),ringtone.NrNotes-i); - - fprintf(stdout,_("This ringtone in Nokia Composer in phone should look: ")); - - firstnote=true; - - for (i=0;ioldnoteslen) { - while (oldnoteslen!=nownoteslen) { - fprintf(stdout,_("8")); - oldnoteslen=oldnoteslen*2; - } - } - - if (nownoteslenFB61_MAX_RINGTONE_NOTES) { - fprintf(stderr,_("Warning: due to phone limitation")); - } else { - fprintf(stderr,_("Warning: ringtone was too long to be saved into SMS,")); - } - fprintf(stderr, _(" only %i first notes were packed (%i cut)\n"),current,ringtone.NrNotes-current); - } - - for (i=0;iFB61_MAX_RINGTONE_NOTES) { - fprintf(stderr,_("Warning: due to phone limitation")); - } else { - fprintf(stderr,_("Warning: ringtone was too long to be saved into SMS,")); - } - fprintf(stderr, _(" only %i first notes were packed (%i cut)\n"),current,ringtone.NrNotes-current); - } - - for (i=0;i2) - { - doit=false; - if (!strcmp(argv[2],"op")) - { - doit=false; - if (argc<4) doit=true; - if (argc<4 && bitmap.type!=GSM_OperatorLogo) doit=true; - if (doit) - { - fbusinit(NULL); - if (GSM->GetNetworkInfo(&NetworkInfo) == GE_NONE) strncpy(bitmap.netcode,NetworkInfo.NetworkCode,7); - GSM->Terminate(); - } - GSM_ResizeBitmap(&bitmap,GSM_OperatorLogo); - if (argc==4) - { - strncpy(bitmap.netcode,argv[3],7); - if (!strcmp(GSM_GetNetworkName(bitmap.netcode),"unknown")) - { - fprintf(stderr,"Sorry, gnokii doesn't know \"%s\" network !\n",bitmap.netcode); - return -1; - } - } - doit=true; - } - if (!strcmp(argv[2],"7110op")) - { - doit=false; - if (argc<4) doit=true; - if (argc<4 && bitmap.type!=GSM_7110OperatorLogo) doit=true; - if (doit) - { - fbusinit(NULL); - if (GSM->GetNetworkInfo(&NetworkInfo) == GE_NONE) strncpy(bitmap.netcode,NetworkInfo.NetworkCode,7); - GSM->Terminate(); - } - GSM_ResizeBitmap(&bitmap,GSM_7110OperatorLogo); - if (argc==4) - { - strncpy(bitmap.netcode,argv[3],7); - if (!strcmp(GSM_GetNetworkName(bitmap.netcode),"unknown")) - { - fprintf(stderr,"Sorry, gnokii doesn't know \"%s\" network !\n",bitmap.netcode); - return -1; - } - } - doit=true; - } - if (!strcmp(argv[2],"caller")) - { - GSM_ResizeBitmap(&bitmap,GSM_CallerLogo); - if (argc>3) - { - num=argv[3][0]-'0'; - if ((num<0)||(num>9)) num=0; - bitmap.number=num; - } else - { - bitmap.number=0; - } - doit=true; - } - if (!strcmp(argv[2],"startup")) - { - GSM_ResizeBitmap(&bitmap,GSM_StartupLogo); - doit=true; - } - if (!strcmp(argv[2],"7110startup")) - { - GSM_ResizeBitmap(&bitmap,GSM_7110StartupLogo); - doit=true; - } - if (!strcmp(argv[2],"6210startup")) - { - GSM_ResizeBitmap(&bitmap,GSM_6210StartupLogo); - doit=true; - } - if (!strcmp(argv[2],"picture")) - { - GSM_ResizeBitmap(&bitmap,GSM_PictureImage); - doit=true; - } - if (!doit) - { - fprintf(stderr,"Unknown type of logo: %s !\n",argv[2]); - return -1; - } - } - - if (GSM_SaveBitmapFileOnConsole(argv[1], &bitmap)!=GE_NONE) return(-1); - - return 0; -} - -int getphoneprofile() -{ - GSM_PPS PPS; - GSM_Error error; - - /* Initialise the GSM interface. */ - fbusinit(NULL); - - PPS.Name=PPS_ALS; - error=GSM->GetProductProfileSetting(&PPS); - if (error!=GE_NONE) { - fprintf(stdout,_("Error!\n")); - GSM->Terminate(); - return -1; - } - fprintf(stdout,_("ALS : ")); - if (PPS.bool_value) fprintf(stdout,_("on\n")); - else fprintf(stdout,_("off\n")); - - PPS.Name=PPS_VibraMenu; - GSM->GetProductProfileSetting(&PPS); - fprintf(stdout,_("Vibra menu : ")); - if (PPS.bool_value) fprintf(stdout,_("on\n")); - else fprintf(stdout,_("off\n")); - - PPS.Name=PPS_GamesMenu; - GSM->GetProductProfileSetting(&PPS); - fprintf(stdout,_("Games menu : ")); - if (PPS.bool_value) fprintf(stdout,_("on\n")); - else fprintf(stdout,_("off\n")); - - PPS.Name=PPS_HRData; - GSM->GetProductProfileSetting(&PPS); - fprintf(stdout,_("HR Data : ")); - if (PPS.bool_value) fprintf(stdout,_("on\n")); - else fprintf(stdout,_("off\n")); - - PPS.Name=PPS_14400Data; - GSM->GetProductProfileSetting(&PPS); - fprintf(stdout,_("14400 Data : ")); - if (PPS.bool_value) fprintf(stdout,_("on\n")); - else fprintf(stdout,_("off\n")); - - PPS.Name=PPS_LCDContrast; - GSM->GetProductProfileSetting(&PPS); - fprintf(stdout,_("LCD Contrast : %i%%\n"),PPS.int_value); - - PPS.Name=PPS_EFR; - GSM->GetProductProfileSetting(&PPS); - fprintf(stdout,_("EFR : ")); - switch (PPS.int_value) { - case 0: fprintf(stdout,_("off\n")); break; - case 1: fprintf(stdout,_("last\n")); break; - case 2: fprintf(stdout,_("second\n"));break; - case 3: fprintf(stdout,_("first\n")); break; - } - - PPS.Name=PPS_FR; - GSM->GetProductProfileSetting(&PPS); - fprintf(stdout,_("FR : ")); - switch (PPS.int_value) { - case 0: fprintf(stdout,_("off\n")); break; - case 1: fprintf(stdout,_("last\n")); break; - case 2: fprintf(stdout,_("second\n"));break; - case 3: fprintf(stdout,_("first\n")); break; - } - - PPS.Name=PPS_HR; - GSM->GetProductProfileSetting(&PPS); - fprintf(stdout,_("HR : ")); - switch (PPS.int_value) { - case 0: fprintf(stdout,_("off\n")); break; - case 1: fprintf(stdout,_("last\n")); break; - case 2: fprintf(stdout,_("second\n"));break; - case 3: fprintf(stdout,_("first\n")); break; - } - - GSM->Terminate(); - - return 0; - -} - -int setphoneprofile(int argc, char *argv[]) -{ - GSM_PPS PPS; - GSM_Error error; - bool correct_arg1=false, correct_arg2=false; - - if (!strcmp(argv[0],"ALS")) { - PPS.Name=PPS_ALS; - correct_arg1=true; - if (!strcmp(argv[1],"1")) { - PPS.bool_value=true; - correct_arg2=true; - } - if (!strcmp(argv[1],"0")) { - PPS.bool_value=false; - correct_arg2=true; - } - if (!correct_arg2) { - fprintf(stdout,_("Settings for ALS parameter can be \"0\" or \"1\" !\n")); - return -1; - } - } - if (!strcmp(argv[0],"HRData")) { - PPS.Name=PPS_HRData; - correct_arg1=true; - if (!strcmp(argv[1],"1")) { - PPS.bool_value=true; - correct_arg2=true; - } - if (!strcmp(argv[1],"0")) { - PPS.bool_value=false; - correct_arg2=true; - } - if (!correct_arg2) { - fprintf(stdout,_("Settings for HRData parameter can be \"0\" or \"1\" !\n")); - return -1; - } - } - if (!correct_arg1) { - fprintf(stdout,_("First parameter can be \"ALS\" or \"HRData\" only !\n")); - return -1; - } - - /* Initialise the GSM interface. */ - fbusinit(NULL); - - error=GSM->SetProductProfileSetting(&PPS); - - if (error!=GE_NONE) { - fprintf(stdout,_("Error!\n")); - GSM->Terminate(); - return -1; - } - - GSM->Reset(0x03); - - GSM->Terminate(); - - return 0; - -} - -int getoperatorname() -{ - - GSM_Network network; - - /* Initialise the GSM interface. */ - fbusinit(NULL); - - if (GSM->GetOperatorName(&network)==GE_NONE) - { - if (!strcmp(network.Name,"")) { - fprintf(stdout,_("Phone doesn't have downloaded operator name\n")); - } else { - fprintf(stdout,_("Phone has downloaded operator name (\"%s\") for \"%s\" (\"%s\") network\n"), - network.Name,network.Code,GSM_GetNetworkName(network.Code)); - } - } - - GSM->Terminate(); - - return 0; - -} - -int setoperatorname(int argc, char *argv[]) -{ - - GSM_Network network; - - /* Initialise the GSM interface. */ - fbusinit(NULL); - - if (argc==2) { - strncpy(network.Code,argv[0],7); - strncpy(network.Name,argv[1],50); - } else { - strcpy(network.Code,"000 00\0"); - strcpy(network.Name,"\0"); - } - - if (GSM->SetOperatorName(&network)==GE_NONE) { - if (GSM->GetOperatorName(&network)==GE_NONE) { - if (!strcmp(network.Name,"")) { - fprintf(stdout,_("Downloaded operator name is removed\n")); - } else { - fprintf(stdout,_("Downloaded operator name changed for \"%s\" network (\"%s\") to \"%s\"\n"), - network.Code,GSM_GetNetworkName(network.Code),network.Name); - } - } - } - - GSM->Terminate(); - - return 0; - -} - -int getvoicemailbox() -{ - GSM_PhonebookEntry entry; - - /* Initialise the GSM interface. */ - fbusinit(NULL); - - if (GSM->GetVoiceMailbox(&entry)==GE_NONE) { - fprintf(stdout,_("Voice mailbox number is ")); - if (!strcmp(entry.Number,"")) - fprintf(stdout,_("not set\n")); - else - fprintf(stdout,_("\"%s\"\n"),entry.Number); - } - - GSM->Terminate(); - - return 0; - -} - -/////////////////////////////////////////////////////////////////////////////// -// flow diagram of netmonitordata(): -/////////////////////////////////////////////////////////////////////////////// -// -// get command line argument -// | -// v -// -// if specific phone model -// use that model -// else -// identify-phone: (((((((( TO DO ))))))))))))) -// -// | -// v -// get_mon_param_info() get phone netmonitor parameters name -// specifically to a 'model' -// | -// v -// parse_check() check command line arguments -// | if all OK, go on else stop. -// | because we can have a input file -// v containing multiple -// parse_process() command lines, we process each at once -// so we can exit early on errors. -// -/////////////////////////////////////////////////////////////////////////////// - -// private functions, see netmonitordata() -void free_nm_info(PARAM_INFO_MON *info) -{ - PARAM_INFO_MON *tmp; // pointer, iterator on info - - // go to end of list - - while (info->next != NULL) - { tmp = info->next; - free(info->name); - free(info->mname); - free(info); - info = tmp; - } - free(info); -} - -/////////////////////////////////////////////////////////////////////////////// -// this func retrieve parameters info from a file -// and load it in a dynamic array, NULL terminated, -// if 2rd parameter is not NULL, it load also description of screen -// return (PARAM_INFO_MON *start) if all is OK, else NULL -/////////////////////////////////////////////////////////////////////////////// -// start->->next->next->next-> ...->next->NULL -// | | | | | -// V V V V V -// par0 par1 par2 parN -/////////////////////////////////////////////////////////////////////////////// -// this should be de-allocated from calling function, -// also, screen_name should be deallocated from calling function -/////////////////////////////////////////////////////////////////////////////// - -PARAM_INFO_MON *get_mon_param_info(char *f_name, char *screen_name[NM_MAX_SCREEN+1]) -{ - PARAM_INFO_MON *start; // pointer to netmonitor parameters info - PARAM_INFO_MON *info; // pointer, iterator on info - PARAM_INFO_MON *check; // pointer, iterator on info, for check usage - - FILE *f_info; - - char buf[256]; - char *param; - char *param_name; - char *tmp; - - char tmp_mname[55]; // very larger, but if netmon bug ... - int x, y, len, s, t; // x & y coord, len, screen nr, type - int i; - - if (screen_name != NULL) - for (i = 0; i <= NM_MAX_SCREEN; i++) - screen_name[i] = NULL; - - - if ((f_info = fopen(f_name, "r")) == NULL) - { fprintf(stderr, "Can' t open file parameter info: <%s>\n", f_name); - return(NULL); - } - - if ((start = malloc(sizeof(PARAM_INFO_MON))) == NULL) - { fprintf(stderr, "no mem\n"); - return(NULL); - } - else - { start->next = NULL; - } - - info = start; - while (fgets(buf, 256, f_info) != NULL) - { - param = buf; - - // Truncate from '#' at right of comments - if ((tmp = strchr(param, '#')) != NULL) - *tmp = '\0'; - - // Strip leading, trailing whitespace - while(isspace((int) *param)) - param++; - - while((strlen(param) > 0) && isspace((int) param[strlen(param) - 1])) - param[strlen(param) - 1] = '\0'; - - // Ignore blank lines - if ((*param == '\n') || (*param == '\0')) - continue; - - -#ifdef DEBUG - fprintf(stderr, "%s: info line: <%s>\n", f_name, param); -#endif - // check for param name - if ((param_name = strtok(param, "=\t\n")) == NULL) - continue; - - // check if screen name - if (strncmp("SCREEN", param_name, 6) == 0) - { - // if we do not want screen names ... - if (screen_name == NULL) - continue; - -// FIXME check for screen nr - if ((tmp = strtok(NULL, ":\n")) == NULL) - continue; - - i = atoi(tmp); -// FIXME: check if already defined screen - - if ((i <= 0) || (i > NM_MAX_SCREEN)) - continue; - // check for screen name - if ((tmp = strtok(NULL, ":\n")) == NULL) - continue; - - screen_name[i] = strdup(tmp); - } - else - { - // parameter - -// FIXME: check for NM_MAX_FIELDS - - // check for x coord - if ((tmp = strtok(NULL, ":\t\n")) == NULL) - continue; - x = atoi(tmp); - - // check for y coord - if ((tmp = strtok(NULL, ":\t\n")) == NULL) - continue; - y = atoi(tmp); - - // check for len - if ((tmp = strtok(NULL, ":\t\n")) == NULL) - continue; - len = atoi(tmp); - - // check for screen - if ((tmp = strtok(NULL, ":\t\n")) == NULL) - continue; - s = atoi(tmp); - - // check for netmon manual name - if ((tmp = strtok(NULL, ":\t\n")) == NULL) - { fprintf(stderr, - "%s: PARAMETER <%s> in screen <%d>, not have netmon manual reference\n", - f_name, param_name, s); - free_nm_info(start); - return(NULL); - } - strcpy(tmp_mname, tmp); - - // check for data type (optional) - if ((tmp = strtok(NULL, ":\t\n")) != NULL) - t = *tmp; - else - t = '\0'; - - // check len, here, so we print parameter name - if (len == 0) - { fprintf(stderr, - "%s: PARAMETER <%s> in screen <%d>, has invalid data lenght\n", - f_name, param_name, s); - free_nm_info(start); - return(NULL); - } - - // check if already defined same param_name - check = start; - while (check->next != NULL) - { check = check->next; - if (strcmp(param_name, check->name) == 0) - { - fprintf(stderr, - "%s: PARAMETER <%s> in screen <%d> already defined as in screen <%d>\n", - f_name, param_name, s, check->s_nr); - free_nm_info(start); - return(NULL); - } - } - - // make space, and add parameter - if ((info->next = malloc(sizeof(PARAM_INFO_MON))) != NULL) - { - info = info->next; - info->name = strdup(param_name); - info->x = x; - info->y = y; - info->len = len; - info->s_nr = s; - info->mname = strdup(tmp_mname); - info->type = t; - - info->next = NULL; // mark end - } - else - { - fprintf(stderr, "no mem"); - free_nm_info(start); - return(NULL); - } - - } - - } - - fclose(f_info); - -#ifdef DEBUG - info = start; - while (info->next != NULL) - { - info = info->next; - fprintf(stderr, "info name %s\n", info->name); - } -#endif - return(start); -} - -// 2, parse the arguments and check command(s) line -// command line, phone spec input, and output are complex, -// so we exit printing info about error instead of std help -/////////////////////////////////////////////////////////////////////////////// - -int parse_check(int argc, char *argv[], PARAM_INFO_MON *start, char *f_name, int line) -{ - int ctr; - int i; - int time_spec; - int found_data; - char *p; - char *tmp; - char *o; - PARAM_INFO_MON *info; // iterator on this list - -#ifdef DEBUG - for (i = 0; i < argc; i++) - fprintf(stderr, "argv[%d] = <%s>\n",i, argv[i]); -#endif - - time_spec = 0; - ctr = 0; - i = 0; - while (i < argc) - { - p = argv[i]; - if (*p == '-') - { // should be one of the short option - if (strcmp(argv[i], "-fs") == 0) - { // field separator, next arg should be a string - if (((i+1) < argc) && (strlen(argv[i+1]) < 10)) - { i++; - // arg OK, do nothing - } - else - { if (line) - fprintf(stderr, - "-fs: Invalid field separator in <%s> at line %d\n", - f_name, line); - else - fprintf(stderr, "-fs: Invalid field separator\n"); - return(-1); - } - } - else if (strcmp(argv[i], "-ls") == 0) - { // line separator, next arg should be a string - if (((i+1) < argc) && (strlen(argv[i+1]) < 10)) - { i++; - // arg OK, do nothing - } - else - { if (line) - fprintf(stderr, - "-ls: Invalid line separator in <%s> at line %d\n", - f_name, line); - else - fprintf(stderr, "-ls: Invalid line separator\n"); - return(-1); - } - } - else if (strcmp(argv[i], "-tm") == 0) - { // time separator, next arg should be a millisecond (200-10000) - if (time_spec) - { if (line) - fprintf(stderr, - "-tm, -ts, are mutually exclusive in <%s> at line %d\n", - f_name, line); - else - fprintf(stderr, "-tm, -ts, are mutually exclusive\n"); - return(-1); - } - - if (((i+1) < argc) && (atoi(argv[i+1]) >= 200) && (atoi(argv[i+1]) <= 10000)) - { i++; - time_spec = 1; - // arg OK, do nothing - } - else - { if (line) - fprintf(stderr, - "-tm: Invalid argument (200-10000 milliseconds), in <%s> at line %d\n", - f_name, line); - else - fprintf(stderr, "-tm: Invalid argument (200-10000 milliseconds)\n"); - return(-1); - } - } - else if (strcmp(argv[i], "-ts") == 0) - { // time separator, next arg should be a seconds (1-3600) - if (time_spec) - { if (line) - fprintf(stderr, - "-tm, -ts, are mutually exclusive, in <%s> at line %d\n", - f_name, line); - else - fprintf(stderr, "-tm, -ts, are mutually exclusive\n"); - return(-1); - } - - if (((i+1) < argc) && (atoi(argv[i+1]) >= 1) && (atoi(argv[i+1]) <= 3600)) - { i++; - time_spec = 1; - // arg OK, do nothing - } - else - { if (line) - fprintf(stderr, - "-ts: Invalid argument (1-3600 seconds) in <%s> at line %d\n", - f_name, line); - else - fprintf(stderr, "-ts: Invalid argument (1-3600 seconds)\n"); - return(-1); - } - } - else if (strcmp(argv[i], "-n") == 0) - { // nr of data pump, before stop collection, - // next arg should be a int > 0 - if (((i+1) < argc) && (atoi(argv[i+1]) >= 1) && (atoi(argv[i+1]) <= 99999)) - { i++; - // arg OK, do nothing - } - else - { if (line) - fprintf(stderr, - "-n: Invalid argument (1-99999 times) in <%s> at line %d\n", - f_name, line); - else - fprintf(stderr, "-n: Invalid argument (1-99999 times)\n"); - return(-1); - } - } - else if (strcmp(argv[i], "-h") == 0) - { // we do NOT want header (default with header) - // arg OK, do nothing - } - else if (strcmp(argv[i], "-S") == 0) - { // we have used use specs from a file instead of standard info, - // next arg is an existing readable filename - // as already parsed correctly, we skip here. - i++; - } - else if (strcmp(argv[i], "-I") == 0) - { // we have used input from a file instead of command line - // next arg is an existing readable filename - // as already parsed correctly, we skip here. - i++; - } - else - { - if (line) - fprintf(stderr, "Unrecognized option %s in <%s> at line %d\n", - argv[i], f_name, line); - else - fprintf(stderr, "Unrecognized option %s\n", argv[i]); - return(-1); - } - } - else - { // should be required data - tmp = strdup(argv[i]); - p = strtok(tmp, ":\t\n"); - while (p != NULL) - { - // check if there is an output format specification - o = p; - while (*o) - { - o++; - if (*o == '-') - { *o = '\0'; - o++; - if (strlen(o) == 0) - { - // we have 'minus', so, probably forget format ... - - if (line) - fprintf(stderr, - "Required data <%s->, without format specifiers in <%s> at line %d\n", - p, f_name, line); - else - fprintf(stderr, - "Required data <%s->, without format specifiers\n", p); - return(-1); - } - } - } - - // we check for params - found_data = 0; - info = start; - while (info->next != NULL) - { - info = info->next; - if (strcmp(p, info->name) == 0) - { - if (ctr > NM_MAX_FIELDS) - { - if (line) - fprintf(stderr, - "too much data field ... in file <%s> at line %d\n", - f_name, line); - else - fprintf(stderr, "too much data field ...\n"); - return (-1); - } -/* - data[ctr] = info; - out_f[ctr] = *o; -*/ - found_data = 1; - ctr++; - break; - } - } - - if (found_data == 0) - { - if (line) - fprintf(stderr, - "Required data <%s>, not found in info-mon specifications in <%s> at line %d\n", - p, f_name, line); - else - fprintf(stderr, - "Required data <%s>, not found in info-mon specifications\n", p); - return(-1); - } - - p = strtok(NULL, ":\t\n"); - - } // end while strtok - - } // end else '-' (short options) - - i++; - - } // end while - - if (ctr == 0) - { - if (line) - fprintf(stderr, "no required data! in <%s> at line %d\n", f_name, line); - else - fprintf(stderr, "no required data!\n"); - return(-1); - } - - return 0; -} - -// 2, parse the arguments and process the command line -// no checks are needed here, because already do in parse_check -// it return a pointer to info needed for make output, or NULL if errors -/////////////////////////////////////////////////////////////////////////////// -OUT_INFO_MON *parse_process(int argc, char *argv[], PARAM_INFO_MON *start) -{ - int ctr; - int i; - int time_spec; - int found_data; - int req_tm; - int req_ts; - char *p; - char *tmp; - char *o; - PARAM_INFO_MON *info; // iterator on this list - OUT_INFO_MON *out_param; // iterator on this list - - if ((out_param = malloc(sizeof(OUT_INFO_MON))) == NULL) - { fprintf(stderr, "no mem\n"); - return(NULL); - } - -#ifdef DEBUG - fprintf(stderr, "parse_process: argc = %d\n", argc); - for (i = 0; i < argc; i++) - fprintf(stderr, "argv[%d] = <%s>\n",i, argv[i]); -#endif - - for (i = 0; i < NM_MAX_FIELDS; i++) - out_param->data[i] = NULL; - - strcpy(out_param->req_fs, " "); -#ifdef WIN32 - strcpy(out_param->req_ls, "\n\r"); -#else - strcpy(out_param->req_ls, "\n"); -#endif - time_spec = 0; - out_param->req_n = 0; - out_param->req_header = 1; - - time_spec = 0; - req_tm = 200; /* default wait */ - req_ts = 0; - - ctr = 0; - i = 0; - while (i < argc) - { - p = argv[i]; - if (*p == '-') - { // should be one of the short option - if (strcmp(argv[i], "-fs") == 0) - { // field separator, next arg should be a string - if (((i+1) < argc) && (strlen(argv[i+1]) < 10)) - { i++; - strcpy(out_param->req_fs, argv[i]); - } - else - { fprintf(stderr, "NEVER BE:-fs: Invalid field separator\n"); - return(NULL); - } - } - else if (strcmp(argv[i], "-ls") == 0) - { // line separator, next arg should be a string - if (((i+1) < argc) && (strlen(argv[i+1]) < 10)) - { i++; - strcpy(out_param->req_ls, argv[i]); - } - else - { fprintf(stderr, "NEVER BE:-ls: Invalid line separator\n"); - return(NULL); - } - } - else if (strcmp(argv[i], "-tm") == 0) - { // time separator, next arg should be a millisecond (200-10000) - if (time_spec) - { fprintf(stderr, "NEVER BE:-tm, -ts, are mutually exclusive"); - return(NULL); - } - - if (((i+1) < argc) && (atoi(argv[i+1]) >= 200) && (atoi(argv[i+1]) <= 10000)) - { i++; - req_tm = atoi(argv[i]); - time_spec = 1; - } - else - { fprintf(stderr, "NEVER BE:-tm: Invalid argument (200-10000 milliseconds)\n"); - return(NULL); - } - } - else if (strcmp(argv[i], "-ts") == 0) - { // time separator, next arg should be a seconds (1-3600) - if (time_spec) - { fprintf(stderr, "NEVER BE:-tm, -ts, are mutually exclusive"); - return(NULL); - } - - if (((i+1) < argc) && (atoi(argv[i+1]) >= 1) && (atoi(argv[i+1]) <= 3600)) - { i++; - req_ts = atoi(argv[i]); - time_spec = 1; - - // delete default - req_tm = 0; - } - else - { fprintf(stderr, "NEVER BE:-ts: Invalid argument (1-3600 seconds)\n"); - return(NULL); - } - } - else if (strcmp(argv[i], "-n") == 0) - { // nr of data pump, before stop collection, - // next arg should be a int > 0 - if (((i+1) < argc) && (atoi(argv[i+1]) >= 1) && (atoi(argv[i+1]) <= 99999)) - { i++; - out_param->req_n = atoi(argv[i]); - } - else - { fprintf(stderr, "NEVER BE:-n: Invalid argument (1-99999 times)\n"); - return(NULL); - } - } - else if (strcmp(argv[i], "-h") == 0) - { // we do NOT want header (default with header) - out_param->req_header = 0; - } - else if (strcmp(argv[i], "-S") == 0) - { // we have used use specs from a file instead of standard info, - // next arg is an existing readable filename - // as already parsed correctly, we skip here. - i++; - } - else if (strcmp(argv[i], "-I") == 0) - { // we have used input from a file instead of command line - // next arg is an existing readable filename - // as already parsed correctly, we skip here. - i++; - } - else - { - fprintf(stderr, "NEVER BE:Unrecognized option %s\n", argv[i]); - return(NULL); - } - } - else - { // should be required data - tmp = strdup(argv[i]); - p = strtok(tmp, ":\t\n"); - while (p != NULL) - { - // check if there is an output format specification - o = p; - while (*o) - { - o++; - if (*o == '-') - { *o = '\0'; - o++; - if (strlen(o) == 0) - { - // we have 'minus', so, probably forget format ... - - fprintf(stderr, - "NEVER BE:Required data <%s->, without format specifiers\n", p); - return(NULL); - } - } - } - - // we check for params - found_data = 0; - info = start; - while (info->next != NULL) - { - info = info->next; - if (strcmp(p, info->name) == 0) - { - if (ctr > NM_MAX_FIELDS) - { - fprintf(stderr, "NEVER BE:too much data field ..."); - return(NULL); - } - out_param->data[ctr] = info; - out_param->out_f[ctr] = *o; - found_data = 1; - ctr++; - break; - } - } - - if (found_data == 0) - { - fprintf(stderr, - "NEVER BE:Required data <%s>, not found in info-mon specifications\n", p); - return(NULL); - } - - - p = strtok(NULL, ":\t\n"); - - } // end while strtok - - // here, we have an array of pointers to required data - // and an array of output specifiers, from 0 to [ctr-1] - - } // end else '-' (short options) - - i++; - - } // end while - - if (ctr == 0) - { - fprintf(stderr, "NEVER BE:no required data!\n"); - return(NULL); - } - - // now, what netmon screen we need to retrieve ? - // we need somewhat were checking is faster, as our goal is lower cicle time - - // we can have NM_MAX_SCREEN=254 screens, so we use an array, of unsigned char, - // each char contain number of needed screen, 255 is list terminator - - for (i = 0; i <= NM_MAX_SCREEN; i++) - out_param->req_screen[i] = 255; - - ctr = 0; -#ifdef DEBUG -fprintf(stderr, "Start Required data %s screen %d\n", out_param->data[ctr]->name, out_param->data[ctr]->s_nr); -#endif - while (out_param->data[ctr] != NULL) - { -#ifdef DEBUG -fprintf(stderr, "Required data %s screen %d\n", out_param->data[ctr]->name, out_param->data[ctr]->s_nr); -#endif - // check if screen already in - found_data = 0; - i = 0; - while (out_param->req_screen[i] != 255) - { - if (out_param->req_screen[i] == out_param->data[ctr]->s_nr) - { // already load, skip - found_data = 1; - break; - } - i++; - } - - if (found_data == 0) - { -#ifdef DEBUG -fprintf(stderr, "i = %d, out_param->req_screen[%d] = %d\n", i, i, out_param->data[ctr]->s_nr); -#endif - out_param->req_screen[i] = out_param->data[ctr]->s_nr; - i++; - } - - ctr++; + switch (error) { + case GE_CANTOPENFILE: + fprintf(stderr, _("Failed to read file \"%s\"\n"), FileName); + break; + case GE_WRONGNUMBEROFCOLORS: + fprintf(stderr, _("Wrong number of colors in \"%s\" logofile (accepted only 2-colors files) !\n"), FileName); + break; + case GE_WRONGCOLORS: + fprintf(stderr, _("Wrong colors in \"%s\" logofile !\n"), FileName); + break; + case GE_INVALIDFILEFORMAT: + fprintf(stderr, _("Invalid format of \"%s\" logofile !\n"), FileName); + break; + case GE_SUBFORMATNOTSUPPORTED: + fprintf(stderr, _("Sorry, gnokii doesn't support used subformat in file \"%s\" !\n"), FileName); + break; + case GE_FILETOOSHORT: + fprintf(stderr, _("\"%s\" logofile is too short !\n"), FileName); + break; + case GE_INVALIDIMAGESIZE: + fprintf(stderr, _("Bitmap size doesn't supported by fileformat or different from 72x14, 84x48 and 72x28 !\n")); + break; + default: + break; } - -#ifdef DEBUG -i = 0; -while (out_param->req_screen[i] != 255) -{ - fprintf(stderr, "Required screen %d\n", out_param->req_screen[i]); - i++; + + return error; } -#endif - - if (req_tm) - out_param->req_wait = req_tm * 1000; - else if (req_ts) - out_param->req_wait = req_ts * 1000000; - else - out_param->req_wait = req_tm * 1000; - - return(out_param); -} -int nmd_output(OUT_INFO_MON *out_param) +int setlogo(int argc, char *argv[]) { - int d; - int len; - int ctr; + GSM_Bitmap bitmap,oldbit; + GSM_NetworkInfo NetworkInfo; + GSM_Error error; + + bool ok = true; int i; - int nr_line; - char *p; - int nr_chr; - int n; - char Screen[NM_MAX_SCREEN_WIDTH]; - time_t sec; - struct tm *date_time; - - if (out_param->req_header) - { -// print phone help header - d = 0; - while (out_param->data[d] != NULL) - { len = out_param->data[d]->len; - if (strlen(out_param->data[d]->name) > len) - len = strlen(out_param->data[d]->name); - if (strlen(out_param->data[d]->mname) > len) - len = strlen(out_param->data[d]->mname); - printf("%*.*s%s", len, len, out_param->data[d]->name, out_param->req_fs); - d++; - } - printf("%s", out_param->req_ls); - -// print netmon manual header - d = 0; - while (out_param->data[d] != NULL) - { len = out_param->data[d]->len; - if (strlen(out_param->data[d]->name) > len) - len = strlen(out_param->data[d]->name); - if (strlen(out_param->data[d]->mname) > len) - len = strlen(out_param->data[d]->mname); - printf("%*.*s%s", len, len, out_param->data[d]->mname, out_param->req_fs); - d++; - } - printf("%s", out_param->req_ls); - printf("%s", out_param->req_ls); - } - - ctr = 0; - while (!bshutdown) - { -// stop after n data punp - - ctr++; - if ((out_param->req_n) && (ctr > out_param->req_n)) - break; - -// datapump: for each screen, for each required data, load data info->value - - i = 0; - while(out_param->req_screen[i] != 255) - { - if (out_param->req_screen[i] == 0) - { - sec = time(0); - date_time = localtime(&sec); - sprintf(Screen, "%02d-%02d-%04d\n%02d:%02d:%02d\n", - date_time->tm_mday, - date_time->tm_mon+1, - date_time->tm_year+1900, - date_time->tm_hour, - date_time->tm_min, - date_time->tm_sec); -#ifdef DEBUG - fprintf(stderr, "%02d-%02d-%04d\n%02d:%02d:%02d\n", - date_time->tm_mday, - date_time->tm_mon+1, - date_time->tm_year+1900, - date_time->tm_hour, - date_time->tm_min, - date_time->tm_sec); -#endif - } - else - { - GSM->NetMonitor(out_param->req_screen[i], Screen); - } - -// we have one screen of data, load those required + + if (!strcmp(argv[0],"text") || !strcmp(argv[0],"dealer")) { + if (!strcmp(argv[0], "text")) bitmap.type = GSM_WelcomeNoteText; + else bitmap.type = GSM_DealerNoteText; + bitmap.text[0] = 0x00; + if (argc > 1) strncpy(bitmap.text, argv[1], 255); + } else { + if (!strcmp(argv[0], "op") || !strcmp(argv[0], "startup") || !strcmp(argv[0], "caller")) { + if (argc > 1) { + if (ReadBitmapFileOnConsole(argv[1], &bitmap) != GE_NONE) { + GSM->Terminate(); + return(-1); + } - d = 0; - while (out_param->data[d] != NULL) - { - if (out_param->data[d]->s_nr == out_param->req_screen[i]) - { - p = Screen; -// goto req y - nr_line = out_param->data[d]->y; - while ((*p) && (nr_line)) - { - if (*p == '\n') - { nr_line--; + if (!strcmp(argv[0], "op")) { + if (bitmap.type != GSM_OperatorLogo || argc < 3) { + if (GSM->GetNetworkInfo(&NetworkInfo) == GE_NONE) strncpy(bitmap.netcode, NetworkInfo.NetworkCode, 7); + } + GSM_ResizeBitmap(&bitmap, GSM_OperatorLogo, GSM_Info); + if (argc == 3) { + strncpy(bitmap.netcode, argv[2], 7); + if (!strcmp(GSM_GetNetworkName(bitmap.netcode), "unknown")) { + fprintf(stderr, "Sorry, gnokii doesn't know %s network !\n", bitmap.netcode); + return -1; } - p++; } -#ifdef DEBUG -fprintf(stderr, "\nthis line: %s\n\n", p); -#endif - -// goto req x - nr_chr = out_param->data[d]->x; - while ((*p) && (nr_chr)) - { p++; - nr_chr--; + } + if (!strcmp(argv[0], "startup")) { + GSM_ResizeBitmap(&bitmap, GSM_StartupLogo, GSM_Info); + } + if (!strcmp(argv[0],"caller")) { + GSM_ResizeBitmap(&bitmap, GSM_CallerLogo, GSM_Info); + if (argc > 2) { + bitmap.number = argv[2][0] - '0'; + if ((bitmap.number < 0) || (bitmap.number > 9)) bitmap.number = 0; + } else { + bitmap.number = 0; } -// this the start of data - n = 0; - len = out_param->data[d]->len; - while ((*p) && (len)) - { out_param->data[d]->value[n] = *p; - p++; - n++; - len--; + oldbit.type = GSM_CallerLogo; + oldbit.number = bitmap.number; + if (GSM->GetBitmap(&oldbit) == GE_NONE) { + /* We have to get the old name and ringtone!! */ + bitmap.ringtone = oldbit.ringtone; + strncpy(bitmap.text, oldbit.text, 255); + } + if (argc > 3) strncpy(bitmap.text, argv[3], 255); + } + fprintf(stdout, _("Setting Logo.\n")); + } else { + /* FIX ME: is it possible to permanently remove op logo ? */ + if (!strcmp(argv[0], "op")) + { + bitmap.type = GSM_OperatorLogo; + strncpy(bitmap.netcode, "000 00", 7); + bitmap.width = 72; + bitmap.height = 14; + bitmap.size = bitmap.width * bitmap.height / 8; + GSM_ClearBitmap(&bitmap); + } + /* FIX ME: how to remove startup and group logos ? */ + fprintf(stdout, _("Removing Logo.\n")); + } + } else { + fprintf(stderr, _("What kind of logo do you want to set ?\n")); + GSM->Terminate(); + return -1; + } + } + + error=GSM->SetBitmap(&bitmap); + + switch (error) { + case GE_NONE: + oldbit.type = bitmap.type; + oldbit.number = bitmap.number; + if (GSM->GetBitmap(&oldbit) == GE_NONE) { + if (bitmap.type == GSM_WelcomeNoteText || + bitmap.type == GSM_DealerNoteText) { + if (strcmp(bitmap.text, oldbit.text)) { + fprintf(stderr, _("Error setting")); + if (bitmap.type == GSM_DealerNoteText) fprintf(stderr, _(" dealer")); + fprintf(stderr, _(" welcome note - ")); + + /* I know, it looks horrible, but... */ + /* I set it to the short string - if it won't be set */ + /* it means, PIN is required. If it will be correct, previous */ + /* (user) text was too long */ + + /* Without it, I could have such thing: */ + /* user set text to very short string (for example, "Marcin") */ + /* then enable phone without PIN and try to set it to the very long (too long for phone) */ + /* string (which start with "Marcin"). If we compare them as only length different, we could think, */ + /* that phone accepts strings 6 chars length only (length of "Marcin") */ + /* When we make it correct, we don't have this mistake */ + + strcpy(oldbit.text, "!\0"); + GSM->SetBitmap(&oldbit); + GSM->GetBitmap(&oldbit); + if (oldbit.text[0]!='!') { + fprintf(stderr, _("SIM card and PIN is required\n")); + } else { + GSM->SetBitmap(&bitmap); + GSM->GetBitmap(&oldbit); + fprintf(stderr, _("too long, truncated to \"%s\" (length %i)\n"),oldbit.text,strlen(oldbit.text)); } -// pad with space if shorter than presumed - while ((*p) && (len)) - { out_param->data[d]->value[n] = ' '; - n++; - len--; + ok = false; + } + } else { + if (bitmap.type == GSM_StartupLogo) { + for (i = 0; i < oldbit.size; i++) { + if (oldbit.bitmap[i] != bitmap.bitmap[i]) { + fprintf(stderr, _("Error setting startup logo - SIM card and PIN is required\n")); + ok = false; + break; + } } - - out_param->data[d]->value[n] = '\0'; } - - d++; // next screen } - - i++; // next screen } + if (ok) fprintf(stdout, _("Done.\n")); + break; + case GE_NOTIMPLEMENTED: + fprintf(stderr, _("Function not implemented.\n")); + break; + case GE_NOTSUPPORTED: + fprintf(stderr, _("This kind of logo is not supported.\n")); + break; + default: + fprintf(stderr, _("Error !\n")); + break; + } + + GSM->Terminate(); -// print row of data - d = 0; - while (out_param->data[d] != NULL) - { - len = out_param->data[d]->len; - if (out_param->req_header) - { if (strlen(out_param->data[d]->name) > len) - len = strlen(out_param->data[d]->name); - if (strlen(out_param->data[d]->mname) > len) - len = strlen(out_param->data[d]->mname); - } -// FIXME check format - printf("%*.*s%s", len, len, out_param->data[d]->value, out_param->req_fs); - d++; - } - printf("%s", out_param->req_ls); + return 0; +} - usleep(out_param->req_wait); - - } - printf("%s%s", out_param->req_ls, out_param->req_ls); +int viewlogo(char *filename) +{ + GSM_Error error; - return(0); + error = GSM_ShowBitmapFile(filename); + return 0; } -// main func -/////////////////////////////////////////////////////////////////////////////// -int netmonitordata(int argc, char *argv[]) +/* Calendar notes receiving. */ +int getcalendarnote(int argc, char *argv[]) { - char *loc_info = NULL; // path to --netmonitordata directory - char *f_name; // absolute path of phone info-file - int flag_phone_spec = 0; // flags, set if used -S option - - char model[20] = "phonepar"; // TO DO: PHONE AUTODETECTION -// char phver[20] = ""; - - PARAM_INFO_MON *start; // pointer to list of parsed phone params - OUT_INFO_MON *out_param; // pointer to struct of output data - - char *f_commands = NULL; // file containings input line arguments - FILE *commands; // Handle for this file - char buf[1024]; // buffer - char *f_argv[NM_MAX_FIELDS+30]; // space for parameters and cmdline options - int f_argc; - char *p, *tmp; // various counter, flags, tmp area ... - int i; - int line; + GSM_CalendarNote CalendarNote; + GSM_Data data; + GSM_Error error = GE_NONE; + int i, first_location, last_location; + bool vCal = false; - - fbusinit(NULL); - - signal(SIGINT, interrupted); + struct option options[] = { + { "vCard", optional_argument, NULL, '1'}, + { NULL, 0, NULL, 0} + }; -// FIXME model, phone_version - - // before parsing phone-info-file, we check for user specified phone-info-file + optarg = NULL; + optind = 0; - i = 0; - while (i < argc) - { - if (strcmp(argv[i], "-S") == 0) - { - if ((i+1) < argc) - { - flag_phone_spec = 1; - loc_info = strdup(argv[i+1]); - break; - } - else - { fprintf(stderr, "option -S require an argument ...\n"); - return -1; - } - } - - i++; + first_location = last_location = atoi(argv[0]); + if ((argc > 1) && (argv[1][0] != '-')) { + last_location = atoi(argv[1]); } - if (loc_info != NULL) - { f_name = strdup(loc_info); - } - else // we use standard file specification - { - if ((tmp = getenv("INFOMONPATH")) == NULL) - { loc_info = strdup("."); - } - else - { loc_info = strdup(tmp); + while ((i = getopt_long(argc, argv, "v", options, NULL)) != -1) { + switch (i) { + case 'v': + vCal=true; + break; + default: + usage(); /* Would be better to have an calendar_usage() here. */ + return -1; } - - f_name = malloc(strlen(loc_info)+strlen(model)+10); - sprintf(f_name, "%s/%s", loc_info, model); } - -#ifdef DEBUG -// fprintf(stderr, "Loc_info <%s> model <%s> version <%s>\n", loc_info, model, phver); - fprintf(stderr, "Info file: <%s>\n", f_name); -#endif - if ((start = get_mon_param_info(f_name, NULL)) == NULL) - return(-1); - - // option -I give us the possibility of specify a filename, - // containing a "sequence" of command line args. - // if you specify this option, you can use (on command line) only -S option. - // other options may be specified inside the input-file. - // contents of this file as the same sintax as the command line, - // except it must not contain "--netmonitordata" or "-I" or "-S" options - /////////////////////////////////////////////////////////////////////// - - i = 0; - while (i < argc) - { - if (strcmp(argv[i], "-I") == 0) - { - if ((i+1) < argc) - { - if ((argc == 2) || ((argc == 4) && flag_phone_spec == 1)) - { f_commands = strdup(argv[i+1]); + + for (i = first_location; i <= last_location; i++) { + CalendarNote.Location = i; + if (GSM && GSM->GetCalendarNote && GSM->Terminate) { + error = GSM->GetCalendarNote(&CalendarNote); + GSM->Terminate(); + } else { + GSM_DataClear(&data); + data.CalendarNote = &CalendarNote; + + error = SM_Functions(GOP_GetCalendarNote, &data, &State); + } + switch (error) { + case GE_NONE: + if (vCal) { + fprintf(stdout, "BEGIN:VCALENDAR\n"); + fprintf(stdout, "VERSION:1.0\n"); + fprintf(stdout, "BEGIN:VEVENT\n"); + fprintf(stdout, "CATEGORIES:"); + switch (CalendarNote.Type) { + case GCN_REMINDER: + fprintf(stdout, "MISCELLANEOUS\n"); + break; + case GCN_CALL: + fprintf(stdout, "PHONE CALL\n"); + break; + case GCN_MEETING: + fprintf(stdout, "MEETING\n"); + break; + case GCN_BIRTHDAY: + fprintf(stdout, "SPECIAL OCCASION\n"); + break; + default: + fprintf(stdout, "UNKNOWN\n"); + break; } - else - { fprintf(stderr, "option -I accept only additional -S option.\n"); - return -1; + fprintf(stdout, "SUMMARY:%s\n",CalendarNote.Text); + fprintf(stdout, "DTSTART:%04d%02d%02dT%02d%02d%02d\n", CalendarNote.Time.Year, + CalendarNote.Time.Month, CalendarNote.Time.Day, CalendarNote.Time.Hour, + CalendarNote.Time.Minute, CalendarNote.Time.Second); + if (CalendarNote.Alarm.Year!=0) { + fprintf(stdout, "DALARM:%04d%02d%02dT%02d%02d%02d\n", CalendarNote.Alarm.Year, + CalendarNote.Alarm.Month, CalendarNote.Alarm.Day, CalendarNote.Alarm.Hour, + CalendarNote.Alarm.Minute, CalendarNote.Alarm.Second); + } + fprintf(stdout, "END:VEVENT\n"); + fprintf(stdout, "END:VCALENDAR\n"); + + } else { /* not vCal */ + fprintf(stdout, _(" Type of the note: ")); + + switch (CalendarNote.Type) { + case GCN_REMINDER: + fprintf(stdout, _("Reminder\n")); + break; + case GCN_CALL: + fprintf(stdout, _("Call\n")); + break; + case GCN_MEETING: + fprintf(stdout, _("Meeting\n")); + break; + case GCN_BIRTHDAY: + fprintf(stdout, _("Birthday\n")); + break; + default: + fprintf(stdout, _("Unknown\n")); + break; } - break; - } - else - { fprintf(stderr, "option -I require an argument ...\n"); - return -1; - } - } - - i++; - } - - // before all, we check all command line - - if (f_commands != NULL) - { -#ifdef DEBUG - fprintf(stderr, "netmonitordata(check): commands from <%s>\n", f_commands); -#endif - // for each line - // do - // read line, make array f_argv, and counter f_argc - // parse & check args, so errors are checked before real processing - // (-I option here is ignored) - // (-S option can be here, and it is used) - // done - - if ((commands = fopen(f_commands, "r")) == NULL) - { fprintf(stderr, "Can' t open file commands input :<%s>n", f_commands); - return(-1); - } - -// FIXME line may be be splitted - line = 0; - while (fgets(buf, 1024, commands) != NULL) - { - p = buf; - line++; - - // Truncate from '#' at right of comments - if ((tmp = strchr(p, '#')) != NULL) - *tmp = '\0'; - - // Strip leading, trailing whitespace - while(isspace((int) *p)) - p++; - - while((strlen(p) > 0) && isspace((int) p[strlen(p) - 1])) - p[strlen(p) - 1] = '\0'; - - // Ignore blank lines - if ((*p == '\n') || (*p == '\0')) - continue; - -#ifdef DEBUG -fprintf(stderr, "netmonitordata(check): row <%s>\n", p); -#endif - // make args - f_argc = 0; - - p = strtok(p, " \t"); - do - { f_argv[f_argc++] = strdup(p); -#ifdef DEBUG -fprintf(stderr, "netmonitordata(check): token <%s>\n", p); -#endif - p = strtok(NULL, " \t"); // OK p, (NULL) - } - while ((p != NULL) && (*p)); - - // here we have f_argc, f_argv, this line is OK - - if (parse_check(f_argc, f_argv, start, f_commands, line) != 0) - { free_nm_info(start); - return(-1); - } - } - - fclose(commands); - } - else // as above, but we have only command line, argv, argc. - { - if (parse_check(argc, argv, start, NULL, 0) != 0) - { free_nm_info(start); - return(-1); - } - } - - // here, all commands line are checked, and are correct - - if (f_commands != NULL) - { -#ifdef DEBUG - fprintf(stderr, "netmonitordata(process): commands from <%s>\n", f_commands); -#endif + fprintf(stdout, _(" Date: %d-%02d-%02d\n"), CalendarNote.Time.Year, + CalendarNote.Time.Month, + CalendarNote.Time.Day); - // for each line - // do - // read line, make array f_argv, and counter f_argc - // parse_process argument, (-I option here is ignored) - // (-S option can be here, and it is used) - // (make header // these are in nmd_output(); - // loop - // get net-mon-info - // make output - // done) - // done - - if ((commands = fopen(f_commands, "r")) == NULL) - { fprintf(stderr, "Can' t open file commands input :<%s>n", f_commands); - return(-1); - } - -// FIXME line may be be splitted - while (fgets(buf, 1024, commands) != NULL) - { - p = buf; + fprintf(stdout, _(" Time: %02d:%02d:%02d\n"), CalendarNote.Time.Hour, + CalendarNote.Time.Minute, + CalendarNote.Time.Second); - // Truncate from '#' at right of comments - if ((tmp = strchr(p, '#')) != NULL) - *tmp = '\0'; + if (CalendarNote.Alarm.AlarmEnabled == 1) { + fprintf(stdout, _(" Alarm date: %d-%02d-%02d\n"), CalendarNote.Alarm.Year, + CalendarNote.Alarm.Month, + CalendarNote.Alarm.Day); - // Strip leading, trailing whitespace - while(isspace((int) *p)) - p++; + fprintf(stdout, _(" Alarm time: %02d:%02d:%02d\n"), CalendarNote.Alarm.Hour, + CalendarNote.Alarm.Minute, + CalendarNote.Alarm.Second); + } - while((strlen(p) > 0) && isspace((int) p[strlen(p) - 1])) - p[strlen(p) - 1] = '\0'; - - // Ignore blank lines - if ((*p == '\n') || (*p == '\0')) - continue; - - // make args + fprintf(stdout, _(" Text: %s\n"), CalendarNote.Text); - f_argc = 0; - p = strtok(p, " \t"); - do - { f_argv[f_argc++] = strdup(p); - p = strtok(NULL, " \t"); // OK p, (NULL) - } - while ((p != NULL) && (*p)); - - // here we have f_argc, f_argv, this line is OK - - if ((out_param = parse_process(f_argc, f_argv, start)) == NULL) - { free_nm_info(start); - return(-1); /* NEVER BE */ + if (CalendarNote.Type == GCN_CALL) + fprintf(stdout, _(" Phone: %s\n"), CalendarNote.Phone); } - - // here, command line has no error ... - - nmd_output(out_param); - - free(out_param); - } - - fclose(commands); - } - else // as above, but we have only command line, argv, argc. - { - if ((out_param = parse_process(argc, argv, start)) == NULL) - { free_nm_info(start); - return(-1); /* NEVER BE */ + break; + case GE_NOTIMPLEMENTED: + fprintf(stderr, _("Function not implemented.\n")); + break; + default: + fprintf(stderr, _("The calendar note can not be read\n")); + break; } - nmd_output(out_param); - - free(out_param); } + GSM->Terminate(); - - free(loc_info); - free(f_name); - -/* I analised this source and this should be done. But when compile with VC6 */ -/* I have error. So, commented... MW */ -#ifndef VC6 - free_nm_info(start); -#endif - - return(0); + return error; } - -// used by nm_collect() -/////////////////////////////////////////////////////////////////////////////// -char *rowScreen(char *s) +/* Writing calendar notes. */ +int writecalendarnote(char *argv[]) { - char *p; - - // make Screen in one row - p = s; - while(*p) - { - if (*p == '\n') - *p = ' '; - p++; - } + GSM_CalendarNote CalendarNote; - return(s); -} + if (GSM_ReadVCalendarFile(argv[0], &CalendarNote, atoi(argv[1]))) { + fprintf(stdout, _("Failed to load vCalendar file.\n")); + return(-1); + } -void printtime(void) -{ + /* Error 22=Calendar full ;-) */ + if ((GSM->WriteCalendarNote(&CalendarNote)) == GE_NONE) + fprintf(stdout, _("Succesfully written!\n")); + else + fprintf(stdout, _("Failed to write calendar note!\n")); - struct mydate { - int Year; /* The complete year specification - e.g. 1999. Y2K :-) */ - int Month; /* January = 1 */ - int Day; - int Hour; - int Minute; - int Second; - int Timezone; /* The difference between local time and GMT */ - } Date; - - struct tm *now; - time_t nowh; - nowh=time(NULL); - now=localtime(&nowh); - - Date.Year = now->tm_year; - Date.Month = now->tm_mon+1; - Date.Day = now->tm_mday; - Date.Hour = now->tm_hour; - Date.Minute = now->tm_min; - Date.Second = now->tm_sec; - - /* I have 100 (for 2000) Year now :-) */ - if (Date.Year>99 && Date.Year<1900) { - Date.Year=Date.Year+1900; - } - - printf("%d:%d:%d:%d:%d:%d ",Date.Day,Date.Month,Date.Year,Date.Hour,Date.Minute,Date.Second); + GSM->Terminate(); + return 0; } -// like netmonitor(), but print in one row, 1, 2 or 3 screen, every ~0.3 s -/////////////////////////////////////////////////////////////////////////////// -int nm_collect(int argc, char *argv[]) +/* Calendar note deleting. */ +int deletecalendarnote(int argc, char *argv[]) { - int mode[MAX_NM_COLLECT]; - char Screen[NM_MAX_SCREEN_WIDTH]; - int i; - - for (i=0;i i ? (mode[i] = atoi(argv[i])): (mode[i] = 0); - } - - for (i=0;i 1) last_location = atoi(argv[1]); + + for (i = first_location; i <= last_location; i++) { - fbusinit(NULL); + CalendarNote.Location = i; - // end on CTRL-C - while (!bshutdown) - { - for (i=0;iNetMonitor(mode[i], Screen); - printf("%s::", rowScreen(Screen)); - } + if (GSM->DeleteCalendarNote(&CalendarNote) == GE_NONE) { + fprintf(stdout, _(" Calendar note deleted.\n")); + } else { + fprintf(stderr, _("The calendar note can not be deleted\n")); } - - printf("\n\n"); - usleep(150000); } GSM->Terminate(); @@ -7482,1433 +2119,967 @@ int nm_collect(int argc, char *argv[]) return 0; } -#ifdef DEBUG -int sniff(int argc, char *argv[]) -{ - /* base model comes from gnokiirc */ - strcat(model,"sniff"); - - if (argc>0) strcpy(Port,argv[0]); - - /* Initialise the GSM interface. */ - fbusinit(NULL); - - /* Loop here indefinitely - allows you to see messages from GSM code in - response to unknown messages etc. The loops ends after pressing the - Ctrl+C. */ - while (!bshutdown) { - sleep(1); - } - - GSM->Terminate(); - - return 0; - -} - -int decodefile(int argc, char *argv[]) +/* Setting the date and time. */ +int setdatetime(int argc, char *argv[]) { - FILE *infile; - unsigned char in_buffer[255]; - int nr_read = 0; - int i = 0; - - /* base model comes from gnokiirc */ - strcat(model,"decode"); + struct tm *now; + time_t nowh; + GSM_DateTime Date; - /* Initialise the GSM interface. */ - fbusinit(NULL); + nowh = time(NULL); + now = localtime(&nowh); - printf ("open InPutFile: %s\n", argv[0]); - if ( (infile = fopen( argv[0], "rb")) == NULL ) { - printf ("Failed to open InPutFile: %s\n", argv[0]); - exit (1); } + Date.Year = now->tm_year; + Date.Month = now->tm_mon+1; + Date.Day = now->tm_mday; + Date.Hour = now->tm_hour; + Date.Minute = now->tm_min; + Date.Second = now->tm_sec; - while ( (nr_read = fread(in_buffer, 1, 16, infile)) > 0 ) { - for (i=0; i < nr_read; i++) - Protocol->StateMachine(in_buffer[i]); - } - - return 0; -} + if (argc > 0) Date.Year = atoi (argv[0]); + if (argc > 1) Date.Month = atoi (argv[1]); + if (argc > 2) Date.Day = atoi (argv[2]); + if (argc > 3) Date.Hour = atoi (argv[3]); + if (argc > 4) Date.Minute = atoi (argv[4]); -#endif + if (Date.Year < 1900) { -int getringtone(int argc, char *argv[]) -{ - GSM_BinRingtone ringtone; - GSM_Error error; - GSM_Ringtone SMringtone; + /* Well, this thing is copyrighted in U.S. This technique is known as + Windowing and you can read something about it in LinuxWeekly News: + http://lwn.net/1999/features/Windowing.phtml. This thing is beeing + written in Czech republic and Poland where algorithms are not allowed + to be patented. */ - ringtone.location=1; - if (argc>1) ringtone.location=atoi(argv[1]); + if (Date.Year > 90) + Date.Year = Date.Year + 1900; + else + Date.Year = Date.Year + 2000; + } - /* Initialise the GSM interface. */ - fbusinit(NULL); + /* FIXME: Error checking should be here. */ + GSM->SetDateTime(&Date); - error=GSM_GetPhoneRingtone(&ringtone,&SMringtone); + GSM->Terminate(); - fprintf(stdout, _("Downloaded ringtone, location %i: "),ringtone.location); - - switch (error) { - case GE_NONE: - fprintf(stdout, _("get succeeded!\n")); - /* In 33.. we have normal "Smart Messaging" format */ - if (GetModelFeature (FN_RINGTONES)==F_RING_SM) { - fprintf(stdout, _("Name: %s (normal format)\n"),SMringtone.name); - GSM_SaveRingtoneFileOnConsole(argv[0], &SMringtone); - } else { - fprintf(stdout, _("Name: %s (binary format)\n"),ringtone.name); - GSM_SaveBinRingtoneFile(argv[0], &ringtone); - } - GSM->Terminate(); - return 0; - break; - case GE_INVALIDRINGLOCATION: - fprintf(stdout, _("invalid location %i!\n"),ringtone.location); - break; - case GE_UNKNOWNMODEL: - fprintf(stdout, _("mygnokii doesn't know format for this model!\n")); - break; - case GE_NOTIMPLEMENTED: - fprintf(stdout, _("not implemented for this model!\n")); - break; - default: - fprintf(stdout, _("not supported by this model!\n")); - break; - } - - GSM->Terminate(); - - return(-1); + return 0; } -int binringtoneconvert(int argc, char *argv[]) -{ - GSM_BinRingtone ringtone; - - int i,j,z; - bool isok; - int deflen=7,m,w; - bool pause; - - FILE *file; - -//{ "c", "c#", "d", "d#", "e", "f", "f#", "g", "g#", "a", "a#", "h" }; - int binary_notes[12] = - { 0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11 , 12}; - - if (GSM_ReadBinRingtoneFile(argv[0],&ringtone)!=GE_NONE) { - fprintf(stdout,_("Failed to read %s file!\n"),argv[0]); - return -1; - } - - file = fopen(argv[1], "wb"); - - if (!file) - return(GE_CANTOPENFILE); - - i=5; - while (true) { - if (ringtone.frame[i]==0) break; - fprintf(file,_("%c"),ringtone.frame[i]); - i++; - } - - fprintf(file,_(":d=32,o=5,b=300:")); - - i=i+5;j=0;z=0; - while (true) { - if (ringtone.frame[i]!=j) { - if (j!=0) { - isok=false; - if (j==64) { - j=255;//Pause - isok=true; - } - if (!isok && j>=114 && j<=125) { - j=14*3+binary_notes[j-114]; - isok=true; - } - if (!isok && j>=126 && j<=137) { - j=14*1+binary_notes[j-126]; - isok=true; - } - if (!isok && j>=138 && j<=149) { - j=14*2+binary_notes[j-138]; - isok=true; - } - if (!isok && j>=150 && j<=161) { - j=14*4+binary_notes[j-150]; - isok=true; - } - if (!isok) { - if (j!=10) { - fprintf(stdout,_("Unknown block in binary ringtone %i %i\n"),j,z); - } +/* In this mode we receive the date and time from mobile phone. */ +int getdatetime(void) { + GSM_Data data; + GSM_DateTime date_time; + GSM_Error error; + + if (GSM && GSM->GetDateTime && GSM->Terminate) { + error = GSM->GetDateTime(&date_time); + GSM->Terminate(); } else { - w=deflen; - for (m=0;m<6;m++) { - w=w*2; - if (w>z && (w/2)<=z) { - switch (m) { - case 1:fprintf(file,_("16"));break; - case 2:fprintf(file,_("8"));break; - case 3:fprintf(file,_("4"));break; - case 4:fprintf(file,_("2"));break; - case 5:fprintf(file,_("1"));break; - } - break; - } - } - if (z>w) fprintf(file,_("1")); - pause=false; - switch (GSM_GetNote(j)) { - case Note_C :fprintf(file,_("c"));break; - case Note_Cis:fprintf(file,_("c#"));break; - case Note_D :fprintf(file,_("d"));break; - case Note_Dis:fprintf(file,_("d#"));break; - case Note_E :fprintf(file,_("e"));break; - case Note_F :fprintf(file,_("f"));break; - case Note_Fis:fprintf(file,_("f#"));break; - case Note_G :fprintf(file,_("g"));break; - case Note_Gis:fprintf(file,_("g#"));break; - case Note_A :fprintf(file,_("a"));break; - case Note_Ais:fprintf(file,_("a#"));break; - case Note_H :fprintf(file,_("h"));break; - default :pause=true;fprintf(file,_("p"));break; //Pause ? - } - w=deflen*1.5; - for (m=0;m<6;m++) { - w=w*2; - if (w>z && (w/2)<=z) { - fprintf(file,_(".")); - break; - } - } - if ((j/14)!=1 && !pause) fprintf(file,_("%i"),j/14); - fprintf(file,_(",")); + GSM_DataClear(&data); + data.DateTime = &date_time; + + error = SM_Functions(GOP_GetDateTime, &data, &State); } - } - j=ringtone.frame[i]; - z=ringtone.frame[i+1]; - } else { - z=z+ringtone.frame[i+1]; - } - i=i+2; - if (i>=ringtone.length) break; - } - - fclose(file); - - return 0; - -} - -int renamesmsc(int argc, char *argv[]) -{ - GSM_MessageCenter MessageCenter; - - MessageCenter.No=atoi(argv[0]); - - /* Initialise the GSM interface. */ - fbusinit(NULL); - - if (GSM->GetSMSCenter(&MessageCenter) == GE_NONE) { - fprintf(stdout,_("SMSC number %i get OK\n"),MessageCenter.No); - } else { - GSM->Terminate(); - fprintf(stdout,_("Error getting SMSC number %i\n"),MessageCenter.No); - return 0; - } - - strncpy(MessageCenter.Name,argv[1],10); - - if (GSM->SetSMSCenter(&MessageCenter) == GE_NONE) { - fprintf(stdout,_("SMSC number %i set OK (renamed to \"%s\")\n"),MessageCenter.No,MessageCenter.Name); - } else { - GSM->Terminate(); - fprintf(stdout,_("Error setting SMSC number %i\n"),MessageCenter.No); - return 0; - } - - GSM->Terminate(); - - return 0; + + switch (error) { + case GE_NONE: + fprintf(stdout, _("Date: %4d/%02d/%02d\n"), date_time.Year, date_time.Month, date_time.Day); + fprintf(stdout, _("Time: %02d:%02d:%02d\n"), date_time.Hour, date_time.Minute, date_time.Second); + break; + case GE_NOTIMPLEMENTED: + fprintf(stdout, _("Function not implemented in %s !\n"), model); + break; + default: + fprintf(stdout, _("Internal error\n")); + break; + } + + return error; } -/* - * Returns number of sostituited characters. - * ... may be useful one day ?? - */ -int semicolon_pipe_substitution( GSM_PhonebookEntry *pentry, unsigned int direction ) - /* direction = 0 : after reading phone memory ( - * 1 : writing phone memory - */ +/* Setting the alarm. */ +int setalarm(char *argv[]) { - register int i; - register int count=0; - char charfrom, charto; + GSM_DateTime Date; - charfrom= (direction==0) ? ';' : '|'; - charto = (direction==0) ? '|' : ';'; + Date.Hour = atoi(argv[0]); + Date.Minute = atoi(argv[1]); - count+=str_substch(pentry->Name, charfrom, charto ); - count+=str_substch(pentry->Number, charfrom, charto ); + GSM->SetAlarm(1, &Date); - for( i = 0; i < pentry->SubEntriesCount; i++ ) - { - if( pentry->SubEntries[i].EntryType != GSM_Date ) - count+=str_substch(pentry->SubEntries[i].data.Number ,charfrom,charto); - } - - return( count ); -} + GSM->Terminate(); -int str_substch( char *str, const char toric, const char sost ) -{ - unsigned int ct; - int i_sost=0; - - for( ct = 0; ct < strlen(str); ct++ ) - if( str[ct] == (unsigned char) toric ) - { str[ct] = sost; i_sost++; } - - return( i_sost ); -} - -/* Allows to set simlock state. - With older phone (older 51xx, 61xx) can open them, with older - and newer should be able to close them */ -/* DO NOT TRY, IF DON'T WANT, WHAT YOU DO !!!!!!!!!! */ -int setsimlock() -{ - GSM_AllSimlocks siml; - - unsigned char closebuffer[20]= - { 0x00, 0x01, 0x82, 0x01, - 0x00, /* which simlock */ - 0x00, 0x00, - 0x00, 0x00, 0x00, /* lock 1 info */ - 0x00, 0x00, 0x00, 0x00, 0x00, /* lock 4 info */ - 0x00, 0x00, /* lock 2 info */ - 0x00, 0x00, /* lock 3 info */ - 0x00}; - unsigned char openbuffer[10]= { 0x00, 0x01, 0x81, 0x01, - 0x00, /* lock number */ - 0x10, 0x10, 0x10, 0x10, 0x10 }; - unsigned char openbuffer0[10]= {0x00, 0x01, 0x02, 0x03, 0x1f, 0x11, 0x01, 0x01, 0x10, 0x00 }; - - unsigned char info[120]; - int i,j; - - /* Initialise the code for the GSM interface. */ - fbusinit(NULL); - if (strstr(GSM_Info->FBUSModels, "3310") == NULL) - { - fprintf(stderr,("Not supported\n")); - GSM->Terminate(); - return -1; - } - N6110_EnableExtendedCommands(0x02); - /* Initial info */ - if (GSM->SimlockInfo(&siml)!=GE_NONE) { - fprintf(stderr,_("Error getting simlock info\n"));GSM->Terminate();return -1; - } - /* Opening all locks (we must check, if we can open them) */ - NULL_SendMessageSequence(50, &CurrentMagicError, 10, 0x40,openbuffer0); - openbuffer[4]=1;NULL_SendMessageSequence(50, &CurrentMagicError, 10, 0x40,openbuffer); - openbuffer[4]=2;NULL_SendMessageSequence(50, &CurrentMagicError, 10, 0x40,openbuffer); - openbuffer[4]=4;NULL_SendMessageSequence(50, &CurrentMagicError, 10, 0x40,openbuffer); - openbuffer[4]=8;NULL_SendMessageSequence(50, &CurrentMagicError, 10, 0x40,openbuffer); - if (GSM->SimlockInfo(&siml)!=GE_NONE) { - fprintf(stderr,_("Error getting simlock info\n"));GSM->Terminate();return -1; - } - for (i=0;i<4;i++) { - if (siml.simlocks[i].enabled) { - fprintf(stderr,_("Can not open simlock %i\n"),i+1);GSM->Terminate();return -1; - } - } - /* Making frame for closing simlocks */ - strcpy(info,"00101"); - j=0;i=7; - while (j!=strlen(info)) { - if (j+2<=strlen(info)) { - closebuffer[i]=((info[j] & 0x0f)<<4) | (info[j+1] & 0x0f);j=j+2; - } else { - closebuffer[i]=(info[j] & 0x0f) << 4;j++; - }i++; - } - strcpy(info,"0000");j=0;i=15; - while (j!=strlen(info)) { - if (j+2<=strlen(info)) { - closebuffer[i]=((info[j] & 0x0f)<<4) | (info[j+1] & 0x0f);j=j+2; - } else { - closebuffer[i]=(info[j] & 0x0f) << 4;j++; - }i++; - } - strcpy(info,"0000");j=0;i=17; - while (j!=strlen(info)) { - if (j+2<=strlen(info)) { - closebuffer[i]=((info[j] & 0x0f)<<4) | (info[j+1] & 0x0f);j=j+2; - } else { - closebuffer[i]=(info[j] & 0x0f) << 4;j++; - }i++; - } - strcpy(info,"0000000001");j=0;i=9; - while (j!=strlen(info)) { - if (j+2<=strlen(info)) { - if (j==0) { - closebuffer[i]=closebuffer[i] | (info[j] & 0x0f);j++; - } else { - closebuffer[i]=((info[j] & 0x0f)<<4) | (info[j+1] & 0x0f);j=j+2; - } - } else { - closebuffer[i]=(info[j] & 0x0f) << 4;j++; - }i++; - } - /* Closing simlock with given values */ - closebuffer[4]=1+2+4+8; - NULL_SendMessageSequence(50, &CurrentMagicError, 20, 0x40,closebuffer); - /* Opening all locks */ - NULL_SendMessageSequence(50, &CurrentMagicError, 10, 0x40,openbuffer0); - openbuffer[4]=1;NULL_SendMessageSequence(50, &CurrentMagicError, 10, 0x40,openbuffer); - openbuffer[4]=2;NULL_SendMessageSequence(50, &CurrentMagicError, 10, 0x40,openbuffer); - openbuffer[4]=4;NULL_SendMessageSequence(50, &CurrentMagicError, 10, 0x40,openbuffer); - openbuffer[4]=8;NULL_SendMessageSequence(50, &CurrentMagicError, 10, 0x40,openbuffer); - GSM->Reset(0x03); - GSM->Terminate(); - return 0; + return 0; } -int simlockinfo() +/* Getting the alarm. */ +int getalarm(void) { - GSM_AllSimlocks siml; - char s[7]; - - /* Initialise the code for the GSM interface. */ - fbusinit(NULL); - - if (GSM->SimlockInfo(&siml)!=GE_NONE) fprintf(stderr,_("Error\n")); - - fprintf(stdout,_("MCC + MNC : %s ("),siml.simlocks[0].data); - if (siml.simlocks[0].enabled) fprintf(stdout,_("CLOSED")); - else fprintf(stdout,_("opened")); - if (siml.simlocks[0].factory) fprintf(stdout,_(") (factory")); - else fprintf(stdout,_(") (user")); - fprintf(stdout,_(") (counter %i"),siml.simlocks[0].counter); - - s[0]=siml.simlocks[0].data[0]; - s[1]=siml.simlocks[0].data[1]; - s[2]=siml.simlocks[0].data[2]; - s[3]=' '; - s[4]=siml.simlocks[0].data[3]; - s[5]=siml.simlocks[0].data[4]; - s[6]=0; - - if (strcmp(GSM_GetNetworkName(s),"unknown")) - fprintf(stdout,_(") (network \"%s\""),GSM_GetNetworkName(s)); - - fprintf(stdout,_(")\n")); - - fprintf(stdout,_("GID1 : %s ("),siml.simlocks[1].data); - if (siml.simlocks[1].enabled) fprintf(stdout,_("CLOSED")); - else fprintf(stdout,_("opened")); - if (siml.simlocks[1].factory) fprintf(stdout,_(") (factory")); - else fprintf(stdout,_(") (user")); - fprintf(stdout,_(") (counter %i"),siml.simlocks[1].counter); - fprintf(stdout,_(")\n")); - - fprintf(stdout,_("GID2 : %s ("),siml.simlocks[2].data); - if (siml.simlocks[2].enabled) fprintf(stdout,_("CLOSED")); - else fprintf(stdout,_("opened")); - if (siml.simlocks[2].factory) fprintf(stdout,_(") (factory")); - else fprintf(stdout,_(") (user")); - fprintf(stdout,_(") (counter %i"),siml.simlocks[2].counter); - fprintf(stdout,_(")\n")); - - fprintf(stdout,_("MSIN : %s ("),siml.simlocks[3].data); - if (siml.simlocks[3].enabled) fprintf(stdout,_("CLOSED")); - else fprintf(stdout,_("opened")); - if (siml.simlocks[3].factory) fprintf(stdout,_(") (factory")); - else fprintf(stdout,_(") (user")); - fprintf(stdout,_(") (counter %i"),siml.simlocks[3].counter); - fprintf(stdout,_(")\n")); - - GSM->Terminate(); - - return 0; + GSM_Error error; + GSM_Data data; + GSM_DateTime date_time; + + if (GSM && GSM->GetAlarm && GSM->Terminate) { + error = GSM->GetAlarm(0, &date_time); + GSM->Terminate(); + } else { + GSM_DataClear(&data); + data.DateTime = &date_time; + + error = SM_Functions(GOP_GetAlarm, &data, &State); + } + + switch (error) { + case GE_NONE: + fprintf(stdout, _("Alarm: %s\n"), (date_time.AlarmEnabled==0)?"off":"on"); + fprintf(stdout, _("Time: %02d:%02d\n"), date_time.Hour, date_time.Minute); + break; + case GE_NOTIMPLEMENTED: + fprintf(stdout, _("Function not implemented in %s !\n"), model); + break; + default: + fprintf(stdout, _("Internal error\n")); + break; + } + + return error; } -/* Getting EEPROM from older phones */ -/* Tested with N5110 5.07, 6150 5.22 */ -int geteeprom() -{ - int i=0x40; - - unsigned char buffer[1000]={ 0x00, 0x01, 0xd4, 0x02, 0x00, 0xa0, - 0x00, 0x00, /* location Lo and Hi */ - 0x10 }; /* how many bytes */ +/* In monitor mode we don't do much, we just initialise the fbus code. + Note that the fbus code no longer has an internal monitor mode switch, + instead compile with DEBUG enabled to get all the gumpf. */ +int monitormode(void) +{ + float rflevel = -1, batterylevel = -1; +// GSM_PowerSource powersource = -1; + GSM_RFUnits rf_units = GRF_Arbitrary; + GSM_BatteryUnits batt_units = GBU_Arbitrary; + GSM_Statemachine *sm = &State; + GSM_Data data; + +// GSM_NetworkInfo NetworkInfo; +// GSM_CBMessage CBMessage; + + GSM_MemoryStatus SIMMemoryStatus = {GMT_SM, 0, 0}; + GSM_MemoryStatus PhoneMemoryStatus = {GMT_ME, 0, 0}; + GSM_MemoryStatus DC_MemoryStatus = {GMT_DC, 0, 0}; + GSM_MemoryStatus EN_MemoryStatus = {GMT_EN, 0, 0}; + GSM_MemoryStatus FD_MemoryStatus = {GMT_FD, 0, 0}; + GSM_MemoryStatus LD_MemoryStatus = {GMT_LD, 0, 0}; + GSM_MemoryStatus MC_MemoryStatus = {GMT_MC, 0, 0}; + GSM_MemoryStatus ON_MemoryStatus = {GMT_ON, 0, 0}; + GSM_MemoryStatus RC_MemoryStatus = {GMT_RC, 0, 0}; + +// GSM_SMSStatus SMSStatus = {0, 0}; + +// char Number[20]; + + GSM_DataClear(&data); - strcpy(Connection,"mbus"); - fprintf(stderr,_("Switching connection type to MBUS\n")); + /* We do not want to monitor serial line forever - press Ctrl+C to stop the + monitoring mode. */ + signal(SIGINT, interrupted); - strcpy(model,"5110"); - - /* Initialise the code for the GSM interface. */ - fbusinit(NULL); - - if (strstr(GSM_Info->FBUSModels, "3310") == NULL) - { - fprintf(stderr,("Not supported\n")); - GSM->Terminate(); - return -1; - } - - for (i=0;i<64;i++) { - fprintf(stdout,_("%c"),0xff); - } - - while (i<300000) { - buffer[6] = i/256; - buffer[7] = i%256; - - if ((i/256)!=((i-1)/256)) fprintf(stderr,_(".")); - - if (NULL_SendMessageSequence(50, &CurrentMagicError, 9, 0x40,buffer)!=GE_NONE) break; + fprintf (stderr, _("Entering monitor mode...\n")); - i=i+0x10; - } + //sleep(1); + //GSM->EnableCellBroadcast(); - fprintf(stderr,_("\n")); - - GSM->Terminate(); + /* Loop here indefinitely - allows you to see messages from GSM code in + response to unknown messages etc. The loops ends after pressing the + Ctrl+C. */ + data.RFUnits=&rf_units; + data.RFLevel=&rflevel; + data.BatteryUnits=&batt_units; + data.BatteryLevel=&batterylevel; - return 0; -} + while (!bshutdown) { + if (SM_Functions(GOP_GetRFLevel,&data,sm) == GE_NONE) + fprintf(stdout, _("RFLevel: %d\n"), (int)rflevel); -int getsmsfolders() -{ - GSM_SMSFolders folders; - GSM_Error error; + if (SM_Functions(GOP_GetBatteryLevel,&data,sm) == GE_NONE) + fprintf(stdout, _("Battery: %d\n"), (int)batterylevel); - int i; - - /* Initialise the code for the GSM interface. */ - fbusinit(NULL); +// if (GSM->GetPowerSource(&powersource) == GE_NONE) +// fprintf(stdout, _("Power Source: %s\n"), (powersource==GPS_ACDC)?_("AC/DC"):_("battery")); - folders.number = 0; + data.MemoryStatus=&SIMMemoryStatus; + if (SM_Functions(GOP_GetMemoryStatus,&data,sm) == GE_NONE) + fprintf(stdout, _("SIM: Used %d, Free %d\n"), SIMMemoryStatus.Used, SIMMemoryStatus.Free); - error=GSM->GetSMSFolders(&folders); - - GSM->Terminate(); + data.MemoryStatus=&PhoneMemoryStatus; + if (SM_Functions(GOP_GetMemoryStatus,&data,sm) == GE_NONE) + fprintf(stdout, _("Phone: Used %d, Free %d\n"), PhoneMemoryStatus.Used, PhoneMemoryStatus.Free); - if (error!=GE_NONE && !folders.number) { - fprintf(stdout,_("Error!\n")); - return -1; - } - - for (i=0;iResetPhoneSettings(); + data.MemoryStatus=&FD_MemoryStatus; + if (SM_Functions(GOP_GetMemoryStatus,&data,sm) == GE_NONE) + fprintf(stdout, _("FD: Used %d, Free %d\n"), FD_MemoryStatus.Used, FD_MemoryStatus.Free); - GSM->Reset(0x03); - - GSM->Terminate(); + data.MemoryStatus=&LD_MemoryStatus; + if (SM_Functions(GOP_GetMemoryStatus,&data,sm) == GE_NONE) + fprintf(stdout, _("LD: Used %d, Free %d\n"), LD_MemoryStatus.Used, LD_MemoryStatus.Free); - return 0; -} + data.MemoryStatus=&MC_MemoryStatus; + if (SM_Functions(GOP_GetMemoryStatus,&data,sm) == GE_NONE) + fprintf(stdout, _("MC: Used %d, Free %d\n"), MC_MemoryStatus.Used, MC_MemoryStatus.Free); -/* Checked on 3310 4.02 and doesn't work. - Possible reasons: SMSC has problems (possible), bug in phone firmware - (very possible) or here in code. - I quess, that the second is the most possible - 3310 treat only 3 SMS - as linked (the most often profile needs 4 - 2 and few bytes in 3'th - for screen saver, few bytes for profile name and 1 or 2 sms for ringtone). - When send separate ringtone (see --sendringtone with --profilestyle) - and screen saver (--sendlogo screensaver...), it's received OK. - It's for checking in higher firmware. */ -int sendprofile(int argc, char *argv[]) -{ - GSM_Ringtone ringtone; - GSM_Bitmap bitmap; - GSM_MultiSMSMessage MultiSMS; + data.MemoryStatus=&ON_MemoryStatus; + if (SM_Functions(GOP_GetMemoryStatus,&data,sm) == GE_NONE) + fprintf(stdout, _("ON: Used %d, Free %d\n"), ON_MemoryStatus.Used, ON_MemoryStatus.Free); - int current=0,i,j; + data.MemoryStatus=&RC_MemoryStatus; + if (SM_Functions(GOP_GetMemoryStatus,&data,sm) == GE_NONE) + fprintf(stdout, _("RC: Used %d, Free %d\n"), RC_MemoryStatus.Used, RC_MemoryStatus.Free); - u8 MessageBuffer[140*4]; - u16 MessageLength=0; - - char profilename[10+1]; - - if (GSM_ReadRingtoneFileOnConsole(argv[2], &ringtone)!=GE_NONE) return(-1); +// if (GSM->GetSMSStatus(&SMSStatus) == GE_NONE) +// fprintf(stdout, _("SMS Messages: UnRead %d, Number %d\n"), SMSStatus.UnRead, SMSStatus.Number); - ringtone.allnotesscale=false; - for (i=0;iGetIncomingCallNr(Number) == GE_NONE) +// fprintf(stdout, _("Incoming call: %s\n"), Number); - /* The fourth argument is the bitmap file. */ - if (GSM_ReadBitmapFileOnConsole(argv[3], &bitmap)!=GE_NONE) return -1; +// if (GSM->GetNetworkInfo(&NetworkInfo) == GE_NONE) +// fprintf(stdout, _("Network: %s (%s), LAC: %s, CellID: %s\n"), GSM_GetNetworkName (NetworkInfo.NetworkCode), GSM_GetCountryName(NetworkInfo.NetworkCode), NetworkInfo.LAC, NetworkInfo.CellID); - GSM_ResizeBitmap(&bitmap,GSM_PictureImage); +// if (GSM->ReadCellBroadcast(&CBMessage) == GE_NONE) +// fprintf(stdout, _("Cell broadcast received on channel %d: %s\n"), CBMessage.Channel, CBMessage.Message); + + sleep(1); + } - strncpy(profilename,argv[1],10); + fprintf (stderr, _("Leaving monitor mode...\n")); - MessageBuffer[MessageLength++]=0x30; //SM version. Here 3.0 + //GSM->Terminate(); - MessageBuffer[MessageLength++]=SM30_PROFILENAME; //ID for profile name - MessageBuffer[MessageLength++]=0x00; //length hi - MessageBuffer[MessageLength++]=strlen(profilename);//length lo - - EncodeUnicode (MessageBuffer+MessageLength,profilename ,strlen(profilename)); - MessageLength=MessageLength+2*strlen(profilename); - - MessageBuffer[MessageLength++]=SM30_RINGTONE; //ID for ringtone - i=MessageLength; - MessageBuffer[MessageLength++]=0x01; //length hi - MessageBuffer[MessageLength++]=0x00; //length lo - - j=SM30_MAX_RINGTONE_FRAME_LENGTH; - current=GSM_PackRingtone(&ringtone, MessageBuffer+MessageLength, &j); - MessageLength=MessageLength+j; - - if (current!=ringtone.NrNotes) { - if (current>FB61_MAX_RINGTONE_NOTES) { - fprintf(stderr,_("Warning: due to phone limitation")); - } else { - fprintf(stderr,_("Warning: ringtone was too long to be saved into SMS,")); - } - fprintf(stderr, _(" only %i first notes were packed (%i cut)\n"),current,ringtone.NrNotes-current); - } - - MessageBuffer[i]=(j)/256; - MessageBuffer[i+1]=(j)%256; + return 0; +} - MessageBuffer[MessageLength++]=SM30_SCREENSAVER; //ID for OTA screen saver - MessageBuffer[MessageLength++]=0x01; //length hi - MessageBuffer[MessageLength++]=0x00; //length lo - MessageBuffer[MessageLength++]=0x00; - MessageBuffer[MessageLength++]=bitmap.width; - MessageBuffer[MessageLength++]=bitmap.height; - MessageBuffer[MessageLength++]=0x01; - memcpy(MessageBuffer+MessageLength,bitmap.bitmap,bitmap.size); - MessageLength=MessageLength+bitmap.size; +#define ESC "\e" - GSM_MakeMultiPartSMS2(&MultiSMS,MessageBuffer,MessageLength, GSM_ProfileUDH, GSM_Coding_Default); +static GSM_Error PrettyOutputFn(char *Display, char *Indicators) +{ + if (Display) + printf(ESC "[10;0H Display is:\n%s\n", Display); + if (Indicators) + printf(ESC "[9;0H Indicators: %s \n", Indicators); + printf(ESC "[1;1H"); + return GE_NONE; +} - optind = 4; +#if 0 +// Uncomment it if used +static GSM_Error OutputFn(char *Display, char *Indicators) +{ + if (Display) + printf("New display is:\n%s\n", Display); + if (Indicators) + printf("Indicators: %s\n", Indicators); + return GE_NONE; +} +#endif - /* Initialise the GSM interface. */ - fbusinit(NULL); +void console_raw(void) +{ +#ifndef WIN32 + struct termios it; - for (i=0;i 0) { + fprintf(stderr, "handling keys (%d).\n", strlen(buf)); + if (GSM->HandleString(buf) != GE_NONE) + fprintf(stdout, _("Key press simulation failed.\n")); + memset(buf, 0, 102); + } + SM_Loop(sm, 1); + } + fprintf (stderr, "Shutting down\n"); - settings.location=atoi(argv[0]); - - /* Initialise the GSM interface. */ - fbusinit(NULL); + fprintf (stderr, _("Leaving display monitor mode...\n")); + data.OutputFn = NULL; - error=GSM->GetWAPSettings(&settings); - - switch (error) { - case GE_NONE: - fprintf(stdout,_("%s."),argv[0]); - if (!(strcmp(settings.title,""))) fprintf(stdout,_("Set %s\n"),argv[0]); - else fprintf(stdout,_("%s\n"),settings.title); - fprintf(stdout,_("Homepage: %s\n"),settings.homepage); - if (settings.iscontinuous) fprintf(stdout,_("Connection type: continuous\n")); - else fprintf(stdout,_("Connection type: temporary\n")); - if (settings.issecurity) fprintf(stdout,_("Connection security: on\n")); - else fprintf(stdout,_("Connection security: off\n")); - switch (settings.bearer) { - case WAPSETTINGS_BEARER_SMS: - fprintf(stdout,_("Bearer: SMS\n")); - fprintf(stdout,_("Server number: %s\n"),settings.server); - fprintf(stdout,_("Service number: %s\n"),settings.service); - break; - case WAPSETTINGS_BEARER_DATA: - fprintf(stdout,_("Bearer: Data (CSD)\n")); - fprintf(stdout,_("Dial-up number: %s\n"),settings.dialup); - fprintf(stdout,_("IP address: %s\n"),settings.ipaddress); - if (settings.isnormalauthentication) fprintf(stdout,_("Authentication type: normal\n")); - else fprintf(stdout,_("Authentication type: secure\n")); - if (settings.isISDNcall) fprintf(stdout,_("Data call type: ISDN\n")); - else fprintf(stdout,_("Data call type: analogue\n")); - if (settings.isspeed14400) fprintf(stdout,_("Data call speed: 14400\n")); - else fprintf(stdout,_("Data call speed: 9600\n")); - fprintf(stdout,_("User name: %s\n"),settings.user); - fprintf(stdout,_("Password: %s\n"),settings.password); - break; - case WAPSETTINGS_BEARER_USSD: - fprintf(stdout,_("Bearer: USSD\n")); - fprintf(stdout,_("Service code: %s\n"),settings.code); - if (settings.isIP) fprintf(stdout,_("Address type: IP address\nIPaddress: %s\n"),settings.service); - else fprintf(stdout,_("Address type: service number\nService number: %s\n"),settings.service); - break; - } - break; - default: - fprintf(stderr,_("%s\n"),print_error(error)); - } - - GSM->Terminate(); - - return 0; + error = SM_Functions(GOP_DisplayOutput, &data, sm); + if (error != GE_NONE) + fprintf (stderr, _("Error!\n")); + } else + fprintf (stderr, _("Error!\n")); + GSM->Terminate(); + return 0; } -/* Not full done now */ -int savewapsettings(int argc, char *argv[]) +/* Reads profile from phone and displays its' settings */ +int getprofile(int argc, char *argv[]) { - GSM_WAPSettings settings; - GSM_MultiSMSMessage MultiSMS; - GSM_Error error; - int w; - - settings.location=atoi(argv[0]); + int max_profiles; + int start, stop, i; + GSM_Profile profile; + GSM_Error error; - /* Initialise the GSM interface. */ - fbusinit(NULL); + /* Hopefully is 64 larger as FB38_MAX* / FB61_MAX* */ + char model[64]; - error=GSM->GetWAPSettings(&settings); -// strcpy(settings.homepage,"http://OtherSites/"); -// strcpy(settings.title,"Orange"); + profile.Number = 0; + error = GSM->GetProfile(&profile); - error=GE_NONE; + if (error == GE_NONE) { - switch (error) { - case GE_NONE: - /* Put settings into SMS structure */ - GSM_SaveWAPSettingsToSMS(&MultiSMS,&settings); + while (GSM->GetModel(model) != GE_NONE) + sleep(1); + + max_profiles = 7; /* This is correct for 6110 (at least my). How do we get + the number of profiles? */ - for (w=0;w 0) { + profile.Number = atoi(argv[0]) - 1; + start = profile.Number; + stop = start + 1; - break; - default: - fprintf(stderr,_("%s\n"),print_error(error)); - } + if (profile.Number < 0) { + fprintf(stderr, _("Profile number must be value from 1 to %d!\n"), max_profiles); + GSM->Terminate(); + return -1; + } - GSM->Terminate(); + if (profile.Number >= max_profiles) { + fprintf(stderr, _("This phone supports only %d profiles!\n"), max_profiles); + GSM->Terminate(); + return -1; + } + } else { + start = 0; + stop = max_profiles; + } - return 0; -} + i = start; + while (i < stop) { + profile.Number = i; -int sendwapsettings(int argc, char *argv[]) -{ - GSM_WAPSettings settings; - GSM_MultiSMSMessage MultiSMS; - GSM_Error error; - int w; + if (profile.Number != 0) + GSM->GetProfile(&profile); - settings.location=atoi(argv[0]); - - /* Initialise the GSM interface. */ - fbusinit(NULL); + fprintf(stdout, "%d. \"%s\"\n", profile.Number + 1, profile.Name); + if (profile.DefaultName == -1) fprintf(stdout, _(" (name defined)\n")); - error=GSM->GetWAPSettings(&settings); -// strcpy(settings.homepage,"http://OtherSites/"); -// strcpy(settings.title,"Orange"); + fprintf(stdout, _("Incoming call alert: %s\n"), GetProfileCallAlertString(profile.CallAlert)); - error=GE_NONE; - - switch (error) { - case GE_NONE: - /* Put settings into SMS structure */ - GSM_SaveWAPSettingsToSMS(&MultiSMS,&settings); + /* For different phones different ringtones names */ - for (w=0;wTerminate(); + fprintf(stdout, _("Warning and game tones: %s\n"), GetProfileWarningToneString(profile.WarningTone)); - return 0; -} + /* FIXME: Light settings is only used for Car */ + if (profile.Number == (max_profiles - 2)) fprintf(stdout, _("Lights: %s\n"), profile.Lights ? _("On") : _("Automatic")); -int getwapbookmark(int argc, char *argv[]) -{ - GSM_WAPBookmark bookmark; - GSM_Error error; + fprintf(stdout, _("Vibration: %s\n"), GetProfileVibrationString(profile.Vibration)); - bookmark.location=atoi(argv[0]); - - /* Initialise the GSM interface. */ - fbusinit(NULL); + /* FIXME: it will be nice to add here reading caller group name. */ + if (max_profiles != 3) fprintf(stdout, _("Caller groups: 0x%02x\n"), profile.CallerGroups); - error=GSM->GetWAPBookmark(&bookmark); - - switch (error) { - case GE_NONE: - if (bookmark.address[0]==0) { - fprintf(stdout,_("Empty bookmark location\n")); - } else { - fprintf(stdout,_("Address: \"%s\"\n"),bookmark.address); - if (bookmark.title[0]==0) - fprintf(stdout,_("Title: \"%s\"\n"),bookmark.address); - else - fprintf(stdout,_("Title: \"%s\"\n"),bookmark.title); - } - break; - default: - fprintf(stderr,_("%s\n"),print_error(error)); - } - - GSM->Terminate(); - - return 0; + /* FIXME: Automatic answer is only used for Car and Headset. */ + if (profile.Number >= (max_profiles - 2)) fprintf(stdout, _("Automatic answer: %s\n"), profile.AutomaticAnswer ? _("On") : _("Off")); + + fprintf(stdout, "\n"); + + i++; + } + } else { + if (error == GE_NOTIMPLEMENTED) { + fprintf(stderr, _("Function not implemented in %s model!\n"), model); + GSM->Terminate(); + return -1; + } else { + fprintf(stderr, _("Unspecified error\n")); + GSM->Terminate(); + return -1; + } + } + GSM->Terminate(); + return 0; } -int setwapbookmark(int argc, char *argv[]) +/* Get requested range of memory storage entries and output to stdout in + easy-to-parse format */ +int getmemory(int argc, char *argv[]) { - GSM_WAPBookmark bookmark; - GSM_Error error; - - if (argc == 3) /* if location given, use it */ - bookmark.location=atoi(argv[2]); - else /* else use first empty location */ - bookmark.location=0xffff; + GSM_PhonebookEntry entry; + int count; + GSM_Error error; + char *memory_type_string; + int start_entry; + int end_entry; + GSM_Statemachine *sm = &State; + + /* Handle command line args that set type, start and end locations. */ + memory_type_string = argv[0]; + entry.MemoryType = StrToMemoryType(memory_type_string); + if (entry.MemoryType == GMT_XX) { + fprintf(stderr, _("Unknown memory type %s (use ME, SM, ...)!\n"), argv[0]); + return (-1); + } - strcpy(bookmark.title, argv[0]); - strcpy(bookmark.address, argv[1]); + start_entry = atoi (argv[1]); + if (argc > 2) end_entry = atoi (argv[2]); + else end_entry = start_entry; - /* Initialise the GSM interface. */ - fbusinit(NULL); + /* Now retrieve the requested entries. */ + for (count = start_entry; count <= end_entry; count ++) { - error=GSM->SetWAPBookmark(&bookmark); - - switch (error) { - case GE_NONE: - fprintf(stdout,_("No errors\n")); - break; - default: - fprintf(stderr,_("%s\n"),print_error(error)); - } + entry.Location = count; - GSM->Terminate(); + data.PhonebookEntry=&entry; + error=SM_Functions(GOP_ReadPhonebook,&data,sm); - return 0; + if (error == GE_NONE) { + fprintf(stdout, "%s;%s;%s;%d;%d\n", entry.Name, entry.Number, memory_type_string, entry.Location, entry.Group); + if (entry.MemoryType == GMT_MC || entry.MemoryType == GMT_DC || entry.MemoryType == GMT_RC) + fprintf(stdout, "%02u.%02u.%04u %02u:%02u:%02u\n", entry.Date.Day, entry.Date.Month, entry.Date.Year, entry.Date.Hour, entry.Date.Minute, entry.Date.Second); + } + else { + if (error == GE_NOTIMPLEMENTED) { + fprintf(stderr, _("Function not implemented in %s model!\n"), model); + return -1; + } + else if (error == GE_INVALIDMEMORYTYPE) { + fprintf(stderr, _("Memory type %s not supported!\n"), memory_type_string); + return -1; + } + fprintf(stdout, _("%s|%d|Bad location or other error!(%d)\n"), memory_type_string, count, error); + } + } + return 0; } -int savewapbookmark(int argc, char *argv[]) +/* Read data from stdin, parse and write to phone. The parsing is relatively + crude and doesn't allow for much variation from the stipulated format. */ +/* FIXME: I guess there's *very* similar code in xgnokii */ +int writephonebook(int argc, char *args[]) { - GSM_WAPBookmark bookmark; - GSM_MultiSMSMessage MultiSMS; - GSM_Error error; - int w; + GSM_PhonebookEntry entry; + GSM_Error error; + char *memory_type_string; + int line_count=0; + int subentry; - bookmark.location=atoi(argv[0]); - - /* Initialise the GSM interface. */ - fbusinit(NULL); + char *Line, OLine[100], BackLine[100]; + char *ptr; + + /* Check argument */ + if (argc && (strcmp("-i", args[0]))) + usage(); - error=GSM->GetWAPBookmark(&bookmark); + Line = OLine; -// strcpy(bookmark.title,"tytulagagagagagagagagagagagagagagagagagagagagagend"); -// strcpy(bookmark.address,"http://jajajajajajajajajajajajagagagagagagagagagagagagagagagagagagagagagpapapapapapapapapapapapapapapapapapapapapapapapapapapapapapapapap¥papapapapapapapapagagagagagagagagagagagagagagagagagagagagagagagagagadadadadadadadajdjdjdjdjdjdjdjdjdjdjdjdjdjdjdjdstp"); - error=GE_NONE; + /* Go through data from stdin. */ + while (GetLine(stdin, Line, 99)) { + strcpy(BackLine, Line); + line_count++; - switch (error) { - case GE_NONE: + ptr = strtok(Line, ";"); + if (ptr) strcpy(entry.Name, ptr); + else entry.Name[0] = 0; - if (bookmark.address[0]==0) { - fprintf(stdout,_("Empty bookmark location\n")); - GSM->Terminate(); - return 1; - } + ptr = strtok(NULL, ";"); + if (ptr) strcpy(entry.Number, ptr); + else entry.Number[0] = 0; - /* Put bookmark into SMS structure */ - GSM_SaveWAPBookmarkToSMS(&MultiSMS,&bookmark); + ptr = strtok(NULL, ";"); - for (w=0;wTerminate(); + ptr = strtok(NULL, ";"); + if (ptr) entry.Group = atoi(ptr); + else entry.Group = 0; - return 0; + if (!ptr) { + fprintf(stderr, _("Format problem on line %d [%s]\n"), line_count, BackLine); + continue; + } -} + for (subentry = 0; ; subentry++) { + ptr = strtok(NULL, ";"); -int sendwapbookmark(int argc, char *argv[]) -{ - GSM_WAPBookmark bookmark; - GSM_MultiSMSMessage MultiSMS; - GSM_Error error; - int w; + if (ptr && *ptr != 0) + entry.SubEntries[subentry].EntryType = atoi(ptr); + else + break; - bookmark.location=atoi(argv[0]); - - /* Initialise the GSM interface. */ - fbusinit(NULL); + ptr = strtok(NULL, ";"); + if (ptr) + entry.SubEntries[subentry].NumberType=atoi(ptr); - error=GSM->GetWAPBookmark(&bookmark); - - switch (error) { - case GE_NONE: + /* Phone Numbers need to have a number type. */ + if (!ptr && entry.SubEntries[subentry].EntryType == GSM_Number) { + fprintf(stderr, _("Missing phone number type on line %d" + " entry %d [%s]\n"), line_count, subentry, BackLine); + subentry--; + break; + } - if (bookmark.address[0]==0) { - fprintf(stdout,_("Empty bookmark location\n")); - GSM->Terminate(); - return 1; - } + ptr = strtok(NULL, ";"); + if (ptr) + entry.SubEntries[subentry].BlockNumber=atoi(ptr); - /* Put bookmark into SMS structure */ - GSM_SaveWAPBookmarkToSMS(&MultiSMS,&bookmark); + ptr = strtok(NULL, ";"); - for (w=0;wTerminate(); + Line = OLine; - return 0; + if (argc) { + GSM_PhonebookEntry aux; -} + aux.Location = entry.Location; + error = GSM->GetMemoryLocation(&aux); + + if (error == GE_NONE) { + if (!aux.Empty) { + int confirm = -1; + char ans[8]; + + fprintf(stdout, _("Location busy. ")); + while (confirm < 0) { + fprintf(stdout, _("Overwrite? (yes/no) ")); + GetLine(stdin, ans, 7); + if (!strcmp(ans, _("yes"))) confirm = 1; + else if (!strcmp(ans, _("no"))) confirm = 0; + } + if (!confirm) continue; + } + } else { + fprintf(stderr, _("Unknown error (%d)\n"), error); + GSM->Terminate(); + return 0; + } + } -int savecalendarnote(int argc, char *argv[]) -{ - GSM_MultiSMSMessage MultiSMS; - int w; - GSM_CalendarNote CalendarNote; - int number; + /* Do write and report success/failure. */ + error = GSM->WritePhonebookLocation(&entry); - number=atoi(argv[1]); - - if (number<1) { - fprintf(stdout, _("Number of calendar note must be 1 or higher\n")); - return -1; - } - - switch ( GSM_ReadVCalendarFile(argv[0], &CalendarNote, &number) ) { - case GE_NONE: - break; - case GE_CANTOPENFILE: - fprintf(stdout, _("Failed to open vCalendar file \"%s\"\n"),argv[0]); - return -1; - case GE_TOOSHORT: - fprintf(stdout, _("Number of given calendar note is too high (max=%i)\n"),number); - return(-1); - default: - fprintf(stdout, _("Failed to parse vCalendar file \"%s\"\n"),argv[0]); - return -1; - } - - fbusinit(NULL); - - /* Put note into SMS structure */ - GSM_SaveCalendarNoteToSMS(&MultiSMS,&CalendarNote); - - for (w=0;wTerminate(); + return 0; } -/* Example function for continuous receiving SMS */ -/* When phone receives SMS, it's read by mygnokii, ID number is created - and SMS is saved to file. After it it's deleted - Checking many errors is also done */ -int receivesms(int argc, char *argv[]) +/* Getting speed dials. */ +int getspeeddial(char *Number) { - char Dir[500]; - - GSM_SMSStatus SMSStatus = {0, 0}; - GSM_SMSMessage SMS; - int read, location, number; - unsigned char name[50],filename[400]; - char nowdate[12]="", nowtime[12]=""; - FILE *file; - FILE *logfile; - struct CFG_Header *cfg_info; - - /* We do not want to monitor serial line forever - press Ctrl+C to stop the - monitoring mode. */ - - signal(SIGINT, interrupted); - - fprintf (stderr, _("Entering monitor mode (press CTRL+C to break)...\n")); - - cfg_info=CFG_FindGnokiirc(); - - strcpy(Dir,""); - if (cfg_info!=NULL) { - if (CFG_Get(cfg_info, "receivesms", "path")) { - strcpy(Dir,CFG_Get(cfg_info, "receivesms", "path")); - } - } - - fprintf(stderr,_("Path for sms files is \"%s\"\n"),Dir); - - fprintf (stderr, _("Initialising GSM interface...")); - - /* Initialise the code for the GSM interface. */ - fbusinit(NULL); - - fprintf (stderr, _("done\n")); - - sleep(1); - - /* Loop here indefinitely - allows you to see messages from GSM code in - response to unknown messages etc. The loops ends after pressing the - Ctrl+C. */ - while (!bshutdown) { - if (GSM->GetSMSStatus(&SMSStatus) == GE_NONE) { - if (SMSStatus.Number!=0) { - - GetMachineDateTime(nowdate, nowtime ); - logfile = fopen("log", "a"); - if (logfile) { - fprintf(logfile, _("%s %s SMS Messages: UnRead %d, Number %d\n"), - nowdate, nowtime, SMSStatus.UnRead, SMSStatus.Number); - fclose(logfile); - } - - read=0; - location=1; - - while (!bshutdown) { - - SMS.Location=location; - if (GSM->GetSMSMessage(&SMS)==GE_NONE) { - if (SMS.folder==0 || SMS.folder==0x08) { //GST_7110_INBOX - - GetMachineDateTime(nowdate, nowtime ); - logfile = fopen("log", "a"); - if (logfile) { - fprintf(logfile,_("%s %s SMS on location %i\n"), - nowdate,nowtime,SMS.MessageNumber); - fclose(logfile); - } - - number= 16*(SMS.MessageText[2] >> 4)+ (SMS.MessageText[2] & 0x0f); - number=number+ 256*16*(SMS.MessageText[1] >> 4)+ 256*(SMS.MessageText[1] & 0x0f); - number=number+65536*16*(SMS.MessageText[0] >> 4)+65536*(SMS.MessageText[0] & 0x0f); - - sprintf( name, "%07i_%02d%02d%02d_%02d%02d%02d.sms", number, - SMS.Time.Year, SMS.Time.Month, SMS.Time.Day, - SMS.Time.Hour, SMS.Time.Minute, SMS.Time.Second); - - strcpy(filename,Dir); - strcat(filename,name); - - logfile = fopen("log", "a"); - if (logfile) { - fprintf(logfile,_("%s %s Name is \"%s\"\n"),nowdate,nowtime,filename); - fclose(logfile); - } - - file = fopen(filename, "rb"); - if (!file) { - file = fopen(filename, "wb"); - if (!file) { - GetMachineDateTime(nowdate, nowtime ); - fprintf(stderr,_("%s %s ERROR: opening file \"%s\" failed !\n"),nowdate,nowtime,filename); - logfile = fopen("log", "a"); - if (logfile) { - fprintf(logfile,_("%s %s ERROR: opening file \"%s\" failed !\n"),nowdate,nowtime,filename); - fclose(logfile); - } - } else { - fwrite(SMS.MessageText,1,SMS.Length,file); - fclose(file); - } - } else { - fclose(file); - - GetMachineDateTime(nowdate, nowtime ); - fprintf(stderr,_("%s %s ERROR: file \"%s\" already exist !\n"),nowdate,nowtime,filename); - logfile = fopen("log", "a"); - if (logfile) { - fprintf(logfile,_("%s %s ERROR: file \"%s\" already exist !\n"),nowdate,nowtime,filename); - fclose(logfile); - } - } - - SMS.Location=SMS.MessageNumber; - if (GSM->DeleteSMSMessage(&SMS)!=GE_NONE) { - GetMachineDateTime(nowdate, nowtime ); - fprintf(stderr,_("%s %s ERROR: Deleting SMS location %i failed !\n"),nowdate,nowtime,SMS.MessageNumber); - logfile = fopen("log", "a"); - if (logfile) { - fprintf(logfile,_("%s %s ERROR: Deleting SMS location %i failed !\n"),nowdate,nowtime,SMS.MessageNumber); - fclose(logfile); - } - } - } - read++; - } - location++; - if (read==SMSStatus.Number) break; - } - } - } else { - GetMachineDateTime(nowdate, nowtime ); - fprintf(stderr,_("%s %s ERROR: Can't get SMS status !\n"),nowdate,nowtime); - logfile = fopen("log", "a"); - if (logfile) { - fprintf(logfile,_("%s %s ERROR: Can't get SMS status !\n"),nowdate,nowtime); - fclose(logfile); - } - } - - sleep(1); - } - - fprintf (stderr, _("Leaving monitor mode...\n")); - - GSM->Terminate(); - - return 0; + GSM_SpeedDial SpeedDial; + GSM_Data data; + GSM_Error error; + + SpeedDial.Number = atoi(Number); + + if (GSM && GSM->GetSpeedDial && GSM->Terminate) { + error = GSM->GetSpeedDial(&SpeedDial); + GSM->Terminate(); + } else { + GSM_DataClear(&data); + data.SpeedDial = &SpeedDial; + + error = SM_Functions(GOP_GetSpeedDial, &data, &State); + } + + switch (error) { + case GE_NONE: + fprintf(stdout, _("SpeedDial nr. %d: %d:%d\n"), SpeedDial.Number, SpeedDial.MemoryType, SpeedDial.Location); + break; + case GE_NOTIMPLEMENTED: + fprintf(stdout, _("Function not implemented in %s !\n"), model); + break; + default: + fprintf(stdout, _("Internal error\n")); + break; + } + + return error; } -int divert(int argc, char *argv[]) +/* Setting speed dials. */ +int setspeeddial(char *argv[]) { - GSM_CallDivert cd; - GSM_Error error; + GSM_SpeedDial entry; - memset(&cd, 0, sizeof(GSM_CallDivert)); + char *memory_type_string; - if (!strcmp("register", argv[0])){cd.Operation = GSM_CDV_Register ;} - else if (!strcmp("enable" , argv[0])){cd.Operation = GSM_CDV_Enable ;} - else if (!strcmp("disable" , argv[0])){cd.Operation = GSM_CDV_Disable ;} - else if (!strcmp("erasure" , argv[0])){cd.Operation = GSM_CDV_Erasure ;} - else if (!strcmp("query" , argv[0])){cd.Operation = GSM_CDV_Query ;} - else { - usage(); - exit(-1); - } + /* Handle command line args that set type, start and end locations. */ - if (!strcmp("all" , argv[1])) {cd.DType = GSM_CDV_AllTypes ;} - else if (!strcmp("busy" , argv[1])) {cd.DType = GSM_CDV_Busy ;} - else if (!strcmp("noans" , argv[1])) {cd.DType = GSM_CDV_NoAnswer ;} - else if (!strcmp("outofreach", argv[1])) {cd.DType = GSM_CDV_OutOfReach;} - else { - usage(); - exit(-1); + if (strcmp(argv[1], "ME") == 0) { + entry.MemoryType = 0x02; + memory_type_string = "ME"; + } else if (strcmp(argv[1], "SM") == 0) { + entry.MemoryType = 0x03; + memory_type_string = "SM"; + } else { + fprintf(stderr, _("Unknown memory type %s!\n"), argv[1]); + return -1; } - if (!strcmp("all" , argv[2])) {cd.CType = GSM_CDV_AllCalls ;} - else if (!strcmp("voice", argv[2])) {cd.CType = GSM_CDV_VoiceCalls;} - else if (!strcmp("fax" , argv[2])) {cd.CType = GSM_CDV_FaxCalls ;} - else if (!strcmp("data" , argv[2])) {cd.CType = GSM_CDV_DataCalls ;} - else { - usage(); - exit(-1); - } + entry.Number = atoi(argv[0]); + entry.Location = atoi(argv[2]); - if (argc>3) strcpy(cd.Number, argv[3]); + if (GSM->SetSpeedDial(&entry) == GE_NONE) { + fprintf(stdout, _("Succesfully written!\n")); + } - if (argc>4) cd.Timeout = atoi(argv[4]); + GSM->Terminate(); + return 0; +} - /* Initialise the code for the GSM interface. */ - fbusinit(NULL); +/* Getting the status of the display. */ +int getdisplaystatus(void) +{ + int Status; - error=GSM->CallDivert(&cd); + GSM->GetDisplayStatus(&Status); - if (error == GE_NONE) { - switch (cd.Operation) - { - case GSM_CDV_Query: - fprintf(stdout, _("Divert type: ")); - switch (cd.DType) { - case GSM_CDV_Busy :fprintf(stdout, _("when busy"));break; - case GSM_CDV_NoAnswer :fprintf(stdout, _("when not answered"));break; - case GSM_CDV_OutOfReach:fprintf(stdout, _("when phone off or no coverage"));break; - case GSM_CDV_AllTypes :fprintf(stdout, _("all call diverts"));break; //? - default: fprintf(stdout, _("unknown %i"),cd.DType);break; - } - - fprintf(stdout, _("\nCalls type : ")); - switch (cd.CType) { - case GSM_CDV_VoiceCalls: fprintf(stdout, _("voice"));break; - case GSM_CDV_FaxCalls : fprintf(stdout, _("fax"));break; - case GSM_CDV_DataCalls : fprintf(stdout, _("data"));break; - case GSM_CDV_AllCalls : fprintf(stdout, _("voice, fax & data"));break; - default: fprintf(stdout, _("unknown %i"),cd.CType);break; - } - fprintf(stdout, _("\n")); - - if (cd.Enabled) { - fprintf(stdout, _("Status : active\n")); - fprintf(stdout, _("Timeout : %i seconds\n"),cd.Timeout); - fprintf(stdout, _("Number : %s\n"),cd.Number); - } else { - fprintf(stdout, _("Status : deactivated\n")); - } - - break; - default: - fprintf(stdout,_("Divert done\n")); - } - } else - fprintf(stderr,_("%s\n"),print_error(error)); + fprintf(stdout, _("Call in progress: %s\n"), Status & (1<Terminate(); - return 0; } -int savephonebookentry(int argc, char *argv[]) +int netmonitor(char *Mode) { - GSM_MultiSMSMessage MultiSMS; - GSM_PhonebookEntry entry; - GSM_Error error; - int w; + unsigned char mode = atoi(Mode); + char Screen[50]; + + if (!strcmp(Mode, "reset")) + mode = 0xf0; + else if (!strcmp(Mode, "off")) + mode = 0xf1; + else if (!strcmp(Mode, "field")) + mode = 0xf2; + else if (!strcmp(Mode, "devel")) + mode = 0xf3; + else if (!strcmp(Mode, "next")) + mode = 0x00; + + memset(&Screen, 0, 50); + GSM->NetMonitor(mode, Screen); - fbusinit(NULL); + if (Screen) + fprintf(stdout, "%s\n", Screen); - /* Handle command line args that set type, start and end locations. */ - if (!GetMemoryTypeID(argv[0], &entry.MemoryType)) - { - fprintf(stderr, _("Unknown memory type %s!\n"), argv[0]); - return (-1); - } + GSM->Terminate(); + return 0; +} - entry.Location=atoi(argv[1]); +int identify(void) +{ + /* Hopefully is 64 larger as FB38_MAX* / FB61_MAX* */ + char imei[64], model[64], rev[64], manufacturer[64]; + GSM_Statemachine *sm = &State; - fbusinit(NULL); + data.Manufacturer=manufacturer; + data.Model=model; + data.Revision=rev; + data.Imei=imei; - error=GSM->GetMemoryLocation(&entry); + /* Retrying is bad idea: what if function is simply not implemented? + Anyway let's wait 2 seconds for the right packet from the phone. */ + sleep(2); - switch (error) { - case GE_NONE: + strcpy(imei, "(unknown)"); + strcpy(manufacturer, "(unknown)"); + strcpy(model, "(unknown)"); + strcpy(rev, "(unknown)"); - /* Put entry into SMS structure */ - if (GetModelFeature(FN_PHONEBOOK)==F_PBK71INT) { - GSM_SavePhonebookEntryToSMS(&MultiSMS,&entry,21); - } else { - GSM_SavePhonebookEntryToSMS(&MultiSMS,&entry,10); - } + SM_Functions(GOP_Identify, &data, sm); - for (w=0;wTerminate(); - default: - fprintf(stdout,_("Error\n"));break; - } + return 0; +} - return 0; +int senddtmf(char *String) +{ + GSM->SendDTMF(String); + GSM->Terminate(); + return 0; } -int sendphonebookentry(int argc, char *argv[]) +/* Resets the phone */ +int reset( char *type) { - GSM_MultiSMSMessage MultiSMS; - GSM_PhonebookEntry entry; - GSM_Error error; - int w; + unsigned char _type = 0x03; + + if (type) { + if(!strcmp(type, "soft")) + _type = 0x03; + else + if(!strcmp(type, "hard")) + _type = 0x04; + else { + fprintf(stderr, _("What kind of reset do you want??\n")); + return -1; + } + } - fbusinit(NULL); + GSM->Reset(_type); + GSM->Terminate(); + + return 0; +} - /* Handle command line args that set type, start and end locations. */ - if (!GetMemoryTypeID(argv[1], &entry.MemoryType)) - { - fprintf(stderr, _("Unknown memory type %s!\n"), argv[1]); - return (-1); - } +/* pmon allows fbus code to run in a passive state - it doesn't worry about + whether comms are established with the phone. A debugging/development + tool. */ +int pmon(void) +{ - entry.Location=atoi(argv[2]); + GSM_Error error; + GSM_ConnectionType connection=GCT_Serial; + GSM_Statemachine sm; - fbusinit(NULL); + /* Initialise the code for the GSM interface. */ + error = GSM_Initialise(model, Port, Initlength, connection, NULL, &sm); - error=GSM->GetMemoryLocation(&entry); + if (error != GE_NONE) { + fprintf(stderr, _("GSM/FBUS init failed! (Unknown model ?). Quitting.\n")); + return -1; + } - switch (error) { - case GE_NONE: + while (1) { + usleep(50000); + } - /* Put entry into SMS structure */ - if (GetModelFeature(FN_PHONEBOOK)==F_PBK71INT) { - GSM_SavePhonebookEntryToSMS(&MultiSMS,&entry,21); - } else { - GSM_SavePhonebookEntryToSMS(&MultiSMS,&entry,10); - } + return 0; +} - for (w=0;w sizeof(SMS.Destination)) { + fprintf(stdout, _("Destination number \"%s\" length too long!\n"), argv[0]); + return(-1); + } + strcpy(SMS.Destination, argv[0]); + GSM_PackRingtone(&ringtone, Package, &size); - default: - fprintf(stdout,_("Error\n"));break; - } + sendsms_deconcatenated(&SMS,Package,size,true/*useudh*/); - return 0; + GSM->Terminate(); + return 0; } -#ifdef DEBUG -int getbinringfromfile(int argc, char *argv[]) + +int setringtone(int argc, char *argv[]) { - FILE *file; - int i,j; - bool found; - GSM_BinRingtone binring,ringtone; + GSM_Ringtone ringtone; + GSM_Error error; - fprintf(stdout,_("Offset %ld\n"),atol(argv[2])); + if (GSM_ReadRingtoneFile(argv[0], &ringtone)) { + fprintf(stdout, _("Failed to load ringtone.\n")); + return(-1); + } - file = fopen(argv[0], "rb"); + error = GSM->SetRingtone(&ringtone); - if (!file) return(GE_CANTOPENFILE); + if (error == GE_NONE) + fprintf(stdout, _("Send succeeded!\n")); + else + fprintf(stdout, _("Send failed\n")); - fseek(file,atol(argv[2]),0); - - ringtone.length=fread(ringtone.frame, 1, 900, file); - - fclose(file); - - i=0;found=false; - while (true) { - if (ringtone.frame[i ]==0x00 && ringtone.frame[i+1]==0x02 && - ringtone.frame[i+2]==0xFC && ringtone.frame[i+3]==0x09) { - found=true; - break; - } - i++; - if (i==ringtone.length-3) break; - } - - if (!found) { - fprintf(stdout,_("Start not found\n")); - return (-1); - } - - j=0;found=false; - while (true) { - if (ringtone.frame[j]==0x07 && ringtone.frame[j+1]==0x0B) { - found=true; - break; - } - j++; - if (j==ringtone.length-2) break; - } - - if (!found) { - fprintf(stdout,_("End not found\n")); - return (-1); - } - - binring.length=0; - binring.frame[binring.length++]=0x00; - binring.frame[binring.length++]=0x00; - binring.frame[binring.length++]=0x0C; - binring.frame[binring.length++]=0x01; - binring.frame[binring.length++]=0x2C; - - memcpy(binring.frame+binring.length,argv[1],strlen(argv[1])); - binring.length=binring.length+strlen(argv[1]); + GSM->Terminate(); + return 0; +} - binring.frame[binring.length++]=0x00; +int presskeysequence(void) +{ + char buf[105]; - memcpy(binring.frame+binring.length,ringtone.frame+i,j-i+2); - binring.length=binring.length+j-i+2; + console_raw(); - GSM_SaveBinRingtoneFile(argv[3], &binring); + memset(&buf[0], 0, 102); + while (read(0, buf, 100) > 0) { + fprintf(stderr, "handling keys (%d).\n", strlen(buf)); + if (GSM->HandleString(buf) != GE_NONE) + fprintf(stdout, _("Key press simulation failed.\n")); + memset(buf, 0, 102); + } - return GE_NONE; + GSM->Terminate(); + return 0; +} + +/* This is a "convenience" function to allow quick test of new API stuff which + doesn't warrant a "proper" command line function. */ +#ifndef WIN32 +int foogle(char *argv[]) +{ + /* Initialise the code for the GSM interface. */ + fbusinit(NULL); + // Fill in what you would like to test here... + return 0; } #endif + diff --git a/gnokiid/Makefile b/gnokiid/Makefile index fde8ac2..ccf0253 100644 --- a/gnokiid/Makefile +++ b/gnokiid/Makefile @@ -10,38 +10,30 @@ TOPDIR=.. include $(TOPDIR)/Makefile.global CFLAGS += $(PTHREAD_CFLAGS) -LDFLAGS += $(PTHREAD_LIBS) +LDFLAGS += $(PTHREAD_LIBS) -L../common -lgnokii OBJS = gnokiid.o all: gnokiid -gnokiid: $(OBJS) $(TOPDIR)/common/COMMON.o $(TOPDIR)/common/DATA.o +gnokiid: $(OBJS) $(TOPDIR)/common/libgnokii.so $(TOPDIR)/common/data/DATA.o -$(TOPDIR)/common/COMMON.o: - $(MAKE) -C $(TOPDIR)/common COMMON.o +$(TOPDIR)/common/libgnokii.so: + $(MAKE) -C $(TOPDIR)/common libgnokii.so -$(TOPDIR)/common/DATA.o: - $(MAKE) -C $(TOPDIR)/common DATA.o - -$(TOPDIR)/common/libmygnokii.so: - $(MAKE) -C $(TOPDIR)/common makelib - -makelib: $(OBJS) $(TOPDIR)/common/libmygnokii.so - $(CC) $(LDFLAGS) -L$(TOPDIR)/common -lmygnokii $(OBJS) -o gnokiidlib +$(TOPDIR)/common/data/DATA.o: + $(MAKE) -C $(TOPDIR)/common/data DATA.o clean: - $(RM) $(OBJS) *~ depend gnokiid gnokiidlib *.exe core *.bak + $(RM) $(OBJS) *~ depend gnokiid *.exe core *.bak install: all $(INSTALL) -d $(sbindir) $(INSTALL) gnokiid $(sbindir) - $(INSTALL) gnokiidlib $(sbindir)/gnokiid install-strip: all $(INSTALL) -d $(sbindir) $(INSTALL) -s gnokiid $(sbindir) - $(INSTALL) -s gnokiidlib $(sbindir)/gnokiid @echo "done" install-suid: all @@ -50,7 +42,6 @@ install-suid: all fi $(INSTALL) -d $(sbindir) $(INSTALL) -o root -g gnokii -m 4750 gnokiid $(sbindir) - $(INSTALL) -o root -g gnokii -m 4750 gnokiidlib $(sbindir)/gnokiid @echo "done" install-ss: all @@ -59,7 +50,6 @@ install-ss: all fi $(INSTALL) -d $(sbindir) $(INSTALL) -o root -g gnokii -m 4750 -s gnokiid $(sbindir) - $(INSTALL) -o root -g gnokii -m 4750 -s gnokiidlib $(sbindir)/gnokiid @echo "done" depend dep: diff --git a/gnokiid/gnokiid.c b/gnokiid/gnokiid.c index 0b589ae..e0b8f16 100644 --- a/gnokiid/gnokiid.c +++ b/gnokiid/gnokiid.c @@ -1,14 +1,32 @@ /* + $Id$ + G N O K I I A Linux/Unix toolset and driver for Nokia mobile phones. + Copyright (C) 1999, 2000 Hugh Blemings & Pavel Janík ml. + Released under the terms of the GNU GPL, see file COPYING for more details. Mainline code for gnokiid daemon. Handles command line parsing and various daemon functions. + $Log$ + Revision 1.1.1.3 2002/04/03 00:08:17 short + Found in "gnokii-working" directory, some November-patches version + + Revision 1.19 2001/06/28 00:28:45 pkot + Small docs updates (Pawel Kot) + + Revision 1.18 2001/02/21 19:57:09 chris + More fiddling with the directory layout + + Revision 1.17 2000/12/19 16:18:18 pkot + configure script updates and added shared function for configfile reading + + */ #include @@ -22,28 +40,31 @@ #include #include "misc.h" -#include "files/cfgreader.h" +#include "cfgreader.h" #include "gsm-common.h" #include "gsm-api.h" #include "data/virtmodem.h" -/* Global variables */ -bool DebugMode; /* When true, run in debug mode */ -char *Model; /* Model from .gnokiirc file. */ -char *Port; /* Port from .gnokiirc file */ -char *Initlength; /* Init length from .gnokiirc file */ -char *Connection; /* Connection type from .gnokiirc file */ -char *SynchronizeTime; -char *BinDir; /* Directory of the mgnokiidev command */ -bool TerminateThread; +/* Global variables */ +bool DebugMode; /* When true, run in debug mode */ +char *Model; /* Model from .gnokiirc file. */ +char *Port; /* Serial port from .gnokiirc file */ +char *Initlength; /* Init length from .gnokiirc file */ +char *Connection; /* Connection type from .gnokiirc file */ +char *BinDir; /* Directory of the mgnokiidev command */ +bool TerminateThread; + +/* Local variables */ +char *DefaultConnection = "serial"; +char *DefaultBinDir = "/usr/local/sbin"; void version(void) { - fprintf(stdout, _("gnokiid Version %s\n" -"Copyright (C) Hugh Blemings , 1999\n" -"Copyright (C) Pavel Janík ml. , 1999\n" + fprintf(stdout, _("gnokiid Version %s\n" +"Copyright (C) Hugh Blemings , 1999\n" +"Copyright (C) Pavel Janík ml. , 1999\n" "Built %s %s for %s on %s \n"), VERSION, __TIME__, __DATE__, Model, Port); } @@ -53,7 +74,7 @@ void version(void) void usage(void) { - fprintf(stdout, _(" usage: gnokiid {--help|--version}\n" + fprintf(stdout, _(" usage: gnokiid {--help|--version}\n" " --help display usage information." " --version displays version and copyright information." " --debug uses stdin/stdout for virtual modem comms.\n")); @@ -65,64 +86,55 @@ void usage(void) int main(int argc, char *argv[]) { - GSM_ConnectionType connection; - - /* For GNU gettext */ + GSM_ConnectionType connection = GCT_Serial; - #ifdef USE_NLS - textdomain("gnokii"); - #endif + /* For GNU gettext */ -#ifndef WIN32 - if (strcmp(GetMygnokiiVersion(),VERSION)!=0) - fprintf(stderr,_("WARNING: version of installed libmygnokii.so (%s) is different to version of gnokiid (%s)\n"),GetMygnokiiVersion(),VERSION); +#ifdef USE_NLS + textdomain("gnokii"); #endif - if (CFG_ReadConfig(&Model, &Port, &Initlength, &Connection, &BinDir, &SynchronizeTime,true) < 0) { + if (readconfig(&Model, &Port, &Initlength, &Connection, &BinDir) < 0) { exit(-1); } - /* Handle command line arguments. */ - - if (argc >= 2 && strcmp(argv[1], "--help") == 0) { - usage(); - exit(0); - } - - /* Display version, copyright and build information. */ - - if (argc >= 2 && strcmp(argv[1], "--version") == 0) { - version(); - exit(0); - } - - if (argc >= 2 && strcmp(argv[1], "--debug") == 0) { - DebugMode = true; - } - else { - DebugMode = false; - } - - connection=GetConnectionTypeFromString(Connection); - - /* MBUS wasn't tested */ - if (connection!=GCT_FBUS && connection!=GCT_MBUS && - connection!=GCT_Infrared && connection!=GCT_Tekram) { - fprintf(stdout,_("Incorrect connection type!\n")); - exit(0); - } - - TerminateThread=false; - - if (VM_Initialise(Model, Port, Initlength, connection, BinDir, DebugMode, true, SynchronizeTime) == false) - exit (-1); - - while (1) { - if (TerminateThread==true) { - VM_Terminate(); - exit(1); - } - sleep (1); - } - exit (0); + + /* Handle command line arguments. */ + + if (argc >= 2 && strcmp(argv[1], "--help") == 0) { + usage(); + exit(0); + } + + /* Display version, copyright and build information. */ + + if (argc >= 2 && strcmp(argv[1], "--version") == 0) { + version(); + exit(0); + } + + if (argc >= 2 && strcmp(argv[1], "--debug") == 0) { + DebugMode = true; + } else { + DebugMode = false; + } + + if (!strcmp(Connection, "infrared")) { + connection=GCT_Infrared; + } + + TerminateThread=false; + + if (VM_Initialise(Model, Port, Initlength, connection, BinDir, DebugMode, true) == false) { + exit (-1); + } + + while (1) { + if (TerminateThread==true) { + VM_Terminate(); + exit(1); + } + sleep (1); + } + exit (0); } diff --git a/include/cfgreader.h b/include/cfgreader.h index 252031e..f0fcdb1 100644 --- a/include/cfgreader.h +++ b/include/cfgreader.h @@ -13,8 +13,8 @@ Header file for config file reader. $Log$ - Revision 1.1.1.1 2001/11/25 21:59:19 short - :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001 + Revision 1.1.1.2 2002/04/03 00:08:17 short + Found in "gnokii-working" directory, some November-patches version Revision 1.4 2000/12/19 16:18:19 pkot configure script updates and added shared function for configfile reading @@ -43,10 +43,16 @@ struct CFG_Header { char *section; }; +/* Global variables */ + +extern struct CFG_Header *CFG_Info; + /* Function prototypes */ struct CFG_Header *CFG_ReadFile(char *filename); -char *CFG_Get(struct CFG_Header *cfg, char *section, char *key); +char *CFG_Get(struct CFG_Header *cfg, const char *section, const char *key); +typedef void (*CFG_GetForeach_func)(const char *section,const char *key,const char *value); +void CFG_GetForeach(struct CFG_Header *cfg, const char *section, CFG_GetForeach_func func); char *CFG_Set(struct CFG_Header *cfg, char *section, char *key, char *value); int CFG_WriteFile(struct CFG_Header *cfg, char *filename); diff --git a/include/config.h.in.in b/include/config.h.in.in index a5dae23..d93593d 100644 --- a/include/config.h.in.in +++ b/include/config.h.in.in @@ -6,8 +6,22 @@ A Linux/Unix toolset and driver for Nokia mobile phones. + Copyright (C) 1999, 2000 Hugh Blemings & Pavel Janík ml. + Released under the terms of the GNU GPL, see file COPYING for more details. + $Log$ + Revision 1.1.1.3 2002/04/03 00:08:17 short + Found in "gnokii-working" directory, some November-patches version + + Revision 1.2 2001/06/20 22:34:45 pkot + Updated Debian packaging system (Erik Rossen) + Updated Makefiles to let packaging process be easier (Pawel Kot) + + Revision 1.1 2001/01/02 09:09:09 pkot + Misc fixes and updates. + + */ /* DO NOT EDIT MANUALLY !!! */ @@ -17,7 +31,7 @@ #define VERSION "@VERSION@" #define XVERSION "@XVERSION@" -#define XGNOKIIDIR "@XGNOKIIDIR@/@XPACKAGE@" +#define XGNOKIIDIR "@XGNOKIIPATH@/@XPACKAGE@" /* Define if you have timersub() */ #undef HAVE_TIMEOPS diff --git a/include/data/at-emulator.h b/include/data/at-emulator.h index 3f95297..c464037 100644 --- a/include/data/at-emulator.h +++ b/include/data/at-emulator.h @@ -6,10 +6,24 @@ A Linux/Unix toolset and driver for Nokia mobile phones. + Copyright (C) 1999, 2000 Hugh Blemings & Pavel Janík ml. + Released under the terms of the GNU GPL, see file COPYING for more details. Header file for AT emulator code. + $Log$ + Revision 1.1.1.3 2002/04/03 00:08:20 short + Found in "gnokii-working" directory, some November-patches version + + Revision 1.2 2001/07/03 15:27:24 pkot + AT commands for SMS handling support (Tamas Bondar) + Small at-emulator code cleanup (me) + + Revision 1.1 2001/02/21 19:57:11 chris + More fiddling with the directory layout + + */ #ifndef __data_at_emulator_h diff --git a/include/data/datapump.h b/include/data/datapump.h index c1e48d1..7c3b4e7 100644 --- a/include/data/datapump.h +++ b/include/data/datapump.h @@ -6,10 +6,20 @@ A Linux/Unix toolset and driver for Nokia mobile phones. + Copyright (C) 1999, 2000 Hugh Blemings & Pavel Janík ml. + Released under the terms of the GNU GPL, see file COPYING for more details. Header file for data pump code. + $Log$ + Revision 1.1.1.3 2002/04/03 00:08:20 short + Found in "gnokii-working" directory, some November-patches version + + Revision 1.1 2001/02/21 19:57:11 chris + More fiddling with the directory layout + + */ #ifndef __data_datapump_h diff --git a/include/data/rlp-common.h b/include/data/rlp-common.h index a03a497..9102fc0 100644 --- a/include/data/rlp-common.h +++ b/include/data/rlp-common.h @@ -6,13 +6,29 @@ A Linux/Unix toolset and driver for Nokia mobile phones. + Copyright (C) 1999, 2000 Hugh Blemings & Pavel Janík ml. + Released under the terms of the GNU GPL, see file COPYING for more details. The development of RLP protocol is sponsored by SuSE CR, s.r.o. (Pavel use the SIM card from SuSE for testing purposes). + This file: rlp-common.h Version 0.3.1 + Header file for RLP protocol. + $Log$ + Revision 1.1.1.4 2002/04/03 00:08:20 short + Found in "gnokii-working" directory, some November-patches version + + Revision 1.2 2001/06/10 11:29:49 machek + It is very bad idea to name enum "Data", because it is then impossible + to use variable called "Data". + + Revision 1.1 2001/02/21 19:57:11 chris + More fiddling with the directory layout + + */ #ifndef __data_rlp_common_h diff --git a/include/data/rlp-crc24.h b/include/data/rlp-crc24.h index 6789510..600b3a9 100644 --- a/include/data/rlp-crc24.h +++ b/include/data/rlp-crc24.h @@ -6,10 +6,22 @@ A Linux/Unix toolset and driver for Nokia mobile phones. + Copyright (C) 1999, 2000 Hugh Blemings & Pavel Janík ml. + Released under the terms of the GNU GPL, see file COPYING for more details. + This file: rlp-crc24.h Version 0.3.1 + Header file for CRC24 (aka FCS) implementation in RLP. + $Log$ + Revision 1.1.1.4 2002/04/03 00:08:20 short + Found in "gnokii-working" directory, some November-patches version + + Revision 1.1 2001/02/21 19:57:11 chris + More fiddling with the directory layout + + */ #ifndef __data_rlp_crc24_h diff --git a/include/data/virtmodem.h b/include/data/virtmodem.h index 6fe838d..aaa094f 100644 --- a/include/data/virtmodem.h +++ b/include/data/virtmodem.h @@ -1,17 +1,29 @@ /* + $Id$ + G N O K I I A Linux/Unix toolset and driver for Nokia mobile phones. + Copyright (C) 1999, 2000 Hugh Blemings & Pavel Janík ml. + Released under the terms of the GNU GPL, see file COPYING for more details. Header file for virtmodem code in virtmodem.c + $Log$ + Revision 1.1.1.3 2002/04/03 00:08:20 short + Found in "gnokii-working" directory, some November-patches version + + Revision 1.1 2001/02/21 19:57:11 chris + More fiddling with the directory layout + + */ -#ifndef __virtmodem_h -#define __virtmodem_h +#ifndef __data_virtmodem_h +#define __data_virtmodem_h /* Prototypes */ @@ -21,8 +33,7 @@ bool VM_Initialise(char *model, GSM_ConnectionType connection, char *bindir, bool debug_mode, - bool GSM_Init, - char *synchronizetime); + bool GSM_Init); int VM_PtySetup(char *bindir); void VM_ThreadLoop(void); void VM_CharHandler(void); @@ -31,7 +42,6 @@ void VM_Terminate(void); GSM_Error VM_GSMInitialise(char *model, char *port, char *initlength, - GSM_ConnectionType connection, - char *synchronizetime); + GSM_ConnectionType connection); #endif /* __virtmodem_h */ diff --git a/include/devices/tekram.h b/include/devices/tekram.h index 36dfaf0..06e97d9 100644 --- a/include/devices/tekram.h +++ b/include/devices/tekram.h @@ -6,6 +6,9 @@ * * A Linux/Unix toolset and driver for Nokia mobile phones. * + * Copyright (C) 1999, 2000 Hugh Blemings & Pavel Janík ml. + * Copyright (C) 2000-2001 Marcel Holtmann + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either @@ -20,6 +23,16 @@ * License along with this library; if not, write to the Free * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * + * $Log$ + * Revision 1.1.1.4 2002/04/03 00:08:20 short + * Found in "gnokii-working" directory, some November-patches version + * + * Revision 1.1 2001/02/21 19:57:11 chris + * More fiddling with the directory layout + * + * Revision 1.1 2001/02/09 18:12:54 chris + * Marcel's tekram support + * */ #ifndef __devices_tekram_h diff --git a/include/devices/unixirda.h b/include/devices/unixirda.h index a852f39..9baf8bd 100644 --- a/include/devices/unixirda.h +++ b/include/devices/unixirda.h @@ -5,6 +5,9 @@ * * A Linux/Unix toolset and driver for Nokia mobile phones. * + * Copyright (C) 1999, 2000 Hugh Blemings & Pavel Janík ml. + * Copyright (C) 2000-2001 Marcel Holtmann + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either @@ -19,8 +22,34 @@ * License along with this library; if not, write to the Free * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * + * $Log$ + * Revision 1.1.1.3 2002/04/03 00:08:20 short + * Found in "gnokii-working" directory, some November-patches version + * + * Revision 1.2 2001/11/08 16:49:20 pkot + * Cleanups + * + * Revision 1.1 2001/02/21 19:57:11 chris + * More fiddling with the directory layout + * + * Revision 1.4 2001/02/20 21:55:12 pkot + * Small #include updates + * + * Revision 1.3 2001/02/06 21:15:37 chris + * Preliminary irda support for 7110 etc. Not well tested! + * + * Revision 1.2 2001/02/06 15:15:25 pkot + * FreeBSD unixirda.h fix (Panagiotis Astithas) + * + * Revision 1.1 2001/02/03 23:56:18 chris + * Start of work on irda support (now we just need fbus-irda.c!) + * Proper unicode support in 7110 code (from pkot) + * */ +#ifndef __unix_irda_h_ +#define __unix_irda_h_ + #include #include #include @@ -28,7 +57,6 @@ #include #include #include -#include #include #include "linuxirda.h" @@ -39,3 +67,5 @@ int irda_close(int fd); int irda_write(int __fd, __const __ptr_t __bytes, int __size); int irda_read(int __fd, __ptr_t __bytes, int __size); int irda_select(int fd, struct timeval *timeout); + +#endif diff --git a/include/devices/unixserial.h b/include/devices/unixserial.h index b044d43..9dca33b 100644 --- a/include/devices/unixserial.h +++ b/include/devices/unixserial.h @@ -6,8 +6,21 @@ A Linux/Unix toolset and driver for Nokia mobile phones. + Copyright (C) 1999, 2000 Hugh Blemings & Pavel Janík ml. + Released under the terms of the GNU GPL, see file COPYING for more details. + $Log$ + Revision 1.1.1.4 2002/04/03 00:08:20 short + Found in "gnokii-working" directory, some November-patches version + + Revision 1.2 2001/08/20 23:27:37 pkot + Add hardware shakehand to the link layer (Manfred Jonsson) + + Revision 1.1 2001/02/21 19:57:12 chris + More fiddling with the directory layout + + */ #ifndef __devices_unixserial_h @@ -30,7 +43,7 @@ int serial_close(int __fd); int serial_opendevice(__const char *__file, int __with_odd_parity, int __with_async, int __with_hw_handshake); void serial_setdtrrts(int __fd, int __dtr, int __rts); -void serial_changespeed(int __fd, int __speed); +bool serial_changespeed(int __fd, int __speed); size_t serial_read(int __fd, __ptr_t __buf, size_t __nbytes); size_t serial_write(int __fd, __const __ptr_t __buf, size_t __n); diff --git a/include/fbus-3810.h b/include/fbus-3810.h new file mode 100644 index 0000000..0e07f58 --- /dev/null +++ b/include/fbus-3810.h @@ -0,0 +1,205 @@ +/* + + $Id$ + + G N O K I I + + A Linux/Unix toolset and driver for Nokia mobile phones. + + Copyright (C) 1999, 2000 Hugh Blemings & Pavel Janík ml. + + Released under the terms of the GNU GPL, see file COPYING for more details. + + Header file for 3810 code. + + $Log$ + Revision 1.1.1.1 2002/04/03 00:08:17 short + Found in "gnokii-working" directory, some November-patches version + + Revision 1.51 2001/06/28 00:40:57 pkot + 8bit SMS handling in 3810 series - old structure yet (Tamas Bondar) + + Revision 1.50 2001/06/28 00:28:45 pkot + Small docs updates (Pawel Kot) + + +*/ + +#ifndef __fbus_3810_h +#define __fbus_3810_h + +#ifndef __gsm_common_h +#include "gsm-common.h" /* Needed for GSM_Error etc. */ +#endif + + /* Global variables */ +extern bool FB38_LinkOK; +extern GSM_Functions FB38_Functions; +extern GSM_Information FB38_Information; +extern void (*FB38_RLP_RXCallback)(RLP_F96Frame *frame); + + /* Prototypes for the functions designed to be used externally. */ +GSM_Error FB38_Initialise(char *port_device, char *initlength, + GSM_ConnectionType connection, + void (*rlp_callback)(RLP_F96Frame *frame)); + +bool FB38_OpenSerial(void); +void FB38_Terminate(void); + +int FB38_GetMemoryType(GSM_MemoryType memory_type); + +GSM_Error FB38_GetMemoryLocation(GSM_PhonebookEntry *entry); + +GSM_Error FB38_WritePhonebookLocation(GSM_PhonebookEntry *entry); + +GSM_Error FB38_GetSpeedDial(GSM_SpeedDial *entry); + +GSM_Error FB38_SetSpeedDial(GSM_SpeedDial *entry); + +GSM_Error FB38_GetMemoryStatus(GSM_MemoryStatus *Status); + +GSM_Error FB38_GetSMSStatus(GSM_SMSStatus *Status); +GSM_Error FB38_GetSMSCenter(GSM_MessageCenter *MessageCenter); +GSM_Error FB38_GetSMSMessage(GSM_SMSMessage *message); + +GSM_Error FB38_GetSMSCenter(GSM_MessageCenter *MessageCenter); +GSM_Error FB38_SetSMSCenter(GSM_MessageCenter *MessageCenter); + +GSM_Error FB38_DeleteSMSMessage(GSM_SMSMessage *message); + +GSM_Error FB38_CancelCall(void); + +GSM_Error FB38_SendSMSMessage(GSM_SMSMessage *SMS); + +GSM_Error FB38_GetRFLevel(GSM_RFUnits *units, float *level); + +GSM_Error FB38_GetBatteryLevel(GSM_BatteryUnits *units, float *level); + +bool FB38_SendRLPFrame(RLP_F96Frame *frame, bool out_dtx); + + /* These aren't presently implemented. */ +GSM_Error FB38_SaveSMSMessage(GSM_SMSMessage *SMS); +GSM_Error FB38_GetPowerSource(GSM_PowerSource *source); +GSM_Error FB38_GetDisplayStatus(int *Status); +GSM_Error FB38_EnterSecurityCode(GSM_SecurityCode SecurityCode); +GSM_Error FB38_GetSecurityCodeStatus(int *Status); +GSM_Error FB38_GetIMEI(char *imei); +GSM_Error FB38_GetRevision(char *revision); +GSM_Error FB38_GetModel(char *model); +GSM_Error FB38_GetDateTime(GSM_DateTime *date_time); +GSM_Error FB38_SetDateTime(GSM_DateTime *date_time); +GSM_Error FB38_GetAlarm(int alarm_number, GSM_DateTime *date_time); +GSM_Error FB38_SetAlarm(int alarm_number, GSM_DateTime *date_time); +GSM_Error FB38_DialVoice(char *Number); +GSM_Error FB38_DialData(char *Number, char type,void (* callpassup)(char c)); +GSM_Error FB38_GetIncomingCallNr(char *Number); +GSM_Error FB38_GetNetworkInfo(GSM_NetworkInfo *NetworkInfo); +GSM_Error FB38_GetCalendarNote(GSM_CalendarNote *CalendarNote); +GSM_Error FB38_WriteCalendarNote(GSM_CalendarNote *CalendarNote); +GSM_Error FB38_DeleteCalendarNote(GSM_CalendarNote *CalendarNote); +GSM_Error FB38_Netmonitor(unsigned char mode, char *Screen); +GSM_Error FB38_SendDTMF(char *String); +GSM_Error FB38_GetBitmap(GSM_Bitmap *Bitmap); +GSM_Error FB38_SetBitmap(GSM_Bitmap *Bitmap); +GSM_Error FB38_SetRingTone (GSM_Ringtone *ringtone); +GSM_Error FB38_Reset(unsigned char type); +GSM_Error FB38_GetProfile(GSM_Profile *Profile); +GSM_Error FB38_SetProfile(GSM_Profile *Profile); + +GSM_Error FB38_EnableDisplayOutput(); +GSM_Error FB38_DisableDisplayOutput(); + +GSM_Error FB38_EnableCellBroadcast (); +GSM_Error FB38_DisableCellBroadcast(void); +GSM_Error FB38_ReadCellBroadcast (GSM_CBMessage *Message); + + /* All defines and prototypes from here down are specific to + this model and so are #ifdef out if __fbus_3810_c isn't + defined. */ +#ifdef __fbus_3810_c + + /* These set length limits for the handset. This is SIM dependant + and ultimately will be set automatically once we know how + to get that information from phone. INT values are + selected when the memory type specified is '1' + this corresponds to internal memory on an 8110 */ +#define FB38_DEFAULT_SIM_PHONEBOOK_NAME_LENGTH (10) +#define FB38_DEFAULT_SIM_PHONEBOOK_NUMBER_LENGTH (30) + +#define FB38_DEFAULT_INT_PHONEBOOK_NAME_LENGTH (20) +#define FB38_DEFAULT_INT_PHONEBOOK_NUMBER_LENGTH (30) + + /* Number of times to try resending SMS (empirical) */ +#define FB38_SMS_SEND_RETRY_COUNT (4) + + /* Miscellaneous values. */ +#define FB38_MAX_RECEIVE_LENGTH (512) +#define FB38_MAX_TRANSMIT_LENGTH (256) +#define FB38_BAUDRATE (B115200) + + /* Limits for IMEI, Revision and Model string storage. */ +#define FB38_MAX_IMEI_LENGTH (20) +#define FB38_MAX_REVISION_LENGTH (10) +#define FB38_MAX_MODEL_LENGTH (8) + + /* Limits for sizing of array in FB38_PhonebookEntry */ +#define FB38_MAX_PHONEBOOK_NAME_LENGTH (30) +#define FB38_MAX_PHONEBOOK_NUMBER_LENGTH (30) + + /* Limits to do with SMS messages. */ +#define FB38_MAX_SMS_CENTER_LENGTH (30) +#define FB38_MAX_SENDER_LENGTH (30) +#define FB38_MAX_SMS_LENGTH (160) + + /* States for receive code. */ +enum FB38_RX_States {FB38_RX_Sync, + FB38_RX_GetLength, + FB38_RX_GetMessage, + FB38_RX_Off}; + + /* Prototypes for internal functions. */ +void FB38_SigHandler(int status); +void FB38_ThreadLoop(void); + +void FB38_RX_StateMachine(char rx_byte); +enum FB38_RX_States FB38_RX_DispatchMessage(void); +enum FB38_RX_States FB38_RX_HandleRLPMessage(void); +void FB38_RX_DisplayMessage(void); +void FB38_RX_Handle0x0b_IncomingCall(void); +void FB38_RX_Handle0x4b_Status(void); +void FB38_RX_Handle0x10_EndOfOutgoingCall(void); +void FB38_RX_Handle0x11_EndOfIncomingCall(void); +void FB38_RX_Handle0x12_EndOfOutgoingCall(void); +void FB38_RX_Handle0x27_SMSMessageText(void); +void FB38_RX_Handle0x30_IncomingSMSNotification(void); +void FB38_RX_Handle0x32_SMSDelivered(void); +void FB38_RX_Handle0x0d_IncomingCallAnswered(void); +void FB38_RX_Handle0x0e_CallEstablished(void); +void FB38_RX_Handle0x2c_SMSHeader(void); +void FB38_RX_Handle0x41_SMSMessageCenterData(void); +void FB38_RX_Handle0x46_MemoryLocationData(void); +void FB38_RX_Handle0x4d_IMEIRevisionModelData(void); + +void FB38_TX_UpdateSequenceNumber(void); +int FB38_TX_SendStandardAcknowledge(u8 message_type); +GSM_Error FB38_TX_SendDialCommand(u8 call_type, char *Number); +bool FB38_TX_SendRLPFrame(RLP_F96Frame *frame, bool out_dtx); + +int FB38_TX_SendMessage(u8 message_length, u8 message_type, u8 sequence_byte, u8 *buffer); +void FB38_TX_Send0x0f_HangupMessage(void); +void FB38_TX_Send0x25_RequestSMSMemoryLocation(u8 memory_type, u8 location); +void FB38_TX_Send0x26_DeleteSMSMemoryLocation(u8 memory_type, u8 location); + +void FB38_TX_Send0x23_SendSMSHeader(char *message_center, char *destination, u8 fo, u8 dcs, u8 total_length); +void FB38_TX_Send0x27_SendSMSMessageText(u8 block_number, u8 block_length, char *text); +void FB38_TX_Send0x3fMessage(void); +void FB38_TX_Send0x4aMessage(void); +int FB38_TX_Send0x42_WriteMemoryLocation(u8 memory_area, u8 location, char *label, char *number); +void FB38_TX_Send0x43_RequestMemoryLocation(u8 memory_area, u8 location); +void FB38_TX_Send0x4c_RequestIMEIRevisionModelData(void); +void FB38_TX_Send0x15Message(u8 sequence_number); +void FB38_TX_SendExploreMessage(u8 message); + +#endif /* __fbus_3810_c */ + +#endif /* __fbus_3810_h */ diff --git a/include/fbus-6110.h b/include/fbus-6110.h index 1b7b9d0..62f878e 100644 --- a/include/fbus-6110.h +++ b/include/fbus-6110.h @@ -14,8 +14,8 @@ the handset interface. See fbus-6110.c for more details. $Log$ - Revision 1.1.1.1 2001/11/25 21:59:19 short - :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001 + Revision 1.1.1.2 2002/04/03 00:08:17 short + Found in "gnokii-working" directory, some November-patches version Revision 1.58 2001/06/28 00:28:45 pkot Small docs updates (Pawel Kot) @@ -162,7 +162,7 @@ GSM_Error FB61_GetSMSCenter(GSM_MessageCenter *MessageCenter); GSM_Error FB61_GetSMSMessage(GSM_SMSMessage *Message); GSM_Error FB61_DeleteSMSMessage(GSM_SMSMessage *Message); -GSM_Error FB61_SendSMSMessage(GSM_SMSMessage *Message, int size); +GSM_Error FB61_SendSMSMessage(GSM_SMSMessage *Message); GSM_Error FB61_SaveSMSMessage(GSM_SMSMessage *Message); GSM_Error FB61_GetRFLevel(GSM_RFUnits *units, float *level); @@ -205,7 +205,6 @@ GSM_Error FB61_SetBitmap( GSM_Bitmap *Bitmap ); GSM_Error FB61_GetBitmap( GSM_Bitmap *Bitmap ); GSM_Error FB61_SetRingTone(GSM_Ringtone *ringtone); -GSM_Error FB61_SendRingTone(GSM_Ringtone *ringtone, char *dest); GSM_Error FB61_EnableDisplayOutput(); GSM_Error FB61_DisableDisplayOutput(); diff --git a/include/gnokii.h b/include/gnokii.h index e9806dd..8cc5b70 100644 --- a/include/gnokii.h +++ b/include/gnokii.h @@ -13,11 +13,8 @@ Header file for test utility. $Log$ - Revision 1.1.1.2 2001/12/14 19:49:13 short - :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Fri Dec 14 20:46 CET 2001 - - Revision 1.28 2001/12/14 14:37:44 pkot - Cleanups. Call divert support for at and 7110 series + Revision 1.1.1.3 2002/04/03 00:08:17 short + Found in "gnokii-working" directory, some November-patches version Revision 1.27 2001/09/14 12:53:00 pkot New preview logos. @@ -78,7 +75,6 @@ int reset(char *type); int getprofile(int argc, char *argv[]); int displayoutput(); int presskeysequence(); -int divert(int argc, char *argv[]); typedef enum { OPT_HELP, @@ -120,7 +116,6 @@ typedef enum { OPT_GETPROFILE, OPT_DISPLAYOUTPUT, OPT_KEYPRESS, - OPT_DIVERT, OPT_FOOGLE } opt_index; diff --git a/include/gsm-api.h b/include/gsm-api.h index fa655b4..fefca54 100644 --- a/include/gsm-api.h +++ b/include/gsm-api.h @@ -1,540 +1,59 @@ /* + $Id$ + G N O K I I A Linux/Unix toolset and driver for Nokia mobile phones. + Copyright (C) 1999, 2000 Hugh Blemings & Pavel Janík ml. + Released under the terms of the GNU GPL, see file COPYING for more details. Header file for the various functions, definitions etc. used to implement the handset interface. See gsm-api.c for more details. -*/ - -#ifndef __gsm_api_h -#define __gsm_api_h - -#include "misc.h" -#include "gsm-common.h" -#include "data/rlp-common.h" -#include "devices/device.h" -#include "gsm-phonebook.h" -#include "gsm-networks.h" -#include "gsm-bitmaps.h" -#include "gsm-datetime.h" -#include "gsm-calendar.h" -#include "gsm-sms.h" -#include "gsm-ringtones.h" -#include "gsm-wap.h" - -/* Undefined functions in fbus/mbus files */ -extern GSM_Error Unimplemented(void); -#define UNIMPLEMENTED (void *) Unimplemented -extern GSM_Error NotSupported(void); -#define NOTSUPPORTED (void *) NotSupported - -/* Define the structure used to hold pointers to the various API functions. - This is in effect the master list of functions provided by the gnokii API. - Modules containing the model specific code each contain one of these - structures which is "filled in" with the corresponding function within the - model specific code. If a function is not supported or not implemented, a - generic not implemented function is used to return a GE_NOTIMPLEMENTED - error code. */ - -typedef struct { - - /* FIXME: comment this. */ - - GSM_Error (*Initialise)( char *port_device, char *initlength, - GSM_ConnectionType connection, - void (*rlp_callback)(RLP_F96Frame *frame)); - - void (*DispatchMessage) (u16 MessageLength, u8 *MessageBuffer, u8 MessageType); - - void (*Terminate)(void); - - void (*KeepAlive)(void); - - GSM_Error (*GetMemoryLocation)( GSM_PhonebookEntry *entry ); - - GSM_Error (*WritePhonebookLocation)( GSM_PhonebookEntry *entry ); - - GSM_Error (*GetSpeedDial)( GSM_SpeedDial *entry); - - GSM_Error (*SetSpeedDial)( GSM_SpeedDial *entry); - - GSM_Error (*GetMemoryStatus)( GSM_MemoryStatus *Status); - - GSM_Error (*GetSMSStatus)( GSM_SMSStatus *Status); - - GSM_Error (*GetSMSCenter)( GSM_MessageCenter *MessageCenter ); - - GSM_Error (*SetSMSCenter)( GSM_MessageCenter *MessageCenter ); - - GSM_Error (*GetSMSMessage)( GSM_SMSMessage *Message ); - - GSM_Error (*DeleteSMSMessage)( GSM_SMSMessage *Message ); - - GSM_Error (*SendSMSMessage)( GSM_SMSMessage *Message); - - GSM_Error (*SaveSMSMessage)( GSM_SMSMessage *Message); - - /* If units is set to a valid GSM_RFUnits value, the code - will return level in these units if it is able. Otherwise - value will be returned as GRF_Arbitary. If phone doesn't - support GetRFLevel, function returns GE_NOTSUPPORTED */ - GSM_Error (*GetRFLevel)( GSM_RFUnits *units, float *level ); - - /* Works the same as GetRFLevel, except returns battery - level if known. */ - GSM_Error (*GetBatteryLevel)( GSM_BatteryUnits *units, float *level ); - - GSM_Error (*GetPowerSource)( GSM_PowerSource *source); - - GSM_Error (*GetDisplayStatus)( int *Status); - - GSM_Error (*EnterSecurityCode)( GSM_SecurityCode Code); - - GSM_Error (*GetSecurityCodeStatus)( int *Status ); - - GSM_Error (*GetSecurityCode)( GSM_SecurityCode *Code); - - GSM_Error (*GetIMEI)( char *imei ); - - GSM_Error (*GetRevision)( char *revision ); - - GSM_Error (*GetModel)( char *model ); - - GSM_Error (*GetDateTime)( GSM_DateTime *date_time); - - GSM_Error (*SetDateTime)( GSM_DateTime *date_time); - - GSM_Error (*GetAlarm)( int alarm_number, GSM_DateTime *date_time ); - - GSM_Error (*SetAlarm)( int alarm_number, GSM_DateTime *date_time ); - - GSM_Error (*DialVoice)( char *Number); - - GSM_Error (*DialData)( char *Number, char type, void (* callpassup)(char c)); - - GSM_Error (*GetIncomingCallNr)( char *Number ); - - GSM_Error (*GetNetworkInfo) ( GSM_NetworkInfo *NetworkInfo ); - - GSM_Error (*GetCalendarNote) ( GSM_CalendarNote *CalendarNote); - - GSM_Error (*WriteCalendarNote) ( GSM_CalendarNote *CalendarNote); - - GSM_Error (*DeleteCalendarNote) ( GSM_CalendarNote *CalendarNote); - - GSM_Error (*NetMonitor) ( unsigned char mode, char *Screen ); - - GSM_Error (*SendDTMF) ( char *String ); - - GSM_Error (*GetBitmap) ( GSM_Bitmap *Bitmap ); - - GSM_Error (*SetBitmap) ( GSM_Bitmap *Bitmap ); - - GSM_Error (*SetRingtone) ( GSM_Ringtone *ringtone , int *maxlength); - - GSM_Error (*SetBinRingtone) ( GSM_BinRingtone *ringtone); - - GSM_Error (*GetBinRingtone) ( GSM_BinRingtone *ringtone); - - GSM_Error (*Reset) ( unsigned char type ); - - GSM_Error (*GetProfile) ( GSM_Profile *Profile ); - - GSM_Error (*SetProfile) ( GSM_Profile *Profile ); - - bool (*SendRLPFrame) ( RLP_F96Frame *frame, bool out_dtx ); - - GSM_Error (*CancelCall) (); - - GSM_Error (*PressKey) (int key, int event); - - GSM_Error (*EnableDisplayOutput) (); - - GSM_Error (*DisableDisplayOutput) (); - - GSM_Error (*EnableCellBroadcast) (); - - GSM_Error (*DisableCellBroadcast) (); - - GSM_Error (*ReadCellBroadcast) ( GSM_CBMessage *Message ); - - GSM_Error (*PlayTone) (int Herz, u8 Volume); - - GSM_Error (*GetProductProfileSetting) ( GSM_PPS *PPS); - - GSM_Error (*SetProductProfileSetting) ( GSM_PPS *PPS); - - GSM_Error (*GetOperatorName) ( GSM_Network *operator); - - GSM_Error (*SetOperatorName) ( GSM_Network *operator); - - GSM_Error (*GetVoiceMailbox) ( GSM_PhonebookEntry *entry); - - GSM_Error (*PhoneTests) (); - - GSM_Error (*SimlockInfo) ( GSM_AllSimlocks *siml); - - GSM_Error (*GetCalendarNotesInfo) (GSM_NotesInfo *NotesInfo); - - GSM_Error (*GetSMSFolders) ( GSM_SMSFolders *folders); - - GSM_Error (*ResetPhoneSettings) (); - - GSM_Error (*GetWAPBookmark) ( GSM_WAPBookmark *bookmark); - - GSM_Error (*SetWAPBookmark) ( GSM_WAPBookmark *bookmark); - - GSM_Error (*GetWAPSettings) ( GSM_WAPSettings *settings); - - GSM_Error (*CallDivert) ( GSM_CallDivert *cd ); - - GSM_Error (*AnswerCall) (char s); - - GSM_Error (*GetManufacturer)( char *manufacturer ); - -} GSM_Functions; - -typedef struct { - - /* FIXME: comment this. */ - - GSM_Error (*Initialise)( char *port_device, char *initlength, - GSM_ConnectionType connection, - void (*rlp_callback)(RLP_F96Frame *frame)); - - int (*SendMessage) (u16 message_length, u8 message_type, u8 *buffer); - - int (*SendFrame) (u16 message_length, u8 message_type, u8 *buffer); - - int (*WritePhone) (u16 length, u8 *buffer); - - void (*Terminate)(void); + $Log$ + Revision 1.1.1.6 2002/04/03 00:08:17 short + Found in "gnokii-working" directory, some November-patches version - void (*StateMachine)(unsigned char rx_byte); + Revision 1.14 2001/06/28 00:28:45 pkot + Small docs updates (Pawel Kot) -} GSM_Protocol; -/* This structure is provided to allow common information about the particular - model to be looked up in a model independant way. Some of the values here - define minimum and maximum levels for values retrieved by the various Get - functions for example battery level. They are not defined as constants to - allow model specific code to set them during initialisation */ - -typedef struct { - - char *FBUSModels; /* Models covered by this type, pipe '|' delimited. */ - char *MBUSModels; /* Models covered by this type, pipe '|' delimited. */ - char *InfraredModels; /* Models covered by this type, pipe '|' delimited. */ - char *DLR3Models; /* Models covered by this type, pipe '|' delimited. */ - char *ATModels; /* Models covered by this type, pipe '|' delimited. */ - char *IrdaModels; /* Models covered by this type, pipe '|' delimited. */ - char *TekramModels; /* Models covered by this type, pipe '|' delimited. */ - char *FBUS3110Models; /* Models covered by this type, pipe '|' delimited. */ - -/* Minimum and maximum levels for RF signal strength. Units are as per the - setting of RFLevelUnits. The setting of RFLevelUnits indicates the - default or "native" units used. In the case of the 3110 and 6110 series - these are arbitrary, ranging from 0 to 4. */ - - float MaxRFLevel; - float MinRFLevel; - GSM_RFUnits RFLevelUnits; - -/* Minimum and maximum levels for battery level. Again, units are as per the - setting of GSM_BatteryLevelUnits. The value that BatteryLevelUnits is set - to indicates the "native" or default value that the phone supports. In the - case of the 3110 and 6110 series these are arbitrary, ranging from 0 to 4. */ - - float MaxBatteryLevel; - float MinBatteryLevel; - GSM_BatteryUnits BatteryLevelUnits; - -/* Information about date, time and alarm support. In case of alarm - information we provide value for the number of alarms supported. */ +*/ - GSM_DateTimeSupport DateTimeSupport; - GSM_DateTimeSupport AlarmSupport; - int MaximumAlarms; -} GSM_Information; +#ifndef __gsm_api_h +#define __gsm_api_h -void NULL_Terminate(void); -void NULL_KeepAlive(); -bool NULL_WritePhone (u16 length, u8 *buffer); -void NULL_TX_DisplayMessage(u16 MessageLength, u8 *MessageBuffer); +/* If gsm-common.h isn't included at this point, little in this file will make + sense so we include it here if required. */ -GSM_Error NULL_WaitUntil (int time, GSM_Error *value); -GSM_Error NULL_SendMessageSequence (int time, GSM_Error *value, - u16 message_length, u8 message_type, u8 *buffer); +#ifndef __gsm_common_h + #include "gsm-common.h" +#endif -GSM_ConnectionType GetConnectionTypeFromString(char *Connection); +/* Ditto rlp_common.h... */ +#ifndef __data_rlp_common_h + #include "data/rlp-common.h" +#endif -bool GetMemoryTypeString(char *memorytext, GSM_MemoryType *type); -bool GetMemoryTypeID(char *memorytext, GSM_MemoryType *type); +#include "gsm-statemachine.h" /* Define these as externs so that app code can pick them up. */ extern bool *GSM_LinkOK; extern GSM_Information *GSM_Info; extern GSM_Functions *GSM; -extern GSM_Protocol *Protocol; - -GSM_PhonebookEntry *CurrentPhonebookEntry; -GSM_Error CurrentPhonebookError; - -GSM_SpeedDial *CurrentSpeedDialEntry; -GSM_Error CurrentSpeedDialError; - -unsigned char Current_IMEI[GSM_MAX_IMEI_LENGTH]; -unsigned char Current_Revision[GSM_MAX_REVISION_LENGTH]; -unsigned char Current_Model[GSM_MAX_MODEL_LENGTH]; - -GSM_SMSMessage *CurrentSMSMessage; -GSM_Error CurrentSMSMessageError; -int CurrentSMSPointer; - -GSM_SMSFolders *CurrentSMSFolders; -GSM_Error CurrentSMSFoldersError; -int CurrentSMSFoldersCount; - -GSM_OneSMSFolder CurrentSMSFolder; -GSM_Error CurrentSMSFolderError; -int CurrentSMSFolderID; - -GSM_MemoryStatus *CurrentMemoryStatus; -GSM_Error CurrentMemoryStatusError; - -GSM_NetworkInfo *CurrentNetworkInfo; -GSM_Error CurrentNetworkInfoError; - -GSM_SMSStatus *CurrentSMSStatus; -GSM_Error CurrentSMSStatusError; - -GSM_MessageCenter *CurrentMessageCenter; -GSM_Error CurrentMessageCenterError; - -int *CurrentSecurityCodeStatus; -GSM_Error CurrentSecurityCodeError; -GSM_SecurityCode *CurrentSecurityCode; - -GSM_DateTime *CurrentDateTime; -GSM_Error CurrentDateTimeError; - -GSM_Error CurrentResetPhoneSettingsError; - -GSM_DateTime *CurrentAlarm; -GSM_Error CurrentAlarmError; - -GSM_CalendarNote *CurrentCalendarNote; -GSM_Error CurrentCalendarNoteError; - -GSM_NotesInfo CurrentCalendarNotesInfo,*CurrentCalendarNotesInfo2; -GSM_Error CurrentCalendarNotesInfoError; - -int *CurrentFirstCalendarFreePos; -GSM_Error CurrentFirstCalendarFreePosError; - -GSM_Error CurrentSetDateTimeError; -GSM_Error CurrentSetAlarmError; - -GSM_Error CurrentEnableExtendedCommandsError; - -int CurrentRFLevel, - CurrentBatteryLevel, - CurrentPowerSource; - -int CurrentDisplayStatus; -GSM_Error CurrentDisplayStatusError; - -char *CurrentNetmonitor; -GSM_Error CurrentNetmonitorError; - -GSM_Bitmap *CurrentGetBitmap; -GSM_Error CurrentGetBitmapError; - -GSM_Error CurrentSetBitmapError; - -GSM_Error CurrentSendDTMFError; - -GSM_Profile *CurrentProfile; -GSM_Error CurrentProfileError; - -GSM_Error CurrentDisplayOutputError; - -GSM_CBMessage *CurrentCBMessage; -GSM_Error CurrentCBError; - -int CurrentPressKeyEvent; -GSM_Error CurrentPressKeyError; - -GSM_Error CurrentPlayToneError; - -GSM_Error CurrentDialVoiceError; - -GSM_Error CurrentGetOperatorNameError; -GSM_Network *CurrentGetOperatorNameNetwork; -GSM_Error CurrentSetOperatorNameError; -GSM_Error CurrentGetIMEIError; - -GSM_Error CurrentGetHWError; - -unsigned char CurrentPPS[4]; -GSM_Error CurrentProductProfileSettingsError; - -char CurrentIncomingCall[20]; - -GSM_Error CurrentBinRingtoneError; -GSM_BinRingtone *CurrentGetBinRingtone; - -GSM_Error CurrentRingtoneError; - -GSM_Error CurrentMagicError; - -GSM_Error CurrentSimlockInfoError; -GSM_AllSimlocks *CurrentSimLock; - -GSM_Error CurrentGetWAPBookmarkError; -GSM_Error CurrentSetWAPBookmarkError; -GSM_WAPBookmark *WAPBookmark; - -GSM_Error CurrentGetWAPSettingsError; -GSM_WAPSettings *WAPSettings; - -GSM_Error CurrentCallDivertError; -GSM_CallDivert *CurrentCallDivert; - -char *CurrentManufacturer; - -/* This is the connection type used in gnokii. */ -GSM_ConnectionType CurrentConnectionType; - -/* Pointer to a callback function used to return changes to a calls status */ -/* This saves unreliable polling */ -void (*CurrentCallPassup)(char c); - -/* Pointer to callback function in user code to be called when RLP frames - are received. */ -void (*CurrentRLP_RXCallback)(RLP_F96Frame *frame); - -/* Used to disconnect the call */ -u8 CurrentCallSequenceNumber; - -bool CurrentLinkOK; - -bool CurrentRequestTerminate; - -bool CurrentDisableKeepAlive; +/* Ugly compatibility cludge: */ +extern GSM_Error compat_Phone_Functions(GSM_Operation op, GSM_Data *data, GSM_Statemachine *state); /* Prototype for the functions actually provided by gsm-api.c. */ -GSM_Error GSM_Initialise(char *model, char *device, char *initlength, GSM_ConnectionType connection, void (*rlp_callback)(RLP_F96Frame *frame), char* SynchronizeTime); - -bool CheckModel (GSM_Information InfoToCheck, char *model, GSM_ConnectionType connection); - -char *GetMygnokiiVersion(); - -typedef enum { - F_CAL61=1,/*Calendar in 6110 style - 4 types,...*/ - F_CAL33, /*Calendar in 3310 style - 10 reminders, Unicode, 3 coding types*/ - F_CAL71, /*Calendar in 7110 style - 4 types, recurrance, etc.*/ - - F_PBK33SIM,/*Phonebook in Unicode(3310 style).Name and number.No internal*/ - F_PBK33INT,/*Phonebook in Unicode(3310 style).Name and number.Internal available*/ - F_PBK71INT,/*Extended phonebook-multiple numbers,Unicode(7110 style).Internal available*/ - F_PBK61INT,/*Name and number,no Unicode(6110 style).Internal available*/ - - F_DATA61, /*We can make data calls using gnokiid. Like in 6110*/ - F_DATA71, /*Datacalls using AT commands*/ - - F_SMS, /*SMS with Inbox, Outbox*/ /*10*/ - F_SMS71, /*SMS with SMS folders like in 7110*/ - - F_AUTH, /*We can make authentication and have "Accessory connected" like in 6110*/ - F_NETMON, /*Netmonitor available*/ - F_CALER61,/*Caller groups in 6110 style - 5 groups with members*/ - F_KEYB, /*We can press keys*/ - F_SMSCDEF,/*SMSC can have default recipient*/ - F_SPEED, /*We can handle speed dials*/ - F_SCRSAV, /*We have screen savers*/ - F_DTMF, /*We can handle DTMF sequences*/ - F_NOPOWER,/*We must get power/battery info from netmonitor*/ /*20*/ - - F_STANIM, /*Startup logo animated or static*/ - F_STA , /*Startup logo static*/ - F_STA62 , /*Startup logo static size 6210*/ - F_STA71 , /*Startup logo static size 7110*/ - - F_PROF61, /*Profiles numbered like in N6110*/ - F_PROF51, /*Profiles numbered like in N5110*/ - F_PROF33, /*Profiles numbered like in N3310.Unicode names*/ - - F_RING_SM,/*Binary ringtone in Smart Messaging*/ - F_RINGBIN,/*Binary ringtone in binary format*/ - - F_WAP /*WAP functions available*/ /*30*/ -} feat_index; - -typedef enum { - FN_CALENDAR=0, - FN_NETMONITOR, - FN_CALLERGROUPS, - FN_PHONEBOOK, - FN_AUTHENTICATION, - FN_DATACALLS, - FN_KEYPRESS, - FN_SMSCDEFAULT, - FN_SPEEDDIAL, - FN_SCREENSAVER, - FN_DTMF, /*10*/ - FN_SMS, - FN_NOPOWERFRAME, - FN_STARTUP, - FN_PROFILES, - FN_RINGTONES, - FN_WAP, - FN_RINGNUMBER -} featnum_index; - -/* For models table */ -typedef struct { - char *model; - char *number; - feat_index features[18]; -} OnePhoneModel; - -extern char *GetModelName (); -int GetModelFeature (featnum_index num); - -extern bool AppendLog(u8 *buffer, int length,bool format); -extern bool AppendLogText(u8 *buffer,bool format); - -typedef struct { - int SIMPhonebookUsed; - int SIMPhonebookSize; - GSM_PhonebookEntry SIMPhonebook[250]; - - int PhonePhonebookUsed; - int PhonePhonebookSize; - GSM_PhonebookEntry PhonePhonebook[500]; - - bool CallerAvailable; - GSM_Bitmap CallerGroups[5]; - - bool SpeedAvailable; - GSM_SpeedDial SpeedDials[8]; - - bool OperatorLogoAvailable; - GSM_Bitmap OperatorLogo; - - bool StartupLogoAvailable; - GSM_Bitmap StartupLogo; +extern GSM_Error GSM_Initialise(char *model, char *device, char *initlength, GSM_ConnectionType connection, void (*rlp_handler)(RLP_F96Frame *frame), GSM_Statemachine *sm); - GSM_Bitmap StartupText; -} GSM_Backup; +/* All the rest of the API functions are contained in the GSM_Function + structure which ultimately points into the model specific code. */ #endif /* __gsm_api_h */ diff --git a/include/gsm-bitmaps.h b/include/gsm-bitmaps.h index 9d40713..ebca7a9 100644 --- a/include/gsm-bitmaps.h +++ b/include/gsm-bitmaps.h @@ -1,60 +1,42 @@ /* + $Id$ + G N O K I I A Linux/Unix toolset and driver for Nokia mobile phones. + Copyright (C) 1999, 2000 Hugh Blemings & Pavel Janík ml. + Released under the terms of the GNU GPL, see file COPYING for more details. - Functions for manipulating bitmaps + Functions for common bitmap operations. -*/ + $Log$ + Revision 1.1.1.4 2002/04/03 00:08:17 short + Found in "gnokii-working" directory, some November-patches version + + Revision 1.3 2001/06/28 00:28:45 pkot + Small docs updates (Pawel Kot) -#ifndef __gsm_bitmaps_h -#define __gsm_bitmaps_h - -#include "gsm-sms.h" - -/* Bitmap types. */ -typedef enum { - GSM_None=0, - GSM_StartupLogo, /*size 84*48*/ - GSM_OperatorLogo, /*size 72*14*/ - GSM_CallerLogo, /*size 72*14*/ - GSM_PictureImage, /*size 72*28*/ - GSM_7110OperatorLogo, /*size 78*21*/ - GSM_7110StartupLogo, /*size 96*65*/ - GSM_6210StartupLogo, /*size 96*60*/ - GSM_WelcomeNoteText, - GSM_DealerNoteText -} GSM_Bitmap_Types; - -#define MAX_BITMAP_TEXT_LENGTH 256 - -/* Structure to hold incoming/outgoing bitmaps (and welcome-notes). */ -typedef struct { - u8 height; /* Bitmap height (pixels) */ - u8 width; /* Bitmap width (pixels) */ - u16 size; /* Bitmap size (bytes) */ - GSM_Bitmap_Types type; /* Bitmap type */ - char netcode[7]; /* Network operator code */ - char text[MAX_BITMAP_TEXT_LENGTH]; /* Text used for (dealer) welcome-note - or callergroup name or Picture Image text */ - unsigned char bitmap[864]; /* Actual Bitmap ((65+7)/8*96=864) */ - unsigned char number; /* Caller group number */ - char ringtone; /* Ringtone no sent with caller group */ - bool enabled; /* With caller logos = displayed or not */ - char Sender[GSM_MAX_SENDER_LENGTH+1];/* For Picture Images - number of sender */ -} GSM_Bitmap; + +*/ void GSM_SetPointBitmap(GSM_Bitmap *bmp, int x, int y); void GSM_ClearPointBitmap(GSM_Bitmap *bmp, int x, int y); bool GSM_IsPointBitmap(GSM_Bitmap *bmp, int x, int y); void GSM_ClearBitmap(GSM_Bitmap *bmp); -void GSM_ResizeBitmap(GSM_Bitmap *bitmap, GSM_Bitmap_Types target); +void GSM_ResizeBitmap(GSM_Bitmap *bitmap, GSM_Bitmap_Types target, GSM_Information *info); void GSM_PrintBitmap(GSM_Bitmap *bitmap); -GSM_Error GSM_ReadBitmap(GSM_SMSMessage *message, GSM_Bitmap *bitmap); -int GSM_SaveBitmapToSMS(GSM_MultiSMSMessage *SMS, GSM_Bitmap *bitmap,bool ScreenSaver, bool UnicodeText); -int GSM_GetBitmapSize(GSM_Bitmap *bitmap); -#endif +/* SMS bitmap functions */ + +GSM_Error GSM_ReadSMSBitmap(GSM_SMSMessage *message, GSM_Bitmap *bitmap); +int GSM_SaveSMSBitmap(GSM_SMSMessage *message, GSM_Bitmap *bitmap); + + + + + + + diff --git a/include/gsm-common.h b/include/gsm-common.h index dbbe24a..cca004b 100644 --- a/include/gsm-common.h +++ b/include/gsm-common.h @@ -1,84 +1,191 @@ /* + $Id$ + G N O K I I A Linux/Unix toolset and driver for Nokia mobile phones. + Copyright (C) 1999, 2000 Hugh Blemings & Pavel Janík ml. + Released under the terms of the GNU GPL, see file COPYING for more details. Header file for the definitions, enums etc. that are used by all models of handset. + $Log$ + Revision 1.1.1.9 2002/04/03 00:08:19 short + Found in "gnokii-working" directory, some November-patches version + + Revision 1.80 2001/08/20 23:36:27 pkot + More cleanup in AT code (Manfred Jonsson) + + Revision 1.79 2001/07/27 00:02:22 pkot + Generic AT support for the new structure (Manfred Jonsson) + + Revision 1.78 2001/06/28 00:28:45 pkot + Small docs updates (Pawel Kot) + + */ #ifndef __gsm_common_h #define __gsm_common_h -#include "misc.h" +#include + +#include "gsm-common.h" +#include "data/rlp-common.h" + +/* Type of connection. Now we support serial connection with FBUS cable and + IR (only with 61x0 models) */ + +typedef enum { + GCT_Serial, /* Serial connection. */ + GCT_Infrared, /* Infrared connection. */ + GCT_Tekram, /* Tekram Ir-Dongle */ + GCT_Irda +} GSM_ConnectionType; + +/* Maximum length of device name for serial port */ + +#define GSM_MAX_DEVICE_NAME_LENGTH (100) + +/* Define an enum for specifying memory types for retrieving phonebook + entries, SMS messages etc. This type is not mobile specific - the model + code should take care of translation to mobile specific numbers - see 6110 + code. + 01/07/99: Two letter codes follow GSM 07.07 release 6.2.0 +*/ + +typedef enum { + GMT_ME, /* Internal memory of the mobile equipment */ + GMT_SM, /* SIM card memory */ + GMT_FD, /* Fixed dial numbers */ + GMT_ON, /* Own numbers */ + GMT_EN, /* Emergency numbers */ + GMT_DC, /* Dialled numbers */ + GMT_RC, /* Received numbers */ + GMT_MC, /* Missed numbers */ + GMT_LD, /* Last dialed */ + GMT_MT, /* combined ME and SIM phonebook */ + GMT_TA, /* for compatibility only: TA=computer memory */ + GMT_CB, /* Currently selected memory */ + GMT_XX = 0xff /* Error code for unknown memory type (returned by fbus-xxxx functions). */ +} GSM_MemoryType; + +/* Power source types */ + +typedef enum { + GPS_ACDC=1, /* AC/DC powered (charging) */ + GPS_BATTERY /* Internal battery */ +} GSM_PowerSource; + +/* This data-type is used to specify the type of the number. See the official + GSM specification 03.40, version 5.3.0, section 9.1.2.5, page 33. */ + +typedef enum { + GNT_UNKNOWN=0x81, /* Unknown number */ + GNT_INTERNATIONAL=0x91 /* International number */ +} GSM_NumberType; -#define MYGNOKII /* Maximum length of SMS center name */ + #define GSM_MAX_SMS_CENTER_NAME_LENGTH (20) /* Limits of SMS messages. */ + #define GSM_MAX_SMS_CENTER_LENGTH (40) -#define GSM_MAX_RECIPIENT_LENGTH (40) #define GSM_MAX_SENDER_LENGTH (40) #define GSM_MAX_DESTINATION_LENGTH (40) #define GSM_MAX_SMS_LENGTH (160) -#define GSM_MAX_SMS_8_BIT_LENGTH (140) -#define GSM_MAX_USER_DATA_HEADER_LENGTH (140) +#define GSM_MAX_SMS_8BIT_LENGTH (140) + +#define GSM_MAX_CB_MESSAGE (160) + /* The maximum length of an uncompressed concatenated short message is 255 * 153 = 39015 default alphabet characters */ #define GSM_MAX_CONCATENATED_SMS_LENGTH (39015) -#define GSM_MAX_CB_MESSAGE (160) +/* All the concatenated UDH headers may get long (at least logo+concatenation). + * Theoretically it can be (GSM_MAX_SMS_LENGTH*7/8). + */ +#define GSM_MAX_USER_DATA_HEADER_LENGTH (256) -/* Correct for phones in fbus-6110.c */ -/* For other translation could be required */ -#define PHONEKEY_1 0x01 -#define PHONEKEY_2 0x02 -#define PHONEKEY_3 0x03 -#define PHONEKEY_4 0x04 -#define PHONEKEY_5 0x05 -#define PHONEKEY_6 0x06 -#define PHONEKEY_7 0x07 -#define PHONEKEY_8 0x08 -#define PHONEKEY_9 0x09 -#define PHONEKEY_0 0x0a -#define PHONEKEY_HASH 0x0b /* # */ -#define PHONEKEY_ASTERISK 0x0c /* * */ -#define PHONEKEY_POWER 0x0d -#define PHONEKEY_INCREASEVOLUME 0x10 /* doesn't available in some phones as separate button: ie. N5110 */ -#define PHONEKEY_DECREASEVOLUME 0x11 /* doesn't available in some phones as separate button: ie. N5110 */ -#define PHONEKEY_UP 0x17 -#define PHONEKEY_DOWN 0x18 -#define PHONEKEY_MENU 0x19 -#define PHONEKEY_NAMES 0x1a /* doesn't available in some phone: ie. N5110 */ -#define PHONEKEY_GREEN 0x0e /* in some phone ie. N5110 sometimes works identical to POWER */ -#define PHONEKEY_RED 0x0f /* (c) key in some phone: ie. N5110 */ - -/* Correct for phones in fbus-6110.c */ -/* For other translation could be required */ -#define PRESSPHONEKEY 0x01 -#define RELEASEPHONEKEY 0x02 +/* types of User Data Header */ +typedef enum { + GSM_NoUDH, + GSM_ConcatenatedMessages, + GSM_OpLogo, + GSM_CallerIDLogo, + GSM_RingtoneUDH +} GSM_UDH; -/* Limits for IMEI, Revision and Model string storage. */ -#define GSM_MAX_IMEI_LENGTH (20) -#define GSM_MAX_REVISION_LENGTH (20) -#define GSM_MAX_MODEL_LENGTH (10) +/* Define datatype for SMS Message Type */ -/* In 6210 test 57 there seems to be 75 chars */ -#define NM_MAX_SCREEN_WIDTH 75 +typedef enum { + GST_MO, /* Mobile Originated (MO) message - Outbox message */ + GST_MT, /* Mobile Terminated (MT) message - Inbox message */ + GST_DR, /* Delivery Report */ + GST_UN /* Unknown */ +} GSM_SMSMessageType; + +/* Datatype for SMS status */ +/* FIXME - This needs to be made clearer and or turned into a + bitfield to allow compound values (read | sent etc.) */ -/* Power source types */ typedef enum { - GPS_ACDC=1, /* AC/DC powered (charging) */ - GPS_BATTERY /* Internal battery */ -} GSM_PowerSource; + GSS_SENTREAD = true, /* Sent or read message */ + GSS_NOTSENTREAD = false /* Not sent or not read message */ +} GSM_SMSMessageStatus; + +/* SMS Messages sent as... */ + +typedef enum { + GSMF_Text = 0x00, /* Plain text message. */ + GSMF_Fax = 0x22, /* Fax message. */ + GSMF_Voice = 0x24, /* Voice mail message. */ + GSMF_ERMES = 0x25, /* ERMES message. */ + GSMF_Paging = 0x26, /* Paging. */ + GSMF_UCI = 0x2d, /* Email message in 8110i. */ + GSMF_Email = 0x32, /* Email message. */ + GSMF_X400 = 0x31 /* X.400 message. */ +} GSM_SMSMessageFormat; + +/* Validity of SMS Messages. */ + +typedef enum { + GSMV_1_Hour = 0x0b, + GSMV_6_Hours = 0x47, + GSMV_24_Hours = 0xa7, + GSMV_72_Hours = 0xa9, + GSMV_1_Week = 0xad, + GSMV_Max_Time = 0xff +} GSM_SMSMessageValidity; + +/* Define datatype for SMS Message Center */ + +typedef struct { + int No; /* Number of the SMSC in the phone memory. */ + char Name[GSM_MAX_SMS_CENTER_NAME_LENGTH]; /* Name of the SMSC. */ + GSM_SMSMessageFormat Format; /* SMS is sent as text/fax/paging/email. */ + GSM_SMSMessageValidity Validity; /* Validity of SMS Message. */ + char Number[GSM_MAX_SMS_CENTER_LENGTH]; /* Number of the SMSC. */ + char Recipient[GSM_MAX_SMS_CENTER_LENGTH]; /* Number of the default recipient. */ +} GSM_MessageCenter; + +/* Define datatype for Cell Broadcast message */ +typedef struct { + int Channel; /* channel number */ + char Message[GSM_MAX_CB_MESSAGE + 1]; + int New; +} GSM_CBMessage; + + /* Definition of security codes. */ + typedef enum { GSCT_SecurityCode = 0x01, /* Security code. */ GSCT_Pin, /* PIN. */ @@ -89,183 +196,253 @@ typedef enum { } GSM_SecurityCodeType; /* Security code definition. */ + typedef struct { GSM_SecurityCodeType Type; /* Type of the code. */ char Code[10]; /* Actual code. */ } GSM_SecurityCode; -/* Define an enum for specifying memory types for retrieving phonebook - entries, SMS messages etc. This type is not mobile specific - the model - code should take care of translation to mobile specific numbers - see 6110 - code. - 01/07/99: Two letter codes follow GSM 07.07 release 6.2.0 -*/ -typedef enum { - GMT_ME, /* Internal memory of the mobile equipment */ - GMT_SM, /* SIM card memory */ - GMT_FD, /* Fixed dial numbers */ - GMT_ON, /* Own numbers */ - GMT_EN, /* Emergency numbers */ - GMT_DC, /* Dialled numbers */ - GMT_RC, /* Received numbers */ - GMT_MC, /* Missed numbers */ - GMT_LD, /* Last dialed */ - GMT_MT, /* combined ME and SIM phonebook */ - GMT_TA, /* for compatibility only: TA=computer memory */ - GMT_CB, /* Currently selected memory */ - GMT_CG, /* Caller groups */ - GMT_XX = 0xff /* Error code for unknown memory type (returned by fbus-xxxx functions. */ -} GSM_MemoryType; +/* Structure used for passing dates/times to date/time functions such as + GSM_GetTime and GSM_GetAlarm etc. */ -/* This define speed dialing entries. */ typedef struct { - int Number; /* Which number is used to dialing? */ - GSM_MemoryType MemoryType; /* Memory type of the number. */ - int Location; /* Location of the number in MemoryType. */ -} GSM_SpeedDial; + bool AlarmEnabled; /* Is the alarm set? */ + int Year; /* The complete year specification - e.g. 1999. Y2K :-) */ + int Month; /* January = 1 */ + int Day; + int Hour; + int Minute; + int Second; + int Timezone; /* The difference between local time and GMT, FIXME: WHICH UNITS? --- FIX THE CODE! */ +} GSM_DateTime; + +/* Define datatype for SMS messages, used for getting SMS messages from the + phones memory. */ -/* Define enums for Battery units. */ -typedef enum { - GBU_Arbitrary, - GBU_Volts, - GBU_Minutes, - GBU_Percentage -} GSM_BatteryUnits; +typedef struct { + GSM_DateTime Time; /* Date of reception/response of messages. */ + GSM_DateTime SMSCTime; /* Date of SMSC response if DeliveryReport messages. */ + int Validity; /* Validity Period of the SMS message (unit is minutes). */ + bool UDHPresent; /* If UDH is present */ + unsigned char UDH[GSM_MAX_USER_DATA_HEADER_LENGTH]; /* If UDH is present - content of UDH, UDH[0] specifies length */ + char MessageText[GSM_MAX_SMS_LENGTH + 1]; /* (+1) is room for null term, sized by GSM_SMSMessage.MessageTextLength + * GSM_SMSMessage.EightBit==false => MessageText is also '\0'-terminated + */ + int MessageTextLength; /* Unit is determined by GSM_SMSMessage.EightBit */ + GSM_MessageCenter MessageCenter; /* SMS Center. */ + char Sender[GSM_MAX_SENDER_LENGTH + 1]; /* Sender of the SMS message. */ + char Destination[GSM_MAX_DESTINATION_LENGTH + 1]; /* Destination of the message. */ + int MessageNumber; /* Location in the memory (output argument). */ + GSM_MemoryType MemoryType; /* Type of memory message is stored in. */ + GSM_SMSMessageType Type; /* Type of the SMS message */ + GSM_SMSMessageStatus Status; /* Status of the SMS message */ + int Class; /* Class Message: 0, 1, 2, 3 or none (value -1 !); see GSM 03.38 */ + bool EightBit; /* Indicates whether SMS contains 8 bit data */ + bool Compression; /* Indicates whether SMS contains compressed data */ + int Location; /* Location in the memory (input argument). */ + bool ReplyViaSameSMSC; /* Indicates whether "Reply via same center" is set */ +} GSM_SMSMessage; + +/* This structure is used to get the current network status */ -/* This enum is used for display status. */ +typedef struct { + char NetworkCode[10]; /* GSM network code */ + char CellID[10]; /* CellID */ + char LAC[10]; /* LAC */ +} GSM_NetworkInfo; -typedef enum { - DS_Call_In_Progress, /* Call in progress. */ - DS_Unknown, /* The meaning is unknown now :-( */ - DS_Unread_SMS, /* There is Unread SMS. */ - DS_Voice_Call, /* Voice call active. */ - DS_Fax_Call, /* Fax call active. */ - DS_Data_Call, /* Data call active. */ - DS_Keyboard_Lock, /* Keyboard lock status. */ - DS_SMS_Storage_Full /* Full SMS Memory. */ -} DisplayStatusEntity; +/* Limits for sizing of array in GSM_PhonebookEntry. Individual handsets may + not support these lengths so they have their own limits set. */ -/* Constants for Profiles. */ - -#define PROFILE_MESSAGE_NOTONE 0x00 -#define PROFILE_MESSAGE_STANDARD 0x01 -#define PROFILE_MESSAGE_SPECIAL 0x02 -#define PROFILE_MESSAGE_BEEPONCE 0x03 -#define PROFILE_MESSAGE_ASCENDING 0x04 - -#define PROFILE_WARNING_OFF 0xff -#define PROFILE_WARNING_ON 0x04 - -#define PROFILE_CALLALERT_RINGING 0x01 -#define PROFILE_CALLALERT_BEEPONCE 0x02 -#define PROFILE_CALLALERT_OFF 0x04 -#define PROFILE_CALLALERT_RINGONCE 0x05 -#define PROFILE_CALLALERT_ASCENDING 0x06 -#define PROFILE_CALLALERT_CALLERGROUPS 0x07 - -#define PROFILE_KEYPAD_OFF 0xff -#define PROFILE_KEYPAD_LEVEL1 0x00 -#define PROFILE_KEYPAD_LEVEL2 0x01 -#define PROFILE_KEYPAD_LEVEL3 0x02 -//in 5110 I had also once 0x03 - -#define PROFILE_VOLUME_LEVEL1 0x06 -#define PROFILE_VOLUME_LEVEL2 0x07 -#define PROFILE_VOLUME_LEVEL3 0x08 -#define PROFILE_VOLUME_LEVEL4 0x09 -#define PROFILE_VOLUME_LEVEL5 0x0a - -#define PROFILE_CALLERGROUPS_ALL 0xff -#define PROFILE_CALLERGROUPS_FAMILY 0x01 -#define PROFILE_CALLERGROUPS_VIP 0x02 -#define PROFILE_CALLERGROUPS_FRIENDS 0x04 -#define PROFILE_CALLERGROUPS_COLLEAGUES 0x08 -#define PROFILE_CALLERGROUPS_OTHERS 0x10 - -#define PROFILE_VIBRATION_OFF 0x00 -#define PROFILE_VIBRATION_ON 0x01 -#define PROFILE_VIBRATION_FIRST 0x02 +#define GSM_MAX_PHONEBOOK_NAME_LENGTH (50) /* For 7110 */ +#define GSM_MAX_PHONEBOOK_NUMBER_LENGTH (48) /* For 7110 */ +#define GSM_MAX_PHONEBOOK_TEXT_LENGTH (60) /* For 7110 */ +#define GSM_MAX_PHONEBOOK_SUB_ENTRIES (8) /* For 7110 */ + /* 7110 is able to in one + * entry 5 numbers and 2 + * texts [email,notice,postal] */ -/* Structure to hold profile entries. */ +/* Here is a macro for models that do not support caller groups. */ + +#define GSM_GROUPS_NOT_SUPPORTED -1 + +/* This data type is used to report the number of used and free positions in + memory (sim or internal). */ typedef struct { - int Number; /* The number of the profile. */ - char Name[40]; /* The name of the profile. */ - int DefaultName; /* 0-6, when default name is used, -1, when not */ - int KeypadTone; /* Volumen level for keypad tones. */ - int Lights; /* Lights on/off. */ - int CallAlert; /* Incoming call alert. */ - int Ringtone; /* Ringtone for incoming call alert. */ - int Volume; /* Volume of the ringing. */ - int MessageTone; /* The tone for message indication. */ - int WarningTone; /* The tone for warning messages. */ - int Vibration; /* Vibration? */ - int CallerGroups; /* CallerGroups. */ - int ScreenSaver; /* ScreenSaver */ - int AutomaticAnswer; /* Does the phone auto-answer incoming call? */ -} GSM_Profile; + GSM_MemoryType MemoryType; /* Type of the memory */ + int Used; /* Number of used positions */ + int Free; /* Number of free positions */ +} GSM_MemoryStatus; -typedef enum { - PPS_ALS=0, - PPS_HRData, - PPS_14400Data, - PPS_LCDContrast, - PPS_EFR, - PPS_FR, - PPS_HR, - PPS_GamesMenu, /* N3210 5.26 and higher */ - PPS_VibraMenu /* N3210 */ -} GSM_PPS_Settings; +/* This data type is used to hold the current SMS status. */ typedef struct { - GSM_PPS_Settings Name; - bool bool_value; - int int_value; -} GSM_PPS; + int UnRead; /* The number of unread messages (currently not used) */ + int Used; /* The number of currently stored messages */ + int Slots; /* Reading will try all 1..Slots locations */ +} GSM_SMSStatus; + + + +/* Some phones (at the moment 6210/7110) supports extended phonebook + with additional data. Here we have structures for them */ + +typedef enum +{ + GSM_General = 0x0a, + GSM_Mobile = 0x03, + GSM_Work = 0x06, + GSM_Fax = 0x04, + GSM_Home = 0x02 +} GSM_Number_Type; + +typedef enum +{ + GSM_Number = 0x0b, + GSM_Note = 0x0a, + GSM_Postal = 0x09, + GSM_Email = 0x08, + GSM_Name = 0x07, + GSM_Date = 0x13 /* Date is used for DC,RC,etc (last calls) */ +} GSM_EntryType; typedef struct { - char data[10+1];//detailed info about this simlock - bool enabled; //is enabled or not ? - int counter; //how many times user tried to disable simlock using keypad - bool factory; //is factory simlock ? -} GSM_OneSimlock; + GSM_EntryType EntryType; + GSM_Number_Type NumberType; + union { + char Number[GSM_MAX_PHONEBOOK_TEXT_LENGTH + 1]; /* Number */ + GSM_DateTime Date; /* or the last calls list */ + } data; + int BlockNumber; +} GSM_SubPhonebookEntry; + +/* Define datatype for phonebook entry, used for getting/writing phonebook + entries. */ + +typedef struct { + bool Empty; /* Is this entry empty? */ + char Name[GSM_MAX_PHONEBOOK_NAME_LENGTH + 1]; /* Plus 1 for + nullterminator. */ + char Number[GSM_MAX_PHONEBOOK_NUMBER_LENGTH + 1]; /* Number */ + GSM_MemoryType MemoryType; /* Type of memory */ + int Group; /* Group */ + int Location; /* Location */ + GSM_DateTime Date; /* The record date and time + of the number. */ + GSM_SubPhonebookEntry SubEntries[GSM_MAX_PHONEBOOK_SUB_ENTRIES]; + /* For phones with + * additional phonebook + * entries */ + int SubEntriesCount; /* Should be 0, if extended + phonebook is not used */ +} GSM_PhonebookEntry; + + + +/* This define speed dialing entries. */ typedef struct { - GSM_OneSimlock simlocks[4]; -} GSM_AllSimlocks; + int Number; /* Which number is used to dialing? */ + GSM_MemoryType MemoryType; /* Memory type of the number. */ + int Location; /* Location of the number in MemoryType. */ +} GSM_SpeedDial; + +/* Define enum used to describe what sort of date/time support is + available. */ + +typedef enum { + GDT_None, /* The mobile phone doesn't support time and date. */ + GDT_TimeOnly, /* The mobile phone supports only time. */ + GDT_DateOnly, /* The mobile phone supports only date. */ + GDT_DateTime /* Wonderful phone - it supports date and time. */ +} GSM_DateTimeSupport; + +/* Define enums for RF units. GRF_CSQ asks for units in form used + in AT+CSQ command as defined by GSM 07.07 */ -/* Data structures for the call divert */ typedef enum { - GSM_CDV_Busy = 0x01, /* Divert when busy */ - GSM_CDV_NoAnswer, /* Divert when not answered */ - GSM_CDV_OutOfReach, /* Divert when phone off or no coverage */ - GSM_CDV_AllTypes /* Divert all calls without ringing */ -} GSM_CDV_DivertTypes; + GRF_Arbitrary, + GRF_dBm, + GRF_mV, + GRF_uV, + GRF_CSQ, + GRF_Percentage +} GSM_RFUnits; + +/* Define enums for Battery units. */ typedef enum { - GSM_CDV_VoiceCalls = 0x01, - GSM_CDV_FaxCalls, - GSM_CDV_DataCalls, - GSM_CDV_AllCalls -} GSM_CDV_CallTypes; + GBU_Arbitrary, + GBU_Volts, + GBU_Minutes, + GBU_Percentage +} GSM_BatteryUnits; + +/* Define enums for Calendar Note types */ -/* See GSM 02.82 for diverts types */ typedef enum { - GSM_CDV_Disable = 0x00, - GSM_CDV_Enable = 0x01, - GSM_CDV_Query = 0x02, /* Is concrete divert enabled ? */ - GSM_CDV_Register = 0x03, /* Sets divert */ - GSM_CDV_Erasure = 0x04 /* Erase concrete divert */ -} GSM_CDV_Opers; + GCN_REMINDER=1, /* Reminder */ + GCN_CALL, /* Call */ + GCN_MEETING, /* Meeting */ + GCN_BIRTHDAY /* Birthday */ +} GSM_CalendarNoteType; + +/* Calendar note type */ typedef struct { - GSM_CDV_DivertTypes DType; - GSM_CDV_CallTypes CType; - GSM_CDV_Opers Operation; - char Number[GSM_MAX_SENDER_LENGTH + 1]; - unsigned int Timeout; - bool Enabled; -} GSM_CallDivert; + int Location; /* The number of the note in the phone memory */ + GSM_CalendarNoteType Type; /* The type of the note */ + GSM_DateTime Time; /* The time of the note */ + GSM_DateTime Alarm; /* The alarm of the note */ + char Text[20]; /* The text of the note */ + char Phone[20]; /* For Call only: the phone number */ + double Recurance; /* Recurance of the note */ +} GSM_CalendarNote; + +/* This structure is provided to allow common information about the particular + model to be looked up in a model independant way. Some of the values here + define minimum and maximum levels for values retrieved by the various Get + functions for example battery level. They are not defined as constants to + allow model specific code to set them during initialisation */ + +typedef struct { + + char *Models; /* Models covered by this type, pipe '|' delimited. */ + +/* Minimum and maximum levels for RF signal strength. Units are as per the + setting of RFLevelUnits. The setting of RFLevelUnits indicates the + default or "native" units used. In the case of the 3110 and 6110 series + these are arbitrary, ranging from 0 to 4. */ + + float MaxRFLevel; + float MinRFLevel; + GSM_RFUnits RFLevelUnits; + +/* Minimum and maximum levels for battery level. Again, units are as per the + setting of GSM_BatteryLevelUnits. The value that BatteryLevelUnits is set + to indicates the "native" or default value that the phone supports. In the + case of the 3110 and 6110 series these are arbitrary, ranging from 0 to 4. */ + + float MaxBatteryLevel; + float MinBatteryLevel; + GSM_BatteryUnits BatteryLevelUnits; + +/* FIXME: some very similar code is in common/misc.c */ + +/* Information about date, time and alarm support. In case of alarm + information we provide value for the number of alarms supported. */ + + GSM_DateTimeSupport DateTimeSupport; + GSM_DateTimeSupport AlarmSupport; + int MaximumAlarms; + u8 StartupLogoH; /* Logo Widths and Heights - if supported */ + u8 StartupLogoW; + u8 OpLogoH; + u8 OpLogoW; + u8 CallerLogoH; + u8 CallerLogoW; +} GSM_Information; /* Define standard GSM error/return code values. These codes are also used for some internal functions such as SIM read/write in the model specific code. */ @@ -274,14 +451,13 @@ typedef enum { GE_NONE = 0, /* No error. */ GE_DEVICEOPENFAILED, /* Couldn't open specified serial device. */ GE_UNKNOWNMODEL, /* Model specified isn't known/supported. */ - GE_NOTSUPPORTED, /* We are sure, that function not supported by phone model */ GE_NOLINK, /* Couldn't establish link with phone. */ GE_TIMEOUT, /* Command timed out. */ GE_TRYAGAIN, /* Try again. */ GE_INVALIDSECURITYCODE, /* Invalid Security code. */ GE_NOTIMPLEMENTED, /* Command called isn't implemented in model. */ GE_INVALIDSMSLOCATION, /* Invalid SMS location. */ - GE_INVALIDPHBOOKLOCATION, /* Invalid phonebook location. */ /*10*/ + GE_INVALIDPHBOOKLOCATION, /* Invalid phonebook location. */ GE_INVALIDMEMORYTYPE, /* Invalid type of memory. */ GE_INVALIDSPEEDDIALLOCATION, /* Invalid speed dial location. */ GE_INVALIDCALNOTELOCATION,/* Invalid calendar note location. */ @@ -291,7 +467,7 @@ typedef enum { GE_PHBOOKNUMBERTOOLONG, /* Phonebook number is too long. */ GE_PHBOOKWRITEFAILED, /* Phonebook write failed. */ GE_SMSSENDOK, /* SMS was send correctly. */ - GE_SMSSENDFAILED, /* SMS send fail. */ /*20*/ + GE_SMSSENDFAILED, /* SMS send fail. */ GE_SMSWAITING, /* Waiting for the next part of SMS. */ GE_SMSTOOLONG, /* SMS message too long. */ GE_NONEWCBRECEIVED, /* Attempt to read CB when no new CB received */ @@ -301,28 +477,512 @@ typedef enum { GE_WRONGCOLORS, /* Wrong colors in bitmap file */ GE_INVALIDFILEFORMAT, /* Invalid format of file */ GE_SUBFORMATNOTSUPPORTED, /* Subformat of file not supported */ - GE_TOOSHORT, /* Too short file, structure, etc. to read */ /*30*/ - GE_TOOLONG, /* Too long file, structure, etc. to read */ - GE_INVALIDIMAGESIZE, /* Invalid size of bitmap (in file, etc.) */ + GE_FILETOOSHORT, /* Too short file to read */ + GE_FILETOOLONG, /* Too long file to read */ + GE_INVALIDIMAGESIZE, /* Invalid size of bitmap (in file, sms etc.) */ + GE_NOTSUPPORTED, /* Function not supported by the phone */ GE_BUSY, /* Command is still being executed. */ - GE_UNKNOWN, /* Unknown error - well better than nothing!! */ /*34*/ - GE_NOACCESS, GE_USERCANCELED, + GE_UNKNOWN, /* Unknown error - well better than nothing!! */ GE_MEMORYFULL, - GE_INVALIDRINGLOCATION, - GE_INSIDEBOOKMARKSMENU, - GE_INVALIDBOOKMARKLOCATION, - GE_INSIDESETTINGSMENU, - GE_INVALIDSETTINGSLOCATION, - GE_EMPTYSMSC, - + GE_NOTWAITING, /* Not waiting for a response from the phone */ + GE_NOTREADY, + /* The following are here in anticipation of data call requirements. */ GE_LINEBUSY, /* Outgoing call requested reported line busy */ - GE_NOCARRIER, /* No Carrier error during data call setup ? */ - GE_SMSSAVEFAILED, /* save sms failed */ - GE_SMSISINMEM, /* sms is already in memory */ - GE_BUSYSMSLOCATION /* there is a sms at the requested sms location */ + GE_NOCARRIER /* No Carrier error during data call setup ? */ } GSM_Error; + +/* This enum is used for display status. */ + +typedef enum { + DS_Call_In_Progress, /* Call in progress. */ + DS_Unknown, /* The meaning is unknown now :-( */ + DS_Unread_SMS, /* There is Unread SMS. */ + DS_Voice_Call, /* Voice call active. */ + DS_Fax_Call, /* Fax call active. */ + DS_Data_Call, /* Data call active. */ + DS_Keyboard_Lock, /* Keyboard lock status. */ + DS_SMS_Storage_Full /* Full SMS Memory. */ +} DisplayStatusEntity; + +/* Bitmap types. */ + +typedef enum { + GSM_None=0, + GSM_StartupLogo, + GSM_OperatorLogo, + GSM_CallerLogo, + GSM_PictureImage, + GSM_WelcomeNoteText, + GSM_DealerNoteText +} GSM_Bitmap_Types; + +#define GSM_MAX_BITMAP_SIZE 864 + +/* Structure to hold incoming/outgoing bitmaps (and welcome-notes). */ + +typedef struct { + u8 height; /* Bitmap height (pixels) */ + u8 width; /* Bitmap width (pixels) */ + u16 size; /* Bitmap size (bytes) */ + GSM_Bitmap_Types type; /* Bitmap type */ + char netcode[7]; /* Network operator code */ + char text[256]; /* Text used for welcome-note or callergroup name */ + char dealertext[256]; /* Text used for dealer welcome-note */ + bool dealerset; /* Is dealer welcome-note set now ? */ + unsigned char bitmap[GSM_MAX_BITMAP_SIZE]; /* Actual Bitmap */ + char number; /* Caller group number */ + char ringtone; /* Ringtone no sent with caller group */ +} GSM_Bitmap; + + +/* NoteValue is encoded as octave(scale)*14 + note */ +/* where for note: c=0, d=2, e=4 .... */ +/* ie. c#=1 and 5 and 13 are invalid */ +/* note=255 means a pause */ + +#define MAX_RINGTONE_NOTES 256 + +/* Structure to hold note of ringtone. */ + +typedef struct { + u8 duration; + u8 note; +} GSM_RingtoneNote; + +/* Structure to hold ringtones. */ + +typedef struct { + char name[20]; + u8 tempo; + u8 NrNotes; + GSM_RingtoneNote notes[MAX_RINGTONE_NOTES]; +} GSM_Ringtone; + +/* Structure to hold profile entries. */ + +typedef struct { + int Number; /* The number of the profile. */ + char Name[40]; /* The name of the profile. */ + int DefaultName; /* 0-6, when default name is used, -1, when not. */ + int KeypadTone; /* Volume level for keypad tones. */ + int Lights; /* Lights on/off. */ + int CallAlert; /* Incoming call alert. */ + int Ringtone; /* Ringtone for incoming call alert. */ + int Volume; /* Volume of the ringing. */ + int MessageTone; /* The tone for message indication. */ + int WarningTone; /* The tone for warning messages. */ + int Vibration; /* Vibration? */ + int CallerGroups; /* CallerGroups. */ + int AutomaticAnswer; /* Does the phone auto-answer incoming call? */ +} GSM_Profile; + + +#define FO_SUBMIT 0x01 +#define FO_RD 0x40 +#define FO_VPF_NONE 0x00 +#define FO_VPF_REL 0x10 +#define FO_VPF_ABS 0x18 +#define FO_VPF_ENH 0x08 +#define FO_SRR 0x20 +#define FO_UDHI 0x40 +#define FO_RP 0x80 +#define FO_DEFAULT (FO_SUBMIT | FO_VPF_REL | FO_SRR) + +#define PID_DEFAULT 0x00 +#define PID_TYPE0 0x40 +#define PID_REPLACE1 0x41 +#define PID_REPLACE2 0x42 +#define PID_REPLACE3 0x43 +#define PID_REPLACE4 0x44 +#define PID_REPLACE5 0x45 +#define PID_REPLACE6 0x46 +#define PID_REPLACE7 0x47 +#define PID_RETURN_CALL 0x5f + +#define DCS_DEFAULT 0x00 +#define DCS_MSG_WAIT_VOICE_DISCARD 0xc8 +#define DCS_MSG_WAIT_VOICE_OFF 0xc0 +#define DCS_MSG_WAIT_VOICE_STORE 0xd8 +#define DCS_DATA 0xf4 +#define DCS_CLASS0 0xf0 +#define DCS_CLASS1 0xf1 +#define DCS_CLASS2 0xf2 +#define DCS_CLASS3 0xf3 + +/* Limits for IMEI, Revision and Model string storage. */ + +#define GSM_MAX_IMEI_LENGTH (20) +#define GSM_MAX_REVISION_LENGTH (16) +#define GSM_MAX_MODEL_LENGTH (64) +#define GSM_MAX_MANUFACTURER_LENGTH (36) + + + +/* This is a generic holder for high level information - eg a GSM_Bitmap */ + +typedef struct { + GSM_SMSMessage *SMSMessage; + GSM_PhonebookEntry *PhonebookEntry; + GSM_SpeedDial *SpeedDial; + GSM_MemoryStatus *MemoryStatus; + GSM_SMSStatus *SMSStatus; + GSM_MessageCenter *MessageCenter; + char *Imei; + char *Revision; + char *Model; + char *Manufacturer; + GSM_NetworkInfo *NetworkInfo; + GSM_CalendarNote *CalendarNote; + GSM_Bitmap *Bitmap; + char *BitmapDest; + GSM_Ringtone *Ringtone; + char *RingtoneDest; + GSM_Profile *Profile; + GSM_BatteryUnits *BatteryUnits; + float *BatteryLevel; + GSM_RFUnits *RFUnits; + float *RFLevel; + GSM_Error (*OutputFn)(char *Display, char *Indicators); + char *IncomingCallNr; + GSM_PowerSource *PowerSource; + GSM_SecurityCode *SecurityCode; + GSM_SecurityCodeType *SecurityCodeStatus; + GSM_DateTime *DateTime; + int *AlarmNumber; + GSM_DateTime *AlarmDateTime; + char *VoiceNumber; + char *DataNumber; + char *DataType; + void (*DataCallPassUp)(char c); + unsigned char *NetMonitorMode; + char *NetMonitorScreen; + char *DTMF; + char *ResetType; + RLP_F96Frame *RLPFrame; + bool *RLPFrame_out_dtx; + GSM_CBMessage *CBMessage; + int *SetKeyKey; + int *SetKeyUp; + char *HandleString; + char *CallNo; + int *DisplayStatus; +} GSM_Data; + + +/* Global structures intended to be independant of phone etc */ +/* Obviously currently rather Nokia biased but I think most things */ +/* (eg at commands) can be enumerated */ + + +/* A structure to hold information about the particular link */ +/* The link comes 'under' the phone */ +typedef struct { + char PortDevice[20]; /* The port device */ + int InitLength; /* Number of chars sent to sync the serial port */ + GSM_ConnectionType ConnectionType; /* Connection type, serial, ir etc */ + + /* A regularly called loop function */ + /* timeout can be used to make the function block or not */ + GSM_Error (*Loop)(struct timeval *timeout); + + /* A pointer to the function used to send out a message */ + /* This is used by the phone specific code to send a message over the link */ + GSM_Error (*SendMessage)(u16 messagesize, u8 messagetype, void *message); + +} GSM_Link; + + +/* Small structure used in GSM_Phone */ +/* Messagetype is passed to the function in case it is a 'generic' one */ +typedef struct { + u8 MessageType; + GSM_Error (*Functions)(int messagetype, unsigned char *buffer, int length, GSM_Data *data); +} GSM_IncomingFunctionType; + +typedef enum { + GOP_Init, + GOP_Terminate, + GOP_GetModel, + GOP_GetRevision, + GOP_GetImei, + GOP_GetManufacturer, + GOP_Identify, + GOP_GetBitmap, + GOP_SetBitmap, + GOP_SetRingtone, + GOP_GetBatteryLevel, + GOP_GetRFLevel, + GOP_DisplayOutput, + GOP_GetMemoryStatus, + GOP_ReadPhonebook, + GOP_WritePhonebook, + GOP_GetPowersource, + GOP_GetDisplayStatus, + GOP_EnterSecurityCode, + GOP_GetSecurityCodeStatus, + GOP_GetAlarm, + GOP_SetAlarm, + GOP_DialVoice, + GOP_DialData, + GOP_GetSMSStatus, + GOP_SetSMSStatus, + GOP_GetIncomingCallNr, + GOP_GetNetworkInfo, + GOP_GetSMS, + GOP_DeleteSMS, + GOP_SendSMS, + GOP_SaveSMS, + GOP_GetSpeedDial, + GOP_SetSpeedDial, + GOP_GetSMSCenter, + GOP_SetSMSCenter, + GOP_GetDateTime, + GOP_SetDateTime, + GOP_GetCalendarNote, + GOP_WriteCalendarNote, + GOP_DeleteCalendarNote, + GOP_NetMonitor, + GOP_SendDTMF, + GOP_Reset, + GOP_GetProfile, + GOP_SetProfile, + GOP_SendRLPFrame, + GOP_CancelCall, + GOP_EnableDisplayOutput, + GOP_DisableDisplayOutput, + GOP_EnableCellBroadcast, + GOP_DisableCellBroadcast, + GOP_ReadCellBroadcast, + GOP_SetKey, + GOP_HandleString, + GOP_AnswerCall, + GOP_Max /* don't append anything after this entry */ +} GSM_Operation; + +/* This structure contains the 'callups' needed by the statemachine */ +/* to deal with messages from the phone and other information */ + +typedef struct _GSM_Statemachine GSM_Statemachine; + +typedef struct { + /* These make up a list of functions, one for each message type and NULL terminated */ + GSM_IncomingFunctionType *IncomingFunctions; + GSM_Error (*DefaultFunction)(int messagetype, unsigned char *buffer, int length); + GSM_Information Info; + GSM_Error (*Functions)(GSM_Operation op, GSM_Data *data, GSM_Statemachine *state); +} GSM_Phone; + + +/* The states the statemachine can take */ + +typedef enum { + Startup, /* Not yet initialised */ + Initialised, /* Ready! */ + MessageSent, /* A command has been sent to the link(phone) */ + WaitingForResponse, /* We are waiting for a response from the link(phone) */ + ResponseReceived /* A response has been received - waiting for the phone layer to collect it */ +} GSM_State; + +/* How many message types we can wait for at one */ +#define SM_MAXWAITINGFOR 3 + + +/* All properties of the state machine */ + +struct _GSM_Statemachine{ + GSM_State CurrentState; + GSM_Link Link; + GSM_Phone Phone; + + /* Store last message for resend purposes */ + u8 LastMsgType; + u16 LastMsgSize; + void *LastMsg; + + /* The responses we are waiting for */ + unsigned char NumWaitingFor; + unsigned char NumReceived; + unsigned char WaitingFor[SM_MAXWAITINGFOR]; + GSM_Error ResponseError[SM_MAXWAITINGFOR]; + /* Data structure to be filled in with the response */ + GSM_Data *Data[SM_MAXWAITINGFOR]; +}; + + + +/* Define the structure used to hold pointers to the various API functions. + This is in effect the master list of functions provided by the gnokii API. + Modules containing the model specific code each contain one of these + structures which is "filled in" with the corresponding function within the + model specific code. If a function is not supported or not implemented, a + generic not implemented function is used to return a GE_NOTIMPLEMENTED + error code. */ + +typedef struct { + + /* FIXME: comment this. */ + + GSM_Error (*Initialise)( char *port_device, char *initlength, + GSM_ConnectionType connection, + void (*rlp_callback)(RLP_F96Frame *frame)); + + void (*Terminate)(void); + + GSM_Error (*GetMemoryLocation)( GSM_PhonebookEntry *entry ); + + GSM_Error (*WritePhonebookLocation)( GSM_PhonebookEntry *entry ); + + GSM_Error (*GetSpeedDial)( GSM_SpeedDial *entry); + + GSM_Error (*SetSpeedDial)( GSM_SpeedDial *entry); + + GSM_Error (*GetMemoryStatus)( GSM_MemoryStatus *Status); + + GSM_Error (*GetSMSStatus)( GSM_SMSStatus *Status); + + GSM_Error (*GetSMSCenter)( GSM_MessageCenter *MessageCenter ); + + GSM_Error (*SetSMSCenter)( GSM_MessageCenter *MessageCenter ); + + GSM_Error (*GetSMSMessage)( GSM_SMSMessage *Message ); + + GSM_Error (*DeleteSMSMessage)( GSM_SMSMessage *Message ); + + GSM_Error (*SendSMSMessage)( GSM_SMSMessage *Message ); + + GSM_Error (*SaveSMSMessage)( GSM_SMSMessage *Message ); + + /* If units is set to a valid GSM_RFUnits value, the code + will return level in these units if it is able. Otherwise + value will be returned as GRF_Arbitary. If phone doesn't + support GetRFLevel, function returns GE_NOTSUPPORTED */ + GSM_Error (*GetRFLevel)( GSM_RFUnits *units, float *level ); + + /* Works the same as GetRFLevel, except returns battery + level if known. */ + GSM_Error (*GetBatteryLevel)( GSM_BatteryUnits *units, float *level ); + + GSM_Error (*GetPowerSource)( GSM_PowerSource *source); + + GSM_Error (*GetDisplayStatus)( int *Status); + + GSM_Error (*EnterSecurityCode)( GSM_SecurityCode Code); + + GSM_Error (*GetSecurityCodeStatus)( int *Status ); + + GSM_Error (*GetIMEI)( char *imei ); + + GSM_Error (*GetRevision)( char *revision ); + + GSM_Error (*GetModel)( char *model ); + + GSM_Error (*GetManufacturer)( char *manufacturer ); + + GSM_Error (*GetDateTime)( GSM_DateTime *date_time); + + GSM_Error (*SetDateTime)( GSM_DateTime *date_time); + + GSM_Error (*GetAlarm)( int alarm_number, GSM_DateTime *date_time ); + + GSM_Error (*SetAlarm)( int alarm_number, GSM_DateTime *date_time ); + + GSM_Error (*DialVoice)( char *Number); + + GSM_Error (*DialData)( char *Number, char type, void (* callpassup)(char c)); + + GSM_Error (*GetIncomingCallNr)( char *Number ); + + GSM_Error (*GetNetworkInfo) ( GSM_NetworkInfo *NetworkInfo ); + + GSM_Error (*GetCalendarNote) ( GSM_CalendarNote *CalendarNote); + + GSM_Error (*WriteCalendarNote) ( GSM_CalendarNote *CalendarNote); + + GSM_Error (*DeleteCalendarNote) ( GSM_CalendarNote *CalendarNote); + + GSM_Error (*NetMonitor) ( unsigned char mode, char *Screen ); + + GSM_Error (*SendDTMF) ( char *String ); + + GSM_Error (*GetBitmap) ( GSM_Bitmap *Bitmap ); + + GSM_Error (*SetBitmap) ( GSM_Bitmap *Bitmap ); + + GSM_Error (*SetRingtone) ( GSM_Ringtone *ringtone ); + + GSM_Error (*Reset) ( unsigned char type ); + + GSM_Error (*GetProfile) ( GSM_Profile *Profile ); + + GSM_Error (*SetProfile) ( GSM_Profile *Profile ); + + bool (*SendRLPFrame) ( RLP_F96Frame *frame, bool out_dtx ); + + GSM_Error (*CancelCall) (); + + GSM_Error (*EnableDisplayOutput) (); + + GSM_Error (*DisableDisplayOutput) (); + + GSM_Error (*EnableCellBroadcast) (); + + GSM_Error (*DisableCellBroadcast) (); + + GSM_Error (*ReadCellBroadcast) ( GSM_CBMessage *Message ); + + GSM_Error (*SetKey) (int c, int up); + + GSM_Error (*HandleString) (char *s); + + GSM_Error (*AnswerCall) (char s); + +} GSM_Functions; + +typedef struct { + bool first; /* MUST be set to "true" during the first call of SMS_Deconcatenate() */ + bool singleshot; /* no concatenation wrapping was needed */ + unsigned sequence; /* =1 for the first part etc. */ + u8 *sequencep; /* For updating inside-PDU header sequence number */ + size_t cargoitems; /* How many items of MessageText fit in one SMS part */ + } GSM_Deconcatenate_state; + +/* Undefined functions in fbus/mbus files */ +extern GSM_Error Unimplemented(void); +#define UNIMPLEMENTED (void *) Unimplemented + +extern unsigned char GSM_Default_Alphabet[]; + +/* Coding functions */ +extern void EncodeAscii (unsigned char* dest, const unsigned char* src, int len); +extern void DecodeAscii (unsigned char* dest, const unsigned char* src, int len); +extern void EncodeUnicode (unsigned char* dest, const unsigned char* src, int len); +extern void DecodeUnicode (unsigned char* dest, const unsigned char* src, int len); + +extern unsigned char EncodeWithDefaultAlphabet(unsigned char); +extern unsigned char DecodeWithDefaultAlphabet(unsigned char); +extern wchar_t EncodeWithUnicodeAlphabet(unsigned char); +extern unsigned char DecodeWithUnicodeAlphabet(wchar_t); +extern GSM_MemoryType StrToMemoryType (const char *s); +extern unsigned char SMS_Validity_to_VP(int Validity); +extern int SMS_VP_to_Validity(GSM_SMSMessageValidity Validity); +extern int SemiOctetPack(char *Number, unsigned char *Output); +extern char *SemiOctetUnpack(char *dest,size_t destlen,u8 *Number,size_t nibbles); +extern char *SemiOctetUnpack_static(u8 *Number,size_t nibbles); +#define SEMIOCTETUNPACK_STATIC_BYTES(Number) (SemiOctetUnpack_static((Number)+1,*(Number)*2)) +#define SEMIOCTETUNPACK_STATIC_NIBBLES(Number) (SemiOctetUnpack_static((Number)+1,*(Number) )) +extern int PackSevenBitsToEight(int UsedBits, unsigned char *input, unsigned char *output); +extern int UnpackEightBitsToSeven(int offset, int in_length, int out_length, + unsigned char *input, unsigned char *output); +extern GSM_Error SMS_SetupUDH(GSM_SMSMessage *sms,GSM_UDH UDHType); +extern GSM_UDH SMS_DetectUDH(GSM_SMSMessage *sms); +extern bool SMS_Deconcatenate(GSM_Deconcatenate_state *state,GSM_SMSMessage *sms,char *buf,size_t buflen,bool useudh); +extern u8 *SMS_BlockFromHex(u8 *d,const char *s,size_t len); +extern char *SMS_BlockToHex(char *d,const u8 *s,size_t len); + +inline void GSM_DataClear(GSM_Data *data); + #endif /* __gsm_common_h */ diff --git a/include/gsm-networks.h b/include/gsm-networks.h index 367a964..ed1a820 100644 --- a/include/gsm-networks.h +++ b/include/gsm-networks.h @@ -1,42 +1,35 @@ /* + $Id$ + G N O K I I A Linux/Unix toolset and driver for Nokia mobile phones. + Copyright (C) 1999, 2000 Hugh Blemings & Pavel Janík ml. + Released under the terms of the GNU GPL, see file COPYING for more details. Header file for GSM networks. -*/ + $Log$ + Revision 1.1.1.3 2002/04/03 00:08:19 short + Found in "gnokii-working" directory, some November-patches version -#ifndef __gsm_networks_h -#define __gsm_networks_h + Revision 1.5 2001/06/28 00:28:46 pkot + Small docs updates (Pawel Kot) -/* Define enums for RF units. GRF_CSQ asks for units in form used - in AT+CSQ command as defined by GSM 07.07 */ -typedef enum { - GRF_Arbitrary, - GRF_dBm, - GRF_mV, - GRF_uV, - GRF_CSQ, - GRF_Percentage -} GSM_RFUnits; -/* This structure is used to get the current network status */ +*/ -typedef struct { - char NetworkCode[10]; /* GSM network code */ - char CellID[10]; /* CellID */ - char LAC[10]; /* LAC */ -} GSM_NetworkInfo; +#ifndef __gsm_networks_h +#define __gsm_networks_h /* This type is used to hold information about various GSM networks. */ typedef struct { - char Code[9+1]; /* GSM network code */ - char Name[50]; /* GSM network name */ + char *Code; /* GSM network code */ + char *Name; /* GSM network name */ } GSM_Network; /* This type is used to hold information about various GSM countries. */ @@ -53,7 +46,4 @@ char *GSM_GetNetworkCode(char *NetworkName); char *GSM_GetCountryName(char *CountryCode); char *GSM_GetCountryCode(char *CountryName); -void EncodeNetworkCode(unsigned char* buffer, unsigned char* output); -void DecodeNetworkCode(unsigned char* buffer, unsigned char* output); - #endif /* __gsm_networks_h */ diff --git a/include/gsm-ringtones.h b/include/gsm-ringtones.h index 948966d..bc3a514 100644 --- a/include/gsm-ringtones.h +++ b/include/gsm-ringtones.h @@ -1,14 +1,26 @@ /* + $Id$ + G N O K I I A Linux/Unix toolset and driver for Nokia mobile phones. + Copyright (C) 1999, 2000 Hugh Blemings & Pavel Janík ml. + Released under the terms of the GNU GPL, see file COPYING for more details. This file provides definitions of macros from the Smart Messaging Specification. It is mainly rewrite of the spec to C :-) Viva Nokia! + $Log$ + Revision 1.1.1.4 2002/04/03 00:08:19 short + Found in "gnokii-working" directory, some November-patches version + + Revision 1.2 2001/06/28 00:28:46 pkot + Small docs updates (Pawel Kot) + + */ #ifndef __gsm_ringtones_h @@ -20,41 +32,6 @@ #include #include "misc.h" #include "gsm-common.h" -#include "gsm-sms.h" - -#define MAX_RINGTONE_NOTES 255 - -/* Structure to hold note of ringtone. */ -/* NoteValue is encoded as octave(scale)*14 + note */ -/* where for note: c=0, d=2, e=4 .... */ -/* ie. c#=1 and 5 and 13 are invalid */ -/* note=255 means a pause */ -typedef struct { - u8 duration; - u8 note; - int tempo; - u8 style; -} GSM_RingtoneNote; - -/* Structure to hold ringtones. */ -typedef struct { - char name[20]; - unsigned char Loop; - u8 NrNotes; - GSM_RingtoneNote notes[256]; - bool allnotesscale; /* Some Nokia phones doesn't receive correctly some - ringtones without it. N3310 4.02 */ - int location; -} GSM_Ringtone; - -/* Structure to hold binary ringtones. */ - -typedef struct { - char name[20]; - unsigned char frame[1000]; - int length; - int location; -} GSM_BinRingtone; #define GetBit(Stream,BitNr) Stream[(BitNr)/8] & 1<<(7-((BitNr)%8)) #define SetBit(Stream,BitNr) Stream[(BitNr)/8] |= 1<<(7-((BitNr)%8)) @@ -68,8 +45,6 @@ typedef struct { #define CancelCommand (0x05<<1) /* binary 0000 101 */ #define RingingToneProgramming (0x25<<1) /* binary 0100 101 */ #define Sound (0x1d<<1) /* binary 0011 101 */ -/* MW: I didn't find phone, which can unpack ringtone with Unicode - command. Tested 3310, 6150 */ #define Unicode (0x22<<1) /* binary 0100 010 */ /* Song-Type Encoding */ @@ -86,13 +61,13 @@ typedef struct { #define ScaleInstructionId (0x02<<5) /* binary 010 */ #define StyleInstructionId (0x03<<5) /* binary 011 */ #define TempoInstructionId (0x04<<5) /* binary 100 */ -#define VolumeInstructionId (0x05<<5) /* binary 101 */ +#define VolumeInstructionId (0x05<<5) /* binary 101 */ /* Style-Value Encoding*/ #define NaturalStyle (0x00<<6) /* binary 00 */ #define ContinuousStyle (0x01<<6) /* binary 01 */ -#define StaccatoStyle (0x02<<6) /* binary 10 */ +#define StaccatoStyle (0x02<<6) /* binary 11 */ /* Note-Scale Encoding */ @@ -140,57 +115,26 @@ typedef struct { #define D_part (0x03<<6) /* binary 11 */ /* Command-End */ -#define CommandEnd (0x00) /* binary 00000000 */ - -u8 GSM_PackRingtone(GSM_Ringtone *ringtone, unsigned char *package, int *maxlength); -GSM_Error GSM_UnPackRingtone(GSM_Ringtone *ringtone, char *package, int maxlength); -int GSM_GetDuration(int number, unsigned char *spec); -int GSM_GetNote(int number); -int GSM_GetScale(int number); -int GSM_GetTempo(int Beats); - -void GSM_PlayOneNote (GSM_RingtoneNote note); -void GSM_PlayRingtone (GSM_Ringtone *ringtone); - -int GSM_GetFrequency(int number); - -GSM_Error GSM_ReadRingtone(GSM_SMSMessage *message, GSM_Ringtone *ringtone); - -int GSM_SaveRingtoneToSMS(GSM_MultiSMSMessage *SMS, - GSM_Ringtone *ringtone,bool profilestyle); - -/* FIXME: For each phone probaby different */ -#define FB61_MAX_RINGTONE_FRAME_LENGTH 200 - -/* Smart Messaging 3.0 says: 16*9=144 bytes, - but on 3310 4.02 it was possible to save about 196 chars (without cutting) */ -#define SM30_MAX_RINGTONE_FRAME_LENGTH 196 - -/* Like PC Composer help say */ -#define FB61_MAX_RINGTONE_NOTES 130 - -/* Nokia ringtones codes. */ - -struct OneRingtone { - char name[30]; - int menu; - int code; -}; +#define CommandEnd (0x00) /* binary 00000000 */ -void PrepareRingingTones(char model[64], char rev[64]); +/* Definition of the Note type */ -/* returns names from code or number in menu */ -char *RingingToneName(int code, int menu); +typedef struct { + int Scale; + int NoteID; + int Duration; + int DurationSpecifier; +} Note; -/* returns code from number in menu */ -int RingingToneCode(int menu); +#define GSM_MAX_RINGTONE_PACKAGE_LENGTH 200 -/* returns number in menu from code */ -int RingingToneMenu(int code); +/* From PC Composer help */ +#define GSM_MAX_RINGTONE_NOTES 130 -int NumberOfRingtones(); +u8 GSM_PackRingtone(GSM_Ringtone *ringtone, char *package, int *maxlength); +GSM_Error GSM_UnPackRingtone(GSM_Ringtone *ringtone, char *package, int maxlength); -GSM_Error GSM_GetPhoneRingtone(GSM_BinRingtone *ringtone,GSM_Ringtone *SMringtone); +int GSM_GetNote(int number); #endif /* __gsm_ringtones_h */ diff --git a/include/gsm-sms.h b/include/gsm-sms.h index fac18b9..37190ae 100644 --- a/include/gsm-sms.h +++ b/include/gsm-sms.h @@ -1,292 +1,341 @@ /* + $Id$ + G N O K I I A Linux/Unix toolset and driver for Nokia mobile phones. + Copyright (C) 2001 Pawe³ Kot + Released under the terms of the GNU GPL, see file COPYING for more details. + Include file for SMS library. + + $Log$ + Revision 1.1.1.6 2002/04/03 00:08:20 short + Found in "gnokii-working" directory, some November-patches version + + Revision 1.1 2001/11/08 16:23:20 pkot + New version of libsms. Not functional yet, but it reasonably stable API. + + Revision 1.1 2001/07/09 23:06:26 pkot + Moved sms.* files from my hard disk to CVS + + */ -#ifndef __gsm_sms_h -#define __gsm_sms_h +#ifndef __gnokii_sms_h_ +#define __gnokii_sms_h_ -#include "gsm-common.h" -#include "gsm-datetime.h" +#include "misc.h" +#include "gsm-error.h" -/* This data-type is used to specify the type of the number. See the official - GSM specification 03.40, version 5.3.0, section 9.1.2.5, page 33. */ -typedef enum { - GNT_UNKNOWN=0x81, /* Unknown number */ - GNT_INTERNATIONAL=0x91, /* International number */ - GNT_ALPHANUMERIC=0xD0 /* Alphanumeric number */ -} GSM_NumberType; +/* Maximum length of SMS center name */ -/* For folder table */ -typedef struct { - int smsnum; - u8 folder; - int location; -//future use GSM_SMSMessage *message; -} GSM_SMS2Foldertable; +#define GSM_MAX_SMS_CENTER_NAME_LENGTH (20) -/* This data type is used to hold the current SMS status. */ -typedef struct { - int UnRead; /* The number of unread messages */ - int Number; /* The number of messages */ - GSM_SMS2Foldertable foldertable[255]; /* for 6210/7110 */ -} GSM_SMSStatus; +/* Limits of SMS messages. */ -/* Define datatype for SMS Message Type */ -typedef enum { - GST_SMS, - GST_DR, /* Delivery Report */ - GST_UN /* Unknown */ -} GSM_SMSMessageType; +#define GSM_MAX_SMS_CENTER_LENGTH (40) +#define GSM_MAX_SENDER_LENGTH (40) +#define GSM_MAX_DESTINATION_LENGTH (40) -#define GST_INBOX 0; /* Mobile Terminated (MT) message - Inbox message */ -#define GST_OUTBOX 1; /* Mobile Originated (MO) message - Outbox message */ -#define GST_7110_INBOX 0x08; /* Inbox in 6210/7110 */ -#define GST_7110_OUTBOX 0x10; /* Outbox in 6210/7110 */ +#define GSM_MAX_SMS_LENGTH (160) +#define GSM_MAX_8BIT_SMS_LENGTH (140) -/* Datatype for SMS status */ -typedef enum { - GSS_SENTREAD = 0x01, /* Sent or read message */ - GSS_NOTSENTREAD = 0x03, /* Not sent or not read message */ - GSS_UNKNOWN = 0x05, /* RTH FIXME: ? */ - GSS_TEMPLATE = 0x07 /* Template ? */ -} GSM_SMSMessageStatus; +#define SMS_MAX_ADDRESS_LENGTH (40) -/* SMS Messages sent as... */ -typedef enum { - GSMF_Text = 0x00, /* Plain text message. */ - GSMF_Fax = 0x22, /* Fax message. */ - GSMF_Voice = 0x24, /* Voice mail message. */ - GSMF_ERMES = 0x25, /* ERMES message. */ - GSMF_Paging = 0x26, /* Paging. */ - GSMF_UCI = 0x2d, /* Email message in 8110i. */ - GSMF_Email = 0x32, /* Email message. */ - GSMF_X400 = 0x31 /* X.400 message. */ -} GSM_SMSMessageFormat; +/* FIXME: what value should be here? (Pawel Kot) */ +//#define GSM_MAX_USER_DATA_HEADER_LENGTH (10) +#define SMS_MAX_UDH_HEADER_NUMBER 10 -/* Validity of SMS Messages. */ -/* Ready values for TP-VP. Don't give them for function packing SMS validity - (creating TP-VP from validity value in minutes) */ -typedef enum { - GSMV_1_Hour = 0x0b, - GSMV_6_Hours = 0x47, - GSMV_24_Hours = 0xa7, - GSMV_72_Hours = 0xa9, - GSMV_1_Week = 0xad, - GSMV_Max_Time = 0xff -} GSM_SMSMessageValidity; - -/* 7 bit SMS Coding type */ -typedef enum { - GSM_Coding_Unicode = 0x01, - GSM_Coding_Default = 0x02, - GSM_Coding_8bit = 0x03 -} GSM_Coding_Type; +/*** MEMORY INFO ***/ -/* Define datatype for SMS Message Center */ typedef struct { - int No; /* Number of the SMSC in the phone memory. */ - char Name[GSM_MAX_SMS_CENTER_NAME_LENGTH]; /* Name of the SMSC. */ - GSM_SMSMessageFormat Format; /* SMS is sent as text/fax/paging/email. */ - GSM_SMSMessageValidity Validity; /* Validity of SMS Message. */ - char Number[GSM_MAX_SMS_CENTER_LENGTH]; /* Number of the SMSC. */ - char DefaultRecipient[GSM_MAX_RECIPIENT_LENGTH]; /* Number of default recipient */ -} GSM_MessageCenter; + int Unread; /* Number of unread messages */ + int Number; /* Number of all messages */ +} GSM_SMSMemoryStatus; + +/*** DATE AND TIME ***/ -/* Define datatype for Cell Broadcast message */ typedef struct { - int Channel; /* channel number */ - char Message[GSM_MAX_CB_MESSAGE + 1]; - int New; -} GSM_CBMessage; + int Year; /* The complete year specification - e.g. 1999. Y2K :-) */ + int Month; /* January = 1 */ + int Day; + int Hour; + int Minute; + int Second; + int Timezone; /* The difference between local time and GMT */ +} SMS_DateTime; + +/*** USER DATA HEADER ***/ /* types of User Data Header */ typedef enum { - GSM_NoUDH, - GSM_ConcatenatedMessages, - GSM_OpLogo, - GSM_CallerIDLogo, - GSM_RingtoneUDH, - GSM_EnableVoice, - GSM_DisableVoice, - GSM_EnableEmail, - GSM_DisableEmail, - GSM_EnableFax, - GSM_DisableFax, - GSM_VoidSMS, - GSM_HangSMS, - GSM_BugSMS, - GSM_UnknownUDH, //Gnokii doesn't know this UDH - GSM_WAPBookmarkUDH, - GSM_WAPBookmarkUDHLong, - GSM_WAPSettingsUDH, - GSM_CalendarNoteUDH, - GSM_CalendarNoteUDH2, - GSM_PhonebookUDH, - GSM_ProfileUDH, -} GSM_UDH; - -/* Define datatype for SMS messages, used for getting SMS messages from the - phones memory. */ -typedef struct { - GSM_Coding_Type Coding; - GSM_DateTime Time; /* Date of reception/response of messages. */ - GSM_DateTime SMSCTime; /* Date of SMSC response if DeliveryReport messages. */ - int Length; /* Length of the SMS message. */ - int Validity; /* Validity Period of the SMS message. */ - GSM_UDH UDHType; /* If UDH is present - type of UDH */ - unsigned char UDH[GSM_MAX_USER_DATA_HEADER_LENGTH]; /* If UDH is present - content of UDH */ - unsigned char MessageText[GSM_MAX_SMS_LENGTH + 1]; /* Room for null term. */ - GSM_MessageCenter MessageCenter; /* SMS Center. */ - char Sender[GSM_MAX_SENDER_LENGTH + 1]; /* Sender of the SMS message. */ - char Destination[GSM_MAX_DESTINATION_LENGTH+1];/* Destination of the message. */ - int MessageNumber; /* Location in the memory, where SMS is saved */ - GSM_MemoryType MemoryType; /* Type of memory message is stored in. */ - GSM_SMSMessageType Type; /* Type of the SMS message */ - GSM_SMSMessageStatus Status; /* Status of the SMS message */ - int Class; /* Class Message: 0, 1, 2, 3 or none; see GSM 03.38 */ - bool Compression; /* Indicates whether SMS contains compressed data */ - int Location; /* Location in the memory, when save SMS */ - bool ReplyViaSameSMSC; /* Indicates whether "Reply via same center" is set */ - int folder; /* Folder: 0-Inbox,1-Outbox, etc. */ - bool SMSData; /* if folder contains sender, SMSC number and sending date */ - unsigned char Name[25+1]; /* Name in Nokia 6210/7110, etc. Ignored in other */ -} GSM_SMSMessage; + SMS_NoUDH = 0x00, + SMS_ConcatenatedMessages = 0x01, + SMS_OpLogo = 0x02, + SMS_CallerIDLogo = 0x03, + SMS_Ringtone = 0x04, + SMS_VoiceMessage = 0x05, + SMS_FaxMessage = 0x06, + SMS_EmailMessage = 0x07, + SMS_OtherMessage = 0x08, + SMS_UnknownUDH = 0x09 +} SMS_UDHType; typedef struct { - int number; - GSM_SMSMessage SMS[6]; -} GSM_MultiSMSMessage; + SMS_UDHType Type; + union { + struct { + unsigned short ReferenceNumber; + unsigned short MaximumNumber; + unsigned short CurrentNumber; + } ConcatenatedShortMessage; /* SMS_ConcatenatedMessages */ + struct { + bool Store; + unsigned short MessageCount; + } SpecialSMSMessageIndication; /* SMS_VoiceMessage, SMS_FaxMessage, SMS_EmailMessage, SMS_OtherMessage */ + struct { + char NetworkCode[6]; +// ... + } Logo; /* SMS_OpLogo, SMS_CallerIDLogo */ + struct { +// ... + } Ringtone; /* SMS_Ringtone */ + } u; +} SMS_UDHInfo; -/* Maximal number of SMS folders */ -/* #define MAX_SMS_FOLDERS 10 */ -#define MAX_SMS_FOLDERS 24 +typedef enum { + SMS_PID, /* Set Protocol Identifier to `Return Call Message' */ + SMS_DCS, /* Set Data Coding Scheme "to indicate the type of message waiting and whether there are some messages or no messages" */ + SMS_UDH /* Use User Data Header - Special SMS Message Indication; the maximium level of information, may not be supported by all phones */ +} SMS_MessageWaitingType; -typedef struct { - char Name[15]; /* Name for SMS folder */ - u8 locations[160]; /* locations of SMS messages in that folder (6210 specific) */ - u8 number; /* number of SMS messages in that folder*/ -} GSM_OneSMSFolder; +/*** DATA CODING SCHEME ***/ -typedef struct { - GSM_OneSMSFolder Folder[MAX_SMS_FOLDERS]; - u8 FoldersID[MAX_SMS_FOLDERS]; // ID specific for this folder and phone. - // Used in internal functions. Do not use it. - u8 number; //number of SMS folders -} GSM_SMSFolders; - -/* Identifiers for Smart Messaging 3.0 multipart SMS */ -#define SM30_ISOTEXT 0 // ISO 8859-1 text -#define SM30_UNICODETEXT 1 -#define SM30_OTA 2 -#define SM30_RINGTONE 3 -#define SM30_PROFILENAME 4 -#define SM30_SCREENSAVER 6 - -/* TP-Message-Type-Indicator */ -/* See GSM 03.40 version 6.1.0 Release 1997 Section 9.2.3.1 */ -typedef enum { - SMS_Deliver = 0x00, /* when we save SMS in Inbox */ - SMS_Deliver_Report, - SMS_Status_Report, /* Delivery Report received by phone */ - SMS_Command, - SMS_Submit, /* when we send SMS or save it in Outbox */ - SMS_Submit_Report -} SMS_MessageType; +typedef enum { + SMS_GeneralDataCoding, + SMS_MessageWaiting +} SMS_DataCodingSchemeType; -/* Structure to hold UDH Header */ -typedef struct { - GSM_UDH UDHType; /* Type */ - int Length; /* Length */ - unsigned char *Text; /* Text */ -} GSM_UDHHeader; +typedef enum { + SMS_DefaultAlphabet = 0x00, + SMS_8bit = 0x01, + SMS_UCS2 = 0x02 +} SMS_AlphabetType; + +typedef enum { + SMS_VoiceMail = 0x00, + SMS_Fax = 0x01, + SMS_Email = 0x02, + SMS_Text = 0x03, + SMS_Other = 0x04 +} SMS_IndicationType; typedef struct { - unsigned char MessageText[GSM_MAX_SMS_LENGTH + 1]; - /* TP-User-Data. See GSM 03.40 section 9.2.3.24. Room for null term. */ + SMS_DataCodingSchemeType Type; + union { + struct { + unsigned short Class; /* 0 - no class + 1 - Class 0 + 2 - Class 1 + 3 - Class 2 + 4 - Class 3 */ + bool Compressed; + SMS_AlphabetType Alphabet; + } General; + struct { + bool Discard; + SMS_AlphabetType Alphabet; /* ucs16 not supported */ + bool Active; + SMS_IndicationType Type; + } MessageWaiting; + } u; +} SMS_DataCodingScheme; + +/*** VALIDITY PERIOD ***/ - unsigned char Number[GSM_MAX_SENDER_LENGTH + 1]; - /*In SMS-Deliver TP-Originating-Address.See GSM 03.40 section 9.2.3.7 */ - /*In SMS-Submit TP-Destination-Address.See GSM 03.40 section 9.2.3.8 */ - /*In SMS-Status-Report TP-Recipient-Address. See GSM 03.40 section 9.2.3.14*/ +typedef enum { + SMS_NoValidityPeriod = 0x00, + SMS_EnhancedFormat = 0x01, + SMS_RelativeFormat = 0x02, + SMS_AbsoluteFormat = 0x03 +} SMS_ValidityPeriodFormat; - unsigned char SMSCNumber[GSM_MAX_SMS_CENTER_LENGTH]; - /* SMSC number */ +typedef enum { + SMS_EnhancedNoValidityPeriod = 0x00, + SMS_EnhancedRelativeFormat = 0x01, + SMS_EnhancedRelativeSeconds = 0x02, /* Only one ocetet more is used */ + SMS_EnhancedRelativeSemiOctet = 0x03 /* 3 octets contain relative time in hours, minutes and seconds in semi-octet representation */ +} SMS_EnhancedValidityPeriodType; - unsigned char TPPID; - /* TP-Protocol-Identifier. See GSM 03.40 section 9.2.3.9 */ +typedef struct { + bool extension; /* we need to set it to 0 at the moment; FIXME: how to handle `1' here? */ + bool single_shot; + SMS_EnhancedValidityPeriodType type; + union { + unsigned short relative; + unsigned short seconds; + SMS_DateTime hms; + } period; +} SMS_EnhancedValidityPeriod; - unsigned char TPDCS; - /* TP-Data-Coding-Scheme. See GSM 03.40 section 9.2.3.10 */ +/* Validity of SMS Messages. */ - unsigned char DeliveryDateTime[7]; - /* For SMS-Submit TP-Validity-Period. See GSM 03.40 section 9.2.3.12 */ - /* For SMS-Status-Report TP-Discharge Time. See GSM 03.40 section 9.2.3.13 */ +typedef enum { + SMS_V1H = 0x0b, + SMS_V6H = 0x47, + SMS_V24H = 0xa7, + SMS_V72H = 0xa9, + SMS_V1W = 0xad, + SMS_VMax = 0xff +} SMS_ValidityPeriod; - unsigned char SMSCDateTime[7]; - /* TP-Service-Centre-Time-Stamp in SMS-Status-Report. - See GSM 03.40 section 9.2.3.11 */ +typedef struct { + SMS_ValidityPeriodFormat VPF; + union { + SMS_EnhancedValidityPeriod Enhanced; + SMS_ValidityPeriod Relative; /* 8 bit */ + SMS_DateTime Absolute; + } u; +} SMS_MessageValidity; - unsigned char TPStatus; - /* TP-Status in SMS-Status-Report. See GSM 03.40 section 9.2.3.15 */ - unsigned char TPUDL; - /* TP-User-Data-Length. See GSM 03.40 section 9.2.3.16 */ +/*** MESSAGE CENTER ***/ - unsigned char TPVP; - /* TP-Validity Period in SMS-Submit. See GSM 03.40 section 9.2.3.12 */ +typedef struct { + int No; /* Number of the SMSC in the phone memory. */ + char Name[GSM_MAX_SMS_CENTER_NAME_LENGTH]; /* Name of the SMSC. */ + SMS_IndicationType Format; /* SMS is sent as text/fax/paging/email. */ + SMS_ValidityPeriod Validity; /* Validity of SMS Message. */ + char Number[GSM_MAX_SMS_CENTER_LENGTH]; /* Number of the SMSC. */ + char Recipient[GSM_MAX_SMS_CENTER_LENGTH]; /* Number of the default recipient. */ +} SMS_MessageCenter; - unsigned char TPMR; - /* TP-Message Reference in SMS-Submit. See GSM 03.40 section 9.2.3.6 */ - unsigned char firstbyte; - /* Byte contains in SMS-Deliver: - TP-Message-Type-Indicator (2 bits) See GSM 03.40 section 9.2.3.1 +/*** SHORT MESSAGE CORE ***/ - TP-More-Messages-To-Send (1 bit). See GSM 03.40 section 9.2.3.2 +/* This data-type is used to specify the type of the number. See the official + GSM specification 03.40, version 6.1.0, section 9.1.2.5, page 35-37. */ +typedef enum { + SMS_Unknown = 0x81, /* Unknown number */ + SMS_International = 0x91, /* International number */ + SMS_National = 0xa1, /* National number */ + SMS_Network = 0xb1, /* Network specific number */ + SMS_Subscriber = 0xc1, /* Subscriber number */ + SMS_Alphanumeric = 0xd0, /* Alphanumeric number */ + SMS_Abbreviated = 0xe1 /* Abbreviated number */ +} SMS_NumberType; - TP-Reply-Path (1 bit). See GSM 03.40 section 9.2.3.17 - TP-User-Data-Header-Indicator (1 bit). See GSM 03.40 section 9.2.3.23 - TP-Status-Report-Indicator (1 bit). See GSM 03.40 section 9.2.3.4 +typedef struct { + SMS_NumberType type; + char number[SMS_MAX_ADDRESS_LENGTH]; +} SMS_Number; + +typedef enum { /* Bits meaning */ + SMS_Deliver = 0x00, /* 00 0 First 2 digits are taken from */ + SMS_Delivery_Report = 0x01, /* 00 1 GSM 03.40 version 6.1.0 Release 1997 */ + SMS_Submit = 0x02, /* 01 0 */ + SMS_Submit_Report = 0x03, /* 01 1 */ + SMS_Command = 0x04, /* 10 0 mark a report */ + SMS_Status_Report = 0x05, /* 10 1 Section 9.2.3.1; 3rd digit is to */ +} SMS_MessageType; - Byte contains in SMS-Submit: +typedef enum { + SMS_Enquiry = 0x00, /* Enquiry relating to previosly submitted short message; sets SRR to 1 */ + SMS_CancelStatusReport = 0x01, /* Cancel Status Report Request relating to previously submitted short message; sets SRR to 0 */ + SMS_DeleteSM = 0x02, /* Delete previousle submitted Short Message; sets SRR to 0 */ + SMS_EnableStatusReport = 0x03 /* Enable Status Report Request relating to previously submitted short message; sets SRR to 0 */ +} SMS_CommandType; - TP-Message-Type-Indicator (2 bits) See GSM 03.40 section 9.2.3.1 +typedef struct { + SMS_CommandType Type; +} SMS_MessageCommand; - TP-Reject-Duplicates (1 bit). See GSM 03.40 section - TP-Validity-Period-Format (2 bits).See GSM 03.40 section 9.2.3.3 +/* Datatype for SMS status */ +typedef enum { + SMS_Read = 0x01, + SMS_Unread = 0x03, + SMS_Sent = 0x05, + SMS_Unsent = 0x07 +} SMS_MessageStatus; - TP-Reply-Path (1 bit). See GSM 03.40 section 9.2.3.17 - TP-User-Data-Header-Indicator (1 bit). See GSM 03.40 section 9.2.3.23 - TP-Status-Report-Request (1 bit). See GSM 03.40 section 9.2.3.5 */ -} GSM_ETSISMSMessage; +typedef enum { + SMS_XXX = 0x01 +} SMS_MemoryType; + +/* Define datatype for SMS messages, describes precisely GSM Spec 03.40 */ +typedef struct { + /* Specification fields */ + SMS_MessageType Type; /* Message Type Indicator - 2 bits (9.2.3.1) */ + bool MoreMessages; /* More Messages to Send (9.2.3.2) */ + bool ReplyViaSameSMSC; /* Reply Path (9.2.3.17) - `Reply via same centre' in the phone */ + bool RejectDuplicates; /* Reject Duplicates (9.2.3.25) */ + bool Report; /* Status Report (9.2.3.4, 9.2.3.5 & 9.2.3.26) - `Delivery reports' in the phone */ + + unsigned short Number; /* Message Number - 8 bits (9.2.3.18) */ + unsigned short Reference; /* Message Reference - 8 bit (9.2.3.6) */ + unsigned short PID; /* Protocol Identifier - 8 bit (9.2.3.9) */ + unsigned short ReportStatus; /* Status - 8 bit (9.2.3.15), Failure Cause (9.2.3.22) */ + unsigned short Length; /* User Data Length (9.2.3.16), Command Data Length (9.2.3.20) */ + + SMS_MessageCenter MessageCenter; /* SMSC Address (9.2.3.7, 9.2.3.8, 9.2.3.14) */ + SMS_Number RemoteNumber; /* Origination, destination, Recipient Address (9.2.3.7, 9.2.3.8, 9.2.3.14) */ + unsigned char MessageText[GSM_MAX_SMS_LENGTH]; /* User Data (9.2.3.24), Command Data (9.2.3.21) */ + SMS_DataCodingScheme DCS; /* Data Coding Scheme (9.2.3.10) */ + SMS_MessageValidity Validity; /* Validity Period Format & Validity Period (9.2.3.3 & 9.2.3.12) - `Message validity' in the phone */ + + unsigned short UDH_No; /* Number of presend UDHs */ + SMS_UDHInfo UDH[SMS_MAX_UDH_HEADER_NUMBER]; /* User Data Header Indicator & User Data Header (9.2.3.23 & 9.2.3.24) */ + + SMS_DateTime SMSCTime; /* Service Centre Time Stamp (9.2.3.11) */ + SMS_DateTime Time; /* Discharge Time (9.2.3.13) */ + + /* Other fields */ + SMS_MemoryType MemoryType; /* memoryType (for 6210/7110: folder indicator */ + SMS_MessageStatus Status; /* Status of the message: sent/read or unsent/unread */ + +// SMS_CommandType Command; /* Command Type - 8 bits (9.2.3.19); FIXME: use it!!!! */ +// unsigned char Parameter[???]; /* Parameter Indicator (9.2.3.27); FIXME: how to use it??? */ +} GSM_SMSMessage; -int GSM_PackSemiOctetNumber (u8 *Number, u8 *Output, bool semioctet); -char *GSM_UnpackSemiOctetNumber(u8 *Number, bool semioctet); +extern GSM_Error EncodePDUSMS(GSM_SMSMessage *SMS, char *frame); +extern GSM_Error DecodePDUSMS(unsigned char *message, GSM_SMSMessage *SMS, int MessageLength); +extern GSM_Error EncodeTextSMS(); +extern GSM_Error DecodeTextSMS(unsigned char *message, GSM_SMSMessage *SMS); -int GSM_UnpackEightBitsToSeven(int fillbits, int in_length, int out_length, unsigned char *input, unsigned char *output); -int GSM_PackSevenBitsToEight (int offset, unsigned char *input, unsigned char *output); +/*** FOLDERS ***/ -GSM_Error GSM_EncodeETSISMS(GSM_SMSMessage *SMS, GSM_ETSISMSMessage *ETSI, SMS_MessageType PDU, int *length); -GSM_Error GSM_DecodeETSISMS(GSM_SMSMessage *SMS, GSM_ETSISMSMessage *ETSI); +/* Maximal number of SMS folders */ +#define MAX_SMS_FOLDERS 24 -GSM_Error GSM_EncodeSMSDateTime(GSM_DateTime *DT, unsigned char *req); +/* Datatype for SMS folders ins 6210/7110 */ +typedef struct { + char Name[15]; /* Name for SMS folder */ + bool SMSData; /* if folder contains sender, SMSC number and sending date */ + u8 locations[160]; /* locations of SMS messages in that folder (6210 specific) */ + u8 number; /* number of SMS messages in that folder*/ + u8 FolderID; /* ID od fthe current folder */ +} SMS_Folder; -GSM_Error GSM_DecodeETSISMSSubmitData(GSM_SMSMessage *SMS, GSM_ETSISMSMessage *ETSI); +typedef struct { + SMS_Folder Folder[MAX_SMS_FOLDERS]; + u8 FoldersID[MAX_SMS_FOLDERS]; /* ID specific for this folder and phone. */ + /* Used in internal functions. Do not use it. */ + u8 number; /* number of SMS folders */ +} SMS_FolderList; -GSM_Error GSM_DecodeETSISMSStatusReportData(GSM_SMSMessage *SMS, GSM_ETSISMSMessage *ETSI); +/*** CELL BROADCAST ***/ -void GSM_SetDefaultSMSData(GSM_SMSMessage *SMS); -GSM_Error EncodeUDHHeader(char *text, GSM_UDH UDHType); +#define GSM_MAX_CB_MESSAGE (160) -int GSM_MakeSinglePartSMS2(GSM_SMSMessage *SMS, - unsigned char *MessageBuffer,int cur, GSM_UDH UDHType, GSM_Coding_Type Coding); -void GSM_MakeMultiPartSMS2(GSM_MultiSMSMessage *SMS, - unsigned char *MessageBuffer,int MessageLength, GSM_UDH UDHType, GSM_Coding_Type Coding); +/* Define datatype for Cell Broadcast message */ +typedef struct { + int Channel; /* channel number */ + char Message[GSM_MAX_CB_MESSAGE + 1]; + int New; +} GSM_CBMessage; -#endif /* __gsm_sms_h */ +#endif /* __gnokii_sms_h_ */ diff --git a/include/links/atbus.h b/include/links/atbus.h index b7e0a27..30ff136 100644 --- a/include/links/atbus.h +++ b/include/links/atbus.h @@ -11,11 +11,8 @@ Released under the terms of the GNU GPL, see file COPYING for more details. $Log$ - Revision 1.1.1.1 2001/11/25 21:59:21 short - :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001 - - Revision 1.3 2001/11/19 13:03:18 pkot - nk3110.c cleanup + Revision 1.1.1.2 2002/04/03 00:08:20 short + Found in "gnokii-working" directory, some November-patches version Revision 1.2 2001/08/20 23:27:37 pkot Add hardware shakehand to the link layer (Manfred Jonsson) @@ -34,7 +31,7 @@ GSM_Error ATBUS_Initialise(GSM_Statemachine *state, int hw_handshake); #ifdef __atbus_c /* Prototype functions for atbus.c only */ GSM_Error ATBUS_Loop(struct timeval *timeout); -bool ATBUS_OpenSerial(int hw_handshake, char *device); +bool ATBUS_OpenSerial(int hw_handshake); void ATBUS_RX_StateMachine(unsigned char rx_char); #endif /* #ifdef __atbus_c */ diff --git a/include/links/atbus.h-REMOVE b/include/links/atbus.h-REMOVE new file mode 100644 index 0000000..e69de29 diff --git a/include/links/fbus.h b/include/links/fbus.h index c425ea1..0fc6cd0 100644 --- a/include/links/fbus.h +++ b/include/links/fbus.h @@ -17,11 +17,8 @@ The various routines are called FBUS_(whatever). $Log$ - Revision 1.1.1.1 2001/11/25 21:59:22 short - :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001 - - Revision 1.5 2001/11/15 12:04:06 pkot - Faster initialization for 6100 series (don't check for dlr3 cable) + Revision 1.1.1.2 2002/04/03 00:08:20 short + Found in "gnokii-working" directory, some November-patches version Revision 1.4 2001/03/21 23:36:08 chris Added the statemachine @@ -138,7 +135,8 @@ typedef struct{ u8 RequestSequenceNumber; } FBUS_Link; -GSM_Error FBUS_Initialise(GSM_Link *newlink, GSM_Statemachine *state, int type); +GSM_Error FBUS_Initialise(GSM_Link *newlink, GSM_Statemachine *state); + #ifdef __links_fbus_c /* Prototype functions for fbus-generic.c only */ diff --git a/include/mbus-6160.h b/include/mbus-6160.h index ea1708d..cd00dde 100644 --- a/include/mbus-6160.h +++ b/include/mbus-6160.h @@ -13,8 +13,8 @@ Header file for 6160 code. $Log$ - Revision 1.1.1.1 2001/11/25 21:59:20 short - :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001 + Revision 1.1.1.2 2002/04/03 00:08:19 short + Found in "gnokii-working" directory, some November-patches version Revision 1.16 2001/06/28 00:28:46 pkot Small docs updates (Pawel Kot) @@ -71,7 +71,7 @@ GSM_Error MB61_GetRFLevel(GSM_RFUnits *units, float *level); GSM_Error MB61_GetBatteryLevel(GSM_BatteryUnits *units, float *level); /* These aren't presently implemented. */ -GSM_Error MB61_SaveSMSMessage(GSM_SMSMessage *SMS); +GSM_Error MB61_SaveSMSMessage(GSM_SMSMessage *SMS, int data_size); GSM_Error MB61_GetPowerSource(GSM_PowerSource *source); GSM_Error MB61_GetDisplayStatus(int *Status); @@ -97,7 +97,6 @@ GSM_Error MB61_SendDTMF(char *String); GSM_Error MB61_GetBitmap(GSM_Bitmap *Bitmap); GSM_Error MB61_SetBitmap(GSM_Bitmap *Bitmap); GSM_Error MB61_SetRingTone(GSM_Ringtone *ringtone); -GSM_Error MB61_SendRingTone(GSM_Ringtone *ringtone, char *dest); GSM_Error MB61_Reset(unsigned char type); GSM_Error MB61_GetProfile(GSM_Profile *Profile); GSM_Error MB61_SetProfile(GSM_Profile *Profile); diff --git a/include/mbus-640.h b/include/mbus-640.h index ef37f38..70eddfe 100644 --- a/include/mbus-640.h +++ b/include/mbus-640.h @@ -13,8 +13,8 @@ Header file for 640 code. $Log$ - Revision 1.1.1.1 2001/11/25 21:59:20 short - :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001 + Revision 1.1.1.2 2002/04/03 00:08:19 short + Found in "gnokii-working" directory, some November-patches version Revision 1.10 2001/06/28 00:28:46 pkot Small docs updates (Pawel Kot) @@ -64,7 +64,7 @@ GSM_Error MB640_SetSMSCenter(GSM_MessageCenter *MessageCenter); GSM_Error MB640_DeleteSMSMessage(GSM_SMSMessage *message); GSM_Error MB640_SendSMSMessage(GSM_SMSMessage *SMS, int data_size); -GSM_Error MB640_SaveSMSMessage(GSM_SMSMessage *SMS); +GSM_Error MB640_SaveSMSMessage(GSM_SMSMessage *SMS, int data_size); GSM_Error MB640_GetRFLevel(GSM_RFUnits *units, float *level); @@ -96,7 +96,6 @@ GSM_Error MB640_SendDTMF(char *String); GSM_Error MB640_GetBitmap(GSM_Bitmap *Bitmap); GSM_Error MB640_SetBitmap(GSM_Bitmap *Bitmap); GSM_Error MB640_SetRingTone(GSM_Ringtone *ringtone); -GSM_Error MB640_SendRingTone(GSM_Ringtone *ringtone, char *dest); GSM_Error MB640_Reset(unsigned char type); GSM_Error MB640_GetProfile(GSM_Profile *Profile); GSM_Error MB640_SetProfile(GSM_Profile *Profile); diff --git a/include/misc.h b/include/misc.h index 2a16e51..435314c 100644 --- a/include/misc.h +++ b/include/misc.h @@ -1,32 +1,35 @@ /* + $Id$ + G N O K I I A Linux/Unix toolset and driver for Nokia mobile phones. + Copyright (C) 1999, 2000 Hugh Blemings & Pavel Janík ml. + Released under the terms of the GNU GPL, see file COPYING for more details. Header file for miscellaneous defines, typedefs etc. -*/ + $Log$ + Revision 1.1.1.4 2002/04/03 00:08:19 short + Found in "gnokii-working" directory, some November-patches version -#ifndef __misc_h -#define __misc_h + Revision 1.25 2001/07/03 15:27:14 pkot + AT commands for SMS handling support (Tamas Bondar) + Small at-emulator code cleanup (me) -#include -#include + Revision 1.24 2001/06/28 00:28:46 pkot + Small docs updates (Pawel Kot) -#ifndef VC6 - #include "config.h" - /* Use gsprintf instead of sprintf and sprintf */ - #ifdef HAVE_SNPRINTF - # define gsprintf(a, b, c...) snprintf(a, b, c) - #else - # define gsprintf(a, b, c...) sprintf(a, c) - #endif +*/ -#endif +#ifndef __misc_h +#define __misc_h + +#include /* Some general defines. */ @@ -42,20 +45,70 @@ #define bool int #endif -/* This one is for NLS. */ +#define ARRAY_LEN(x) (sizeof((x))/sizeof((x)[0])) -#ifdef USE_NLS +#define SAFE_STRNCPY(dest,src,n) do { \ + strncpy((dest),(src),(n)); \ + if ((n)>0) \ + (dest)[(n)-1]='\0'; \ + } while (0) - #ifndef VC6 - #include - #define _(x) gettext(x) - #else - #define _(x) (x) - #endif +#define SAFE_STRNCPY_SIZEOF(dest,src) \ + SAFE_STRNCPY((dest),(src),sizeof((dest))) + +/* Stolen from : */ +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4) +#define G_GNUC_PRINTF( format_idx, arg_idx ) \ + __attribute__((format (printf, format_idx, arg_idx))) +#else /* !__GNUC__ */ +#define G_GNUC_PRINTF( format_idx, arg_idx ) +#endif /* !__GNUC__ */ + +#define GNOKII_MAX(a, b) (((a) > (b)) ? (a) : (b)) +#define GNOKII_MIN(a, b) (((a) < (b)) ? (a) : (b)) + +/* A define to make debug printfs neat */ +#ifndef DEBUG +#define dprintf(a...) do { } while (0) +#else +#define dprintf(a...) do { fprintf(stderr, a); fflush(stderr); } while (0) +#endif +/* Use gsprintf instead of sprintf and sprintf */ +#ifdef HAVE_SNPRINTF +# define gsprintf(a, b, c...) snprintf(a, b, c) +#else +# define gsprintf(a, b, c...) sprintf(a, c) +#endif +#ifdef HAVE_VSNPRINTF +# define gvsprintf(a, b, c...) vsnprintf(a, b, c) +#else +# define gvsprintf(a, b, c...) vsprintf(a, c) +#endif +#ifdef HAVE_ASPRINTF +# define gasprintf(a...) asprintf(a) +#else +#include +extern int gasprintf(char **destp,const char *fmt,...); +#endif +#ifdef HAVE_VASPRINTF +# define gvasprintf(a...) vasprintf(a) +#else +#include +extern int gvasprintf(char **destp,const char *fmt,va_list ap); +#endif + +/* Get rid of long defines. Use #if __unices__ */ +#define __unices__ defined(__svr4__) || defined(__FreeBSD__) || defined(__bsdi__) + +/* This one is for NLS. */ +#ifdef USE_NLS + #include + #define _(x) gettext(x) #else #define _(x) (x) #endif /* USE_NLS */ +#define N_(x) (x) /* Definitions for u8, u16, u32 and u64, borrowed from /usr/src/linux/include/asm-i38/types.h */ @@ -97,6 +150,22 @@ /* Add here any timer operations which are not supported by libc5 */ #ifndef HAVE_TIMEOPS +#ifdef WIN32 + +#include +#include +#define timersub(a, b, result) + do { + (result)->tv_sec = (a)->time - (b)->time; + (result)->tv_usec = ((a)->millitm - (b)->millitm) * 1000; + if ((result)->tv_usec < 0) { + --(result)->tv_sec; + (result)->tv_usec += 1000000; + } + } while (0) +#define gettimeofday(a, b) _ftime(a) + +#else #include #ifndef timersub @@ -111,15 +180,33 @@ } while (0) #endif +#endif /* WIN32 */ #endif /* HAVE_TIMEOPS */ -#include +#include extern int GetLine(FILE *File, char *Line, int count); -int mem_to_int(const char str[], int len); - -void hexdump(u16 MessageLength, u8 *MessageBuffer); -void txhexdump(u16 MessageLength, u8 *MessageBuffer); +/* For models table */ +typedef struct { + char *model; + char *number; + int flags; +} PhoneModel; + +#define PM_CALLERGROUP 0x0001 +#define PM_NETMONITOR 0x0002 +#define PM_KEYBOARD 0x0004 +#define PM_SMS 0x0008 +#define PM_CALENDAR 0x0010 +#define PM_DTMF 0x0020 +#define PM_DATA 0x0040 +#define PM_SPEEDDIAL 0x0080 +#define PM_EXTPBK 0x0100 +#define PM_AUTHENTICATION 0x0200 + +extern char *GetModel (const char *); +extern PhoneModel *GetPhoneModel (const char *); #endif /* __misc_h */ + diff --git a/include/phones/nk6100.h b/include/phones/nk6100.h index 01950a8..ab41fdf 100644 --- a/include/phones/nk6100.h +++ b/include/phones/nk6100.h @@ -14,14 +14,8 @@ See README for more details on supported mobile phones. $Log$ - Revision 1.1.1.1 2001/11/25 21:59:22 short - :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001 - - Revision 1.3 2001/11/17 16:44:07 pkot - Cleanup. Reading SMS for 6100 series. Not that it has some bugs more and does not support UDH yet - - Revision 1.2 2001/11/15 12:15:04 pkot - smslib updates. begin work on sms in 6100 series + Revision 1.1.1.2 2002/04/03 00:08:20 short + Found in "gnokii-working" directory, some November-patches version Revision 1.1 2001/07/09 23:55:36 pkot Initial support for 6100 series in the new structure (me) @@ -60,10 +54,8 @@ static GSM_Error Identify(GSM_Data *data, GSM_Statemachine *state); static GSM_Error GetBatteryLevel(GSM_Data *data, GSM_Statemachine *state); static GSM_Error GetRFLevel(GSM_Data *data, GSM_Statemachine *state); static GSM_Error GetMemoryStatus(GSM_Data *data, GSM_Statemachine *state); -static GSM_Error GetSMSMessage(GSM_Data *data, GSM_Statemachine *state); static GSM_Error IncomingPhoneInfo(int messagetype, unsigned char *buffer, int length, GSM_Data *data); static GSM_Error IncomingModelInfo(int messagetype, unsigned char *buffer, int length, GSM_Data *data); -static GSM_Error IncomingSMS(int messagetype, unsigned char *buffer, int length, GSM_Data *data); static GSM_Error Incoming0x03(int messagetype, unsigned char *buffer, int length, GSM_Data *data); static GSM_Error Incoming0x0a(int messagetype, unsigned char *buffer, int length, GSM_Data *data); static GSM_Error Incoming0x17(int messagetype, unsigned char *buffer, int length, GSM_Data *data); diff --git a/include/phones/nk7110.h b/include/phones/nk7110.h index df3674e..dee0f6c 100644 --- a/include/phones/nk7110.h +++ b/include/phones/nk7110.h @@ -16,6 +16,51 @@ The various routines are called P7110_(whatever). + $Log$ + Revision 1.1.1.3 2002/04/03 00:08:21 short + Found in "gnokii-working" directory, some November-patches version + + Revision 1.6 2001/11/08 16:47:48 pkot + Start fiddling with 7110 and SMS + + Revision 1.5 2001/06/27 23:52:52 pkot + 7110/6210 updates (Marian Jancar) + + Revision 1.4 2001/05/24 20:47:30 chris + More updating of 7110 code and some of xgnokii_lowlevel changed over. + + Revision 1.3 2001/03/23 13:40:25 chris + Pavel's patch and a few fixes. + + Revision 1.2 2001/03/21 23:36:08 chris + Added the statemachine + This will break gnokii --identify and --monitor except for 6210/7110 + + Revision 1.1 2001/02/21 19:57:13 chris + More fiddling with the directory layout + + Revision 1.1 2001/02/16 14:29:54 chris + Restructure of common/. Fixed a problem in fbus-phonet.c + Lots of dprintfs for Marcin + Any size xpm can now be loaded (eg for 7110 startup logos) + nk7110 code detects 7110/6210 and alters startup logo size to suit + Moved Marcin's extended phonebook code into gnokii.c + + Revision 1.4 2001/01/29 17:14:44 chris + dprintf now in misc.h (and fiddling with 7110 code) + + Revision 1.3 2001/01/23 15:32:44 chris + Pavel's 'break' and 'static' corrections. + Work on logos for 7110. + + Revision 1.2 2001/01/17 02:54:56 chris + More 7110 work. Use with care! (eg it is not possible to delete phonebook entries) + I can now edit my phonebook in xgnokii but it is 'work in progress'. + + Revision 1.1 2001/01/14 22:47:01 chris + Preliminary 7110 support (dlr9 only) and the beginnings of a new structure + + */ #ifndef __phones_nk7110_h @@ -30,7 +75,6 @@ extern bool P7110_LinkOK; #define P7110_MSG_COMMSTATUS 0x01 /* Communication status */ #define P7110_MSG_SMS 0x02 /* SMS handling */ #define P7110_MSG_PHONEBOOK 0x03 /* Phonebook functions */ -#define P7110_MSG_DIVERT 0x06 /* Call Divert */ #define P7110_MSG_NETSTATUS 0x0a /* Network status */ #define P7110_MSG_CALENDAR 0x13 /* Calendar notes */ #define P7110_MSG_FOLDER 0x14 /* Folders handling */ @@ -151,10 +195,8 @@ static GSM_Error P7110_GetSMSCenter(GSM_Data *data, GSM_Statemachine *state); static GSM_Error P7110_GetClock(char req_type, GSM_Data *data, GSM_Statemachine *state); static GSM_Error P7110_GetCalendarNote(GSM_Data *data, GSM_Statemachine *state); static GSM_Error P7110_GetSMS(GSM_Data *data, GSM_Statemachine *state); -static GSM_Error P7110_SendSMS(GSM_Data *data, GSM_Statemachine *state); static GSM_Error P7110_GetSMSFolders(GSM_Data *data, GSM_Statemachine *state); static GSM_Error P7110_GetSMSFolderStatus(GSM_Data *data, GSM_Statemachine *state); -static GSM_Error P7110_CallDivert(GSM_Data *data, GSM_Statemachine *state); static GSM_Error P7110_Incoming0x1b(int messagetype, unsigned char *buffer, int length, GSM_Data *data); static GSM_Error P7110_IncomingPhonebook(int messagetype, unsigned char *buffer, int length, GSM_Data *data); @@ -165,7 +207,6 @@ static GSM_Error P7110_IncomingSMS(int messagetype, unsigned char *buffer, int l static GSM_Error P7110_IncomingFolder(int messagetype, unsigned char *buffer, int length, GSM_Data *data); static GSM_Error P7110_IncomingClock(int messagetype, unsigned char *message, int length, GSM_Data *data); static GSM_Error P7110_IncomingCalendar(int messagetype, unsigned char *message, int length, GSM_Data *data); -static GSM_Error P7110_IncomingCallDivert(int messagetype, unsigned char *message, int length, GSM_Data *data); static int GetMemoryType(GSM_MemoryType memory_type); diff --git a/include/phones/nokia.h b/include/phones/nokia.h index 11c3801..d99582a 100644 --- a/include/phones/nokia.h +++ b/include/phones/nokia.h @@ -17,11 +17,8 @@ The various routines are called PNOK_... $Log$ - Revision 1.1.1.1 2001/11/25 21:59:22 short - :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001 - - Revision 1.2 2001/11/15 12:12:34 pkot - 7110 and 6110 series phones introduce as Nokia + Revision 1.1.1.2 2002/04/03 00:08:21 short + Found in "gnokii-working" directory, some November-patches version Revision 1.1 2001/02/21 19:57:13 chris More fiddling with the directory layout @@ -35,6 +32,9 @@ #ifndef __phones_nokia_h #define __phones_nokia_h + +#define PNOK_MAX_MANUFACTURER_LENGTH 16 + GSM_Error PNOK_GetManufacturer(char *manufacturer); #endif diff --git a/packaging/Debian/README.debian b/packaging/Debian/README.debian index 97e2238..7830020 100644 --- a/packaging/Debian/README.debian +++ b/packaging/Debian/README.debian @@ -1,6 +1,7 @@ Gnokii for DEBIAN ------------------- -This package was debianized by Karel Zak +This package was debianized by Karel Zak and later +taken over by Erik Rossen . diff --git a/packaging/Debian/control b/packaging/Debian/control index 7414d1f..d68850d 100644 --- a/packaging/Debian/control +++ b/packaging/Debian/control @@ -1,11 +1,14 @@ Source: gnokii Section: comm Priority: optional -Maintainer: Karel Zak -Standards-Version: 2.4.0.0 +Build-Depends: debhelper, libc6-dev, xlibs-dev, xutils, libgtk1.2-dev +Maintainer: Erik Rossen (Linux consultant) +Standards-Version: 3.1.0.0 Package: gnokii Architecture: any -Depends: ${shlibs:Depends} -Description: Gnokii is a Linux/Unix tool suite and (eventually) - modem/fax driver for Nokia mobile phones, released under the GPL. \ No newline at end of file +Depends: adduser, ${shlibs:Depends} +Description: Linux/Unix tool suite for Nokia mobile phones + Gnokii is a Linux/Unix tool suite and (eventually) modem/fax driver + for Nokia mobile phones, released under the GPL. + diff --git a/packaging/Debian/copyright b/packaging/Debian/copyright index 5b582e7..049061c 100644 --- a/packaging/Debian/copyright +++ b/packaging/Debian/copyright @@ -1,16 +1,30 @@ -* Copyright (C) 1999-2000 Hugh Blemings & Pavel Janík ml. +GNOKII - A Linux/Unix toolset and driver for the Nokia 3x10/8110/51x0/61x0 + Copyright (C) 1999 Hugh Blemings & Pavel Janík ml. -* 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; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +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; if not, write to the Free Software Foundation, Inc., 59 Temple +Place - Suite 330, Boston, MA 02111-1307, USA. + +You can contact authors by mail at + +hugh@linuxcare.com Pavel.Janik@suse.cz +Hugh Blemings Mgr. Pavel Janík, SuSE CR, s.r.o. +PO Box 234 Pod Pekárnami 338/12 +Belconnen ACT 2616 190 00 Praha 9 +Australia Czech Republic + +We would be delighted to receive a postcard from you if you use gnokii but +this is not a requirement of these licence terms! :) + +Any trademarks in this or other gnokii documents/files are the property of +their respective owners. diff --git a/packaging/Debian/docs b/packaging/Debian/docs index 8290213..43a1a30 100644 --- a/packaging/Debian/docs +++ b/packaging/Debian/docs @@ -4,17 +4,10 @@ Docs/README-3810 Docs/README-6110 Docs/README-2110 Docs/README-WIN32 -Docs/sample/gnokiirc -Docs/sample/options -Docs/sample/pap-secrets -Docs/sample/ppp-gnokii -Docs/sample/ppp-on Docs/DataCalls-QuickStart Docs/gettext-howto Docs/gnokii-ir-howto Docs/packaging-howto Docs/gnokii.nol Docs/FAQ -COPYING -INSTALL TODO diff --git a/packaging/Debian/menu b/packaging/Debian/menu index 51ae09d..2ccf430 100644 --- a/packaging/Debian/menu +++ b/packaging/Debian/menu @@ -1 +1 @@ -?package(gnokii):needs=text section="Apps/Comm" title="XGnokii" command="/usr/bin/xgnokii" +?package(gnokii):needs="X11" section="Apps/Net" title="XGnokii" command="/usr/bin/xgnokii" diff --git a/packaging/Debian/postinst b/packaging/Debian/postinst index 785ba4e..125800a 100644 --- a/packaging/Debian/postinst +++ b/packaging/Debian/postinst @@ -1,3 +1,8 @@ #!/bin/sh -e -/usr/sbin/groupdel gnokii +echo 'Setting /usr/sbin/mgnokiidev SUID root, executable only by the "gnokii" group.' +echo 'Read /usr/share/doc/gnokii/FAQ and README concerning the security risk.' +chown root.gnokii /usr/sbin/mgnokiidev +chmod 4750 /usr/sbin/mgnokiidev + +#DEBHELPER# diff --git a/packaging/Debian/preinst b/packaging/Debian/preinst index 593bbc7..82814da 100644 --- a/packaging/Debian/preinst +++ b/packaging/Debian/preinst @@ -1,4 +1,11 @@ #!/bin/sh -e -/usr/sbin/groupadd gnokii +if [ -z "`grep -e '^gnokii:' /etc/group`" ] +then + /usr/sbin/groupadd gnokii +else + echo 'notice: group "gnokii" already exists' + echo 'I assume that you have used a gnokii before, Mr. Bond.' +fi +#DEBHELPER# diff --git a/packaging/Debian/rules b/packaging/Debian/rules index b48eee8..d964aae 100755 --- a/packaging/Debian/rules +++ b/packaging/Debian/rules @@ -1,16 +1,25 @@ #!/usr/bin/make -f -#export DH_VERBOSE=1 +export DH_VERBOSE=1 +export DH_COMPAT=3 + +export build_dir=$(shell pwd)/debian/gnokii build: build-stamp build-stamp: dh_testdir +# if [ ! -f ./configure ] ; then autoconf ; fi ./configure --prefix=/usr --with-x +# ./configure --prefix=/usr --with-x --enable-debug --enable-xdebug --enable-rlpdebug make + touch build + touch build-stamp clean: dh_testdir dh_testroot + rm -f build build-stamp config.* + touch Makefile.global make clean dh_clean @@ -26,27 +35,44 @@ binary-arch: build dh_testdir dh_testroot dh_installdirs - make install prefix=`pwd`/debian/tmp/usr - mkdir -p `pwd`/debian/tmp/etc/ - sed 's#/usr/local/sbin/#/usr/sbin/#' < Docs/sample/gnokiirc > `pwd`/debian/tmp/etc/gnokiirc +# The following two lines are to prevent the install process from installing +# mgnokiidev owned by the probably not-yet-existing group "gnokii". mgnokiidev +# gets SGID after dpkg runs preinst which creates the group "gnokii". + mv utils/Makefile utils/Makefile.ORIG + sed 's#-o root -g gnokii -m 4750 ##' < utils/Makefile.ORIG > utils/Makefile +# + make install prefix=$(build_dir)/usr +# +# just to leave the sources in a pristine state... + mv utils/Makefile.ORIG utils/Makefile +# + mkdir -p $(build_dir)/etc + sed 's#/usr/local/sbin/#/usr/sbin/#' < Docs/sample/gnokiirc > $(build_dir)/etc/gnokiirc +# lintian complains if there are multiple licence files in one package, hence +# the next two commands + sed 's#"COPYING"#"file:/usr/share/doc/gnokii/copyright"#' < \ + xgnokii/docs/help/en_US/faq.html > \ + $(build_dir)/usr/share/xgnokii/help/en_US/faq.html + rm -f $(build_dir)/usr/share/xgnokii/help/en_US/COPYING +# lintian complains if there is a binary that does not have a man page. +# Pawel says that xlogos will soon be dumped anyways, so... + rm -f $(build_dir)/usr/bin/xlogos # dh_installdebconf -# dh_installexamples + dh_installexamples dh_installdocs dh_installmenu # dh_installemacsen # dh_installpam # dh_installinit # dh_installcron -# dh_installmanpages - dh_installinfo + dh_installman +# dh_installinfo # dh_undocumented dh_installchangelogs dh_link dh_strip dh_compress dh_fixperms - # You may want to make some executables suid here. - dh_suidregister # dh_makeshlibs dh_installdeb # dh_perl diff --git a/packaging/RedHat/gnokii.spec.in b/packaging/RedHat/gnokii.spec.in index 2d80a62..f3b5411 100644 --- a/packaging/RedHat/gnokii.spec.in +++ b/packaging/RedHat/gnokii.spec.in @@ -9,7 +9,7 @@ Release: %{release} Copyright: GPL Packager: Pavel Janik ml. , Jan Derfinak Group: Applications/Communications -Source: ftp://multivac.fatburen.org/pub/gnokii/%{name}-%{version}.tar.gz +Source: ftp://ftp.gnokii.org/pub/gnokii/%{name}-%{version}.tar.gz BuildRoot: /var/tmp/%{name}-%{version}-root %description @@ -55,22 +55,30 @@ rm -rf ${RPM_BUILD_ROOT} %doc Docs/CREDITS Docs/DataCalls-QuickStart Docs/FAQ Docs/README %doc Docs/README-3810 Docs/README-6110 Docs/README-2110 Docs/README-WIN32 %doc Docs/gettext-howto Docs/gnokii.nol Docs/gnokii-ir-howto Docs/packaging-howto +%doc Docs/README-dancall Docs/logos.txt Docs/gnokii.xpm Docs/Bugs %doc Docs/sample/gnokiirc Docs/sample/options Docs/sample/pap-secrets %doc Docs/sample/ppp-gnokii Docs/sample/ppp-on +%doc Docs/protocol/nk2110.txt Docs/protocol/nk3110.txt Docs/protocol/nk6110.txt Docs/protocol/nk6160.txt +%doc Docs/protocol/nk6185.txt Docs/protocol/nk640.txt Docs/protocol/nk7110.txt Docs/protocol/nokia.txt %attr(0750, root, gnokii) /usr/bin/gnokii -%attr(0750, root, gnokii) /usr/sbin/gnokiid -%attr(4750, root, gnokii) /usr/sbin/mgnokiidev %config /etc/gnokiirc %files xgnokii %defattr(-,root,root) -/usr/bin/xgnokii -/usr/bin/xlogos -/usr/bin/todologo -/usr/lib/xgnokii +/usr/X11R6/bin/xgnokii +/usr/share/xgnokii %changelog +* Fri Sep 28 2001 Pawel Kot +- last minute fixes. + +* Thu Sep 27 2001 Pawel Kot +- updates to 0.3.3 version - new docs, new ftp server + +* Sun Sep 2 2001 Pawel Kot +- removes xlogos + * Thu Jan 11 2001 Pawel Kot - misc updates diff --git a/packaging/Slackware/SlackBuild.in b/packaging/Slackware/SlackBuild.in index d49b081..0853b6a 100644 --- a/packaging/Slackware/SlackBuild.in +++ b/packaging/Slackware/SlackBuild.in @@ -5,11 +5,14 @@ # Written by Pawe³ Kot # -ARCH=@ARCH@ PN=@PACKAGE@ PV=@VERSION@ -DOCS="COPYING ChangeLog VERSION Docs/CREDITS Docs/DataCalls-QuickStart Docs/README*" +ARCH="i386" +BUILD=1 + +DOCS1="Docs/*" +DOCS2="Docs/protocol Docs/sample" CONF="Docs/sample/gnokiirc" CWD=`pwd` @@ -34,24 +37,26 @@ tar xzvf $CWD/$PN-$PV.tar.gz cd $PN-$PV # Configure and make package -./configure --prefix=/usr --with-x --enable-nls $ARCH-slackware-linux || exit 1 -make || exit 1 -make prefix=$PKG/usr install || exit 1 +./configure --prefix=/usr --with-xgnokiidir=/usr/X11R6 i386-slackware-linux +make +make prefix=$PKG/usr xgnokii_libdir=$PKG/usr/X11R6 install # Copy the docs mkdir -p $PKG/usr/doc/$PN-$PV -cp -a $DOCS $PKG/usr/doc/$PN-$PV -chmod 644 $PKG/usr/doc/$PN-$PV +cp $DOCS1 $PKG/usr/doc/$PN-$PV +cp -r $DOCS2 $PKG/usr/doc/$PN-$PV # and the configuration mkdir -p $PKG/etc -sed "s|/usr/local/sbin|/usr/sbin|" < $CONF > $PKG/etc/gnokiirc +sed "s|/usr/local/sbin|/usr/sbin|" < $CONF > $PKG/etc/gnokiirc.new # Now, add gnokii group, set the permissions GROUPADD=`which groupadd` cd $PKG mkdir install cat > install/doinst.sh </dev/null 2>&1 chown root.gnokii /usr/bin/gnokii chmod 750 /usr/bin/gnokii @@ -59,11 +64,17 @@ chown root.gnokii /usr/sbin/gnokiid chmod 750 /usr/sbin/gnokiid chown root.gnokii /usr/sbin/mgnokiidev chmod 4750 /usr/sbin/mgnokiidev + +if [ -f /etc/gnokiirc ]; then + rm -f /etc/gnokiirc.new +else + mv /etc/gnokiirc.new /etc/gnokiirc +fi EOF # and build the package answering "yes" twice echo "y -y" | makepkg $TMP/$PN.tgz +y" | makepkg $TMP/$PN-$PV-$ARCH-$BUILD.tgz # Cleanup rm -rf $TMP/$PN-$PV diff --git a/po/Makefile.in.in b/po/Makefile.in.in index 94a1088..f9aa397 100644 --- a/po/Makefile.in.in +++ b/po/Makefile.in.in @@ -1,6 +1,6 @@ # # -# Makefile for gnokii I18n, +# Makefile for gnokii I18n, # based on the Makefile.in.in that comes with gettext # # Erwin Dieterich, 20. 1. 1998 Erwin.Dieterich.ED@Bayer-AG.de @@ -55,7 +55,7 @@ DEFS = @DEFS@ CFLAGS = @CFLAGS@ CPPFLAGS = @CPPFLAGS@ -INCLUDES = -I.. +INCLUDES = -I.. COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(XCFLAGS) @@ -68,7 +68,7 @@ CATOBJEXT = @CATOBJEXT@ INSTOBJEXT = @INSTOBJEXT@ .SUFFIXES: -.SUFFIXES: .c .o .po .pox .gmo .mo .msg +.SUFFIXES: .c .o .po .pox .gmo .mo .msg .c.o: $(COMPILE) $< @@ -84,6 +84,8 @@ INSTOBJEXT = @INSTOBJEXT@ file=`echo $* | sed 's,.*/,,'`.gmo \ && rm -f $$file && $(GMSGFMT) -o $$file $< + + all: all-@USE_NLS@ all-yes: $(PACKAGE).pot $(CATALOGS) @@ -93,13 +95,12 @@ all-no: $(PACKAGE).pot: $(POTFILES) if test -n "$(XGETTEXT)"; then \ $(XGETTEXT) --default-domain=$(PACKAGE) --directory=$(srcdir)/.. \ - --keyword=_ --files-from=$(srcdir)/POTFILES.in; \ + --c++ --keyword=_ --files-from=$(srcdir)/POTFILES.in; \ mv $(PACKAGE).po $(PACKAGE).pot; \ else \ echo "xgettext not available: $(PACKAGE).pot not updated" 1>&2; \ fi -makelib: all-@USE_NLS@ install: install-exec install-data install-exec: diff --git a/po/POTFILES.in b/po/POTFILES.in index 7e766df..b0d64d0 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -1,22 +1,36 @@ -common/protocol/fbus.c -common/protocol/mbus.c -common/newmodules/n7110.c -common/newmodules/n6110.c -common/files/cfgreader.c -common/gsm-ringtones.c -common/gsm-bitmaps.c -common/data/at-emulator.c +common/cfgreader.c common/data/rlp-common.c common/data/virtmodem.c -gnokii/gnokii.c +common/devices/unixserial.c +common/fbus-6110.c +common/fbus-6110-ringtones.c +common/gsm-bitmaps.c +common/gsm-filetypes.c +common/gsm-ringtones.c +common/links/cbus.c +common/links/fbus.c +common/links/fbus-phonet.c +common/mbus-2110.c +common/mbus-6160.c +common/mbus-640.c +common/misc.c +common/phones/generic.c +common/phones/nk7110.c +common/vcal.c +common/vcal.lx gnokiid/gnokiid.c +gnokii/gnokii.c +smsd/lowlevel.c xgnokii/xgnokii.c +xgnokii/xgnokii_calendar.c xgnokii/xgnokii_cfg.c xgnokii/xgnokii_common.c xgnokii/xgnokii_contacts.c +xgnokii/xgnokii_data.c xgnokii/xgnokii_dtmf.c +xgnokii/xgnokii_logos.c +xgnokii/xgnokii_lowlevel.c xgnokii/xgnokii_netmon.c xgnokii/xgnokii_sms.c xgnokii/xgnokii_speed.c xgnokii/xgnokii_xkeyb.c -xgnokii/xgnokii_logos.c diff --git a/po/et.po b/po/et.po index 9df54cb..42417ea 100644 --- a/po/et.po +++ b/po/et.po @@ -1,8 +1,12 @@ +# Nokia DataSuite asendaja Linux keskkonnas GNOKII eestindus. +# Copyright (C) 2000 Free Software Foundation, Inc. +# Hans Mõtshärg ,2000 +# msgid "" msgstr "" "Project-Id-Version: gnokii\n" -"POT-Creation-Date: 2000-09-09 23:32+0200\n" -"PO-Revision-Date: 2000-09-11 06:20:00+0200\n" +"POT-Creation-Date: 2001-02-01 14:12+0200\n" +"PO-Revision-Date: 2001-01-01 11:43:00+0200\n" "Last-Translator: Hans Mõtshärg \n" "Language-Team: gnokii\n" "MIME-Version: 1.0\n" @@ -12,91 +16,91 @@ msgstr "" "Files: fbus-3810.h fbus-6110.h gsm-api.h gsm-common.h misc.h fbus-3810.c " "fbus-6110.c gnokii.c gsm-api.c\n" -#: common/fbus-3810.c:521 common/fbus-6110.c:2186 +#: common/fbus-3810.c:582 common/fbus-6110.c:1649 #, c-format msgid "Sending SMS to %s via message center %s\n" msgstr "Saadan SMS'i %s kasutades saatekeskust %s\n" -#: common/fbus-3810.c:625 +#: common/fbus-3810.c:686 #, c-format msgid "SMS Send attempt failed, trying again (%d of %d)\n" msgstr "SMS saatmine ebaõnnestus, proovin veel (katse %d %d-st)\n" -#: common/fbus-3810.c:1196 -msgid "Couldn't open FB38 device: " -msgstr "Ei suuda avada FB38 seadet: " +#: common/fbus-3810.c:1304 +msgid "Couldn't open FB38 device" +msgstr "Ei suuda avada FB38 seadet:" -#: common/fbus-3810.c:1288 +#: common/fbus-3810.c:1397 msgid "restarting.\n" msgstr "käivitun uuesti.\n" -#: common/fbus-3810.c:1344 +#: common/fbus-3810.c:1453 #, c-format msgid "MT Fail %02x" msgstr "MT Viga %02x" -#: common/fbus-3810.c:1351 common/mbus-6160.c:1202 +#: common/fbus-3810.c:1460 common/mbus-6160.c:992 #, c-format msgid "CS Fail %02x != %02x" msgstr "CS Viga %02x != %02x" -#: common/fbus-3810.c:1465 +#: common/fbus-3810.c:1572 #, c-format msgid "0x15 Registration Response 0x%02x\n" msgstr "0x15 Registreerimise vastus 0x%02x\n" -#: common/fbus-3810.c:1481 +#: common/fbus-3810.c:1588 #, c-format msgid "0x16 Registration Response 0x%02x\n" msgstr "0x15 Registreerimise vastus 0x%02x\n" -#: common/fbus-3810.c:1482 +#: common/fbus-3810.c:1589 #, c-format msgid "SIM access: %s.\n" msgstr "" -#: common/fbus-3810.c:1558 +#: common/fbus-3810.c:1665 #, c-format msgid "SMS Stored into location 0x%02x\n" msgstr "SMS salvestatud 0x%02x\n" -#: common/fbus-3810.c:1568 +#: common/fbus-3810.c:1675 #, c-format msgid "SMS Store failed: 0x%02x\n" msgstr "SMS salvestamine 0x%02x ebaõnnestus\n" -#: common/fbus-3810.c:1689 +#: common/fbus-3810.c:1796 msgid "PIN [possibly] entered.\n" msgstr "PIN [tõenäoliselt] sisestatud.\n" -#: common/fbus-3810.c:1698 +#: common/fbus-3810.c:1805 msgid "Phone powering off..." msgstr "Telefon lülitub välja" -#: common/fbus-3810.c:1727 common/mbus-6160.c:809 +#: common/fbus-3810.c:1834 common/mbus-6160.c:599 msgid "Standard Ack write failed!" msgstr "" -#: common/fbus-3810.c:1753 +#: common/fbus-3810.c:1860 msgid "Unknown: " msgstr "Tundmatu: " -#: common/fbus-3810.c:1755 +#: common/fbus-3810.c:1862 #, c-format msgid "Msg Type: %02x " msgstr "Msg Tüüp: %02x " -#: common/fbus-3810.c:1756 +#: common/fbus-3810.c:1863 #, c-format msgid "Msg Len: %02x " msgstr "Msg pikkus: %02x" -#: common/fbus-3810.c:1757 +#: common/fbus-3810.c:1864 #, c-format msgid "Sequence Number: %02x " msgstr "Järjenumber: %02x " -#: common/fbus-3810.c:1758 +#: common/fbus-3810.c:1865 #, c-format msgid "" "Checksum: %02x \n" @@ -105,130 +109,130 @@ msgstr "" "Kontrollsumma: %02x \n" " " -#: common/fbus-3810.c:1850 common/fbus-3810.c:1980 +#: common/fbus-3810.c:1957 common/fbus-3810.c:2087 msgid "Set Mem Loc Write failed!" msgstr "" -#: common/fbus-3810.c:1895 +#: common/fbus-3810.c:2002 msgid "TX_SendRLPFrame - write:" msgstr "" -#: common/fbus-3810.c:1907 +#: common/fbus-3810.c:2014 msgid "Request HangupMessage Write failed!" msgstr "" -#: common/fbus-3810.c:1919 +#: common/fbus-3810.c:2026 msgid "0x4a Write failed!" msgstr "0x4a Kirjutamine ebaõnnestus!" -#: common/fbus-3810.c:1934 +#: common/fbus-3810.c:2041 msgid "Explore Write failed!" msgstr "" -#: common/fbus-3810.c:1944 +#: common/fbus-3810.c:2051 msgid "0x3f Write failed!" msgstr "0x3f Kirjutamine ebaõnnestus!" -#: common/fbus-3810.c:2004 +#: common/fbus-3810.c:2111 msgid "Request Mem Loc Write failed!" msgstr "" -#: common/fbus-3810.c:2017 +#: common/fbus-3810.c:2124 msgid "Request IMEI/Revision/Model Write failed!" msgstr "" -#: common/fbus-3810.c:2060 +#: common/fbus-3810.c:2167 msgid "Send SMS header failed!" msgstr "SMS päise saatmine ebaõnnestus!" -#: common/fbus-3810.c:2119 +#: common/fbus-3810.c:2226 msgid "Store SMS header failed!" msgstr "SMS päise salvestamine ebaõnnestus!" -#: common/fbus-3810.c:2144 +#: common/fbus-3810.c:2251 #, c-format msgid "Send SMS block %d failed!" msgstr "" -#: common/fbus-3810.c:2167 +#: common/fbus-3810.c:2274 msgid "Request SMS Mem Loc Write failed!" msgstr "" -#: common/fbus-3810.c:2190 +#: common/fbus-3810.c:2297 msgid "Delete SMS Mem Loc write failed!" msgstr "SMS kustutamine mälupesast ebaõnnestus!" -#: common/fbus-3810.c:2209 +#: common/fbus-3810.c:2316 msgid "0x15 Write failed!" msgstr "0x15 Kirjutamine ebaõnnestus!" -#: common/fbus-3810.c:2226 common/mbus-6160.c:1280 +#: common/fbus-3810.c:2333 common/mbus-6160.c:1070 msgid "TX_SendMessage - message too long!\n" msgstr "TX_SendMessage - sõnum on liiga pikk!\n" -#: common/fbus-3810.c:2252 common/mbus-6160.c:1083 common/mbus-6160.c:1312 +#: common/fbus-3810.c:2359 common/mbus-6160.c:873 common/mbus-6160.c:1102 msgid "TX_SendMessage - write:" msgstr "TX_SendMessage - kirjuta:" -#: common/fbus-3810.c:2265 common/fbus-3810.c:2398 common/fbus-3810.c:2412 -#: common/fbus-3810.c:2426 common/fbus-3810.c:2440 common/fbus-3810.c:2574 -#: common/fbus-3810.c:2635 common/fbus-3810.c:2694 common/fbus-3810.c:2732 +#: common/fbus-3810.c:2372 common/fbus-3810.c:2508 common/fbus-3810.c:2526 +#: common/fbus-3810.c:2544 common/fbus-3810.c:2558 common/fbus-3810.c:2692 +#: common/fbus-3810.c:2753 common/fbus-3810.c:2812 common/fbus-3810.c:2852 msgid "Write failed!" msgstr "Kirjutamine ebaõnnestus!" -#: common/fbus-3810.c:2279 +#: common/fbus-3810.c:2386 #, c-format msgid "Incoming call - Type: %s. %02x, Number %s.\n" msgstr "Saabuv kõne - Tüüp: %s. %02x, Number %s.\n" -#: common/fbus-3810.c:2306 +#: common/fbus-3810.c:2413 msgid "0x27 Write failed!" msgstr "0x27 Kirjutamine ebaõnnestus!" -#: common/fbus-3810.c:2354 +#: common/fbus-3810.c:2461 msgid "0x4b Write failed!" msgstr "0x4b Kirjutamine ebaõnnestus!" -#: common/fbus-3810.c:2373 +#: common/fbus-3810.c:2480 #, c-format msgid "Status: %s. Batt %02x RF %02x.\n" msgstr "Olek: %s Batt %02x RF %02x.\n" -#: common/fbus-3810.c:2384 +#: common/fbus-3810.c:2491 msgid "0x10 Write failed!" msgstr "0x10 Kirjutamine ebaõnnestus!" -#: common/fbus-3810.c:2388 +#: common/fbus-3810.c:2495 msgid "Call terminated from phone (0x10 message).\n" msgstr "Kõne telefonilt katkestatud (0x10 teade).\n" -#: common/fbus-3810.c:2402 +#: common/fbus-3810.c:2512 msgid "Call terminated from opposite end of line (or from network).\n" msgstr "Kõne katkestatud vastuvõtja või võrgu poolt.\n" -#: common/fbus-3810.c:2416 +#: common/fbus-3810.c:2530 msgid "Call terminated from phone (0x12 message).\n" msgstr "Väljuv kõne katkestatud (0x12 teade).\n" -#: common/fbus-3810.c:2430 +#: common/fbus-3810.c:2548 msgid "Incoming call answered from phone.\n" msgstr "Saabuv kõne vastatud.\n" -#: common/fbus-3810.c:2444 +#: common/fbus-3810.c:2562 #, c-format msgid "%s call established - status bytes %02x %02x.\n" msgstr "%s kõne moodustatud - staatuse bitid %02x %02x.\n" -#: common/fbus-3810.c:2461 +#: common/fbus-3810.c:2579 msgid "0x2c Write failed!" msgstr "0x2c Kirjutamine ebaõnnestus!" -#: common/fbus-3810.c:2548 +#: common/fbus-3810.c:2666 #, c-format msgid "PID:%02x DCS:%02x Timezone:%02x Stat1:%02x Stat2:%02x\n" msgstr "PID:%02x DCS:%02x Ajavöönd:%02x Stat1:%02x Stat2:%02x\n" -#: common/fbus-3810.c:2615 +#: common/fbus-3810.c:2733 #, c-format msgid "" "Incoming SMS %d/%d/%d %d:%02d:%02d tz:0x%02x Sender: %s(Type %02x) Msg " @@ -237,7 +241,7 @@ msgstr "" "Saabuv SMS sõnum %d/%d/%d %d:%02d:%02d AV:0x%02x Saatja: %s(%02x tüüpi) Msg " "Keskus: %s\n" -#: common/fbus-3810.c:2617 +#: common/fbus-3810.c:2735 #, c-format msgid "" " Msg Length %d, Msg memory %d Msg number %d, PID: %02x DCS: %02x Unknown: " @@ -246,1227 +250,1236 @@ msgstr "" " Msg pikkus %d, Msg mälukoht %d Msg number %d, PID: %02x DCS: %02x " "Tundmatud baidid: %02x\n" -#: common/fbus-3810.c:2710 +#: common/fbus-3810.c:2828 msgid "Mobile phone identification received:\n" msgstr "Mobiiltelefeni identifikaator saabus:\n" -#: common/fbus-3810.c:2711 +#: common/fbus-3810.c:2829 #, c-format msgid " IMEI: %s\n" msgstr " IMEI: %s\n" -#: common/fbus-3810.c:2713 +#: common/fbus-3810.c:2831 #, c-format msgid " Model: %s\n" msgstr " Mudel: %s\n" -#: common/fbus-3810.c:2715 +#: common/fbus-3810.c:2833 #, c-format msgid " Revision: %s\n" msgstr " Versioon: %s\n" -#: common/fbus-3810.c:2783 +#: common/fbus-3810.c:2907 msgid "SMS Message Center Data:\n" msgstr "SMS Keskuse info: \n" -#: common/fbus-3810.c:2784 +#: common/fbus-3810.c:2908 #, c-format msgid "Selected memory: 0x%02x\n" msgstr "Valitud mälu: 0x%02x\n" -#: common/fbus-3810.c:2785 +#: common/fbus-3810.c:2909 #, c-format msgid "Messages in Phone: 0x%02x Unread: 0x%02x\n" msgstr "Lühisõnumeid Telefonis: 0x%02x Lugemata: 0x%02x\n" -#: common/fbus-3810.c:2787 +#: common/fbus-3810.c:2911 #, c-format msgid "Messages in SIM: 0x%02x Unread: 0x%02x\n" msgstr "Lühisõnumeid SIM kaardil: 0x%02x Lugemata: 0x%02x\n" -#: common/fbus-3810.c:2789 +#: common/fbus-3810.c:2913 #, c-format msgid "Reply via own centre: 0x%02x (%s)\n" msgstr "" -#: common/fbus-3810.c:2791 +#: common/fbus-3810.c:2915 #, c-format msgid "Delivery reports: 0x%02x (%s)\n" msgstr "Saateraport: 0x%02x (%s)\n" -#: common/fbus-3810.c:2793 +#: common/fbus-3810.c:2917 #, c-format msgid "Messages sent as: 0x%02x\n" msgstr "Sõnum saadetud nagu 0x%02x\n" -#: common/fbus-3810.c:2794 +#: common/fbus-3810.c:2918 #, c-format msgid "Message validity: 0x%02x\n" msgstr "Sõnumi kehtivus on 0x%02x\n" -#: common/fbus-3810.c:2795 +#: common/fbus-3810.c:2919 #, c-format msgid "Unknown: 0x%02x\n" msgstr "Tundmatu: 0x%02x\n" -#: common/fbus-3810.c:2798 +#: common/fbus-3810.c:2922 msgid "UnknownNumber field empty." msgstr "TundmatuNumber väli on tühi." -#: common/fbus-3810.c:2800 +#: common/fbus-3810.c:2924 msgid "UnknownNumber: " msgstr "TundmatuNumber: " -#: common/fbus-3810.c:2807 +#: common/fbus-3810.c:2931 msgid "Number field empty." msgstr "Numbriväli on tühi." -#: common/fbus-3810.c:2810 +#: common/fbus-3810.c:2934 xgnokii/xgnokii_calendar.c:229 msgid "Number: " msgstr "Number: " -#: common/fbus-6110.c:891 +#: common/fbus-6110-ringtones.c:352 +#, c-format +msgid "Error in PackRingtone - StartBit different to HowLong %d - %d)\n" +msgstr "" + +#: common/fbus-6110-ringtones.c:411 +msgid "Not header\n" +msgstr "" + +#: common/fbus-6110-ringtones.c:418 +msgid "Not RingingToneProgramming\n" +msgstr "" + +#: common/fbus-6110-ringtones.c:429 +msgid "Not Sound\n" +msgstr "" + +#: common/fbus-6110-ringtones.c:436 +msgid "Not BasicSongType\n" +msgstr "" + +#: common/fbus-6110-ringtones.c:454 +msgid "Not PatternHeaderId\n" +msgstr "" + +#: common/fbus-6110-ringtones.c:556 +msgid "Unsupported block\n" +msgstr "" + +#: common/fbus-6110.c:761 msgid "Timeout in IR-mode\n" msgstr "" -#: common/fbus-6110.c:923 +#: common/fbus-6110.c:795 msgid "Couldn't open FB61 infrared device" msgstr "Ei suuda avada FB61 IR-seadet" -#: common/fbus-6110.c:991 +#: common/fbus-6110.c:875 msgid "Starting IR mode...!\n" msgstr "Alustan IR ühendust...!\n" -#: common/fbus-6110.c:2570 gnokii/gnokii.c:1056 gnokii/gnokii.c:1850 -#: gnokii/gnokii.c:3291 gnokii/gnokii.c:3318 +#: common/fbus-6110.c:2051 gnokii/gnokii.c:978 gnokii/gnokii.c:1808 +#: gnokii/gnokii.c:3215 gnokii/gnokii.c:3242 msgid "Send succeeded!\n" msgstr "Saatmine õnnestus!\n" -#: common/fbus-6110.c:2572 gnokii/gnokii.c:1058 gnokii/gnokii.c:1852 -#: gnokii/gnokii.c:3293 +#: common/fbus-6110.c:2052 gnokii/gnokii.c:980 gnokii/gnokii.c:1810 +#: gnokii/gnokii.c:3217 #, c-format msgid "SMS Send failed (error=%d)\n" msgstr "SMS saatmine ebaõnnestus (viga=%d)\n" -#: common/fbus-6110.c:2603 +#: common/fbus-6110.c:2075 msgid "Serial flags dump:\n" msgstr "Serialpordi lippude olek:\n" -#: common/fbus-6110.c:2604 common/mbus-640.c:928 +#: common/fbus-6110.c:2076 common/mbus-640.c:774 #, c-format msgid "DTR is %s.\n" msgstr "DTR on %s.\n" -#: common/fbus-6110.c:2604 common/fbus-6110.c:2605 common/fbus-6110.c:2606 -#: common/fbus-6110.c:2607 common/mbus-640.c:928 common/mbus-640.c:929 +#: common/fbus-6110.c:2076 common/fbus-6110.c:2077 common/fbus-6110.c:2078 +#: common/fbus-6110.c:2079 common/mbus-640.c:774 common/mbus-640.c:775 msgid "up" -msgstr "toimib" +msgstr "püsti" -#: common/fbus-6110.c:2604 common/fbus-6110.c:2605 common/fbus-6110.c:2606 -#: common/fbus-6110.c:2607 common/mbus-640.c:928 common/mbus-640.c:929 +#: common/fbus-6110.c:2076 common/fbus-6110.c:2077 common/fbus-6110.c:2078 +#: common/fbus-6110.c:2079 common/mbus-640.c:774 common/mbus-640.c:775 msgid "down" -msgstr "maas" +msgstr "pikali" -#: common/fbus-6110.c:2605 common/mbus-640.c:929 +#: common/fbus-6110.c:2077 common/mbus-640.c:775 #, c-format msgid "RTS is %s.\n" msgstr "RTS on %s.\n" -#: common/fbus-6110.c:2606 +#: common/fbus-6110.c:2078 #, c-format msgid "CAR is %s.\n" msgstr "CAR on %s.\n" -#: common/fbus-6110.c:2607 +#: common/fbus-6110.c:2079 #, c-format msgid "CTS is %s.\n" msgstr "CTS on %s.\n" -#: common/fbus-6110.c:2642 +#: common/fbus-6110.c:2112 msgid "Setting FBUS communication...\n" -msgstr "Tekitan FBUS ühendust...\n" +msgstr "Seadistan FBUS ühendust...\n" -#: common/fbus-6110.c:2673 +#: common/fbus-6110.c:2146 msgid "Couldn't open FB61 device" msgstr "Ei suuda avada FB61 seadet" -#: common/fbus-6110.c:2800 +#: common/fbus-6110.c:2253 msgid "Message: Call message, type 0x02:" msgstr "Teade: Kõneteade, tüüp 0x02:" -#: common/fbus-6110.c:2801 common/fbus-6110.c:2813 common/fbus-6110.c:2915 +#: common/fbus-6110.c:2254 common/fbus-6110.c:2261 common/fbus-6110.c:2326 msgid " Exact meaning not known yet, sorry :-(\n" msgstr " Täpne tagamõte hetkel tundmatu ... :-(\n" -#: common/fbus-6110.c:2811 +#: common/fbus-6110.c:2259 msgid "Message: Call message, type 0x03:" msgstr "Teade: Kõneteade, tüüp 0x03:" -#: common/fbus-6110.c:2812 common/fbus-6110.c:2828 common/fbus-6110.c:2846 -#: common/fbus-6110.c:2877 common/fbus-6110.c:2888 common/fbus-6110.c:2914 +#: common/fbus-6110.c:2260 common/fbus-6110.c:2271 common/fbus-6110.c:2280 +#: common/fbus-6110.c:2299 common/fbus-6110.c:2305 common/fbus-6110.c:2325 #, c-format msgid " Sequence nr. of the call: %d\n" msgstr " Kõne järjenumber: %d\n" -#: common/fbus-6110.c:2827 +#: common/fbus-6110.c:2270 msgid "Message: Remote end hang up.\n" msgstr "Teade: Teine pool katkestas kõne.\n" -#: common/fbus-6110.c:2841 +#: common/fbus-6110.c:2277 msgid "Message: Incoming call alert:\n" msgstr "Teade: Saabuva kõne hoiatus:\n" -#: common/fbus-6110.c:2847 common/fbus-6110.c:3130 +#: common/fbus-6110.c:2281 common/fbus-6110.c:2476 msgid " Number: " msgstr " Number: " -#: common/fbus-6110.c:2855 common/fbus-6110.c:3114 +#: common/fbus-6110.c:2286 common/fbus-6110.c:2464 msgid " Name: " msgstr " Nimi: " -#: common/fbus-6110.c:2876 +#: common/fbus-6110.c:2298 msgid "Message: Call answered.\n" msgstr "Sõnum: Kõne vastatud.\n" -#: common/fbus-6110.c:2887 +#: common/fbus-6110.c:2304 msgid "Message: Call ended by your phone.\n" msgstr "Teade: Kõne lõpetatud oma telefoni poolt.\n" -#: common/fbus-6110.c:2913 +#: common/fbus-6110.c:2324 msgid "Message: Call message, type 0x0a:" msgstr "Teade: Kõneteade, tüüp 0x0a:" -#: common/fbus-6110.c:2926 +#: common/fbus-6110.c:2333 msgid "Message: Unknown message of type 0x01\n" msgstr "Teade: Tundmatu 0x01 tüüpi sõnum\n" -#: common/fbus-6110.c:2944 +#: common/fbus-6110.c:2343 msgid "Message: SMS Message correctly sent.\n" msgstr "Teade: SMS sõnum korrektselt saadetud.\n" -#: common/fbus-6110.c:2955 +#: common/fbus-6110.c:2348 msgid "Message: Sending SMS Message failed.\n" msgstr "Teade: SMS sõnumi saatmine ebaõnnestus.\n" -#: common/fbus-6110.c:2964 +#: common/fbus-6110.c:2353 msgid "Message: SMS Message Received\n" msgstr "Teade: SMS sõnum saabus\n" -#: common/fbus-6110.c:2965 common/fbus-6110.c:4407 +#: common/fbus-6110.c:2354 common/fbus-6110.c:3299 #, c-format msgid " SMS center number: %s\n" msgstr " SMS keskuse number: %s\n" -#: common/fbus-6110.c:2969 common/fbus-6110.c:4408 +#: common/fbus-6110.c:2358 common/fbus-6110.c:3300 #, c-format msgid " Remote number: %s\n" msgstr " Teise poole number: %s\n" -#: common/fbus-6110.c:2970 +#: common/fbus-6110.c:2359 #, c-format msgid " Date: %s\n" msgstr " Kuupäev: %s\n" -#: common/fbus-6110.c:2971 +#: common/fbus-6110.c:2360 msgid " SMS: " msgstr " SMS: " -#: common/fbus-6110.c:2986 +#: common/fbus-6110.c:2370 +msgid "Message: Cell Broadcast enabled/disabled successfully.\n" +msgstr "" + +#: common/fbus-6110.c:2379 +msgid "Message: CB received.\n" +msgstr "" + +#: common/fbus-6110.c:2380 +#, c-format +msgid "Message: channel number %i\n" +msgstr "Teade: kanal number %i\n" + +#: common/fbus-6110.c:2392 msgid "Message: SMS Center correctly set.\n" msgstr "Teade: SMS keskus korrektselt paigas.\n" -#: common/fbus-6110.c:3002 +#: common/fbus-6110.c:2404 msgid "Message: SMS Center received:\n" msgstr "Teade: SMS keskus saabus:\n" -#: common/fbus-6110.c:3003 +#: common/fbus-6110.c:2405 #, c-format msgid " %d. SMS Center name is %s\n" msgstr " %d. SMS Keskuse nimi on %s\n" -#: common/fbus-6110.c:3004 +#: common/fbus-6110.c:2406 #, c-format msgid " SMS Center number is %s\n" msgstr " SMS keskuse number on %s\n" -#: common/fbus-6110.c:3006 +#: common/fbus-6110.c:2407 msgid " SMS Center message format is " msgstr " SMS keskuse teate formaat on " -#: common/fbus-6110.c:3011 gnokii/gnokii.c:1149 xgnokii/xgnokii.c:528 -#: xgnokii/xgnokii.c:557 xgnokii/xgnokii.c:1384 +#: common/fbus-6110.c:2410 gnokii/gnokii.c:1117 xgnokii/xgnokii.c:546 +#: xgnokii/xgnokii.c:575 xgnokii/xgnokii.c:1445 xgnokii/xgnokii_calendar.c:862 msgid "Text" msgstr "Tekst" -#: common/fbus-6110.c:3015 gnokii/gnokii.c:1153 xgnokii/xgnokii.c:532 -#: xgnokii/xgnokii.c:1398 +#: common/fbus-6110.c:2411 gnokii/gnokii.c:1121 xgnokii/xgnokii.c:550 +#: xgnokii/xgnokii.c:1459 msgid "Paging" -msgstr "" +msgstr "Piipar" -#: common/fbus-6110.c:3019 gnokii/gnokii.c:1157 xgnokii/xgnokii.c:536 -#: xgnokii/xgnokii.c:1391 +#: common/fbus-6110.c:2412 gnokii/gnokii.c:1125 xgnokii/xgnokii.c:554 +#: xgnokii/xgnokii.c:1452 xgnokii/xgnokii_contacts.c:1784 msgid "Fax" msgstr "Faks" -#: common/fbus-6110.c:3023 gnokii/gnokii.c:1162 +#: common/fbus-6110.c:2413 gnokii/gnokii.c:1130 msgid "Email" msgstr "" -#: common/fbus-6110.c:3027 common/fbus-6110.c:3061 common/fbus-6110.c:4629 -#: common/fbus-6110.c:5167 gnokii/gnokii.c:1174 gnokii/gnokii.c:1208 +#: common/fbus-6110.c:2414 common/fbus-6110.c:2428 common/fbus-6110.c:3467 +#: common/fbus-6110.c:3879 gnokii/gnokii.c:1142 gnokii/gnokii.c:1176 +#: xgnokii/xgnokii_calendar.c:153 msgid "Unknown" msgstr "Tundmatu" -#: common/fbus-6110.c:3032 +#: common/fbus-6110.c:2419 msgid " SMS Center message validity is " msgstr " SMS keskuse teate kehtivusaeg on " -#: common/fbus-6110.c:3037 gnokii/gnokii.c:1184 +#: common/fbus-6110.c:2422 gnokii/gnokii.c:1152 msgid "1 hour" msgstr "1 tund" -#: common/fbus-6110.c:3041 gnokii/gnokii.c:1188 +#: common/fbus-6110.c:2423 gnokii/gnokii.c:1156 msgid "6 hours" msgstr "6 tundi" -#: common/fbus-6110.c:3045 gnokii/gnokii.c:1192 +#: common/fbus-6110.c:2424 gnokii/gnokii.c:1160 msgid "24 hours" msgstr "24 tundi" -#: common/fbus-6110.c:3049 gnokii/gnokii.c:1196 +#: common/fbus-6110.c:2425 gnokii/gnokii.c:1164 msgid "72 hours" msgstr "72 tundi" -#: common/fbus-6110.c:3053 gnokii/gnokii.c:1200 xgnokii/xgnokii.c:580 -#: xgnokii/xgnokii.c:1463 +#: common/fbus-6110.c:2426 gnokii/gnokii.c:1168 xgnokii/xgnokii.c:598 +#: xgnokii/xgnokii.c:1524 msgid "1 week" msgstr "1 nädal" -#: common/fbus-6110.c:3057 gnokii/gnokii.c:1204 +#: common/fbus-6110.c:2427 gnokii/gnokii.c:1172 msgid "Maximum time" msgstr "Maksimaalne aeg" -#: common/fbus-6110.c:3079 +#: common/fbus-6110.c:2438 msgid "Message: SMS Center error received:\n" msgstr "Teade: SMS keskuse viga saabus:\n" -#: common/fbus-6110.c:3080 +#: common/fbus-6110.c:2439 msgid " The request for SMS Center failed.\n" msgstr " Sõnumikeskuse päring ebaõnnestus.\n" -#: common/fbus-6110.c:3091 +#: common/fbus-6110.c:2446 msgid "Unknown message!\n" msgstr "Tundmatu sõnum!\n" -#: common/fbus-6110.c:3113 +#: common/fbus-6110.c:2463 msgid "Message: Phonebook entry received:\n" msgstr "Teade: Telefoniraamatu kirje saabus:\n" -#: common/fbus-6110.c:3150 +#: common/fbus-6110.c:2492 msgid " Date: " msgstr " Kuupäev: " -#: common/fbus-6110.c:3152 +#: common/fbus-6110.c:2494 msgid " Time: " msgstr " Kellaaeg: " -#: common/fbus-6110.c:3165 +#: common/fbus-6110.c:2504 msgid "Message: Phonebook read entry error received:\n" msgstr "Teade: Telefoniraamatu lugemise viga saabus:\n" -#: common/fbus-6110.c:3173 +#: common/fbus-6110.c:2507 msgid " Invalid memory type!\n" msgstr " Vale mälu tüüp!\n" -#: common/fbus-6110.c:3183 common/fbus-6110.c:3221 +#: common/fbus-6110.c:2511 common/fbus-6110.c:2534 msgid " Unknown error!\n" msgstr " Tundmatu viga!\n" -#: common/fbus-6110.c:3194 +#: common/fbus-6110.c:2518 msgid "Message: Phonebook written correctly.\n" msgstr "Teade: Telefoniraamat korrektselt kirjutatud.\n" -#: common/fbus-6110.c:3211 +#: common/fbus-6110.c:2529 msgid "Message: Phonebook not written - name is too long.\n" msgstr "Teade: Telefoniraamatusse ei kirjutatud - nimi on liiga pikk.\n" -#: common/fbus-6110.c:3232 +#: common/fbus-6110.c:2542 msgid "Message: Memory status received:\n" msgstr "Teade: Mälu olek saabus:\n" -#: common/fbus-6110.c:3234 +#: common/fbus-6110.c:2543 #, c-format msgid " Memory Type: %s\n" msgstr " Mälu tüüp: %s\n" -#: common/fbus-6110.c:3235 +#: common/fbus-6110.c:2544 #, c-format msgid " Used: %d\n" msgstr " Kasutatud: %d\n" -#: common/fbus-6110.c:3236 +#: common/fbus-6110.c:2545 #, c-format msgid " Free: %d\n" msgstr " Vaba: %d\n" -#: common/fbus-6110.c:3251 +#: common/fbus-6110.c:2554 msgid "Message: Memory status error, phone is probably powered off.\n" msgstr "Teade: Mälu oleku viga, telefon on tõenäoliselt väljalülitatud.\n" -#: common/fbus-6110.c:3258 +#: common/fbus-6110.c:2559 msgid "" "Message: Memory status error, memory type not supported by phone model.\n" -msgstr "" -"Teade: Mälu oleku viga, mälu tüüp pole telefoni poolt toetatud.\n" +msgstr "Teade: Mälu oleku viga, mälu tüüp pole telefoni poolt toetatud.\n" -#: common/fbus-6110.c:3265 +#: common/fbus-6110.c:2564 msgid "Message: Memory status error, waiting for security code.\n" msgstr "Teade: Mälu oleku viga, ootan turvakoodi.\n" -#: common/fbus-6110.c:3272 +#: common/fbus-6110.c:2569 #, c-format msgid "" "Message: Unknown Memory status error, subtype (MessageBuffer[4]) = %02x\n" msgstr "" -#: common/fbus-6110.c:3289 +#: common/fbus-6110.c:2584 msgid "Message: Caller group logo etc.\n" msgstr "Teade: Helistaja grupi Logo jms.\n" -#: common/fbus-6110.c:3290 +#: common/fbus-6110.c:2585 #, c-format msgid "Caller group name: %s\n" msgstr "Helistaja grupi nimi: %s\n" -#: common/fbus-6110.c:3310 +#: common/fbus-6110.c:2602 msgid "Message: Caller group data received but not requested!\n" msgstr "Teade: Helistaja grupi andmed saabusid kuid polnud küsitud!\n" -#: common/fbus-6110.c:3320 +#: common/fbus-6110.c:2608 msgid "Message: Error attempting to get caller group data.\n" msgstr "Teade: Helistajagrupi andmete saamise viga.\n" -#: common/fbus-6110.c:3328 +#: common/fbus-6110.c:2613 msgid "Message: Caller group data set correctly.\n" msgstr "Teade: Helistaja grupi andmed korrektselt seatud.\n" -#: common/fbus-6110.c:3336 +#: common/fbus-6110.c:2618 msgid "Message: Error attempting to set caller group data\n" msgstr "Teade: Helistajagrupi andmete seadmise viga.\n" -#: common/fbus-6110.c:3347 +#: common/fbus-6110.c:2624 msgid "Message: Speed dial entry received:\n" msgstr "Teade: kiirvalimise kirje saabus:\n" -#: common/fbus-6110.c:3348 +#: common/fbus-6110.c:2625 #, c-format msgid " Location: %d\n" msgstr " Asukoht: %d\n" -#: common/fbus-6110.c:3349 +#: common/fbus-6110.c:2626 #, c-format msgid " MemoryType: %s\n" msgstr " Mälu tüüp: %s\n" -#: common/fbus-6110.c:3350 +#: common/fbus-6110.c:2627 #, c-format msgid " Number: %d\n" msgstr " Number: %d\n" -#: common/fbus-6110.c:3360 +#: common/fbus-6110.c:2632 msgid "Message: Speed dial entry error\n" msgstr "Teade: kiirvalimise sisestuse viga\n" -#: common/fbus-6110.c:3370 +#: common/fbus-6110.c:2637 msgid "Message: Speed dial entry set.\n" msgstr "Teade: kiirvalimise kirje seatud.\n" -#: common/fbus-6110.c:3380 +#: common/fbus-6110.c:2642 msgid "Message: Speed dial entry setting error.\n" msgstr "Teade: kiirvalimise kirje seade viga.\n" -#: common/fbus-6110.c:3390 +#: common/fbus-6110.c:2647 msgid "Message: Unknown message of type 0x03\n" msgstr "Teade: Tundmatu 0x03 tüüpi sõnum\n" -#: common/fbus-6110.c:3406 +#: common/fbus-6110.c:2658 msgid "Message: Phone status received:\n" msgstr "Teade: Telefoni olek saabunud:\n" -#: common/fbus-6110.c:3407 +#: common/fbus-6110.c:2659 msgid " Mode: " msgstr " Olek: " -#: common/fbus-6110.c:3413 +#: common/fbus-6110.c:2661 msgid "registered within the network\n" msgstr "registreeritud võrkku\n" -#: common/fbus-6110.c:3422 +#: common/fbus-6110.c:2664 msgid "call in progress\n" msgstr "kõne käimas\n" -#: common/fbus-6110.c:3428 +#: common/fbus-6110.c:2665 msgid "waiting for security code\n" msgstr "ootan turvakoodi.\n" -#: common/fbus-6110.c:3434 +#: common/fbus-6110.c:2666 msgid "powered off\n" msgstr "toide välja\n" -#: common/fbus-6110.c:3440 common/fbus-6110.c:3462 +#: common/fbus-6110.c:2667 common/fbus-6110.c:2673 msgid "unknown\n" msgstr "tundmatu\n" -#: common/fbus-6110.c:3444 +#: common/fbus-6110.c:2669 msgid " Power source: " msgstr " Toiteallikas: " -#: common/fbus-6110.c:3450 +#: common/fbus-6110.c:2671 msgid "AC/DC\n" msgstr "Vahelduvvool/Alalisvool\n" -#: common/fbus-6110.c:3456 +#: common/fbus-6110.c:2672 msgid "battery\n" msgstr "aku\n" -#: common/fbus-6110.c:3466 +#: common/fbus-6110.c:2675 #, c-format msgid " Battery Level: %d\n" msgstr " Aku laadumus: %d\n" -#: common/fbus-6110.c:3467 +#: common/fbus-6110.c:2676 #, c-format msgid " Signal strength: %d\n" msgstr " Signaali väljatugevus: %d\n" -#: common/fbus-6110.c:3479 +#: common/fbus-6110.c:2684 msgid "Message: Unknown message of type 0x04\n" msgstr "Teade: Tundmatu 0x04 tüüpi sõnum\n" -#: common/fbus-6110.c:3495 +#: common/fbus-6110.c:2695 msgid "Message: Profile feature change result.\n" msgstr "Teade: Profiili omadus muutis tulemust.\n" -#: common/fbus-6110.c:3553 +#: common/fbus-6110.c:2737 msgid "Message: Startup Logo, welcome note and dealer welcome note received.\n" -msgstr "Teade: Saabusid Startup Logo, Teretere teade ja diileri tervitustede.\n" +msgstr "Teade: Saabusid Startup Logo, Teretere teade ja diileri tervitusteade.\n" -#: common/fbus-6110.c:3577 +#: common/fbus-6110.c:2755 msgid "Startup logo supported - " msgstr "Startup Logo on toetatud - " -#: common/fbus-6110.c:3580 +#: common/fbus-6110.c:2756 msgid "currently set\n" msgstr "hetkel seatud\n" -#: common/fbus-6110.c:3582 common/fbus-6110.c:3601 common/fbus-6110.c:3621 -#: gnokii/gnokii.c:2017 +#: common/fbus-6110.c:2757 common/fbus-6110.c:2772 common/fbus-6110.c:2788 +#: gnokii/gnokii.c:1913 msgid "currently empty\n" msgstr "hetkel tühi\n" -#: common/fbus-6110.c:3594 +#: common/fbus-6110.c:2766 msgid "Startup Text supported - " msgstr "Startup Tekst on toetatud - " -#: common/fbus-6110.c:3597 common/fbus-6110.c:3617 +#: common/fbus-6110.c:2768 common/fbus-6110.c:2785 msgid "currently set to \"" msgstr "hetkel seatud \"" -#: common/fbus-6110.c:3598 common/fbus-6110.c:3618 common/fbus-6110.c:4755 -#: common/fbus-6110.c:4759 +#: common/fbus-6110.c:2769 common/fbus-6110.c:2786 #, c-format msgid "%c" msgstr "" -#: common/fbus-6110.c:3599 common/fbus-6110.c:3619 +#: common/fbus-6110.c:2770 common/fbus-6110.c:2787 msgid "\"\n" msgstr "" -#: common/fbus-6110.c:3614 +#: common/fbus-6110.c:2783 msgid "Dealer Welcome supported - " msgstr "" -#: common/fbus-6110.c:3634 +#: common/fbus-6110.c:2796 msgid "Message: Startup logo received but not requested!\n" msgstr "Teade: Startup logo saabus, kuid pole küsitud!\n" -#: common/fbus-6110.c:3643 +#: common/fbus-6110.c:2801 msgid "" "Message: Startup logo, welcome note or dealer welcome note correctly set.\n" msgstr "" -#: common/fbus-6110.c:3669 +#: common/fbus-6110.c:2820 msgid "Message: Operator logo correctly set.\n" msgstr "Teade: Operaatori Logo korrektselt paigas.\n" -#: common/fbus-6110.c:3678 +#: common/fbus-6110.c:2826 msgid "Message: Error setting operator logo!\n" msgstr "Teade: Viga operaatori logo kehtestamisel!\n" -#: common/fbus-6110.c:3701 +#: common/fbus-6110.c:2841 #, c-format msgid "Message: Operator Logo for %s (%s) network received.\n" msgstr "Teade: Saabus Operaatori Logo võrgule %s (%s).\n" -#: common/fbus-6110.c:3719 +#: common/fbus-6110.c:2855 msgid "Message: Operator logo received but not requested!\n" msgstr "Teade: Operaatori Logo saabunud, kuid mitte küsitud!\n" -#: common/fbus-6110.c:3728 +#: common/fbus-6110.c:2859 msgid "Message: Error getting operator logo!\n" msgstr "Teade: Viga operaatori logo võtmisel!\n" -#: common/fbus-6110.c:3746 +#: common/fbus-6110.c:2871 msgid "Message: Security Code status received: " msgstr "Teade: Security koodi olek saabus: " -#: common/fbus-6110.c:3752 gnokii/gnokii.c:1604 +#: common/fbus-6110.c:2873 gnokii/gnokii.c:1659 msgid "waiting for Security Code.\n" msgstr "ootan Security koodi.\n" -#: common/fbus-6110.c:3757 gnokii/gnokii.c:1609 +#: common/fbus-6110.c:2874 gnokii/gnokii.c:1664 msgid "waiting for PIN.\n" msgstr "ootan PIN koodi.\n" -#: common/fbus-6110.c:3762 gnokii/gnokii.c:1614 +#: common/fbus-6110.c:2875 gnokii/gnokii.c:1669 msgid "waiting for PIN2.\n" msgstr "ootan PIN2 koodi.\n" -#: common/fbus-6110.c:3767 gnokii/gnokii.c:1619 +#: common/fbus-6110.c:2876 gnokii/gnokii.c:1674 msgid "waiting for PUK.\n" msgstr "ootan PUK koodi.\n" -#: common/fbus-6110.c:3772 gnokii/gnokii.c:1624 +#: common/fbus-6110.c:2877 gnokii/gnokii.c:1679 msgid "waiting for PUK2.\n" msgstr "ootan PUK2 koodi.\n" -#: common/fbus-6110.c:3777 gnokii/gnokii.c:1629 +#: common/fbus-6110.c:2878 gnokii/gnokii.c:1684 msgid "nothing to enter.\n" msgstr "pole midagi sisestada.\n" -#: common/fbus-6110.c:3782 gnokii/gnokii.c:1634 +#: common/fbus-6110.c:2879 gnokii/gnokii.c:1689 msgid "Unknown!\n" msgstr "Tundmatu!\n" -#: common/fbus-6110.c:3794 +#: common/fbus-6110.c:2885 msgid "Message: Security code accepted.\n" msgstr "Teade: Security kood aksepteeritud.\n" -#: common/fbus-6110.c:3804 +#: common/fbus-6110.c:2890 msgid "Message: Security code is wrong. You're not my big owner :-)\n" msgstr "Teade: Security kood on vale. Sa pole telefoni õige omanik :-)\n" -#: common/fbus-6110.c:3831 -msgid "Message: Network informations:\n" +#: common/fbus-6110.c:2909 +msgid "Message: Network information:\n" msgstr "Teade: Võrgu informatsioon:\n" -#: common/fbus-6110.c:3833 +#: common/fbus-6110.c:2911 #, c-format msgid " CellID: %s\n" msgstr " KärjeID: %s\n" -#: common/fbus-6110.c:3834 +#: common/fbus-6110.c:2912 #, c-format msgid " LAC: %s\n" msgstr "" -#: common/fbus-6110.c:3835 +#: common/fbus-6110.c:2913 #, c-format msgid " Network code: %s\n" msgstr " Võrgu kood: %s\n" -#: common/fbus-6110.c:3836 +#: common/fbus-6110.c:2914 #, c-format msgid " Network name: %s (%s)\n" msgstr " Võrgu nimi: %s (%s)\n" -#: common/fbus-6110.c:3839 +#: common/fbus-6110.c:2917 msgid " Status: " msgstr " Olek: " -#: common/fbus-6110.c:3842 +#: common/fbus-6110.c:2920 msgid "home network selected" msgstr "koduvõrk valitud" -#: common/fbus-6110.c:3843 +#: common/fbus-6110.c:2921 msgid "roaming network" msgstr "roaming võrk" -#: common/fbus-6110.c:3844 +#: common/fbus-6110.c:2922 msgid "requesting network" msgstr "võrgupäring" -#: common/fbus-6110.c:3845 +#: common/fbus-6110.c:2923 msgid "not registered in the network" msgstr "pole võrkku registreerunud" -#: common/fbus-6110.c:3846 +#: common/fbus-6110.c:2924 xgnokii/xgnokii_lowlevel.c:116 +#: xgnokii/xgnokii_lowlevel.c:191 xgnokii/xgnokii_lowlevel.c:193 +#: xgnokii/xgnokii_lowlevel.c:194 msgid "unknown" msgstr "tundmatu" -#: common/fbus-6110.c:3851 +#: common/fbus-6110.c:2929 #, c-format msgid " Network selection: %s\n" msgstr " Võrgu valik: %s\n" -#: common/fbus-6110.c:3851 +#: common/fbus-6110.c:2929 msgid "manual" msgstr "käsiraamat" -#: common/fbus-6110.c:3851 +#: common/fbus-6110.c:2929 msgid "automatic" msgstr "automaatne" -#: common/fbus-6110.c:3861 +#: common/fbus-6110.c:2935 msgid "Message: Unknown message of type 0x0a\n" msgstr "Teade: Tundmatu 0x0a tüüpi sõnum\n" -#: common/fbus-6110.c:3878 -msgid "Message: Result of key " -msgstr " " - -#: common/fbus-6110.c:3881 -msgid "press\n" -msgstr "vajuta\n" - -#: common/fbus-6110.c:3882 -msgid "release\n" -msgstr "vabasta\n" - -#: common/fbus-6110.c:3883 -msgid "press or release - error\n" -msgstr "vajuta või vabasta - viga\n" - -#: common/fbus-6110.c:3890 -msgid "Message: Unknown message of type 0x0c\n" -msgstr "Teade: Tundmatu 0x0c tüüpi sõnum\n" - -#: common/fbus-6110.c:3925 gnokii/gnokii.c:3119 +#: common/fbus-6110.c:2958 gnokii/gnokii.c:3048 #, c-format msgid "Call in progress: %s\n" msgstr "Kõne on käimas: %s\n" -#: common/fbus-6110.c:3926 gnokii/gnokii.c:3120 +#: common/fbus-6110.c:2959 gnokii/gnokii.c:3049 #, c-format msgid "Unknown: %s\n" msgstr "Tundmatu: %s\n" -#: common/fbus-6110.c:3927 gnokii/gnokii.c:3121 +#: common/fbus-6110.c:2960 gnokii/gnokii.c:3050 #, c-format msgid "Unread SMS: %s\n" msgstr "Lugemata SMS: %s\n" -#: common/fbus-6110.c:3928 gnokii/gnokii.c:3122 +#: common/fbus-6110.c:2961 gnokii/gnokii.c:3051 #, c-format msgid "Voice call: %s\n" msgstr "" -#: common/fbus-6110.c:3929 gnokii/gnokii.c:3123 +#: common/fbus-6110.c:2962 gnokii/gnokii.c:3052 #, c-format msgid "Fax call active: %s\n" msgstr "Faxi kõne aktiivne: %s\n" -#: common/fbus-6110.c:3930 gnokii/gnokii.c:3124 +#: common/fbus-6110.c:2963 gnokii/gnokii.c:3053 #, c-format msgid "Data call active: %s\n" msgstr "Andmekõne aktiivne: %\n" -#: common/fbus-6110.c:3931 gnokii/gnokii.c:3125 +#: common/fbus-6110.c:2964 gnokii/gnokii.c:3054 #, c-format msgid "Keyboard lock: %s\n" msgstr "Klaviatuuri lukk: %s\n" -#: common/fbus-6110.c:3932 gnokii/gnokii.c:3126 +#: common/fbus-6110.c:2965 gnokii/gnokii.c:3055 #, c-format msgid "SMS storage full: %s\n" msgstr "SMS varamu on täis: %s\n" -#: common/fbus-6110.c:3945 +#: common/fbus-6110.c:2971 msgid "Display output successfully disabled/enabled.\n" msgstr "" -#: common/fbus-6110.c:3955 +#: common/fbus-6110.c:2977 msgid "Unknown message of type 0x0d.\n" msgstr "Tundmatu 0x0d tüüpi sõnum.\n" -#: common/fbus-6110.c:3974 +#: common/fbus-6110.c:2989 msgid "Message: Date and time set correctly\n" msgstr "Teade: Kuupäev ja kellaaeg seatud korrektselt\n" -#: common/fbus-6110.c:3984 common/fbus-6110.c:4030 +#: common/fbus-6110.c:2994 common/fbus-6110.c:3024 msgid "Message: Date and time set error\n" msgstr "Teade: Kuupäeva ja kellaaja seade viga\n" -#: common/fbus-6110.c:4004 +#: common/fbus-6110.c:3009 msgid "Message: Date and time\n" msgstr "Teade: Kuupäev ja kellaaeg\n" -#: common/fbus-6110.c:4005 common/fbus-6110.c:4158 gnokii/gnokii.c:2321 +#: common/fbus-6110.c:3010 common/fbus-6110.c:3109 gnokii/gnokii.c:2276 #, c-format msgid " Time: %02d:%02d:%02d\n" msgstr " Kellaaeg: %02d:%02d:%02d\n" -#: common/fbus-6110.c:4006 +#: common/fbus-6110.c:3011 #, c-format msgid " Date: %4d/%02d/%02d\n" msgstr " Kuupäev: %4d/%02d/%02d\n" -#: common/fbus-6110.c:4020 +#: common/fbus-6110.c:3019 msgid "Message: Alarm set correctly\n" msgstr "Teade: Äratus seatud õieti\n" -#: common/fbus-6110.c:4042 +#: common/fbus-6110.c:3031 msgid "Message: Alarm\n" msgstr "Teade: Äratus\n" -#: common/fbus-6110.c:4043 +#: common/fbus-6110.c:3032 #, c-format msgid " Alarm: %02d:%02d\n" msgstr " Äratus: %02d:%02d\n" -#: common/fbus-6110.c:4044 +#: common/fbus-6110.c:3033 #, c-format msgid " Alarm is %s\n" msgstr " Äratus on %s\n" -#: common/fbus-6110.c:4044 gnokii/gnokii.c:3119 gnokii/gnokii.c:3120 -#: gnokii/gnokii.c:3121 gnokii/gnokii.c:3122 gnokii/gnokii.c:3123 -#: gnokii/gnokii.c:3124 gnokii/gnokii.c:3125 gnokii/gnokii.c:3126 +#: common/fbus-6110.c:3033 gnokii/gnokii.c:3048 gnokii/gnokii.c:3049 +#: gnokii/gnokii.c:3050 gnokii/gnokii.c:3051 gnokii/gnokii.c:3052 +#: gnokii/gnokii.c:3053 gnokii/gnokii.c:3054 gnokii/gnokii.c:3055 msgid "on" msgstr "sisse" -#: common/fbus-6110.c:4044 gnokii/gnokii.c:3119 gnokii/gnokii.c:3120 -#: gnokii/gnokii.c:3121 gnokii/gnokii.c:3122 gnokii/gnokii.c:3123 -#: gnokii/gnokii.c:3124 gnokii/gnokii.c:3125 gnokii/gnokii.c:3126 +#: common/fbus-6110.c:3033 gnokii/gnokii.c:3048 gnokii/gnokii.c:3049 +#: gnokii/gnokii.c:3050 gnokii/gnokii.c:3051 gnokii/gnokii.c:3052 +#: gnokii/gnokii.c:3053 gnokii/gnokii.c:3054 gnokii/gnokii.c:3055 msgid "off" msgstr "välja" -#: common/fbus-6110.c:4060 +#: common/fbus-6110.c:3043 msgid "Message: Unknown message of type 0x11\n" msgstr "Teade: Tundmatu 0x11 tüüpi sõnum\n" -#: common/fbus-6110.c:4083 +#: common/fbus-6110.c:3055 msgid "Message: Calendar note write succesfull!\n" msgstr "Teade: Kalendri teate kirjutamine õnnestus!\n" -#: common/fbus-6110.c:4093 common/fbus-6110.c:4103 +#: common/fbus-6110.c:3059 common/fbus-6110.c:3063 msgid "Message: Calendar note write failed!\n" msgstr "Teade: Kalendri teate kirjutamine ebaõnnestus!\n" -#: common/fbus-6110.c:4112 +#: common/fbus-6110.c:3067 msgid "Unknown message of type 0x13 and subtype 0x65\n" msgstr "Tundmatu 0x13 tüüpi ja 0x65 alamtüüpi sõnum.\n" -#: common/fbus-6110.c:4152 +#: common/fbus-6110.c:3105 msgid "Message: Calendar note received.\n" msgstr "Teade: Kalendri teade saabus\n" -#: common/fbus-6110.c:4154 gnokii/gnokii.c:2317 +#: common/fbus-6110.c:3106 gnokii/gnokii.c:2272 #, c-format msgid " Date: %d-%02d-%02d\n" msgstr " Kuupäev: %d-%02d-%02d\n" -#: common/fbus-6110.c:4165 gnokii/gnokii.c:2326 +#: common/fbus-6110.c:3116 gnokii/gnokii.c:2281 #, c-format msgid " Alarm date: %d-%02d-%02d\n" msgstr " Äratuse kuupäev: %d-%02d-%02d\n" -#: common/fbus-6110.c:4169 gnokii/gnokii.c:2330 +#: common/fbus-6110.c:3119 gnokii/gnokii.c:2285 #, c-format msgid " Alarm time: %02d:%02d:%02d\n" msgstr " Äratusaeg: %02d:%02d:%02d\n" -#: common/fbus-6110.c:4174 +#: common/fbus-6110.c:3124 #, c-format msgid " Type: %d\n" msgstr " Tüüp: %d\n" -#: common/fbus-6110.c:4175 gnokii/gnokii.c:2335 +#: common/fbus-6110.c:3125 gnokii/gnokii.c:2290 #, c-format msgid " Text: %s\n" msgstr " Tekst: %s\n" -#: common/fbus-6110.c:4178 gnokii/gnokii.c:2338 +#: common/fbus-6110.c:3127 gnokii/gnokii.c:2293 #, c-format msgid " Phone: %s\n" msgstr " Telefon: %s\n" -#: common/fbus-6110.c:4188 +#: common/fbus-6110.c:3132 msgid "Message: Calendar note not available\n" msgstr "Teade: Kalendri teade pole võimalik\n" -#: common/fbus-6110.c:4198 +#: common/fbus-6110.c:3137 msgid "Message: Calendar note error\n" msgstr "Teade: Kalendri teate viga\n" -#: common/fbus-6110.c:4220 +#: common/fbus-6110.c:3149 msgid "Message: Calendar note deleted\n" msgstr "Teade: Kalendri teade kustutatud\n" -#: common/fbus-6110.c:4231 +#: common/fbus-6110.c:3153 msgid "Message: Calendar note can't be deleted\n" msgstr "Teade: Kalendri teadet ei saa kustutada\n" -#: common/fbus-6110.c:4241 +#: common/fbus-6110.c:3157 msgid "Message: Calendar note deleting error\n" msgstr "Teade: Kalendri teate kustutamise viga\n" -#: common/fbus-6110.c:4257 +#: common/fbus-6110.c:3167 msgid "Message: Calendar Alarm active\n" msgstr "Teade: Kalendri alarm aktiivne\n" -#: common/fbus-6110.c:4258 +#: common/fbus-6110.c:3168 #, c-format msgid " Item number: %d\n" msgstr "" -#: common/fbus-6110.c:4266 +#: common/fbus-6110.c:3172 msgid "Message: Unknown message of type 0x13\n" msgstr "Teade: Tundmatu 0x13 tüüpi sõnum\n" -#: common/fbus-6110.c:4329 +#: common/fbus-6110.c:3224 msgid "Concatenated message!!!\n" msgstr "" -#: common/fbus-6110.c:4350 +#: common/fbus-6110.c:3253 #, c-format msgid "Number: %d\n" msgstr "Number: %d\n" -#: common/fbus-6110.c:4355 +#: common/fbus-6110.c:3256 msgid "Message: Outbox message (mobile originated)\n" msgstr "" -#: common/fbus-6110.c:4358 +#: common/fbus-6110.c:3258 msgid "Sent\n" msgstr "Saadetud\n" -#: common/fbus-6110.c:4360 +#: common/fbus-6110.c:3260 msgid "Not sent\n" msgstr "Saatmata\n" -#: common/fbus-6110.c:4364 +#: common/fbus-6110.c:3264 msgid "Message: Received SMS (mobile terminated)\n" msgstr "Teade: SMS sõnum saabus (telefon katkestas)\n" -#: common/fbus-6110.c:4367 +#: common/fbus-6110.c:3266 msgid "Delivery Report\n" msgstr "Saateraport\n" -#: common/fbus-6110.c:4369 +#: common/fbus-6110.c:3268 msgid "Unknown type\n" msgstr "Tundmatu tüüp\n" -#: common/fbus-6110.c:4372 +#: common/fbus-6110.c:3271 msgid "Read\n" msgstr "Loe\n" -#: common/fbus-6110.c:4374 +#: common/fbus-6110.c:3273 msgid "Not read\n" msgstr "Lugemata\n" -#: common/fbus-6110.c:4376 +#: common/fbus-6110.c:3275 #, c-format msgid " Date: %s " msgstr " Kuupäev: %s " -#: common/fbus-6110.c:4384 common/fbus-6110.c:4400 gnokii/gnokii.c:1338 -#: gnokii/gnokii.c:1351 gnokii/gnokii.c:1378 +#: common/fbus-6110.c:3283 common/fbus-6110.c:3295 gnokii/gnokii.c:1352 +#: gnokii/gnokii.c:1365 gnokii/gnokii.c:1392 #, c-format msgid "%02d00" msgstr "" -#: common/fbus-6110.c:4391 +#: common/fbus-6110.c:3288 #, c-format msgid " SMSC response date: %s " msgstr " SMSC vastuse kuupäev: %s " -#: common/fbus-6110.c:4475 +#: common/fbus-6110.c:3353 msgid "Delivered" msgstr "Saadetud" -#: common/fbus-6110.c:4480 +#: common/fbus-6110.c:3356 msgid "SM received by the SME" msgstr "" -#: common/fbus-6110.c:4483 +#: common/fbus-6110.c:3359 msgid "" "SM forwarded by the SC to the SME but the SC is unable to confirm delivery" msgstr "" -#: common/fbus-6110.c:4486 +#: common/fbus-6110.c:3362 msgid "SM replaced by the SC" msgstr "" -#: common/fbus-6110.c:4494 +#: common/fbus-6110.c:3368 msgid "Failed" msgstr "Ebaõnnestus" -#: common/fbus-6110.c:4501 +#: common/fbus-6110.c:3373 msgid "Temporary error, SC is not making any more transfer attempts\n" msgstr "Ajutine viga, SC ei proovi enam uuesti saata\n" -#: common/fbus-6110.c:4506 common/fbus-6110.c:4599 +#: common/fbus-6110.c:3377 common/fbus-6110.c:3444 msgid "Congestion" msgstr "" -#: common/fbus-6110.c:4510 common/fbus-6110.c:4603 +#: common/fbus-6110.c:3380 common/fbus-6110.c:3447 msgid "SME busy" msgstr "SME on hõivatud" -#: common/fbus-6110.c:4514 common/fbus-6110.c:4607 +#: common/fbus-6110.c:3383 common/fbus-6110.c:3450 msgid "No response from SME" msgstr "SME ei vasta..." -#: common/fbus-6110.c:4518 common/fbus-6110.c:4611 +#: common/fbus-6110.c:3386 common/fbus-6110.c:3453 msgid "Service rejected" msgstr "Teenus tagasilykatud" -#: common/fbus-6110.c:4522 common/fbus-6110.c:4558 common/fbus-6110.c:4615 +#: common/fbus-6110.c:3389 common/fbus-6110.c:3414 common/fbus-6110.c:3456 msgid "Quality of service not aviable" msgstr "" -#: common/fbus-6110.c:4526 common/fbus-6110.c:4619 +#: common/fbus-6110.c:3392 common/fbus-6110.c:3459 msgid "Error in SME" msgstr "Viga SME-s" -#: common/fbus-6110.c:4530 common/fbus-6110.c:4582 common/fbus-6110.c:4623 -#: common/fbus-6110.c:4633 +#: common/fbus-6110.c:3395 common/fbus-6110.c:3432 common/fbus-6110.c:3462 +#: common/fbus-6110.c:3470 #, c-format msgid "Reserved/Specific to SC: %x" msgstr "" -#: common/fbus-6110.c:4537 +#: common/fbus-6110.c:3399 msgid "Permanent error, SC is not making any more transfer attempts\n" msgstr "Püsiv viga, SC ei proovi enam saatmist korrata\n" -#: common/fbus-6110.c:4542 +#: common/fbus-6110.c:3402 msgid "Remote procedure error" msgstr "" -#: common/fbus-6110.c:4546 +#: common/fbus-6110.c:3405 msgid "Incompatibile destination" msgstr "Kokkusobimatu sihtpunkt" -#: common/fbus-6110.c:4550 +#: common/fbus-6110.c:3408 msgid "Connection rejected by SME" msgstr "Ühendusest keelduti SME poolt" -#: common/fbus-6110.c:4554 +#: common/fbus-6110.c:3411 msgid "Not obtainable" msgstr "Ei saa kätte" -#: common/fbus-6110.c:4562 +#: common/fbus-6110.c:3417 msgid "No internetworking available" msgstr "" -#: common/fbus-6110.c:4566 +#: common/fbus-6110.c:3420 msgid "SM Validity Period Expired" msgstr "" -#: common/fbus-6110.c:4570 +#: common/fbus-6110.c:3423 msgid "SM deleted by originating SME" msgstr "" -#: common/fbus-6110.c:4574 +#: common/fbus-6110.c:3426 msgid "SM Deleted by SC Administration" msgstr "" -#: common/fbus-6110.c:4578 +#: common/fbus-6110.c:3429 msgid "SM does not exist" msgstr "" -#: common/fbus-6110.c:4591 +#: common/fbus-6110.c:3438 msgid "Pending" msgstr "Ootel" -#: common/fbus-6110.c:4595 +#: common/fbus-6110.c:3441 msgid "Temporary error, SC still trying to transfer SM\n" msgstr "Ajutine viga, SC püüab ikkagi saata SM'i\n" -#: common/fbus-6110.c:4661 -msgid "Message: SMS reading failed.\n" -msgstr "Teade: SMS lugemine ebaõnnestus.\n" +#: common/fbus-6110.c:3489 +#, c-format +msgid "Message stored at %d\n" +msgstr "" + +#: common/fbus-6110.c:3494 +msgid "SMS saving failed\n" +msgstr "SMS salvestamine ebaõnnestus\n" -#: common/fbus-6110.c:4669 +#: common/fbus-6110.c:3497 +msgid " All locations busy.\n" +msgstr "" + +#: common/fbus-6110.c:3501 common/fbus-6110.c:3516 msgid " Invalid location!\n" msgstr " Vale asukoht!\n" -#: common/fbus-6110.c:4679 +#: common/fbus-6110.c:3505 +msgid " Unknown error.\n" +msgstr " Tundmatu viga.\n" + +#: common/fbus-6110.c:3513 +msgid "Message: SMS reading failed.\n" +msgstr "Teade: SMS lugemine ebaõnnestus.\n" + +#: common/fbus-6110.c:3520 msgid " Empty SMS location.\n" msgstr " Tühi SMS mälupesa.\n" -#: common/fbus-6110.c:4692 +#: common/fbus-6110.c:3527 msgid "Message: SMS deleted successfully.\n" msgstr "Teade: SMS kustutamine õnnestus.\n" -#: common/fbus-6110.c:4702 +#: common/fbus-6110.c:3532 msgid "Message: SMS Status Received\n" msgstr "Teade: SMS olek saabus\n" -#: common/fbus-6110.c:4703 +#: common/fbus-6110.c:3533 #, c-format msgid " The number of messages: %d\n" msgstr " Sõnumite arv: %d\n" -#: common/fbus-6110.c:4704 +#: common/fbus-6110.c:3534 #, c-format msgid " Unread messages: %d\n" msgstr " Lugemata sõnumeid: %d\n" -#: common/fbus-6110.c:4716 +#: common/fbus-6110.c:3541 msgid "Message: SMS Status error, probably not authorized by PIN\n" msgstr "Teade: SMS oleku viga, tõenäoliselt PIN koodiga autoriseerimata\n" -#: common/fbus-6110.c:4743 -msgid "Message: Security code received: " -msgstr "Teade: Turvakood saabus: " - -#: common/fbus-6110.c:4745 gnokii/gnokii.c:1683 -msgid "Security code" -msgstr "Turvakood" - -#: common/fbus-6110.c:4746 gnokii/gnokii.c:1673 gnokii/gnokii.c:1684 -msgid "PIN" -msgstr "" - -#: common/fbus-6110.c:4747 gnokii/gnokii.c:1674 gnokii/gnokii.c:1685 -msgid "PIN2" -msgstr "" - -#: common/fbus-6110.c:4748 gnokii/gnokii.c:1675 gnokii/gnokii.c:1686 -msgid "PUK" -msgstr "" - -#: common/fbus-6110.c:4749 gnokii/gnokii.c:1676 gnokii/gnokii.c:1687 -msgid "PUK2" -msgstr "" - -#: common/fbus-6110.c:4750 -msgid "unknown !" -msgstr "tundmatu !" - -#: common/fbus-6110.c:4753 -msgid " allowed, value \"" -msgstr "" - -#: common/fbus-6110.c:4761 -msgid "\"" -msgstr "" - -#: common/fbus-6110.c:4763 -msgid " not allowed" -msgstr "" - -#: common/fbus-6110.c:4765 -msgid "\n" -msgstr "" - -#: common/fbus-6110.c:4792 +#: common/fbus-6110.c:3563 msgid "Message: Netmonitor correctly set.\n" msgstr "Teade: Võrgumonitor korrektselt paigas.\n" -#: common/fbus-6110.c:4802 +#: common/fbus-6110.c:3567 #, c-format msgid "Message: Netmonitor menu %d received:\n" msgstr "Teade: Võrgumonitori menüü %d saabunud:\n" -#: common/fbus-6110.c:4818 +#: common/fbus-6110.c:3577 msgid "Unknown message of type 0x40.\n" msgstr "Tundmatu 0x40 tüüpi sõnum.\n" -#: common/fbus-6110.c:4840 +#: common/fbus-6110.c:3595 msgid "Message: Mobile phone identification received:\n" msgstr "Teade: Mobiiltelefoni identiteet saabunud:\n" -#: common/fbus-6110.c:4841 +#: common/fbus-6110.c:3596 #, c-format msgid " IMEI: %s\n" msgstr " IMEI: %s\n" -#: common/fbus-6110.c:4843 +#: common/fbus-6110.c:3597 #, c-format msgid " Model: %s\n" msgstr " Mudel: %s\n" -#: common/fbus-6110.c:4845 +#: common/fbus-6110.c:3598 #, c-format msgid " Production Code: %s\n" msgstr " Valmistuskood: %s\n" -#: common/fbus-6110.c:4847 +#: common/fbus-6110.c:3599 #, c-format msgid " HW: %s\n" msgstr " HW: %s\n" -#: common/fbus-6110.c:4849 +#: common/fbus-6110.c:3600 #, c-format msgid " Firmware: %s\n" msgstr " Riistvara: %s\n" -#: common/fbus-6110.c:4855 +#: common/fbus-6110.c:3606 #, c-format msgid " Magic bytes: %02x %02x %02x %02x\n" msgstr " Maagilised baidid: %02x %02x %02x %02x\n" -#: common/fbus-6110.c:4875 +#: common/fbus-6110.c:3617 #, c-format msgid "[Received Ack of type %02x, seq: %2x]\n" msgstr "" -#: common/fbus-6110.c:4893 +#: common/fbus-6110.c:3624 msgid "Message: The phone is powered on - seq 1.\n" msgstr "" -#: common/fbus-6110.c:4917 +#: common/fbus-6110.c:3638 +#, c-format +msgid "" +"Phone info:\n" +"%s\n" +msgstr "" +"Telefoni info:\n" +"%s\n" + +#: common/fbus-6110.c:3648 msgid "Message: The phone is powered on - seq 2.\n" msgstr "" -#: common/fbus-6110.c:4933 +#: common/fbus-6110.c:3655 msgid "Message: Unknown message.\n" msgstr "Teade: Tundmatu sõnum.\n" -#: common/fbus-6110.c:5031 +#: common/fbus-6110.c:3756 msgid "Interrupted MultiFrame-Message - Ignoring it !!!\n" msgstr "" -#: common/fbus-6110.c:5032 +#: common/fbus-6110.c:3757 msgid "Please report it ...\n" msgstr "Palun teata sellest ... \n" -#: common/fbus-6110.c:5099 +#: common/fbus-6110.c:3783 +msgid "FB61: Message buffer overun - resetting\n" +msgstr "" + +#: common/fbus-6110.c:3808 msgid "Bad checksum!\n" msgstr "Vale kontrollsumma!\n" -#: common/fbus-6110.c:5161 xgnokii/xgnokii.c:1698 +#: common/fbus-6110.c:3873 xgnokii/xgnokii.c:1759 msgid "Phone" msgstr "Telefon" -#: common/fbus-6110.c:5164 +#: common/fbus-6110.c:3876 msgid "PC" msgstr "" -#: common/fbus-6110.c:5182 +#: common/fbus-6110.c:3893 #, c-format msgid "Msg Dest: %s\n" msgstr "Msg sihtpunkt: %s\n" -#: common/fbus-6110.c:5183 +#: common/fbus-6110.c:3894 #, c-format msgid "Msg Source: %s\n" msgstr "Msg allikas: %s\n" -#: common/fbus-6110.c:5185 +#: common/fbus-6110.c:3895 #, c-format msgid "Msg Type: %02x\n" msgstr "Msg tüüp: %02x\n" -#: common/fbus-6110.c:5187 +#: common/fbus-6110.c:3896 #, c-format msgid "Msg Unknown: %02x\n" msgstr "Msg tundmatu: %02x\n" -#: common/fbus-6110.c:5188 +#: common/fbus-6110.c:3897 #, c-format msgid "" "Msg Len: %02x\n" @@ -1475,130 +1488,139 @@ msgstr "" "Msg pikkus: %02x\n" "Telefon: " -#: common/fbus-6110.c:5259 +#: common/fbus-6110.c:3963 msgid "PC: " msgstr "" -#: common/fbus-6110.c:5333 +#: common/fbus-6110.c:4029 #, c-format msgid "[Sending Ack of type %02x, seq: %x]\n" msgstr "" -#: common/mbus-6160.c:761 +#: common/mbus-6160.c:551 msgid "Standard Ack write (0x40) failed!" msgstr "" -#: common/mbus-6160.c:787 +#: common/mbus-6160.c:577 msgid "Standard Ack write (0xd2) failed!" msgstr "" -#: common/mbus-6160.c:1232 +#: common/mbus-6160.c:1022 msgid "Couldn't open MB61 device: " msgstr "Ei suuda avada MB61 seadet: " -#: common/mbus-640.c:821 +#: common/mbus-640.c:667 msgid "Phone: " msgstr "Telefon: " -#: common/mbus-640.c:851 common/mbus-640.c:951 +#: common/mbus-640.c:697 common/mbus-640.c:797 msgid "PC : " msgstr "PC : " -#: common/mbus-640.c:861 common/mbus-640.c:964 +#: common/mbus-640.c:707 common/mbus-640.c:810 msgid "Write error!\n" msgstr "Kirjutamine ebaõnnestus!\n" -#: common/mbus-640.c:888 +#: common/mbus-640.c:734 msgid "Setting MBUS communication...\n" -msgstr "Tekitan MBUS ühendust...\n" +msgstr "Seadistan MBUS ühendust...\n" -#: common/rlp-common.c:701 +#: common/rlp-common.c:705 msgid "Unknown!!! " msgstr "Tundmatu!!!" -#: common/rlp-common.c:766 +#: common/rlp-common.c:770 msgid "BAD" msgstr "" -#: common/rlp-common.c:888 +#: common/rlp-common.c:892 msgid "Frame FCS is bad. Ignoring...\n" msgstr "FCS blokk on vigane. Ignoreerin ...\n" -#: common/rlp-common.c:1003 +#: common/rlp-common.c:1007 msgid "Send_TXU()\n" msgstr "" -#: common/rlp-common.c:1004 +#: common/rlp-common.c:1008 #, c-format msgid "XID_R_State=%d\n" msgstr "" -#: common/rlp-common.c:1375 +#: common/rlp-common.c:1380 msgid "RLP state 0.\n" msgstr "" -#: common/rlp-common.c:1412 +#: common/rlp-common.c:1417 msgid "RLP state 1.\n" msgstr "" -#: common/rlp-common.c:1477 +#: common/rlp-common.c:1465 msgid "RLP state 2.\n" msgstr "" -#: common/rlp-common.c:1511 +#: common/rlp-common.c:1499 msgid "UA received in RLP state 2.\n" msgstr "" -#: common/rlp-common.c:1568 +#: common/rlp-common.c:1556 msgid "RLP state 3.\n" msgstr "" -#: common/rlp-common.c:1626 +#: common/rlp-common.c:1614 msgid "RLP state 4.\n" msgstr "" -#: common/rlp-common.c:1764 +#: common/rlp-common.c:1753 msgid "RLP state 5.\n" msgstr "" -#: common/rlp-common.c:1823 +#: common/rlp-common.c:1812 msgid "RLP state 6 - not yet implemented!\n" msgstr "" -#: common/rlp-common.c:1853 +#: common/rlp-common.c:1843 msgid "RLP state 7.\n" msgstr "" -#: common/rlp-common.c:1894 +#: common/rlp-common.c:1885 msgid "DEBUG: Unknown RLP state!\n" msgstr "" -#: gnokii/gnokii.c:168 +#: gnokii/gnokii.c:206 #, c-format msgid "" "GNOKII Version %s\n" "Copyright (C) Hugh Blemings , 1999, 2000\n" "Copyright (C) Pavel Janík ml. , 1999, 2000\n" +"gnokii is free software, covered by the GNU General Public License, and you " +"are\n" +"welcome to change it and/or distribute copies of it under certain " +"conditions.\n" +"There is absolutely no warranty for gnokii. See GPL for details.\n" "Built %s %s for %s on %s \n" msgstr "" "GNOKII Versioon %s\n" "Copyright (C) Hugh Blemings , 1999, 2000\n" "Copyright (C) Pavel Janík ml. , 1999, 2000\n" +"gnokii on vabavara, GNU General Public License alusel, \n" +"seda võib muuta ja/või levitada programmi koopiaid vastavlt reeglitele.\n" +"gnokii ei oma mitte mingisugust garantiid toimivuse kohta. Vaata GPL tingimusi.\n" "Eestikeelne tõlge Hans Mõtshärg , 2000\n" "Kompileeritud %s %s telefonimudelile %s, ühendus pordis %s \n" -#: gnokii/gnokii.c:182 +#: gnokii/gnokii.c:223 msgid "" " usage: gnokii [--help|--monitor|--version]\n" -" gnokii --getmemory memory_type start end\n" -" gnokii --writephonebook\n" +" gnokii --getmemory memory_type start [end]\n" +" gnokii --writephonebook [-i]\n" " gnokii --getspeeddial number\n" " gnokii --setspeeddial number memory_type location\n" -" gnokii --getsms memory_type start end\n" -" gnokii --deletesms memory_type start end\n" +" gnokii --getsms memory_type start [end] [-f file] [-d]\n" +" gnokii --deletesms memory_type start [end]\n" " gnokii --sendsms destination [--smsc message_center_number |\n" " --smscno message_center_index] [-r] [-C n] [-v n]\n" " [--long n]\n" +" gnokii --savesms [-m] [-l n] [-i]\n" " gnokii --getsmsc message_center_number\n" " gnokii --setdatetime [YYYY [MM [DD [HH [MM]]]]]\n" " gnokii --getdatetime\n" @@ -1606,13 +1628,14 @@ msgid "" " gnokii --getalarm\n" " gnokii --dialvoice number\n" " gnokii --getcalendarnote index [-v]\n" -" gnokii --writecalendarnote\n" +" gnokii --writecalendarnote vcardfile number\n" " gnokii --deletecalendarnote index\n" " gnokii --getdisplaystatus\n" " gnokii --netmonitor {reset|off|field|devel|next|nr}\n" " gnokii --identify\n" " gnokii --senddtmf string\n" " gnokii --sendlogo {caller|op} destination logofile [network code]\n" +" gnokii --sendringtone destination rtttlfile\n" " gnokii --setlogo op [logofile] [network code]\n" " gnokii --setlogo startup [logofile]\n" " gnokii --setlogo caller [logofile] [caller group number] [group " @@ -1620,249 +1643,133 @@ msgid "" " gnokii --setlogo {dealer|text} [text]\n" " gnokii --getlogo op [logofile] [network code]\n" " gnokii --getlogo startup [logofile] [network code]\n" -" gnokii --getlogo caller [logofile] [caller group number] [network " +" gnokii --getlogo caller [logofile][caller group number][network " "code]\n" " gnokii --getlogo {dealer|text}\n" -" gnokii --fileconvert source destination\n" -" gnokii --fileconvert source destination op [network code]\n" -" gnokii --fileconvert source destination caller [caller group " -"number]\n" -" gnokii --fileconvert source destination startup\n" -" gnokii --sendringtone destination rtttlfile\n" " gnokii --setringtone rtttlfile\n" -" gnokii --presskeysequence sequence\n" " gnokii --reset [soft|hard]\n" " gnokii --getprofile [number]\n" " gnokii --displayoutput\n" +" gnokii --keysequence\n" msgstr "" -#: gnokii/gnokii.c:228 +#: gnokii/gnokii.c:266 msgid "" " gnokii --entersecuritycode PIN|PIN2|PUK|PUK2\n" " gnokii --getsecuritycodestatus\n" -" gnokii --getsecuritycode PIN|PIN2|PUK|PUK2|SecurityCode\n" -msgstr "" - -#: gnokii/gnokii.c:234 -msgid "" -"\n" -" --help display usage information.\n" -"\n" -" --monitor continually updates phone status to stderr.\n" -"\n" -" --version displays version and copyright information.\n" -"\n" -" --getmemory reads specificed memory location from phone.\n" -" Valid memory types are:\n" -" ME, SM, FD, ON, EN, DC, RC, MC, LD\n" -"\n" -" --writephonebook reads data from stdin and writes to phonebook.\n" -" Uses the same format as provided by the output " -"of\n" -" the getphonebook command.\n" -"\n" -" --getspeeddial reads speed dial from the specified location.\n" -"\n" -" --setspeeddial specify speed dial.\n" -"\n" -" --getsms gets SMS messages from specified memory type\n" -" starting at entry [start] and ending at [end].\n" -" Entries are dumped to stdout.\n" -"\n" -" --deletesms deletes SMS messages from specified memory type\n" -" starting at entry [start] and ending at [end].\n" -"\n" -" --sendsms sends an SMS message to [destination] via\n" -" [message_center_number] or SMSC number taken " -"from\n" -" phone memory from address " -"[message_center_index].\n" -" If this argument is ommited SMSC number is " -"taken\n" -" from phone memory from location 1. Message text\n" -" is taken from stdin. This function has had\n" -" limited testing and may not work at all on your\n" -" network. Meaning of other optional parameters:\n" -" [-r] - request for delivery report\n" -" [-C n] - Class Message n, where n can be 0..3\n" -" [-v n] - validity in minutes\n" -" [--long n] - send no more then n characters,\n" -" default is 160\n" -"\n" -" --getsmsc show the SMSC number from location\n" -" [message_center_number].\n" -"\n" -" --setdatetime set the date and the time of the phone.\n" -"\n" -" --getdatetime shows current date and time in the phone.\n" -"\n" -" --setalarm set the alarm of the phone.\n" -"\n" -" --getalarm shows current alarm.\n" -"\n" -" --dialvoice initiate voice call.\n" -"\n" -" --getcalendarnote get the note with number index from calendar.\n" -" [-v] - output in vCalendar 1.0 format\n" -"\n" -" --writecalendarnote write the note to calendar.\n" -"\n" -" --deletecalendarnote delete the note with number [index]\n" -" from calendar.\n" -"\n" -" --getdisplaystatus shows what icons are displayed.\n" -"\n" -" --netmonitor setting/querying netmonitor mode.\n" -"\n" -" --identify get IMEI, model and revision\n" -"\n" -" --senddtmf send DTMF sequence\n" -"\n" -" --sendlogo send the logofile to destination as operator\n" -" or CLI logo\n" -"\n" -" --setlogo set caller, startup, operator logo\n" -" or (dealer) welcome note\n" -" If you will not give logofile|text, it will be\n" -" removed from phone\n" -" If you will not give network code, it will be\n" -" set to current\n" -" If you will not give caller group number, it " -"will be\n" -" set to 0\n" -"\n" -" --getlogo get caller, startup, operator logo\n" -"\n" -" or (dealer) welcome note\n" -" If you will give network code and write logo in " -"NOL\n" -" format, it will be written there\n" -" If you will not specify logofile, gnokii will " -"show\n" -" info about logo only\n" -"\n" -" --fileconvert Converts logo files\n" -"\n" -" --sendringtone send the rtttlfile to destination as ringtone\n" -"\n" -" --setringtone set the rtttlfile as ringtone (on 6110)\n" -"\n" -" --presskeysequence presses some keys in phone keyboard\n" -" available keys: 0..9, #, *, m (Menu), n " -"(Names),\n" -" p (Power), g (Green), r (Red), +, - (Volume " -"+-),\n" -" u (Up), d (Down)\n" -" w means 2 sec. pause (useful, when you " -"simulate\n" -" writing SMS)\n" -"\n" -" --reset [soft|hard] resets the phone.\n" -"\n" -" --getprofile [number] show settings for selected(all) profile(s)\n" -"\n" -" --displayoutput show texts displayed in phone's screen\n" -"\n" -msgstr "" - -#: gnokii/gnokii.c:343 -msgid "" -" --entersecuritycode asks for the code and sends it to the phone\n" -"\n" -" --getsecuritycodestatus show if a security code is needed\n" -"\n" -" --getsecuritycode gets specified code from phone\n" -"\n" msgstr "" -#: gnokii/gnokii.c:371 gnokii/gnokii.c:3263 gnokiid/virtmodem.c:262 +#: common/virtmodem.c:292 gnokii/gnokii.c:293 gnokii/gnokii.c:3187 +#: xgnokii/xgnokii_lowlevel.c:171 msgid "GSM/FBUS init failed! (Unknown model ?). Quitting.\n" -msgstr "GSM/FBUS initsialiseerimine ebaõnnestus! (Tundmatu mudel?). Lõpetan....)\n" +msgstr "" +"GSM/FBUS initsialiseerimine ebaõnnestus! (Tundmatu mudel?). Lõpetan....)\n" -#: gnokii/gnokii.c:382 +#: gnokii/gnokii.c:304 msgid "Hmmm... GSM_LinkOK never went true. Quitting.\n" msgstr "Hmmm... GSM_LinkOK ei tekkinud. Lõpetan.\n" -#: gnokii/gnokii.c:653 +#: gnokii/gnokii.c:580 #, c-format msgid "Use '%s --help' for usage informations.\n" msgstr "Kasuta '%s --help' kasutusinfo saamiseks.\n" -#: gnokii/gnokii.c:856 +#: gnokii/gnokii.c:778 #, c-format msgid "Unknown option: %d\n" msgstr "Tundmatu valik: %d\n" -#: gnokii/gnokii.c:866 +#: gnokii/gnokii.c:788 msgid "Wrong number of arguments\n" msgstr "Vale argumentide kogus\n" -#: gnokii/gnokii.c:937 gnokii/gnokii.c:995 +#: gnokii/gnokii.c:859 gnokii/gnokii.c:917 gnokii/gnokii.c:1076 msgid "Input too long!\n" msgstr "Sisend on liiga pikk!\n" -#: gnokii/gnokii.c:990 +#: gnokii/gnokii.c:912 gnokii/gnokii.c:1071 msgid "Couldn't read from stdin!\n" msgstr "Ei suuda lugeda standard sisendist!\n" -#: gnokii/gnokii.c:1101 +#: gnokii/gnokii.c:1046 +msgid "Message at specified location exists. " +msgstr "" + +#: gnokii/gnokii.c:1048 gnokii/gnokii.c:1421 gnokii/gnokii.c:2948 +msgid "Overwrite? (yes/no) " +msgstr "Kas kirjutan üle? (yes/no)" + +#: gnokii/gnokii.c:1056 +msgid "Invalid location\n" +msgstr "Vale asukoht\n" + +#: gnokii/gnokii.c:1062 #, c-format -msgid "Unknown key: %c !\n" -msgstr "Tundmatu võti: %c !\n" +msgid "Location %d empty. Saving\n" +msgstr "Asukoht %d on tühi. Salvestan\n" -#: gnokii/gnokii.c:1108 -msgid "Can't press key !\n" -msgstr "Nuppu ei saa vajutada?! \n" +#: gnokii/gnokii.c:1087 +msgid "Saved!\n" +msgstr "Salvestatud!\n" -#: gnokii/gnokii.c:1114 -msgid "Can't release key !\n" -msgstr "Nuppu ei saa vabastada?! \n" +#: gnokii/gnokii.c:1089 +#, c-format +msgid "Saving failed (error=%d)\n" +msgstr "" -#: gnokii/gnokii.c:1142 +#: gnokii/gnokii.c:1110 #, c-format msgid "%d. SMS center (%s) number is %s\n" msgstr "%d. SMS keskuse (%s) number on %s\n" -#: gnokii/gnokii.c:1144 +#: gnokii/gnokii.c:1112 msgid "Messages sent as " msgstr "Sõnum saadetud nagu " -#: gnokii/gnokii.c:1166 xgnokii/xgnokii.c:545 +#: gnokii/gnokii.c:1134 xgnokii/xgnokii.c:563 msgid "ERMES" msgstr "" -#: gnokii/gnokii.c:1170 xgnokii/xgnokii.c:549 +#: gnokii/gnokii.c:1138 xgnokii/xgnokii.c:567 msgid "X.400" msgstr "" -#: gnokii/gnokii.c:1179 +#: gnokii/gnokii.c:1147 msgid "Message validity is " msgstr "Sõnumi kehtivus on" -#: gnokii/gnokii.c:1215 +#: gnokii/gnokii.c:1183 msgid "SMS center can not be found :-(\n" msgstr "" -#: gnokii/gnokii.c:1284 gnokii/gnokii.c:1491 gnokii/gnokii.c:2855 -#: gnokii/gnokii.c:3040 +#: gnokii/gnokii.c:1256 gnokii/gnokii.c:2805 gnokii/gnokii.c:3016 #, c-format msgid "Unknown memory type %s!\n" msgstr "Tundmatu mälu tüüp %s!\n" -#: gnokii/gnokii.c:1311 +#: gnokii/gnokii.c:1283 +#, c-format +msgid "Saving into %s\n" +msgstr "" + +#: gnokii/gnokii.c:1287 +msgid "Filename too long - will be truncated to 63 charactera.\n" +msgstr "" + +#: gnokii/gnokii.c:1325 #, c-format msgid "%d. Outbox Message " msgstr "%d. Saadetud Sõnumid " -#: gnokii/gnokii.c:1314 +#: gnokii/gnokii.c:1328 msgid "(sent)\n" msgstr "(saadetud)\n" -#: gnokii/gnokii.c:1316 +#: gnokii/gnokii.c:1330 msgid "(not sent)\n" msgstr "(ei saadetud)\n" -#: gnokii/gnokii.c:1318 gnokii/gnokii.c:1357 +#: gnokii/gnokii.c:1332 gnokii/gnokii.c:1371 #, c-format msgid "" "Text: %s\n" @@ -1871,60 +1778,83 @@ msgstr "" "Tekst: %s\n" "\n" -#: gnokii/gnokii.c:1324 +#: gnokii/gnokii.c:1338 #, c-format msgid "%d. Delivery Report " msgstr "%d. Saateraport " -#: gnokii/gnokii.c:1326 gnokii/gnokii.c:1366 +#: gnokii/gnokii.c:1340 gnokii/gnokii.c:1380 msgid "(read)\n" msgstr "(loetud)\n" -#: gnokii/gnokii.c:1328 gnokii/gnokii.c:1368 +#: gnokii/gnokii.c:1342 gnokii/gnokii.c:1382 msgid "(not read)\n" msgstr "(ei loetud)\n" -#: gnokii/gnokii.c:1330 +#: gnokii/gnokii.c:1344 #, c-format msgid "Sending date/time: %d/%d/%d %d:%02d:%02d " msgstr "Saatmise kuupäev/kellaaeg: %d/%d/%d %d:%02d:%02d " -#: gnokii/gnokii.c:1336 gnokii/gnokii.c:1349 gnokii/gnokii.c:1376 +#: gnokii/gnokii.c:1350 gnokii/gnokii.c:1363 gnokii/gnokii.c:1390 #, c-format msgid "+%02d00" msgstr "" -#: gnokii/gnokii.c:1343 +#: gnokii/gnokii.c:1357 #, c-format msgid "Response date/time: %d/%d/%d %d:%02d:%02d " msgstr "Vastuse kuupäev/kellaaeg: %d/%d/%d %d:%02d:%02d " -#: gnokii/gnokii.c:1356 +#: gnokii/gnokii.c:1370 #, c-format msgid "Receiver: %s Msg Center: %s\n" msgstr "Saaja: %s Msg keskus: %s\n" -#: gnokii/gnokii.c:1363 +#: gnokii/gnokii.c:1377 #, c-format msgid "%d. Inbox Message " msgstr "%d. Saabunud Sõnumid " -#: gnokii/gnokii.c:1370 +#: gnokii/gnokii.c:1384 #, c-format msgid "Date/time: %d/%d/%d %d:%02d:%02d " msgstr "Kuupäv/kellaeg: %d/%d/%d %d:%02d:%02d " -#: gnokii/gnokii.c:1382 +#: gnokii/gnokii.c:1396 #, c-format msgid "Sender: %s Msg Center: %s\n" msgstr "Saatja: %s Msg kekus: %s\n" -#: gnokii/gnokii.c:1388 +#: gnokii/gnokii.c:1402 +#, c-format +msgid "GSM operator logo for %s (%s) network.\n" +msgstr "GSM Operaatori Logo võrgule %s (%s).\n" + +#: gnokii/gnokii.c:1404 +msgid "Saved by Logo Express\n" +msgstr "" + +#: gnokii/gnokii.c:1405 +msgid "Saved by Operator Logo Uploader by Thomas Kessler\n" +msgstr "" + +#: gnokii/gnokii.c:1420 +#, c-format +msgid "File %s exists.\n" +msgstr "Fail %s on olemas.\n" + +#: gnokii/gnokii.c:1427 +#, c-format +msgid "Couldn't save logofile %s!\n" +msgstr "Ei suuda logofaili %s salvestada!\n" + +#: gnokii/gnokii.c:1435 #, c-format msgid "Linked (%d/%d):\n" msgstr "Seotud (%d/%d):\n" -#: gnokii/gnokii.c:1394 +#: gnokii/gnokii.c:1437 #, c-format msgid "" "Text:\n" @@ -1935,23 +1865,35 @@ msgstr "" "%s\n" "\n" -#: gnokii/gnokii.c:1403 gnokii/gnokii.c:1514 gnokii/gnokii.c:1580 -#: gnokii/gnokii.c:1693 gnokii/gnokii.c:2773 gnokii/gnokii.c:2882 +#: gnokii/gnokii.c:1442 gnokii/gnokii.c:2268 +msgid "Unknown\n" +msgstr "Tundmatu\n" + +#: gnokii/gnokii.c:1449 +msgid "(delete failed)\n" +msgstr "(kustutamine ebaõnnestus)\n" + +#: gnokii/gnokii.c:1451 +msgid "(message deleted)\n" +msgstr "(teade kustutatud)\n" + +#: gnokii/gnokii.c:1457 gnokii/gnokii.c:1569 gnokii/gnokii.c:1635 +#: gnokii/gnokii.c:2723 gnokii/gnokii.c:2833 #, c-format msgid "Function not implemented in %s model!\n" msgstr "%s mudelis pole see funktsioon rakendatud!\n" -#: gnokii/gnokii.c:1409 +#: gnokii/gnokii.c:1463 #, c-format msgid "Invalid location: %s %d\n" msgstr "Sobimatu asukoht: %s %d\n" -#: gnokii/gnokii.c:1415 +#: gnokii/gnokii.c:1469 #, c-format msgid "SMS location %s %d empty.\n" msgstr "SMS asukoht %s %d on tühi.\n" -#: gnokii/gnokii.c:1421 +#: gnokii/gnokii.c:1475 #, c-format msgid "" "GetSMS %s %d failed!(%d)\n" @@ -1960,12 +1902,17 @@ msgstr "" "LaeSMS %s %d ebõnnestus!(%d)\n" "\n" -#: gnokii/gnokii.c:1511 +#: gnokii/gnokii.c:1545 +#, c-format +msgid "Unknown memory type %s (use ME,SM,....)!\n" +msgstr "Tundmatu mälu tüüp %s (kasuta ME,SM,....)!\n" + +#: gnokii/gnokii.c:1566 #, c-format msgid "Deleted SMS %s %d\n" msgstr "Kustutatud SMS %s %d\n" -#: gnokii/gnokii.c:1518 +#: gnokii/gnokii.c:1573 #, c-format msgid "" "DeleteSMS %s %d failed!(%d)\n" @@ -1974,418 +1921,445 @@ msgstr "" "KustutaSMS %s %d ei õnnestunud!(%d)\n" "\n" -#: gnokii/gnokii.c:1561 gnokii/gnokii.c:1660 -msgid "" -"Wrong code in second parameter (allowed: PIN,PUK,PIN2,PUK2,SecurityCode)\n" -msgstr "" - -#: gnokii/gnokii.c:1569 +#: gnokii/gnokii.c:1624 msgid "Enter your code: " msgstr "Sisesta oma kood: " -#: gnokii/gnokii.c:1576 +#: gnokii/gnokii.c:1631 msgid "Error: invalid code.\n" msgstr "VIGA: Vale kood.\n" -#: gnokii/gnokii.c:1578 +#: gnokii/gnokii.c:1633 msgid "Code ok.\n" msgstr "Kood OK.\n" -#: gnokii/gnokii.c:1582 gnokii/gnokii.c:1696 +#: gnokii/gnokii.c:1637 msgid "Other error.\n" msgstr "Muu viga.\n" -#: gnokii/gnokii.c:1598 +#: gnokii/gnokii.c:1653 msgid "Security code status: " msgstr "Turvakoodi olek:" -#: gnokii/gnokii.c:1670 -msgid "Error: getting " -msgstr "Viga: võtmisel n" - -#: gnokii/gnokii.c:1672 -msgid "security code" -msgstr "Turvakood" - -#: gnokii/gnokii.c:1679 -msgid " not allowed\n" -msgstr " pole lubatud\n" - -#: gnokii/gnokii.c:1690 -#, c-format -msgid " is %s\n" -msgstr " on %s\n" - -#: gnokii/gnokii.c:1762 +#: gnokii/gnokii.c:1755 msgid "Sending operator logo.\n" msgstr "Saadan operaatori logo.\n" -#: gnokii/gnokii.c:1766 +#: gnokii/gnokii.c:1759 msgid "Sending caller line identification logo.\n" msgstr "" -#: gnokii/gnokii.c:1768 -msgid "It isn't possible to send startup logo!\n" -msgstr "" - -#: gnokii/gnokii.c:1771 -msgid "Sending picture image is not implemented !\n" -msgstr "" - -#: gnokii/gnokii.c:1774 +#: gnokii/gnokii.c:1761 msgid "You should specify what kind of logo to send!\n" msgstr "" -#: gnokii/gnokii.c:1785 gnokii/gnokii.c:1876 gnokii/gnokii.c:1950 -#: gnokii/gnokii.c:2067 gnokii/gnokii.c:2125 -#, c-format -msgid "Can't open logofile %s !\n" -msgstr "Ei suuda logofaili %s avada!\n" - -#: gnokii/gnokii.c:1787 gnokii/gnokii.c:1878 gnokii/gnokii.c:2127 -#, c-format -msgid "Wrong number of colors in %s logofile (accepted only 2-colors files) !\n" -msgstr "Vale värvide kogus %s logofailis (toetatud on ainult 2 värvi)!\n" - -#: gnokii/gnokii.c:1789 gnokii/gnokii.c:1880 gnokii/gnokii.c:2129 -#, c-format -msgid "Wrong colors in %s logofile !\n" -msgstr "%s logofailis on valed värvid !\n" - -#: gnokii/gnokii.c:1791 gnokii/gnokii.c:1882 gnokii/gnokii.c:2131 +#: gnokii/gnokii.c:1780 #, c-format -msgid "Invalid format of %s logofile !\n" -msgstr "Sobimatu formaat %s logofailile !\n" +msgid "Operator code: %s\n" +msgstr "Operaatori kood: %s\n" -#: gnokii/gnokii.c:1793 gnokii/gnokii.c:1884 gnokii/gnokii.c:2133 +#: gnokii/gnokii.c:1829 #, c-format -msgid "%s logofile is too short !\n" -msgstr "% logofail on liiga lühike !\n" +msgid "Saving logo. File \"%s\" exists. (O)verwrite, create (n)ew or (s)kip ? " +msgstr "" -#: gnokii/gnokii.c:1795 -msgid "Bitmap size doesn't supported by fileformat or different from 72x14, 84x48 and 72x28 !\n" +#: gnokii/gnokii.c:1837 +msgid "Enter name of new file: " msgstr "" -#: gnokii/gnokii.c:1814 +#: gnokii/gnokii.c:1847 #, c-format -msgid "Operator code: %s\n" -msgstr "Operaatori kood: %s\n" - -#: gnokii/gnokii.c:1869 -msgid "Files can't have the same names !\n" -msgstr "Failidel ei saa olla sama nimi !!\n" - -#: gnokii/gnokii.c:1886 gnokii/gnokii.c:2135 -msgid "Bitmap size doesn't supported by fileformat or different from 72x14, 84x48 and 72x28!\n" +msgid "Failed to write file \"%s\"\n" msgstr "" -#: gnokii/gnokii.c:2000 +#: gnokii/gnokii.c:1898 msgid "Getting Logo\n" msgstr "Võtan logo\n" -#: gnokii/gnokii.c:2009 +#: gnokii/gnokii.c:1905 msgid "Dealer welcome note " msgstr "" -#: gnokii/gnokii.c:2010 +#: gnokii/gnokii.c:1906 msgid "Welcome note " msgstr "" -#: gnokii/gnokii.c:2015 +#: gnokii/gnokii.c:1911 #, c-format msgid "currently set to \"%s\"\n" msgstr "hetkel seatud \"%s\"\n" -#: gnokii/gnokii.c:2079 +#: gnokii/gnokii.c:1969 msgid "Function not implemented !\n" msgstr "See funktsioon pole rakendatud!\n" -#: gnokii/gnokii.c:2082 +#: gnokii/gnokii.c:1972 msgid "This kind of logo is not supported !\n" msgstr "Sellist tüüpi logo toetus pole rakendatud !\n" -#: gnokii/gnokii.c:2085 +#: gnokii/gnokii.c:1975 msgid "Error getting logo !\n" msgstr "Viga logo võtmisel !\n" -#: gnokii/gnokii.c:2091 +#: gnokii/gnokii.c:1981 msgid "What kind of logo do you want to get ?\n" msgstr "" -#: gnokii/gnokii.c:2182 +#: gnokii/gnokii.c:1998 +#, c-format +msgid "Failed to read file \"%s\"\n" +msgstr "" + +#: gnokii/gnokii.c:2000 +#, c-format +msgid "" +"Wrong number of colors in \"%s\" logofile (accepted only 2-colors files) !\n" +msgstr "" +"Vale värvide kogus \"%s\" logofailis (toetatud on ainult 2 värvi)!\n" + +#: gnokii/gnokii.c:2002 +#, c-format +msgid "Wrong colors in \"%s\" logofile !\n" +msgstr "\"%s\" logofailis on valed värvid !\n" + +#: gnokii/gnokii.c:2004 +#, c-format +msgid "Invalid format of \"%s\" logofile !\n" +msgstr "Sobimatu formaat \"%s\" logofailile !\n" + +#: gnokii/gnokii.c:2006 +#, c-format +msgid "Sorry, gnokii doesn't support used subformat in file \"%s\" !\n" +msgstr "" + +#: gnokii/gnokii.c:2008 +#, c-format +msgid "\"%s\" logofile is too short !\n" +msgstr "\"%s\" logofail on liiga lühike !\n" + +#: gnokii/gnokii.c:2010 +msgid "" +"Bitmap size doesn't supported by fileformat or different from 72x14, 84x48 " +"and 72x28 !\n" +msgstr "" + +#: gnokii/gnokii.c:2090 msgid "Setting Logo.\n" msgstr "Määran logo.\n" -#: gnokii/gnokii.c:2196 +#: gnokii/gnokii.c:2104 msgid "Removing Logo.\n" msgstr "Eemaldan logo.\n" -#: gnokii/gnokii.c:2200 +#: gnokii/gnokii.c:2108 msgid "What kind of logo do you want to set ?\n" msgstr "" -#: gnokii/gnokii.c:2210 -msgid "Done.\n" +#: gnokii/gnokii.c:2124 +msgid "Error setting" +msgstr "" + +#: gnokii/gnokii.c:2125 +msgid " dealer" +msgstr "" + +#: gnokii/gnokii.c:2126 +msgid " welcome note - " +msgstr "" + +#: gnokii/gnokii.c:2144 +msgid "SIM card and PIN is required\n" +msgstr "" + +#: gnokii/gnokii.c:2148 +#, c-format +msgid "too long, truncated to \"%s\" (length %i)\n" +msgstr "liiga pikk, lühendatud \"%s\" (pikkus %i)\n" + +#: gnokii/gnokii.c:2156 +msgid "Error setting startup logo - SIM card and PIN is required\n" msgstr "" -#: gnokii/gnokii.c:2212 +#: gnokii/gnokii.c:2164 +msgid "Done.\n" +msgstr "Tehtud.\n" + +#: gnokii/gnokii.c:2166 msgid "Function not implemented.\n" msgstr "See funktsioon pole rakendatud.\n" -#: gnokii/gnokii.c:2214 +#: gnokii/gnokii.c:2168 msgid "This kind of logo is not supported.\n" msgstr "" -#: gnokii/gnokii.c:2216 +#: gnokii/gnokii.c:2170 msgid "Error !\n" msgstr "Viga !\n" -#: gnokii/gnokii.c:2292 +#: gnokii/gnokii.c:2247 msgid " Type of the note: " msgstr " Märke tüüp :" -#: gnokii/gnokii.c:2297 +#: gnokii/gnokii.c:2252 msgid "Reminder\n" msgstr "Meeldetuletus\n" -#: gnokii/gnokii.c:2301 +#: gnokii/gnokii.c:2256 msgid "Call\n" msgstr "Kõne\n" -#: gnokii/gnokii.c:2305 +#: gnokii/gnokii.c:2260 msgid "Meeting\n" msgstr "Koosolek\n" -#: gnokii/gnokii.c:2309 +#: gnokii/gnokii.c:2264 msgid "Birthday\n" msgstr "Sünnipäev\n" -#: gnokii/gnokii.c:2313 -msgid "Unknown\n" -msgstr "Tundmatu\n" - -#: gnokii/gnokii.c:2342 +#: gnokii/gnokii.c:2297 msgid "The calendar note can not be read\n" msgstr "Kalendri kirjet ei saa lugeda\n" -#: gnokii/gnokii.c:2381 gnokii/gnokii.c:3051 +#: gnokii/gnokii.c:2315 +msgid "Failed to load vCalendar file.\n" +msgstr "" + +#: gnokii/gnokii.c:2323 gnokii/gnokii.c:3027 msgid "Succesfully written!\n" msgstr "Edukalt kirjutatud!\n" -#: gnokii/gnokii.c:2401 +#: gnokii/gnokii.c:2325 +msgid "Failed to write calendar note!\n" +msgstr "Kalendri kirje kirjutamine ebaõnnestus!\n" + +#: gnokii/gnokii.c:2344 msgid " Calendar note deleted.\n" msgstr " Kalendri kirje kustutatud.\n" -#: gnokii/gnokii.c:2404 +#: gnokii/gnokii.c:2347 msgid "The calendar note can not be deleted\n" msgstr "Kalendri kirjet ei saa kustutada\n" -#: gnokii/gnokii.c:2473 +#: gnokii/gnokii.c:2416 #, c-format msgid "Date: %4d/%02d/%02d\n" msgstr "Kuupäev: %4d/%02d/%02d\n" -#: gnokii/gnokii.c:2474 +#: gnokii/gnokii.c:2417 #, c-format msgid "Time: %02d:%02d:%02d\n" msgstr "Kellaaeg: %02d:%02d:%02d\n" -#: gnokii/gnokii.c:2510 +#: gnokii/gnokii.c:2453 #, c-format msgid "Alarm: %s\n" msgstr "Äratus: %s\n" -#: gnokii/gnokii.c:2511 +#: gnokii/gnokii.c:2454 #, c-format msgid "Time: %02d:%02d\n" msgstr "Kellaaeg: %02d:%02d\n" -#: gnokii/gnokii.c:2552 +#: gnokii/gnokii.c:2496 msgid "Entering monitor mode...\n" msgstr "Siirdun monitooringu olekusse...\n" -#: gnokii/gnokii.c:2553 +#: gnokii/gnokii.c:2497 msgid "Initialising GSM interface...\n" msgstr "Initsialiseerin GSM liidest...\n" -#: gnokii/gnokii.c:2564 +#: gnokii/gnokii.c:2511 #, c-format msgid "RFLevel: %d\n" -msgstr "Väljatugevus: %d\n" +msgstr "Väljatugevus: %d \"pulka\"\n" -#: gnokii/gnokii.c:2567 +#: gnokii/gnokii.c:2514 #, c-format msgid "Battery: %d\n" -msgstr "Aku: %d\n" +msgstr "Aku: %d \"pulka\"\n" -#: gnokii/gnokii.c:2570 +#: gnokii/gnokii.c:2517 #, c-format msgid "Power Source: %s\n" msgstr "Toiteallikas: %s\n" -#: gnokii/gnokii.c:2570 +#: gnokii/gnokii.c:2517 msgid "AC/DC" msgstr "Vahelduvvool/Alalisvool" -#: gnokii/gnokii.c:2570 +#: gnokii/gnokii.c:2517 msgid "battery" msgstr "aku" -#: gnokii/gnokii.c:2573 +#: gnokii/gnokii.c:2520 #, c-format msgid "SIM: Used %d, Free %d\n" -msgstr "SIM: Kasutusel %d, Vaba %d\n" +msgstr "Kaardi mälukasutus : kasutusel on %d mälupesa, kasutamata %d mälupesa.\n" -#: gnokii/gnokii.c:2576 +#: gnokii/gnokii.c:2523 #, c-format msgid "Phone: Used %d, Free %d\n" -msgstr "Telefon: Kasutusel %d, Vaba %d\n" +msgstr "Telefoni mälukasutus: kasutusel on %d mälupesa, kasutamata %d mälupesa.\n" -#: gnokii/gnokii.c:2579 +#: gnokii/gnokii.c:2526 #, c-format msgid "DC: Used %d, Free %d\n" msgstr "DC: Kasutusel %d, Vaba %d\n" -#: gnokii/gnokii.c:2582 +#: gnokii/gnokii.c:2529 #, c-format msgid "EN: Used %d, Free %d\n" msgstr "EN: Kasutusel %d, Vaba %d\n" -#: gnokii/gnokii.c:2585 +#: gnokii/gnokii.c:2532 #, c-format msgid "FD: Used %d, Free %d\n" msgstr "FD: Kasutusel %d, Vaba %d\n" -#: gnokii/gnokii.c:2588 +#: gnokii/gnokii.c:2535 #, c-format msgid "LD: Used %d, Free %d\n" msgstr "LD: Kasutusel %d, Vaba %d\n" -#: gnokii/gnokii.c:2591 +#: gnokii/gnokii.c:2538 #, c-format msgid "MC: Used %d, Free %d\n" msgstr "MC: Kasutusel %d, Vaba %d\n" -#: gnokii/gnokii.c:2594 +#: gnokii/gnokii.c:2541 #, c-format msgid "ON: Used %d, Free %d\n" msgstr "ON: Kasutusel %d, Vaba %d\n" -#: gnokii/gnokii.c:2597 +#: gnokii/gnokii.c:2544 #, c-format msgid "RC: Used %d, Free %d\n" msgstr "RC: Kasutusel %d, Vaba %d\n" -#: gnokii/gnokii.c:2600 +#: gnokii/gnokii.c:2547 #, c-format msgid "SMS Messages: UnRead %d, Number %d\n" -msgstr "Tekstisõnumeid: lugemata %d, number %d\n" +msgstr "Tekstisõnumid: lugemata sõnumeid %d, kokku sõnumeid %d.\n" -#: gnokii/gnokii.c:2603 +#: gnokii/gnokii.c:2550 #, c-format msgid "Incoming call: %s\n" msgstr "Saabuv kõne: %s\n" -#: gnokii/gnokii.c:2606 +#: gnokii/gnokii.c:2553 #, c-format msgid "Network: %s (%s), LAC: %s, CellID: %s\n" msgstr "Võrk: %s (%s), LAC: %s, KärjeID: %s\n" -#: gnokii/gnokii.c:2611 +#: gnokii/gnokii.c:2556 +#, c-format +msgid "Cell broadcast received on channel %d: %s\n" +msgstr "Kanalil %d: saabus võrguteade %s\n" + +#: gnokii/gnokii.c:2561 msgid "Leaving monitor mode...\n" msgstr "Lahkun monitooringu olekust...\n" -#: gnokii/gnokii.c:2636 +#: gnokii/gnokii.c:2586 msgid "Entering display monitoring mode...\n" msgstr "Siirdun monitooringu olekusse...\n" -#: gnokii/gnokii.c:2644 +#: gnokii/gnokii.c:2594 msgid "Leaving display monitor mode...\n" -msgstr "Lahkun monitooringu olekust...\n" +msgstr "" -#: gnokii/gnokii.c:2648 gnokii/gnokii.c:2650 +#: gnokii/gnokii.c:2598 gnokii/gnokii.c:2600 msgid "Error!\n" msgstr "Viga!\n" -#: gnokii/gnokii.c:2699 +#: gnokii/gnokii.c:2649 #, c-format msgid "Profile number must be value from 1 to %d!\n" -msgstr "" +msgstr "Profiili number peab olema vahemikust 1 kuni %d!\n" -#: gnokii/gnokii.c:2706 +#: gnokii/gnokii.c:2656 #, c-format msgid "This phone supports only %d profiles!\n" msgstr "See telefon toetab ainult %d profiile!\n" -#: gnokii/gnokii.c:2778 +#: gnokii/gnokii.c:2728 msgid "Unspecified error\n" msgstr "Dokumenteerimata viga\n" -#: gnokii/gnokii.c:2887 +#: gnokii/gnokii.c:2838 #, c-format msgid "Memory type %s not supported!\n" msgstr "Mälu tüüp %s pole toetatud!\n" -#: gnokii/gnokii.c:2892 +#: gnokii/gnokii.c:2843 #, c-format msgid "%s|%d|Bad location or other error!(%d)\n" msgstr "%s|%d|Vale asukoht või muu viga!(%d)\n" -#: gnokii/gnokii.c:2969 +#: gnokii/gnokii.c:2902 gnokii/gnokii.c:2917 gnokii/gnokii.c:2935 #, c-format msgid "Format problem on line %d [%s]\n" msgstr "Formaadi probleem real %d [%s]\n" -#: gnokii/gnokii.c:2991 +#: gnokii/gnokii.c:2946 +msgid "Location busy. " +msgstr "" + +#: gnokii/gnokii.c:2956 +#, c-format +msgid "Unknown error (%d)\n" +msgstr "Tundmatu viga (%d)\n" + +#: gnokii/gnokii.c:2967 #, c-format msgid "Write Succeeded: memory type: %s, loc: %d, name: %s, number: %s\n" -msgstr "Salvestamine õnnestus: mälu tüüp: %s, asukoht: %d, nimi: %s, number: %s\n" +msgstr "" +"Salvestamine õnnestus: mälu tüüp: %s, asukoht: %d, nimi: %s, number: %s\n" -#: gnokii/gnokii.c:2993 +#: gnokii/gnokii.c:2969 #, c-format msgid "Write FAILED(%d): memory type: %s, loc: %d, name: %s, number: %s\n" -msgstr "Salvestamine(%d) EBAÕNNESTUS: mälu tüüp: %s, asukoht: %d, nimi: %s, number: %s\n" +msgstr "" +"Salvestamine(%d) EBAÕNNESTUS: mälu tüüp: %s, asukoht: %d, nimi: %s, number: " +"%s\n" -#: gnokii/gnokii.c:3013 +#: gnokii/gnokii.c:2989 #, c-format msgid "SpeedDial nr. %d: %d:%d\n" msgstr "Kiirvalik nr. %d: %d:%d\n" -#: gnokii/gnokii.c:3085 gnokiid/gnokiid.c:148 -#, c-format -msgid "Couldn't open %s or /etc/gnokiirc, using default config\n" -msgstr "Ei suuda %s avada ega ka /etc/gnokiirc, kasutan konfiguratsiooni vaikeväärtusi!\n" - -#: gnokii/gnokii.c:3178 +#: gnokii/gnokii.c:3108 #, c-format msgid "IMEI: %s\n" msgstr "" -#: gnokii/gnokii.c:3179 +#: gnokii/gnokii.c:3109 #, c-format msgid "Model: %s\n" msgstr "Mudel: %s\n" -#: gnokii/gnokii.c:3180 +#: gnokii/gnokii.c:3110 #, c-format msgid "Revision: %s\n" msgstr "Versioon: %s\n" -#: gnokii/gnokii.c:3213 -msgid "" -"What kind of reset do you want (second parameter can be \"soft\" or " -"\"hard\") ?\n" +#: gnokii/gnokii.c:3142 +msgid "What kind of reset do you want??\n" msgstr "" -#: gnokii/gnokii.c:3281 gnokii/gnokii.c:3307 +#: gnokii/gnokii.c:3205 gnokii/gnokii.c:3231 msgid "Failed to load ringtone.\n" msgstr "" -#: gnokii/gnokii.c:3320 +#: gnokii/gnokii.c:3244 msgid "Send failed\n" msgstr "Saatmine ebaõnnestus!\n" -#: gnokiid/gnokiid.c:58 +#: gnokii/gnokii.c:3271 +msgid "Key press simulation failed.\n" +msgstr "" + +#: gnokiid/gnokiid.c:56 #, c-format msgid "" "gnokiid Version %s\n" @@ -2399,7 +2373,7 @@ msgstr "" "Eestikeelne tõlge Hans Mõtshärg , 2000\n" "Kompileeritud %s %s telefonimudelile %s, ühendus pordis %s \n" -#: gnokiid/gnokiid.c:70 +#: gnokiid/gnokiid.c:68 msgid "" " usage: gnokiid {--help|--version}\n" " --help display usage information. --version " @@ -2407,84 +2381,84 @@ msgid "" "uses stdin/stdout for virtual modem comms.\n" msgstr "" -#: gnokiid/virtmodem.c:87 +#: common/virtmodem.c:119 msgid "VM_Initialise - VM_GSMInitialise failed!\n" msgstr "" -#: gnokiid/virtmodem.c:94 +#: common/virtmodem.c:126 msgid "VM_Initialise - VM_PtySetup failed!\n" msgstr "" -#: gnokiid/virtmodem.c:99 +#: common/virtmodem.c:131 msgid "VM_Initialise - ATEM_Initialise failed!\n" msgstr "" -#: gnokiid/virtmodem.c:104 +#: common/virtmodem.c:136 msgid "VM_Initialise - DP_Initialise failed!\n" msgstr "" -#: gnokiid/virtmodem.c:198 +#: common/virtmodem.c:229 msgid "Couldn't open pty!\n" msgstr "" -#: gnokiid/virtmodem.c:206 +#: common/virtmodem.c:237 msgid "gnokiid should not be installed setuid root!\n" -msgstr "gnokiid ei tohiks root õigustes installerida!\n" +msgstr "gnokiid ei tohiks setuid root õigusega installerida!\n" -#: gnokiid/virtmodem.c:210 +#: common/virtmodem.c:242 #, c-format msgid "Slave pty is %s, calling %s to create /dev/gnokii.\n" msgstr "" -#: gnokiid/virtmodem.c:274 +#: common/virtmodem.c:304 msgid "Hmmm... GSM_LinkOK never went true. Quitting. \n" msgstr "Hmmm... GSM_LinkOK ei tekkinud. Lõpetan. \n" -#: xgnokii/xgnokii.c:196 +#: xgnokii/xgnokii.c:214 msgid "Reading caller groups names ..." -msgstr "Loen helistaja grupide nimesid...." +msgstr "Loen helistajagruppide nimesid...." -#: xgnokii/xgnokii.c:200 xgnokii/xgnokii.c:993 +#: xgnokii/xgnokii.c:218 xgnokii/xgnokii.c:1045 msgid "Familly" msgstr "Perekond" -#: xgnokii/xgnokii.c:201 xgnokii/xgnokii.c:1005 +#: xgnokii/xgnokii.c:219 xgnokii/xgnokii.c:1057 msgid "VIP" msgstr "" -#: xgnokii/xgnokii.c:202 xgnokii/xgnokii.c:1017 +#: xgnokii/xgnokii.c:220 xgnokii/xgnokii.c:1069 msgid "Friends" msgstr "Sõbrad" -#: xgnokii/xgnokii.c:203 xgnokii/xgnokii.c:1029 +#: xgnokii/xgnokii.c:221 xgnokii/xgnokii.c:1081 msgid "Colleagues" msgstr "Kolleegid" -#: xgnokii/xgnokii.c:204 xgnokii/xgnokii.c:1041 +#: xgnokii/xgnokii.c:222 xgnokii/xgnokii.c:1093 msgid "Other" msgstr "Muud" -#: xgnokii/xgnokii.c:205 +#: xgnokii/xgnokii.c:223 msgid "No group" msgstr "Grupita" -#: xgnokii/xgnokii.c:324 +#: xgnokii/xgnokii.c:348 msgid "Short Message received" msgstr "Saabus Lühisõnum" -#: xgnokii/xgnokii.c:336 +#: xgnokii/xgnokii.c:354 msgid "Working ..." msgstr "Toimetan..." -#: xgnokii/xgnokii.c:353 +#: xgnokii/xgnokii.c:371 msgid "Call in progress" msgstr "kõne käimas" -#: xgnokii/xgnokii.c:366 +#: xgnokii/xgnokii.c:384 msgid "Hide" msgstr "Peida" -#: xgnokii/xgnokii.c:463 +#: xgnokii/xgnokii.c:481 #, c-format msgid "" "Outgoing call in progress:\n" @@ -2493,7 +2467,7 @@ msgstr "" "Kõne on käimas:\n" "Aeg: %s" -#: xgnokii/xgnokii.c:466 +#: xgnokii/xgnokii.c:484 #, c-format msgid "" "Incomming call from: %s\n" @@ -2502,362 +2476,643 @@ msgstr "" "Saabuv kõne: %s\n" "Kellaaeg: %s" -#: xgnokii/xgnokii.c:519 xgnokii/xgnokii_sms.c:580 +#: xgnokii/xgnokii.c:537 xgnokii/xgnokii_sms.c:687 #, c-format msgid "Set %d" msgstr "Sea %d" -#: xgnokii/xgnokii.c:541 xgnokii/xgnokii.c:1405 +#: xgnokii/xgnokii.c:559 xgnokii/xgnokii.c:1466 msgid "E-Mail" msgstr "" -#: xgnokii/xgnokii.c:553 +#: xgnokii/xgnokii.c:571 msgid "Voice" msgstr "Kõne" -#: xgnokii/xgnokii.c:564 xgnokii/xgnokii.c:1435 +#: xgnokii/xgnokii.c:582 xgnokii/xgnokii.c:1496 msgid "1 h" msgstr "1 t" -#: xgnokii/xgnokii.c:568 xgnokii/xgnokii.c:1442 +#: xgnokii/xgnokii.c:586 xgnokii/xgnokii.c:1503 msgid "6 h" msgstr "6 t" -#: xgnokii/xgnokii.c:572 xgnokii/xgnokii.c:588 xgnokii/xgnokii.c:1449 +#: xgnokii/xgnokii.c:590 xgnokii/xgnokii.c:606 xgnokii/xgnokii.c:1510 msgid "24 h" msgstr "24 t" -#: xgnokii/xgnokii.c:576 xgnokii/xgnokii.c:1456 +#: xgnokii/xgnokii.c:594 xgnokii/xgnokii.c:1517 msgid "72 h" msgstr "72 t" -#: xgnokii/xgnokii.c:584 +#: xgnokii/xgnokii.c:602 msgid "Max. time" msgstr "Max. aeg" -#: xgnokii/xgnokii.c:631 +#: xgnokii/xgnokii.c:649 msgid "Reading SMS centers ..." msgstr "Laadin SMS keskusi ..." -#: xgnokii/xgnokii.c:984 -msgid "Error saving SMS centers!" -msgstr "Viga SMS keskuste salvestamisel!" +#: xgnokii/xgnokii.c:910 +msgid "SMS not supported!" +msgstr "SMS pole toetatud!" -#: xgnokii/xgnokii.c:1054 +#: xgnokii/xgnokii.c:918 +msgid "Calendar not supported!" +msgstr "Kalender pole toetatud!" + +#: xgnokii/xgnokii.c:1106 msgid "Error writing configuration file!" msgstr "Viga konfiguratsioonifaili salvestamisel!" -#: xgnokii/xgnokii.c:1066 xgnokii/xgnokii_contacts.c:2740 +#: xgnokii/xgnokii.c:1118 xgnokii/xgnokii_contacts.c:3025 msgid "Contacts" msgstr "Kontaktid" -#: xgnokii/xgnokii.c:1072 xgnokii/xgnokii.c:1808 +#: xgnokii/xgnokii.c:1124 xgnokii/xgnokii.c:1902 msgid "SMS" msgstr "Lühisõnumid" -#: xgnokii/xgnokii.c:1077 +#: xgnokii/xgnokii.c:1129 xgnokii/xgnokii_calendar.c:867 msgid "Calendar" msgstr "Kalender" -#: xgnokii/xgnokii.c:1082 xgnokii/xgnokii_logos.c:1190 +#: xgnokii/xgnokii.c:1134 xgnokii/xgnokii_logos.c:1339 msgid "Logos" msgstr "Logod" -#: xgnokii/xgnokii.c:1088 +#: xgnokii/xgnokii.c:1140 msgid "DTMF" msgstr "DTMF" -#: xgnokii/xgnokii.c:1093 xgnokii/xgnokii_speed.c:560 +#: xgnokii/xgnokii.c:1145 xgnokii/xgnokii_speed.c:559 msgid "Speed Dial" msgstr "Kiirvalik" -#: xgnokii/xgnokii.c:1098 +#: xgnokii/xgnokii.c:1150 msgid "Keyboard" msgstr "Klaviatuur" -#: xgnokii/xgnokii.c:1103 xgnokii/xgnokii_netmon.c:318 +#: xgnokii/xgnokii.c:1155 xgnokii/xgnokii_netmon.c:317 msgid "Net Monitor" msgstr "Võrgu Monitor" -#: xgnokii/xgnokii.c:1112 xgnokii/xgnokii.c:1568 +#: xgnokii/xgnokii.c:1160 +msgid "Data calls" +msgstr "Andmekõned" + +#: xgnokii/xgnokii.c:1169 xgnokii/xgnokii.c:1629 msgid "Options" msgstr "Valikud" -#: xgnokii/xgnokii.c:1122 xgnokii/xgnokii.c:2088 +#: xgnokii/xgnokii.c:1179 xgnokii/xgnokii.c:2207 msgid "Help" msgstr "Abi" -#: xgnokii/xgnokii.c:1128 xgnokii/xgnokii.c:1145 +#: xgnokii/xgnokii.c:1185 xgnokii/xgnokii.c:1202 msgid "About" msgstr "Üldist" -#: xgnokii/xgnokii.c:1149 xgnokii/xgnokii.c:1329 -#: xgnokii/xgnokii_contacts.c:808 xgnokii/xgnokii_contacts.c:938 -#: xgnokii/xgnokii_contacts.c:1303 xgnokii/xgnokii_contacts.c:2567 -#: xgnokii/xgnokii_sms.c:477 +#: xgnokii/xgnokii.c:1206 xgnokii/xgnokii.c:1390 +#: xgnokii/xgnokii_calendar.c:495 xgnokii/xgnokii_calendar.c:541 +#: xgnokii/xgnokii_calendar.c:616 xgnokii/xgnokii_calendar.c:766 +#: xgnokii/xgnokii_contacts.c:839 xgnokii/xgnokii_contacts.c:1035 +#: xgnokii/xgnokii_contacts.c:1400 xgnokii/xgnokii_contacts.c:2846 +#: xgnokii/xgnokii_sms.c:480 msgid "Ok" msgstr "Ok" -#: xgnokii/xgnokii.c:1162 +#: xgnokii/xgnokii.c:1219 #, c-format msgid "" "xgnokii version: %s\n" "gnokii version: %s\n" "\n" -"Copyright (C) 1999 Pavel Janík ml.,\n" -"Hugh Blemings & Jan Derfinak\n" +"Copyright (C) 1999,2000 Pavel Janík ml.,\n" +"Hugh Blemings, Jan Derfinak and others\n" +"xgnokii is free software, covered by the GNU General Public License, and you " +"are\n" +"welcome to change it and/or distribute copies of it under certain " +"conditions.\n" +"There is absolutely no waranty for xgnokii. See GPL for details.\n" msgstr "" -"xgnokii versioon: %s\n" -"gnokii versioon: %s\n" -"\n" -"Copyright (C) 1999 Pavel Janík ml.,\n" -"Hugh Blemings & Jan Derfinak\n" -#: xgnokii/xgnokii.c:1323 +#: xgnokii/xgnokii.c:1384 msgid "Edit SMS Setting" msgstr "Muuda SMS seadeid" -#: xgnokii/xgnokii.c:1337 xgnokii/xgnokii_common.c:247 -#: xgnokii/xgnokii_common.c:333 xgnokii/xgnokii_contacts.c:816 -#: xgnokii/xgnokii_contacts.c:946 xgnokii/xgnokii_contacts.c:1175 -#: xgnokii/xgnokii_contacts.c:1221 xgnokii/xgnokii_contacts.c:1312 -#: xgnokii/xgnokii_contacts.c:1585 xgnokii/xgnokii_contacts.c:2574 -#: xgnokii/xgnokii_sms.c:485 +#: xgnokii/xgnokii.c:1398 xgnokii/xgnokii_calendar.c:504 +#: xgnokii/xgnokii_calendar.c:550 xgnokii/xgnokii_calendar.c:624 +#: xgnokii/xgnokii_calendar.c:774 xgnokii/xgnokii_common.c:64 +#: xgnokii/xgnokii_common.c:150 xgnokii/xgnokii_contacts.c:847 +#: xgnokii/xgnokii_contacts.c:1043 xgnokii/xgnokii_contacts.c:1272 +#: xgnokii/xgnokii_contacts.c:1318 xgnokii/xgnokii_contacts.c:1409 +#: xgnokii/xgnokii_contacts.c:1682 xgnokii/xgnokii_contacts.c:1797 +#: xgnokii/xgnokii_contacts.c:2853 xgnokii/xgnokii_sms.c:488 msgid "Cancel" msgstr "Tühista" -#: xgnokii/xgnokii.c:1350 +#: xgnokii/xgnokii.c:1411 msgid "Set's name:" msgstr "Seade nimi:" -#: xgnokii/xgnokii.c:1363 +#: xgnokii/xgnokii.c:1424 msgid "Center:" msgstr "Keskus:" -#: xgnokii/xgnokii.c:1376 +#: xgnokii/xgnokii.c:1437 msgid "Sending Format:" msgstr "Saate Formaat:" -#: xgnokii/xgnokii.c:1420 +#: xgnokii/xgnokii.c:1481 msgid "Validity Period:" msgstr "Kehtivus periood:" -#: xgnokii/xgnokii.c:1428 +#: xgnokii/xgnokii.c:1489 msgid "Max. Time" msgstr "Max. Aeg" -#: xgnokii/xgnokii.c:1565 +#: xgnokii/xgnokii.c:1626 msgid "Set's name" msgstr "Seade nimi" -#: xgnokii/xgnokii.c:1565 +#: xgnokii/xgnokii.c:1626 msgid "Center number" msgstr "Keskuse number" -#: xgnokii/xgnokii.c:1565 +#: xgnokii/xgnokii.c:1626 msgid "Format" msgstr "Formaat" -#: xgnokii/xgnokii.c:1565 +#: xgnokii/xgnokii.c:1626 msgid "Validity" msgstr "Kehtivus" -#: xgnokii/xgnokii.c:1573 +#: xgnokii/xgnokii.c:1634 msgid "Apply" msgstr "Kehtesta" -#: xgnokii/xgnokii.c:1582 xgnokii/xgnokii_contacts.c:1569 +#: xgnokii/xgnokii.c:1643 xgnokii/xgnokii_contacts.c:1666 #: xgnokii/xgnokii_dtmf.c:178 msgid "Save" msgstr "Salvesta" -#: xgnokii/xgnokii.c:1589 +#: xgnokii/xgnokii.c:1650 msgid "Close" msgstr "Sulge" -#: xgnokii/xgnokii.c:1604 +#: xgnokii/xgnokii.c:1665 msgid "Phone and connection type" msgstr "Telefon ja ühenduse tüüp" -#: xgnokii/xgnokii.c:1611 +#: xgnokii/xgnokii.c:1672 msgid "Connection" msgstr "Ühendus" -#: xgnokii/xgnokii.c:1618 +#: xgnokii/xgnokii.c:1679 msgid "Port:" msgstr "Pordis:" -#: xgnokii/xgnokii.c:1633 xgnokii/xgnokii.c:1705 +#: xgnokii/xgnokii.c:1694 xgnokii/xgnokii.c:1766 msgid "Model:" msgstr "Mudel:" -#: xgnokii/xgnokii.c:1648 +#: xgnokii/xgnokii.c:1709 msgid "Init length:" msgstr "Init pikkus:" -#: xgnokii/xgnokii.c:1663 +#: xgnokii/xgnokii.c:1724 msgid "Bindir:" msgstr "BIN kataloog:" -#: xgnokii/xgnokii.c:1678 +#: xgnokii/xgnokii.c:1739 msgid "Connection:" msgstr "Ühendus:" -#: xgnokii/xgnokii.c:1682 +#: xgnokii/xgnokii.c:1743 msgid "infrared" msgstr "infrapunane" -#: xgnokii/xgnokii.c:1686 +#: xgnokii/xgnokii.c:1747 msgid "serial" -msgstr "" +msgstr "kaabliga" -#: xgnokii/xgnokii.c:1691 +#: xgnokii/xgnokii.c:1752 msgid "Phone information" msgstr "Telefoni info" -#: xgnokii/xgnokii.c:1720 +#: xgnokii/xgnokii.c:1781 msgid "Version:" msgstr "Versioon:" -#: xgnokii/xgnokii.c:1735 +#: xgnokii/xgnokii.c:1796 msgid "Revision:" msgstr "Revision:" -#: xgnokii/xgnokii.c:1750 +#: xgnokii/xgnokii.c:1811 msgid "IMEI:" msgstr "IMEI:" -#: xgnokii/xgnokii.c:1764 +#: xgnokii/xgnokii.c:1826 +msgid "Names length:" +msgstr "Nime pikkus:" + +#: xgnokii/xgnokii.c:1834 +msgid "SIM:" +msgstr "Kaardil:" + +#: xgnokii/xgnokii.c:1852 +msgid "Phone:" +msgstr "Telefonis:" + +#: xgnokii/xgnokii.c:1859 msgid "Alarm setting" msgstr "Äratuse seaded" -#: xgnokii/xgnokii.c:1771 xgnokii/xgnokii.c:1778 +#: xgnokii/xgnokii.c:1866 xgnokii/xgnokii.c:1873 +#: xgnokii/xgnokii_calendar.c:688 xgnokii/xgnokii_calendar.c:863 msgid "Alarm" -msgstr "Äratus" +msgstr "Meenutus" -#: xgnokii/xgnokii.c:1802 xgnokii/xgnokii_sms.c:1433 +#: xgnokii/xgnokii.c:1896 xgnokii/xgnokii_sms.c:1544 msgid "Short Message Service" msgstr "Lühisõnumi teenus" -#: xgnokii/xgnokii.c:1836 +#: xgnokii/xgnokii.c:1930 msgid "Edit" msgstr "Redigeeri" -#: xgnokii/xgnokii.c:1850 +#: xgnokii/xgnokii.c:1944 msgid "Business Card" msgstr "Visiitkaart" -#: xgnokii/xgnokii.c:1856 +#: xgnokii/xgnokii.c:1950 msgid "User" msgstr "Kasutaja" -#: xgnokii/xgnokii.c:1874 xgnokii/xgnokii_contacts.c:829 +#: xgnokii/xgnokii.c:1968 xgnokii/xgnokii_contacts.c:860 msgid "Name:" msgstr "Nimi:" -#: xgnokii/xgnokii.c:1900 +#: xgnokii/xgnokii.c:1994 msgid "Title:" msgstr "Amet:" -#: xgnokii/xgnokii.c:1926 +#: xgnokii/xgnokii.c:2020 msgid "Company:" msgstr "Ettevõte:" -#: xgnokii/xgnokii.c:1952 +#: xgnokii/xgnokii.c:2046 msgid "Telephone:" msgstr "Telefon:" -#: xgnokii/xgnokii.c:1977 +#: xgnokii/xgnokii.c:2071 msgid "Fax:" msgstr "Fax:" -#: xgnokii/xgnokii.c:2002 +#: xgnokii/xgnokii.c:2096 msgid "E-Mail:" msgstr "E-Mail:" -#: xgnokii/xgnokii.c:2028 +#: xgnokii/xgnokii.c:2122 msgid "Address:" msgstr "Aadress:" -#: xgnokii/xgnokii.c:2052 +#: xgnokii/xgnokii.c:2146 msgid "Caller groups names" msgstr "Helistaja grupi nimi" -#: xgnokii/xgnokii.c:2059 +#: xgnokii/xgnokii.c:2153 msgid "Groups" msgstr "Grupid" -#: xgnokii/xgnokii.c:2068 +#: xgnokii/xgnokii.c:2162 #, c-format msgid "Group %d:" msgstr "Grupp %d:" -#: xgnokii/xgnokii.c:2081 +#: xgnokii/xgnokii.c:2175 +msgid "Mailbox" +msgstr "" + +#: xgnokii/xgnokii.c:2182 +msgid "Mail" +msgstr "" + +#: xgnokii/xgnokii.c:2189 +msgid "Path to mailbox:" +msgstr "" + +#: xgnokii/xgnokii.c:2200 msgid "Help viewer" msgstr "Abi lehitseja" -#: xgnokii/xgnokii.c:2095 +#: xgnokii/xgnokii.c:2214 msgid "Viewer:" msgstr "Lehitseja:" -#: xgnokii/xgnokii.c:2256 xgnokii/xgnokii_cfg.c:71 +#: xgnokii/xgnokii_calendar.c:123 +msgid "Reminder" +msgstr "Meeldetuletus" + +#: xgnokii/xgnokii_calendar.c:130 +msgid "Call" +msgstr "Kõne" + +#: xgnokii/xgnokii_calendar.c:138 +msgid "Meeting" +msgstr "Koosolek" + +#: xgnokii/xgnokii_calendar.c:146 +msgid "Birthday" +msgstr "Sünnipäev" + +#: xgnokii/xgnokii_calendar.c:194 +msgid "Type: " +msgstr "Tüüp: " + +#: xgnokii/xgnokii_calendar.c:202 xgnokii/xgnokii_sms.c:384 +msgid "Date: " +msgstr "Kuupäev: " + +#: xgnokii/xgnokii_calendar.c:217 +msgid "Alarm: " +msgstr "Meenutus: " + +#: xgnokii/xgnokii_calendar.c:238 +msgid "Text: " +msgstr "Tekst: " + +#: xgnokii/xgnokii_calendar.c:488 xgnokii/xgnokii_calendar.c:534 +msgid "Choose date" +msgstr "Vali kuupäev" + +#: xgnokii/xgnokii_calendar.c:571 +msgid "Alarm time:" +msgstr "Meenutuse aeg:" + +#: xgnokii/xgnokii_calendar.c:609 xgnokii/xgnokii_calendar.c:929 +msgid "Add reminder" +msgstr "Lisa meenutus" + +#: xgnokii/xgnokii_calendar.c:641 +msgid "Date:" +msgstr "Kuupäev:" + +#: xgnokii/xgnokii_calendar.c:676 +msgid "Subject:" +msgstr "" + +#: xgnokii/xgnokii_calendar.c:759 +msgid "Delete calendar note" +msgstr "Kustuta kalendri kirje" + +#: xgnokii/xgnokii_calendar.c:791 +msgid "Do you want to delete selected note(s)?" +msgstr "Kas soovid valitud kirje(d) kustutada?" + +#: xgnokii/xgnokii_calendar.c:826 xgnokii/xgnokii_contacts.c:2980 +#: xgnokii/xgnokii_dtmf.c:217 xgnokii/xgnokii_logos.c:1292 +#: xgnokii/xgnokii_netmon.c:259 xgnokii/xgnokii_sms.c:1121 +#: xgnokii/xgnokii_sms.c:1507 xgnokii/xgnokii_speed.c:527 +#: xgnokii/xgnokii_xkeyb.c:242 +msgid "/_File" +msgstr "/_Fail" + +#: xgnokii/xgnokii_calendar.c:827 xgnokii/xgnokii_contacts.c:2981 +#: xgnokii/xgnokii_speed.c:528 +msgid "/File/_Read from phone" +msgstr "/Fail/Loe telefonist" + +#: xgnokii/xgnokii_calendar.c:828 xgnokii/xgnokii_contacts.c:2982 +#: xgnokii/xgnokii_speed.c:529 +msgid "/File/_Save to phone" +msgstr "/Fail/_Salvesta telefoni" + +#: xgnokii/xgnokii_calendar.c:829 xgnokii/xgnokii_contacts.c:2983 +#: xgnokii/xgnokii_dtmf.c:220 xgnokii/xgnokii_logos.c:1296 +#: xgnokii/xgnokii_sms.c:1124 xgnokii/xgnokii_sms.c:1510 +#: xgnokii/xgnokii_speed.c:530 +msgid "/File/Sep1" +msgstr "/Fail/Sep1" + +#: xgnokii/xgnokii_calendar.c:830 +msgid "/File/Send via S_MS" +msgstr "/Fail/Saada S_MS abil" + +#: xgnokii/xgnokii_calendar.c:831 xgnokii/xgnokii_contacts.c:2986 +#: xgnokii/xgnokii_logos.c:1300 xgnokii/xgnokii_sms.c:1127 +#: xgnokii/xgnokii_speed.c:533 +msgid "/File/Sep2" +msgstr "/Fail/Sep2" + +#: xgnokii/xgnokii_calendar.c:832 xgnokii/xgnokii_contacts.c:2984 +#: xgnokii/xgnokii_speed.c:531 +msgid "/File/_Import from file" +msgstr "/Fail/_Impordi failist" + +#: xgnokii/xgnokii_calendar.c:833 xgnokii/xgnokii_contacts.c:2985 +#: xgnokii/xgnokii_speed.c:532 +msgid "/File/_Export to file" +msgstr "/Fail/Salv_esta faili" + +#: xgnokii/xgnokii_calendar.c:834 +msgid "/File/Sep3" +msgstr "/Fail/Sep3" + +#: xgnokii/xgnokii_calendar.c:835 xgnokii/xgnokii_contacts.c:2987 +#: xgnokii/xgnokii_dtmf.c:221 xgnokii/xgnokii_logos.c:1301 +#: xgnokii/xgnokii_netmon.c:260 xgnokii/xgnokii_sms.c:1128 +#: xgnokii/xgnokii_sms.c:1511 xgnokii/xgnokii_speed.c:534 +#: xgnokii/xgnokii_xkeyb.c:243 +msgid "/File/_Close" +msgstr "/Fail/Sulge" + +#: xgnokii/xgnokii_calendar.c:836 xgnokii/xgnokii_contacts.c:2988 +#: xgnokii/xgnokii_logos.c:1302 xgnokii/xgnokii_speed.c:535 +msgid "/_Edit" +msgstr "/R_edigeeri" + +#: xgnokii/xgnokii_calendar.c:837 +msgid "/Edit/Add _reminder" +msgstr "/Redigeeri/Lisa meenutus" + +#: xgnokii/xgnokii_calendar.c:838 +msgid "/Edit/Add _call" +msgstr "/Redigeeri/Lisa kõne" + +#: xgnokii/xgnokii_calendar.c:839 +msgid "/Edit/Add _meeting" +msgstr "/Redigeeri/Lisa koosolek" + +#: xgnokii/xgnokii_calendar.c:840 +msgid "/Edit/Add _birthday" +msgstr "/Redigeeri/Lisa sünnipäev" + +#: xgnokii/xgnokii_calendar.c:841 xgnokii/xgnokii_contacts.c:2991 +#: xgnokii/xgnokii_speed.c:536 +msgid "/Edit/_Edit" +msgstr "/Redigeeri/Paranda" + +#: xgnokii/xgnokii_calendar.c:842 xgnokii/xgnokii_contacts.c:2992 +msgid "/Edit/_Delete" +msgstr "/Redigeeri/Kustuta" + +#: xgnokii/xgnokii_calendar.c:843 xgnokii/xgnokii_contacts.c:2995 +#: xgnokii/xgnokii_logos.c:1310 +msgid "/Edit/Sep4" +msgstr "/Redigeeri/Sep4" + +#: xgnokii/xgnokii_calendar.c:844 xgnokii/xgnokii_contacts.c:2999 +msgid "/Edit/Select _all" +msgstr "/Redigeeri/V_ali kõik" + +#: xgnokii/xgnokii_calendar.c:845 xgnokii/xgnokii_contacts.c:3002 +#: xgnokii/xgnokii_dtmf.c:222 xgnokii/xgnokii_netmon.c:264 +#: xgnokii/xgnokii_sms.c:1129 xgnokii/xgnokii_sms.c:1519 +#: xgnokii/xgnokii_speed.c:537 xgnokii/xgnokii_xkeyb.c:244 +msgid "/_Help" +msgstr "/Abi" + +#: xgnokii/xgnokii_calendar.c:846 xgnokii/xgnokii_contacts.c:3003 +#: xgnokii/xgnokii_dtmf.c:223 xgnokii/xgnokii_netmon.c:265 +#: xgnokii/xgnokii_sms.c:1130 xgnokii/xgnokii_sms.c:1520 +#: xgnokii/xgnokii_speed.c:538 xgnokii/xgnokii_xkeyb.c:245 +msgid "/Help/_Help" +msgstr "/Abi/Abi" + +#: xgnokii/xgnokii_calendar.c:847 xgnokii/xgnokii_contacts.c:3004 +#: xgnokii/xgnokii_dtmf.c:224 xgnokii/xgnokii_netmon.c:266 +#: xgnokii/xgnokii_sms.c:1131 xgnokii/xgnokii_sms.c:1521 +#: xgnokii/xgnokii_speed.c:539 xgnokii/xgnokii_xkeyb.c:246 +msgid "/Help/_About" +msgstr "/Abi/Üldine" + +#: xgnokii/xgnokii_calendar.c:862 +msgid "#" +msgstr "" + +#: xgnokii/xgnokii_calendar.c:862 +msgid "Type" +msgstr "Tüüp" + +#: xgnokii/xgnokii_calendar.c:862 +msgid "Date" +msgstr "Kuupäev" + +#: xgnokii/xgnokii_calendar.c:863 xgnokii/xgnokii_contacts.c:1350 +#: xgnokii/xgnokii_contacts.c:3020 xgnokii/xgnokii_speed.c:554 +msgid "Number" +msgstr "Number" + +#: xgnokii/xgnokii_calendar.c:896 xgnokii/xgnokii_contacts.c:3056 +#: xgnokii/xgnokii_speed.c:590 +msgid "Read from phone" +msgstr "Loe telefonist" + +#: xgnokii/xgnokii_calendar.c:900 xgnokii/xgnokii_contacts.c:3060 +#: xgnokii/xgnokii_speed.c:594 +msgid "Save to phone" +msgstr "Salvesta telefoni" + +#: xgnokii/xgnokii_calendar.c:907 +msgid "Send via SMS" +msgstr "Saada SMS abil" + +#: xgnokii/xgnokii_calendar.c:914 xgnokii/xgnokii_contacts.c:3067 +#: xgnokii/xgnokii_logos.c:1386 xgnokii/xgnokii_speed.c:601 +msgid "Import from file" +msgstr "Ava fail" + +#: xgnokii/xgnokii_calendar.c:918 xgnokii/xgnokii_contacts.c:3071 +#: xgnokii/xgnokii_logos.c:1390 xgnokii/xgnokii_speed.c:605 +msgid "Export to file" +msgstr "Salvesta fail" + +#: xgnokii/xgnokii_calendar.c:925 +msgid "Edit note" +msgstr "Muuda kirjet" + +#: xgnokii/xgnokii_calendar.c:933 +msgid "Add call" +msgstr "Lisa kõne" + +#: xgnokii/xgnokii_calendar.c:937 +msgid "Add meeting" +msgstr "Lisa koosolek" + +#: xgnokii/xgnokii_calendar.c:941 +msgid "Add birthday" +msgstr "Lisa sünnipäev" + +#: xgnokii/xgnokii_calendar.c:945 +msgid "Delete note" +msgstr "Kustuta kirje" + +#: xgnokii/xgnokii_calendar.c:1005 xgnokii/xgnokii_contacts.c:2876 +#: xgnokii/xgnokii_contacts.c:3126 xgnokii/xgnokii_sms.c:1686 +#: xgnokii/xgnokii_speed.c:637 +#, c-format +msgid "Error: %s: line %d: Can't allocate memory!\n" +msgstr "VIGA: %s: rida %d: Ei suuda eraldada mälu!\n" + +#: xgnokii/xgnokii_calendar.c:1034 xgnokii/xgnokii_sms.c:1719 +msgid "couldn't allocate colour" +msgstr "ei suuda värvi määratleda" + +#: xgnokii/xgnokii_cfg.c:80 msgid "WARNING: Can't find HOME enviroment variable!\n" msgstr "HOIATUS: Ei leia HOME keskkonnamuutujat!\n" -#: xgnokii/xgnokii.c:2261 xgnokii/xgnokii_cfg.c:77 xgnokii/xgnokii_cfg.c:92 +#: xgnokii/xgnokii_cfg.c:86 xgnokii/xgnokii_cfg.c:101 msgid "WARNING: Can't allocate memory for config reading!\n" msgstr "HOIATUS: Ei suuda eraldada mälu konfiguratsiooni lugemiseks!\n" -#: xgnokii/xgnokii.c:2276 -#, c-format -msgid "Couldn't open %s or /etc/gnokiirc, using default config!\n" -msgstr "Ei suuda %s avada ega ka /etc/gnokiirc, kasutan konfiguratsiooni vaikeväärtusi!\n" - -#: xgnokii/xgnokii_cfg.c:156 +#: xgnokii/xgnokii_cfg.c:185 msgid "ERROR: Can't find HOME enviroment variable!\n" msgstr "VIGA: Ei leia HOME keskkonnamuutujat!\n" -#: xgnokii/xgnokii_cfg.c:162 xgnokii/xgnokii_cfg.c:180 +#: xgnokii/xgnokii_cfg.c:191 xgnokii/xgnokii_cfg.c:209 msgid "ERROR: Can't allocate memory for config writing!\n" msgstr "VIGA: Ei suuda eraldada konfiguratsiooni kirjutamiseks mälu!\n" -#: xgnokii/xgnokii_cfg.c:168 +#: xgnokii/xgnokii_cfg.c:197 #, c-format msgid "ERROR: Can't open file %s for writing!\n" msgstr "VIGA: Ei suuda faili %s lugemiseks avada!\n" -#: xgnokii/xgnokii_cfg.c:186 +#: xgnokii/xgnokii_cfg.c:215 msgid "ERROR: Can't write config file!\n" -msgstr "VIGA: Ei saa kirjutada konfiguratsiooni faili!\n" +msgstr "VIGA: Ei saa kirjutada konfiguratsioonifaili!\n" -#: xgnokii/xgnokii_common.c:240 +#: xgnokii/xgnokii_common.c:57 msgid "Error" msgstr "Viga" -#: xgnokii/xgnokii_common.c:279 +#: xgnokii/xgnokii_common.c:96 msgid "Info" msgstr "Hangin Infot ...." -#: xgnokii/xgnokii_common.c:317 +#: xgnokii/xgnokii_common.c:134 msgid "Yes" msgstr "Jah" -#: xgnokii/xgnokii_common.c:326 +#: xgnokii/xgnokii_common.c:143 msgid "No" msgstr "Ei" -#: xgnokii/xgnokii_common.c:413 +#: xgnokii/xgnokii_common.c:230 #, c-format msgid "Can't exec %s\n" msgstr "Ei saa käivitada %s\n" -#: xgnokii/xgnokii_contacts.c:232 xgnokii/xgnokii_contacts.c:265 -#: xgnokii/xgnokii_contacts.c:428 xgnokii/xgnokii_contacts.c:453 -#: xgnokii/xgnokii_contacts.c:587 xgnokii/xgnokii_contacts.c:609 +#: xgnokii/xgnokii_contacts.c:246 xgnokii/xgnokii_contacts.c:279 +#: xgnokii/xgnokii_contacts.c:448 xgnokii/xgnokii_contacts.c:473 +#: xgnokii/xgnokii_contacts.c:613 xgnokii/xgnokii_contacts.c:635 msgid "Can't change memory type!" msgstr "Ei saa muuta mälu tüüpi!" -#: xgnokii/xgnokii_contacts.c:276 xgnokii/xgnokii_contacts.c:323 +#: xgnokii/xgnokii_contacts.c:290 xgnokii/xgnokii_contacts.c:337 msgid "" "Sorry, phonebook name will be truncated,\n" "because you save it into SIM memory!" @@ -2865,7 +3120,7 @@ msgstr "" "SIM kaardile ei mahu nii pikk nimi, \n" "lühendan nime, nii et mahuks kaardile!" -#: xgnokii/xgnokii_contacts.c:464 xgnokii/xgnokii_contacts.c:503 +#: xgnokii/xgnokii_contacts.c:484 xgnokii/xgnokii_contacts.c:523 msgid "" "Sorry, phonebook name will be truncated\n" "because you save it into SIM memory!" @@ -2873,61 +3128,65 @@ msgstr "" "SIM kaardile ei mahu nii pikk nimi, \n" "lühendan nime, nii et mahuks kaardile!" -#: xgnokii/xgnokii_contacts.c:698 +#: xgnokii/xgnokii_contacts.c:729 msgid "Can't find pattern!" msgstr "Ei leia sobivust!" -#: xgnokii/xgnokii_contacts.c:842 xgnokii/xgnokii_contacts.c:1321 +#: xgnokii/xgnokii_contacts.c:873 xgnokii/xgnokii_contacts.c:1418 msgid "Number:" msgstr "Number:" -#: xgnokii/xgnokii_contacts.c:854 +#: xgnokii/xgnokii_contacts.c:888 +msgid "Extended:" +msgstr "Laiendatud:" + +#: xgnokii/xgnokii_contacts.c:905 msgid "Memory:" msgstr "Mälu:" -#: xgnokii/xgnokii_contacts.c:858 +#: xgnokii/xgnokii_contacts.c:909 msgid "phone" msgstr "telefon" -#: xgnokii/xgnokii_contacts.c:871 +#: xgnokii/xgnokii_contacts.c:922 msgid "Caller group:" msgstr "Helistajagrupp:" -#: xgnokii/xgnokii_contacts.c:885 xgnokii/xgnokii_contacts.c:2801 -#: xgnokii/xgnokii_speed.c:613 +#: xgnokii/xgnokii_contacts.c:939 xgnokii/xgnokii_contacts.c:3086 +#: xgnokii/xgnokii_speed.c:612 msgid "Edit entry" msgstr "Muuda kirjet" -#: xgnokii/xgnokii_contacts.c:931 +#: xgnokii/xgnokii_contacts.c:1028 msgid "Delete entries" msgstr "Kustuta kirjed" -#: xgnokii/xgnokii_contacts.c:963 +#: xgnokii/xgnokii_contacts.c:1060 msgid "Do you want to delete selected entries?" msgstr "Kas soovid valitud kirje kustutada?" -#: xgnokii/xgnokii_contacts.c:975 xgnokii/xgnokii_contacts.c:2793 +#: xgnokii/xgnokii_contacts.c:1072 xgnokii/xgnokii_contacts.c:3078 msgid "New entry" msgstr "Uus kirje" -#: xgnokii/xgnokii_contacts.c:1014 xgnokii/xgnokii_contacts.c:2797 +#: xgnokii/xgnokii_contacts.c:1111 xgnokii/xgnokii_contacts.c:3082 msgid "Duplicate entry" msgstr "Kopeeri kirjet" -#: xgnokii/xgnokii_contacts.c:1080 xgnokii/xgnokii_contacts.c:1090 -#: xgnokii/xgnokii_contacts.c:1115 +#: xgnokii/xgnokii_contacts.c:1177 xgnokii/xgnokii_contacts.c:1187 +#: xgnokii/xgnokii_contacts.c:1212 msgid "Can't find free memory." msgstr "Ei leia vaba mälu." -#: xgnokii/xgnokii_contacts.c:1159 +#: xgnokii/xgnokii_contacts.c:1256 msgid "Changing memory type" msgstr "Muudan mälu tüüpi" -#: xgnokii/xgnokii_contacts.c:1166 +#: xgnokii/xgnokii_contacts.c:1263 msgid "Continue" msgstr "Jätka" -#: xgnokii/xgnokii_contacts.c:1186 +#: xgnokii/xgnokii_contacts.c:1283 msgid "" "If you change from phone memory to SIM memory\n" "some entries may be truncated." @@ -2935,59 +3194,54 @@ msgstr "" "Kirje muutmisel telefonimälust SIM kaardile\n" "võivad mõned kirjed muutuda lühemaks." -#: xgnokii/xgnokii_contacts.c:1206 xgnokii/xgnokii_contacts.c:1212 +#: xgnokii/xgnokii_contacts.c:1303 xgnokii/xgnokii_contacts.c:1309 msgid "Find" msgstr "Otsi" -#: xgnokii/xgnokii_contacts.c:1234 +#: xgnokii/xgnokii_contacts.c:1331 msgid "Pattern:" msgstr "Mask:" -#: xgnokii/xgnokii_contacts.c:1247 xgnokii/xgnokii_contacts.c:2735 -#: xgnokii/xgnokii_speed.c:555 +#: xgnokii/xgnokii_contacts.c:1344 xgnokii/xgnokii_contacts.c:3020 +#: xgnokii/xgnokii_speed.c:554 msgid "Name" msgstr "Nimi" -#: xgnokii/xgnokii_contacts.c:1253 xgnokii/xgnokii_contacts.c:2735 -#: xgnokii/xgnokii_speed.c:555 -msgid "Number" -msgstr "Number" - -#: xgnokii/xgnokii_contacts.c:1297 xgnokii/xgnokii_contacts.c:2812 +#: xgnokii/xgnokii_contacts.c:1394 xgnokii/xgnokii_contacts.c:3097 msgid "Dial voice" msgstr "Helista" -#: xgnokii/xgnokii_contacts.c:1423 +#: xgnokii/xgnokii_contacts.c:1520 msgid "Phone memory..." msgstr "Telefoni mälu..." -#: xgnokii/xgnokii_contacts.c:1434 +#: xgnokii/xgnokii_contacts.c:1531 msgid "SIM memory..." msgstr "SIM (kaardi) mälu..." -#: xgnokii/xgnokii_contacts.c:1463 +#: xgnokii/xgnokii_contacts.c:1560 msgid "Saving entries" msgstr "Salvestan kirjeid" -#: xgnokii/xgnokii_contacts.c:1497 +#: xgnokii/xgnokii_contacts.c:1594 #, c-format msgid "%s: line: %d:Can't write ME memory entry number %d! Error: %d\n" msgstr "%s: rida %d:Ei suuda kirjutada ME mälupessa %d! Viga: %d\n" -#: xgnokii/xgnokii_contacts.c:1539 +#: xgnokii/xgnokii_contacts.c:1636 #, c-format msgid "%s: line %d:Can't write SM memory entry number %d! Error: %d\n" msgstr "%s: rida %d:Ei suuda kirjutada SM mälupessa %d! Viga: %d\n" -#: xgnokii/xgnokii_contacts.c:1562 +#: xgnokii/xgnokii_contacts.c:1659 msgid "Save changes?" msgstr "Salvesta muudatused?" -#: xgnokii/xgnokii_contacts.c:1578 +#: xgnokii/xgnokii_contacts.c:1675 msgid "Don't save" msgstr "Ära salvesta" -#: xgnokii/xgnokii_contacts.c:1602 +#: xgnokii/xgnokii_contacts.c:1699 msgid "" "You have made changes in your\n" "contacts directory.\n" @@ -3001,13 +3255,33 @@ msgstr "" "\n" "Kas soovid muudatused telefoni salvestada?\n" -#: xgnokii/xgnokii_contacts.c:1668 xgnokii/xgnokii_contacts.c:1695 -#: xgnokii/xgnokii_contacts.c:2279 xgnokii/xgnokii_contacts.c:2302 +#: xgnokii/xgnokii_contacts.c:1760 +msgid "Which Extended Phonebook Entry?" +msgstr "Milline laienadatud telefoniraamatu kirje?" + +#: xgnokii/xgnokii_contacts.c:1766 +msgid "General" +msgstr "Üldine" + +#: xgnokii/xgnokii_contacts.c:1772 +msgid "Mobile" +msgstr "Mobiil" + +#: xgnokii/xgnokii_contacts.c:1778 +msgid "Work" +msgstr "Tööl" + +#: xgnokii/xgnokii_contacts.c:1790 +msgid "Home" +msgstr "Kodus" + +#: xgnokii/xgnokii_contacts.c:1883 xgnokii/xgnokii_contacts.c:1910 +#: xgnokii/xgnokii_contacts.c:2555 xgnokii/xgnokii_contacts.c:2579 #, c-format msgid "%s: line %d: Can't allocate memory!\n" msgstr "%s: rida %d: Ei suuda mälu eraldada!\n" -#: xgnokii/xgnokii_contacts.c:1790 +#: xgnokii/xgnokii_contacts.c:2005 msgid "" "Can't get SM memory status!\n" "\n" @@ -3017,23 +3291,23 @@ msgstr "" "\n" "oletan max SIM kirjete arvuks 100!\n" -#: xgnokii/xgnokii_contacts.c:1815 +#: xgnokii/xgnokii_contacts.c:2030 msgid "Getting entries" msgstr "Loen kirjeid ...." -#: xgnokii/xgnokii_contacts.c:1948 xgnokii/xgnokii_dtmf.c:128 -#: xgnokii/xgnokii_speed.c:427 +#: xgnokii/xgnokii_contacts.c:2163 xgnokii/xgnokii_dtmf.c:128 +#: xgnokii/xgnokii_speed.c:426 #, c-format msgid "Can't open file %s for writing!" msgstr "Ei suuda faili %s kirjutamiseks avada!" -#: xgnokii/xgnokii_contacts.c:2020 xgnokii/xgnokii_dtmf.c:161 -#: xgnokii/xgnokii_speed.c:469 +#: xgnokii/xgnokii_contacts.c:2257 xgnokii/xgnokii_dtmf.c:161 +#: xgnokii/xgnokii_logos.c:1169 xgnokii/xgnokii_speed.c:468 msgid "Overwrite file?" msgstr "Kas kirjutan faili üle?" -#: xgnokii/xgnokii_contacts.c:2021 xgnokii/xgnokii_dtmf.c:162 -#: xgnokii/xgnokii_speed.c:470 +#: xgnokii/xgnokii_contacts.c:2258 xgnokii/xgnokii_dtmf.c:162 +#: xgnokii/xgnokii_logos.c:1170 xgnokii/xgnokii_speed.c:469 #, c-format msgid "" "File %s already exist.\n" @@ -3042,17 +3316,17 @@ msgstr "" "Fail %s on olemas.\n" "Kas kirjutan üle?" -#: xgnokii/xgnokii_contacts.c:2039 xgnokii/xgnokii_speed.c:488 +#: xgnokii/xgnokii_contacts.c:2276 xgnokii/xgnokii_speed.c:487 msgid "Export" msgstr "Ekspordi" -#: xgnokii/xgnokii_contacts.c:2200 xgnokii/xgnokii_dtmf.c:90 -#: xgnokii/xgnokii_speed.c:327 +#: xgnokii/xgnokii_contacts.c:2476 xgnokii/xgnokii_dtmf.c:90 +#: xgnokii/xgnokii_speed.c:326 #, c-format msgid "Can't open file %s for reading!" msgstr "Ei suuda faili %s lugemiseks avada!" -#: xgnokii/xgnokii_contacts.c:2254 +#: xgnokii/xgnokii_contacts.c:2530 msgid "" "Can't get SM memory status!\n" "\n" @@ -3062,177 +3336,104 @@ msgstr "" "\n" "max SIM kirjete arv on 100!\n" -#: xgnokii/xgnokii_contacts.c:2367 xgnokii/xgnokii_speed.c:405 +#: xgnokii/xgnokii_contacts.c:2645 xgnokii/xgnokii_speed.c:404 msgid "Import" msgstr "Impordi" -#: xgnokii/xgnokii_contacts.c:2564 xgnokii/xgnokii_sms.c:1126 +#: xgnokii/xgnokii_contacts.c:2843 xgnokii/xgnokii_sms.c:1233 msgid "Select contacts" msgstr "Vali kontaktid" -#: xgnokii/xgnokii_contacts.c:2597 xgnokii/xgnokii_contacts.c:2841 -#: xgnokii/xgnokii_sms.c:1575 xgnokii/xgnokii_speed.c:638 -#, c-format -msgid "Error: %s: line %d: Can't allocate memory!\n" -msgstr "VIGA: %s: rida %d: Ei suuda eraldada mälu!\n" - -#: xgnokii/xgnokii_contacts.c:2695 xgnokii/xgnokii_dtmf.c:217 -#: xgnokii/xgnokii_logos.c:1143 xgnokii/xgnokii_netmon.c:260 -#: xgnokii/xgnokii_sms.c:1014 xgnokii/xgnokii_sms.c:1397 -#: xgnokii/xgnokii_speed.c:528 xgnokii/xgnokii_xkeyb.c:242 -msgid "/_File" -msgstr "/_Fail" - -#: xgnokii/xgnokii_contacts.c:2696 xgnokii/xgnokii_speed.c:529 -msgid "/File/_Read from phone" -msgstr "/Fail/Loe telefonist" - -#: xgnokii/xgnokii_contacts.c:2697 xgnokii/xgnokii_speed.c:530 -msgid "/File/_Save to phone" -msgstr "/Fail/_Salvesta telefoni" - -#: xgnokii/xgnokii_contacts.c:2698 xgnokii/xgnokii_dtmf.c:220 -#: xgnokii/xgnokii_logos.c:1147 xgnokii/xgnokii_sms.c:1017 -#: xgnokii/xgnokii_sms.c:1399 xgnokii/xgnokii_speed.c:531 -msgid "/File/Sep1" -msgstr "/Fail/Sep1" - -#: xgnokii/xgnokii_contacts.c:2699 xgnokii/xgnokii_speed.c:532 -msgid "/File/_Import from file" -msgstr "/Fail/Ava fail" - -#: xgnokii/xgnokii_contacts.c:2700 xgnokii/xgnokii_speed.c:533 -msgid "/File/_Export to file" -msgstr "/Fail/Salvesta faili" - -#: xgnokii/xgnokii_contacts.c:2701 xgnokii/xgnokii_logos.c:1151 -#: xgnokii/xgnokii_sms.c:1020 xgnokii/xgnokii_speed.c:534 -msgid "/File/Sep2" -msgstr "/Fail/Sep2" - -#: xgnokii/xgnokii_contacts.c:2702 xgnokii/xgnokii_dtmf.c:221 -#: xgnokii/xgnokii_logos.c:1152 xgnokii/xgnokii_netmon.c:261 -#: xgnokii/xgnokii_sms.c:1021 xgnokii/xgnokii_sms.c:1400 -#: xgnokii/xgnokii_speed.c:535 xgnokii/xgnokii_xkeyb.c:243 -msgid "/File/_Close" -msgstr "/Fail/Sulge" - -#: xgnokii/xgnokii_contacts.c:2703 xgnokii/xgnokii_logos.c:1153 -#: xgnokii/xgnokii_speed.c:536 -msgid "/_Edit" -msgstr "/R_edigeeri" - -#: xgnokii/xgnokii_contacts.c:2704 +#: xgnokii/xgnokii_contacts.c:2989 msgid "/Edit/_New" msgstr "/Redigeeri/Uus" -#: xgnokii/xgnokii_contacts.c:2705 +#: xgnokii/xgnokii_contacts.c:2990 msgid "/Edit/D_uplicate" msgstr "/Redigeeri/Palj_unda" -#: xgnokii/xgnokii_contacts.c:2706 xgnokii/xgnokii_speed.c:537 -msgid "/Edit/_Edit" -msgstr "/Redigeeri/Paranda" - -#: xgnokii/xgnokii_contacts.c:2707 -msgid "/Edit/_Delete" -msgstr "/Redigeeri/Kustuta" - -#: xgnokii/xgnokii_contacts.c:2708 xgnokii/xgnokii_logos.c:1156 +#: xgnokii/xgnokii_contacts.c:2993 xgnokii/xgnokii_logos.c:1305 msgid "/Edit/Sep3" msgstr "/Redigeeri/Sep3" -#: xgnokii/xgnokii_contacts.c:2709 +#: xgnokii/xgnokii_contacts.c:2994 msgid "/Edit/_Change memory type" msgstr "/Redigeeri/Muuda mälu tüüp" -#: xgnokii/xgnokii_contacts.c:2710 xgnokii/xgnokii_logos.c:1161 -msgid "/Edit/Sep4" -msgstr "/Redigeeri/Sep4" - -#: xgnokii/xgnokii_contacts.c:2711 +#: xgnokii/xgnokii_contacts.c:2996 msgid "/Edit/_Find" msgstr "/Redigeeri/Leia" -#: xgnokii/xgnokii_contacts.c:2712 +#: xgnokii/xgnokii_contacts.c:2997 msgid "/Edit/Find ne_xt" msgstr "/Redigeeri/Leia järgmine" -#: xgnokii/xgnokii_contacts.c:2713 +#: xgnokii/xgnokii_contacts.c:2998 msgid "/Edit/Sep5" msgstr "/Redigeeri/Sep5" -#: xgnokii/xgnokii_contacts.c:2714 -msgid "/Edit/Select _all" -msgstr "/Redigeeri/V_ali kõik" - -#: xgnokii/xgnokii_contacts.c:2715 +#: xgnokii/xgnokii_contacts.c:3000 msgid "/_Dial" msgstr "/Vali numbri_d" -#: xgnokii/xgnokii_contacts.c:2716 +#: xgnokii/xgnokii_contacts.c:3001 msgid "/Dial/Dial _voice" msgstr "/Vali numbrid/_Vali kõne" -#: xgnokii/xgnokii_contacts.c:2717 xgnokii/xgnokii_dtmf.c:222 -#: xgnokii/xgnokii_netmon.c:265 xgnokii/xgnokii_sms.c:1022 -#: xgnokii/xgnokii_sms.c:1408 xgnokii/xgnokii_speed.c:538 -#: xgnokii/xgnokii_xkeyb.c:244 -msgid "/_Help" -msgstr "/Abi" - -#: xgnokii/xgnokii_contacts.c:2718 xgnokii/xgnokii_dtmf.c:223 -#: xgnokii/xgnokii_netmon.c:266 xgnokii/xgnokii_sms.c:1023 -#: xgnokii/xgnokii_sms.c:1409 xgnokii/xgnokii_speed.c:539 -#: xgnokii/xgnokii_xkeyb.c:245 -msgid "/Help/_Help" -msgstr "/Abi/Abi" - -#: xgnokii/xgnokii_contacts.c:2719 xgnokii/xgnokii_dtmf.c:224 -#: xgnokii/xgnokii_netmon.c:267 xgnokii/xgnokii_sms.c:1024 -#: xgnokii/xgnokii_sms.c:1410 xgnokii/xgnokii_speed.c:540 -#: xgnokii/xgnokii_xkeyb.c:246 -msgid "/Help/_About" -msgstr "/Abi/Üldine" - -#: xgnokii/xgnokii_contacts.c:2735 +#: xgnokii/xgnokii_contacts.c:3020 msgid "Memory" msgstr "Mälu" -#: xgnokii/xgnokii_contacts.c:2735 +#: xgnokii/xgnokii_contacts.c:3020 msgid "Group" msgstr "Grupp" -#: xgnokii/xgnokii_contacts.c:2771 xgnokii/xgnokii_speed.c:591 -msgid "Read from phone" -msgstr "Loe telefonist" +#: xgnokii/xgnokii_contacts.c:3090 +msgid "Delete entry" +msgstr "Kustuta kirje" -#: xgnokii/xgnokii_contacts.c:2775 xgnokii/xgnokii_speed.c:595 -msgid "Save to phone" -msgstr "Salvesta telefoni" +#: xgnokii/xgnokii_data.c:42 +msgid "" +"Data calls are currently\n" +"Disabled\n" +" " +msgstr "" +"Andmekõned on hetkel\n" +"Keelatud\n" +" " -#: xgnokii/xgnokii_contacts.c:2782 xgnokii/xgnokii_speed.c:602 -msgid "Import from file" -msgstr "Ava fail" +#: xgnokii/xgnokii_data.c:44 +msgid "" +"Data calls are currently\n" +"Enabled\n" +" " +msgstr "" +"Andmekõned on hetkel\n" +"Lubatud\n" +" " -#: xgnokii/xgnokii_contacts.c:2786 xgnokii/xgnokii_speed.c:606 -msgid "Export to file" -msgstr "Salvesta fail" +#: xgnokii/xgnokii_data.c:101 +msgid "Virtual Modem" +msgstr "" -#: xgnokii/xgnokii_contacts.c:2805 -msgid "Delete entry" -msgstr "Kustuta kirje" +#: xgnokii/xgnokii_data.c:119 +msgid "Enable" +msgstr "Luba" + +#: xgnokii/xgnokii_data.c:125 +msgid "Disable" +msgstr "Keela" #: xgnokii/xgnokii_dtmf.c:108 msgid "Load" msgstr "Laadi" -#: xgnokii/xgnokii_dtmf.c:218 xgnokii/xgnokii_logos.c:1144 +#: xgnokii/xgnokii_dtmf.c:218 xgnokii/xgnokii_logos.c:1293 msgid "/File/_Open" msgstr "/Fail/Ava" -#: xgnokii/xgnokii_dtmf.c:219 xgnokii/xgnokii_logos.c:1145 -#: xgnokii/xgnokii_sms.c:1016 xgnokii/xgnokii_sms.c:1398 +#: xgnokii/xgnokii_dtmf.c:219 xgnokii/xgnokii_logos.c:1294 +#: xgnokii/xgnokii_sms.c:1123 xgnokii/xgnokii_sms.c:1508 msgid "/File/_Save" msgstr "/Fail/_Salvesta" @@ -3240,259 +3441,403 @@ msgstr "/Fail/_Salvesta" msgid "Dial Tone" msgstr "Vali toon" -#: xgnokii/xgnokii_netmon.c:262 +#: xgnokii/xgnokii_logos.c:823 +#, c-format +msgid "" +"Error getting network info\n" +"(error=%d)" +msgstr "" +"Võrguinfo saamise viga\n" +"(viga=%d)" + +#: xgnokii/xgnokii_logos.c:862 +#, c-format +msgid "" +"Error getting bitmap\n" +"(error=%d)" +msgstr "" +"Pildi saamise viga\n" +"(viga=%d)" + +#: xgnokii/xgnokii_logos.c:907 +#, c-format +msgid "" +"Error setting bitmap\n" +"(error=%d)" +msgstr "" +"Pildi seadmise viga\n" +"(viga=%d)" + +#: xgnokii/xgnokii_logos.c:1141 +#, c-format +msgid "" +"Error saving file\n" +"(error=%d)" +msgstr "" +"Faili salvestamise viga\n" +"(viga=%d)" + +#: xgnokii/xgnokii_logos.c:1191 +#, c-format +msgid "Can't open file %s for reading !" +msgstr "Ei suuda faili %s lugemiseks avada!" + +#: xgnokii/xgnokii_logos.c:1200 +#, c-format +msgid "" +"Error reading file\n" +"(error=%d)" +msgstr "" +"Faili lugemise viga\n" +"(viga=%d)" + +#: xgnokii/xgnokii_logos.c:1295 +msgid "/File/Save _as ..." +msgstr "/Fail/Salvest_a nagu ..." + +#: xgnokii/xgnokii_logos.c:1297 +msgid "/File/_Get operator" +msgstr "/Fail/Tuvasta operaator" + +#: xgnokii/xgnokii_logos.c:1298 +msgid "/File/Get _logo" +msgstr "/Fail/Võta _logo" + +#: xgnokii/xgnokii_logos.c:1299 +msgid "/File/Se_t logo" +msgstr "/Fail/Sea logo" + +#: xgnokii/xgnokii_logos.c:1303 +msgid "/Edit/_Clear" +msgstr "/Redigeeri/Tühjenda" + +#: xgnokii/xgnokii_logos.c:1304 +msgid "/Edit/_Invert" +msgstr "/Redigeeri/Peegelpilt" + +#: xgnokii/xgnokii_logos.c:1306 +msgid "/Edit/_Up logo" +msgstr "/Redigeeri/Pilt samm üles" + +#: xgnokii/xgnokii_logos.c:1307 +msgid "/Edit/_Down logo" +msgstr "/Redigeeri/Pilt samm alla" + +#: xgnokii/xgnokii_logos.c:1308 +msgid "/Edit/_Left logo" +msgstr "/Redigeeri/Pi_lt samm vasakule" + +#: xgnokii/xgnokii_logos.c:1309 +msgid "/Edit/_Right logo" +msgstr "/Redigeeri/Pilt samm pa_remale" + +#: xgnokii/xgnokii_logos.c:1311 +msgid "/Edit/Flip _horizontal" +msgstr "/Redigeeri/Pööra _horisontaalis" + +#: xgnokii/xgnokii_logos.c:1312 +msgid "/Edit/Flip _vertical" +msgstr "/Redigeeri/Pööra _vertikaalis" + +#: xgnokii/xgnokii_logos.c:1604 +msgid "Load preview pixmap error, feature disabled." +msgstr "Eelvaate pildi laadimise viga, omadust ei kasutata." + +#: xgnokii/xgnokii_lowlevel.c:353 +#, c-format +msgid "%s: line %d: Can't get memory entry number %d from memory %d! %d\n" +msgstr "" + +#: xgnokii/xgnokii_lowlevel.c:874 +msgid "Connecting..." +msgstr "Kontakteerun...." + +#: xgnokii/xgnokii_lowlevel.c:907 +msgid "Refreshing SMSes..." +msgstr "Uuendan SMS'e ..." + +#: xgnokii/xgnokii_lowlevel.c:965 +msgid "Working..." +msgstr "Toimetan..." + +#: xgnokii/xgnokii_lowlevel.c:968 +#, c-format +msgid "Event %d failed with return code %d!\n" +msgstr "" + +#: xgnokii/xgnokii_netmon.c:261 msgid "/_Tools" msgstr "/_Tööriistad" -#: xgnokii/xgnokii_netmon.c:263 +#: xgnokii/xgnokii_netmon.c:262 msgid "/Tools/Net monitor o_n" msgstr "/Tööriistad/Võrgu mo_nitor peale" -#: xgnokii/xgnokii_netmon.c:264 +#: xgnokii/xgnokii_netmon.c:263 msgid "/Tools/Net monitor o_ff" msgstr "/Tööriistad/Võrgu monitor maha" -#: xgnokii/xgnokii_netmon.c:381 xgnokii/xgnokii_netmon.c:384 +#: xgnokii/xgnokii_netmon.c:380 xgnokii/xgnokii_netmon.c:383 msgid "Active cell" msgstr "Aktiivne kärg" -#: xgnokii/xgnokii_netmon.c:387 +#: xgnokii/xgnokii_netmon.c:386 msgid "NCELL list I" msgstr "" -#: xgnokii/xgnokii_netmon.c:390 +#: xgnokii/xgnokii_netmon.c:389 msgid "NCELL list II" msgstr "" -#: xgnokii/xgnokii_netmon.c:393 +#: xgnokii/xgnokii_netmon.c:392 msgid "NCELL list III" msgstr "" -#: xgnokii/xgnokii_netmon.c:396 +#: xgnokii/xgnokii_netmon.c:395 msgid "Prefered/Denied networks" -msgstr "Eelistatud/keelatud v6rgud" +msgstr "Eelistatud/keelatud võrgud" -#: xgnokii/xgnokii_netmon.c:399 +#: xgnokii/xgnokii_netmon.c:398 msgid "System information bits" msgstr "Süsteemi informatsiooni bitid" -#: xgnokii/xgnokii_netmon.c:402 +#: xgnokii/xgnokii_netmon.c:401 msgid "TMSI, Paging, PLU" msgstr "" -#: xgnokii/xgnokii_netmon.c:405 +#: xgnokii/xgnokii_netmon.c:404 msgid "Cells info" msgstr "Kärje info" -#: xgnokii/xgnokii_netmon.c:408 +#: xgnokii/xgnokii_netmon.c:407 msgid "DTX, Cipher, Hopping" msgstr "" -#: xgnokii/xgnokii_netmon.c:418 +#: xgnokii/xgnokii_netmon.c:417 msgid "Uplink DTX" msgstr "" -#: xgnokii/xgnokii_netmon.c:421 +#: xgnokii/xgnokii_netmon.c:420 msgid "BTS TEST" msgstr "" -#: xgnokii/xgnokii_netmon.c:424 +#: xgnokii/xgnokii_netmon.c:423 msgid "CELL BARR-Flag" msgstr "" -#: xgnokii/xgnokii_netmon.c:427 +#: xgnokii/xgnokii_netmon.c:426 msgid "Accumulator, Charge status" msgstr "Aku, laadimise staatus" -#: xgnokii/xgnokii_netmon.c:430 +#: xgnokii/xgnokii_netmon.c:429 msgid "?Constant voltage charging display" msgstr "" -#: xgnokii/xgnokii_netmon.c:433 +#: xgnokii/xgnokii_netmon.c:432 msgid "?Battery full detection" msgstr "?Aku laadumuse proov" -#: xgnokii/xgnokii_netmon.c:436 +#: xgnokii/xgnokii_netmon.c:435 msgid "Accumulator" msgstr "Aku" -#: xgnokii/xgnokii_netmon.c:439 +#: xgnokii/xgnokii_netmon.c:438 msgid "SW-Resets" msgstr "" -#: xgnokii/xgnokii_netmon.c:442 +#: xgnokii/xgnokii_netmon.c:441 msgid "Reset-Counter" msgstr "" -#: xgnokii/xgnokii_netmon.c:445 +#: xgnokii/xgnokii_netmon.c:444 msgid "Cause codes for last connection abortion" msgstr "Viimase ühenduse katkestamise põhjuskoodid" -#: xgnokii/xgnokii_netmon.c:455 +#: xgnokii/xgnokii_netmon.c:454 msgid "Reset handover counters" msgstr "" -#: xgnokii/xgnokii_netmon.c:458 +#: xgnokii/xgnokii_netmon.c:457 msgid "Handover Counter" msgstr "" -#: xgnokii/xgnokii_netmon.c:461 +#: xgnokii/xgnokii_netmon.c:460 msgid "Handover Counter (Dual)" msgstr "" -#: xgnokii/xgnokii_netmon.c:464 +#: xgnokii/xgnokii_netmon.c:463 msgid "L2-Timeouts" msgstr "" -#: xgnokii/xgnokii_netmon.c:467 +#: xgnokii/xgnokii_netmon.c:466 msgid "SIM" msgstr "" -#: xgnokii/xgnokii_netmon.c:470 +#: xgnokii/xgnokii_netmon.c:469 msgid "?Block display 1" msgstr "" -#: xgnokii/xgnokii_netmon.c:476 +#: xgnokii/xgnokii_netmon.c:475 msgid "Memory status before reset" msgstr "Mälu olek enne resetti" -#: xgnokii/xgnokii_netmon.c:479 +#: xgnokii/xgnokii_netmon.c:478 msgid "Reset Counters" msgstr "" -#: xgnokii/xgnokii_netmon.c:482 +#: xgnokii/xgnokii_netmon.c:481 msgid "Counter for PLMN Search and Cell reselection (Singleband)" msgstr "" -#: xgnokii/xgnokii_netmon.c:492 +#: xgnokii/xgnokii_netmon.c:491 msgid "Neighbourhood measurement" msgstr "Keskkonnaparameetrite mõõtmine" -#: xgnokii/xgnokii_netmon.c:495 +#: xgnokii/xgnokii_netmon.c:494 msgid "Calls" msgstr "Kõnesid" -#: xgnokii/xgnokii_netmon.c:498 +#: xgnokii/xgnokii_netmon.c:497 msgid "Temporary counters of DSP" msgstr "DSP ajutised loendurid" -#: xgnokii/xgnokii_netmon.c:501 +#: xgnokii/xgnokii_netmon.c:500 msgid "Control of task information displays" msgstr "" -#: xgnokii/xgnokii_netmon.c:504 +#: xgnokii/xgnokii_netmon.c:503 msgid "Information about task numbers 0-7" msgstr "" -#: xgnokii/xgnokii_netmon.c:507 +#: xgnokii/xgnokii_netmon.c:506 msgid "Information about task numbers 8-15" msgstr "" -#: xgnokii/xgnokii_netmon.c:510 +#: xgnokii/xgnokii_netmon.c:509 msgid "Information about task numbers 16-23" msgstr "" -#: xgnokii/xgnokii_netmon.c:513 +#: xgnokii/xgnokii_netmon.c:512 msgid "Information about OS_SYSTEM_STACK" -msgstr "OS_SYSTEM_STACK informatsioon" +msgstr "" -#: xgnokii/xgnokii_netmon.c:516 +#: xgnokii/xgnokii_netmon.c:515 msgid "Information about current MCU and DSP software versions" msgstr "" -#: xgnokii/xgnokii_netmon.c:519 +#: xgnokii/xgnokii_netmon.c:518 msgid "Hardware version" msgstr "Riistvara versioon" -#: xgnokii/xgnokii_netmon.c:538 +#: xgnokii/xgnokii_netmon.c:537 msgid "Chan" msgstr "" -#: xgnokii/xgnokii_netmon.c:539 +#: xgnokii/xgnokii_netmon.c:538 msgid "RxLv" msgstr "" -#: xgnokii/xgnokii_netmon.c:540 +#: xgnokii/xgnokii_netmon.c:539 msgid "C1" msgstr "" -#: xgnokii/xgnokii_netmon.c:541 +#: xgnokii/xgnokii_netmon.c:540 msgid "C2" msgstr "" -#: xgnokii/xgnokii_netmon.c:542 +#: xgnokii/xgnokii_netmon.c:541 msgid "ACT" msgstr "" -#: xgnokii/xgnokii_netmon.c:543 +#: xgnokii/xgnokii_netmon.c:542 msgid "NC2" msgstr "" -#: xgnokii/xgnokii_netmon.c:544 +#: xgnokii/xgnokii_netmon.c:543 msgid "NC3" msgstr "" -#: xgnokii/xgnokii_netmon.c:545 +#: xgnokii/xgnokii_netmon.c:544 msgid "NC4" msgstr "" -#: xgnokii/xgnokii_netmon.c:546 +#: xgnokii/xgnokii_netmon.c:545 msgid "NC5" msgstr "" -#: xgnokii/xgnokii_netmon.c:547 +#: xgnokii/xgnokii_netmon.c:546 msgid "NC6" msgstr "" -#: xgnokii/xgnokii_netmon.c:548 +#: xgnokii/xgnokii_netmon.c:547 msgid "NC7" msgstr "" -#: xgnokii/xgnokii_netmon.c:579 +#: xgnokii/xgnokii_netmon.c:578 msgid "Page:" msgstr "Leht:" -#: xgnokii/xgnokii_sms.c:233 +#: xgnokii/xgnokii_sms.c:236 msgid "report" msgstr "raport" -#: xgnokii/xgnokii_sms.c:238 +#: xgnokii/xgnokii_sms.c:241 msgid "read" -msgstr "loe" +msgstr "loetud" -#: xgnokii/xgnokii_sms.c:243 +#: xgnokii/xgnokii_sms.c:246 msgid "unread" msgstr "lugemata" -#: xgnokii/xgnokii_sms.c:303 +#: xgnokii/xgnokii_sms.c:306 msgid "sent" msgstr "saadetud" -#: xgnokii/xgnokii_sms.c:305 +#: xgnokii/xgnokii_sms.c:308 msgid "unsent" msgstr "saatmata" -#: xgnokii/xgnokii_sms.c:373 +#: xgnokii/xgnokii_sms.c:376 msgid "From: " msgstr "Saatja: " -#: xgnokii/xgnokii_sms.c:381 -msgid "Date: " -msgstr "Kuupäev: " - -#: xgnokii/xgnokii_sms.c:470 +#: xgnokii/xgnokii_sms.c:473 msgid "Delete SMS" msgstr "Kustuta SMS" -#: xgnokii/xgnokii_sms.c:502 +#: xgnokii/xgnokii_sms.c:505 msgid "Do you want to delete selected SMS?" msgstr "Kas soovid valitud SMS kustutada?" -#: xgnokii/xgnokii_sms.c:720 xgnokii/xgnokii_sms.c:851 +#: xgnokii/xgnokii_sms.c:529 +#, c-format +msgid "Cannot open mailbox %s for appending!" +msgstr "Ei suuda faili %s lisamiseks avada!" + +#: xgnokii/xgnokii_sms.c:543 +#, c-format +msgid "" +"Cannot save to mailbox %s.\n" +"%s is locked for process %d!" +msgstr "" +"Ei suuda salvestada %s mailbox'i.\n" +"%s on protsessi %d jaoks lukus!" + +#: xgnokii/xgnokii_sms.c:558 +#, c-format +msgid "Cannot lock mailbox %s!" +msgstr "Ei suuda %s mailbox'i lukustada!" + +#: xgnokii/xgnokii_sms.c:609 +#, c-format +msgid "Cannot unlock mailbox %s!" +msgstr "Ei suuda %s mailbox'i lukku vabastada!" + +#: xgnokii/xgnokii_sms.c:827 xgnokii/xgnokii_sms.c:958 msgid "Address line contains illegal address!" msgstr "Aadressi real on sobimatu aadress!" -#: xgnokii/xgnokii_sms.c:823 +#: xgnokii/xgnokii_sms.c:930 #, c-format msgid "" "SMS send to %s failed\n" @@ -3501,166 +3846,166 @@ msgstr "" "SMS saatmine %s ebõnnestus!\n" "(viga=%d)" -#: xgnokii/xgnokii_sms.c:913 xgnokii/xgnokii_sms.c:950 +#: xgnokii/xgnokii_sms.c:1020 xgnokii/xgnokii_sms.c:1057 #, c-format msgid "Sending SMS to %s (%d/%d) ...\n" msgstr "Saadan SMS'i %s (%d/%d) ...\n" -#: xgnokii/xgnokii_sms.c:977 +#: xgnokii/xgnokii_sms.c:1084 #, c-format msgid "Sending SMS to %s ...\n" msgstr "Saadan SMS'i %s ...\n" -#: xgnokii/xgnokii_sms.c:1015 +#: xgnokii/xgnokii_sms.c:1122 msgid "/File/Sen_d" msgstr "/Fail/Saa_da" -#: xgnokii/xgnokii_sms.c:1018 +#: xgnokii/xgnokii_sms.c:1125 msgid "/File/Check _Names" msgstr "/Fail/_Nime kontroll" -#: xgnokii/xgnokii_sms.c:1019 +#: xgnokii/xgnokii_sms.c:1126 msgid "/File/C_ontacts" msgstr "/Fail/K_ontaktid" -#: xgnokii/xgnokii_sms.c:1078 +#: xgnokii/xgnokii_sms.c:1185 msgid "Send message" msgstr "Saada sõnum" -#: xgnokii/xgnokii_sms.c:1082 +#: xgnokii/xgnokii_sms.c:1189 msgid "Save message to outbox" msgstr "Salvesta sõnum outbox'i" -#: xgnokii/xgnokii_sms.c:1089 +#: xgnokii/xgnokii_sms.c:1196 msgid "Check names" msgstr "Kontrolli nimesid" -#: xgnokii/xgnokii_sms.c:1102 +#: xgnokii/xgnokii_sms.c:1209 msgid "To:" msgstr "Saaja:" -#: xgnokii/xgnokii_sms.c:1174 +#: xgnokii/xgnokii_sms.c:1281 msgid "Delivery report" msgstr "Saateraport" -#: xgnokii/xgnokii_sms.c:1178 +#: xgnokii/xgnokii_sms.c:1285 msgid "Send as Long SMS" msgstr "Saada pika SMS'na" -#: xgnokii/xgnokii_sms.c:1182 +#: xgnokii/xgnokii_sms.c:1289 msgid "SMS Center:" msgstr "SMS Keskus:" -#: xgnokii/xgnokii_sms.c:1201 +#: xgnokii/xgnokii_sms.c:1308 msgid "New Message" msgstr "Uus sõnum" -#: xgnokii/xgnokii_sms.c:1228 +#: xgnokii/xgnokii_sms.c:1335 msgid "Forward Message" msgstr "Edasta sõnum" -#: xgnokii/xgnokii_sms.c:1272 +#: xgnokii/xgnokii_sms.c:1379 msgid "Reply Message" msgstr "Vasta sõnumile" -#: xgnokii/xgnokii_sms.c:1308 xgnokii/xgnokii_sms.c:1475 +#: xgnokii/xgnokii_sms.c:1415 xgnokii/xgnokii_sms.c:1586 msgid "Bussiness Card" msgstr "Visiitkaart" -#: xgnokii/xgnokii_sms.c:1401 +#: xgnokii/xgnokii_sms.c:1509 +msgid "/File/Save to mailbo_x" +msgstr "/Fail/Salvesta mailbo_xi" + +#: xgnokii/xgnokii_sms.c:1512 msgid "/_Messages" msgstr "/Sõnu_mid" -#: xgnokii/xgnokii_sms.c:1402 +#: xgnokii/xgnokii_sms.c:1513 msgid "/_Messages/_New" -msgstr "/Sõnu_mid/Uued" +msgstr "/Sõnu_mid/Uus sõnum" -#: xgnokii/xgnokii_sms.c:1403 +#: xgnokii/xgnokii_sms.c:1514 msgid "/_Messages/_Forward" -msgstr "/Sõnu_mid/Edasta _F" +msgstr "/Sõnu_mid/Saada sõnum edasi" -#: xgnokii/xgnokii_sms.c:1404 +#: xgnokii/xgnokii_sms.c:1515 msgid "/_Messages/_Reply" -msgstr "/Sõnu_mid/Vasta _R" +msgstr "/Sõnu_mid/Vasta sõnumile" -#: xgnokii/xgnokii_sms.c:1405 +#: xgnokii/xgnokii_sms.c:1516 msgid "/_Messages/_Delete" -msgstr "/Sõnu_mid/Kustuta" +msgstr "/Sõnu_mid/Kustuta sõnum" -#: xgnokii/xgnokii_sms.c:1406 +#: xgnokii/xgnokii_sms.c:1517 msgid "/Messages/Sep3" msgstr "/Sõnu_mid/Sep3" -#: xgnokii/xgnokii_sms.c:1407 +#: xgnokii/xgnokii_sms.c:1518 msgid "/_Messages/_Bussiness card" msgstr "/Sõnu_mid/Visiitkaart" -#: xgnokii/xgnokii_sms.c:1428 +#: xgnokii/xgnokii_sms.c:1539 msgid "Status" msgstr "Olek" -#: xgnokii/xgnokii_sms.c:1428 +#: xgnokii/xgnokii_sms.c:1539 msgid "Date / Time" msgstr "Kuupäev/Kellaaeg" -#: xgnokii/xgnokii_sms.c:1428 +#: xgnokii/xgnokii_sms.c:1539 msgid "Sender" msgstr "Saatja" -#: xgnokii/xgnokii_sms.c:1428 +#: xgnokii/xgnokii_sms.c:1539 msgid "Message" msgstr "Sõnum" -#: xgnokii/xgnokii_sms.c:1462 +#: xgnokii/xgnokii_sms.c:1573 msgid "New message" msgstr "Uus sõnum" -#: xgnokii/xgnokii_sms.c:1466 +#: xgnokii/xgnokii_sms.c:1577 msgid "Forward message" msgstr "Saada sõnum edasi" -#: xgnokii/xgnokii_sms.c:1470 +#: xgnokii/xgnokii_sms.c:1581 msgid "Reply message" msgstr "Vasta sõnumile" -#: xgnokii/xgnokii_sms.c:1482 +#: xgnokii/xgnokii_sms.c:1593 msgid "Delete message" msgstr "Kustuta sõnum" -#: xgnokii/xgnokii_sms.c:1507 +#: xgnokii/xgnokii_sms.c:1618 msgid "SMS's" -msgstr "" +msgstr "Lühisõnumid" -#: xgnokii/xgnokii_sms.c:1516 +#: xgnokii/xgnokii_sms.c:1627 msgid "Inbox" -msgstr "" +msgstr "Saadud lühisõnumid" -#: xgnokii/xgnokii_sms.c:1522 +#: xgnokii/xgnokii_sms.c:1633 msgid "Outbox" -msgstr "" +msgstr "Saadetud lühisõnumid" -#: xgnokii/xgnokii_sms.c:1608 -msgid "couldn't allocate colour" -msgstr "ei suuda värvi määratleda" - -#: xgnokii/xgnokii_speed.c:181 +#: xgnokii/xgnokii_speed.c:180 msgid "Reading data ..." msgstr "Loen andmeid ..." -#: xgnokii/xgnokii_speed.c:192 xgnokii/xgnokii_speed.c:198 -#: xgnokii/xgnokii_speed.c:257 +#: xgnokii/xgnokii_speed.c:191 xgnokii/xgnokii_speed.c:197 +#: xgnokii/xgnokii_speed.c:256 msgid "Cannot allocate memory!" msgstr "Ei suuda mälu eraldada!" -#: xgnokii/xgnokii_speed.c:345 +#: xgnokii/xgnokii_speed.c:344 msgid "Cannot allocate memory!\n" msgstr "Ei suuda mälu eraldada!\n" -#: xgnokii/xgnokii_speed.c:357 xgnokii/xgnokii_speed.c:385 +#: xgnokii/xgnokii_speed.c:356 xgnokii/xgnokii_speed.c:384 msgid "Error reading file!" msgstr "Viga faili lugemisel!" -#: xgnokii/xgnokii_speed.c:555 +#: xgnokii/xgnokii_speed.c:554 msgid "Key" msgstr "Klahv" @@ -3672,84 +4017,66 @@ msgstr "Ei suuda laadida taustapilti!" msgid "XGnokii Keyboard" msgstr "XGnokii Klaviatuur" -#: xgnokii/xgnokii_logos.c:834 -#, c-format -msgid "" -"Error getting network info\n" -"(error=%d)" -msgstr "" -"Viga võrguinfo saamisel\n" -"(viga=%d)" +#~ msgid "Alarm date:" +#~ msgstr "Meenutuse kuupäev:" -#: xgnokii/xgnokii_logos.c:867 -#, c-format -msgid "" -"Error getting bitmap\n" -"(error=%d)" -msgstr "" -"Viga bitmap saamisel\n" -"(viga=%d)" +#~ msgid "Message: Result of key " +#~ msgstr " " -#: xgnokii/xgnokii_logos.c:912 -#, c-format -msgid "" -"Error setting bitmap\n" -"(error=%d)" -msgstr "" -"Viga bitmap seadmisel\n" -"(viga=%d)" +#~ msgid "press\n" +#~ msgstr "vajuta\n" -#: xgnokii/xgnokii_logos.c:1146 -msgid "/File/Save _as ..." -msgstr "/Fail/Salvest_a nagu ..." +#~ msgid "release\n" +#~ msgstr "vabasta\n" -#: xgnokii/xgnokii_logos.c:1148 -msgid "/File/_Get operator" -msgstr "/Fail/Tuvasta operaator" +#~ msgid "press or release - error\n" +#~ msgstr "vajuta või vabasta - viga\n" -#: xgnokii/xgnokii_logos.c:1149 -msgid "/File/Get _logo" -msgstr "/Fail/Võta _logo" +#~ msgid "Message: Unknown message of type 0x0c\n" +#~ msgstr "Teade: Tundmatu 0x0c tüüpi sõnum\n" -#: xgnokii/xgnokii_logos.c:1150 -msgid "/File/Se_t logo" -msgstr "/Fail/Sea logo" +#~ msgid "Message: Security code received: " +#~ msgstr "Teade: Turvakood saabus: " -#: xgnokii/xgnokii_logos.c:1154 -msgid "/Edit/_Clear" -msgstr "/Redigeeri/Tühjenda" +#~ msgid "Security code" +#~ msgstr "Turvakood" -#: xgnokii/xgnokii_logos.c:1155 -msgid "/Edit/_Invert" -msgstr "/Redigeeri/_Invert" +#~ msgid "unknown !" +#~ msgstr "tundmatu !" -#: xgnokii/xgnokii_logos.c:1157 -msgid "/Edit/_Up logo" -msgstr "/Redigeeri/Logo üles" +#~ msgid "Unknown key: %c !\n" +#~ msgstr "Tundmatu võti: %c !\n" -#: xgnokii/xgnokii_logos.c:1158 -msgid "/Edit/_Down logo" -msgstr "/Redigeeri/Logo alla" +#~ msgid "Can't press key !\n" +#~ msgstr "Nuppu ei saa vajutada?! \n" -#: xgnokii/xgnokii_logos.c:1159 -msgid "/Edit/_Left logo" -msgstr "/Redigeeri/_Logo vasakule" +#~ msgid "Can't release key !\n" +#~ msgstr "Nuppu ei saa vabastada?! \n" -#: xgnokii/xgnokii_logos.c:1160 -msgid "/Edit/_Right logo" -msgstr "/Redigeeri/Logo paremale" +#~ msgid "security code" +#~ msgstr "Turvakood" -#: xgnokii/xgnokii_logos.c:1162 -msgid "/Edit/Flip _horizontal" -msgstr "/Redigeeri/Pööra _horisontaalis" +#~ msgid " not allowed\n" +#~ msgstr " pole lubatud\n" -#: xgnokii/xgnokii_logos.c:1163 -msgid "/Edit/Flip _vertical" -msgstr "/Redigeeri/Pööra _vertikaalis" +#~ msgid " is %s\n" +#~ msgstr " on %s\n" -#: xgnokii/xgnokii_logos.c:1442 -msgid "Load preview pixmap error, feature disabled." -msgstr "" +#~ msgid "Files can't have the same names !\n" +#~ msgstr "Failidel ei saa olla sama nimi !!\n" + +#~ msgid "Couldn't open %s or /etc/gnokiirc, using default config\n" +#~ msgstr "" +#~ "Ei suuda %s avada ega ka /etc/gnokiirc, kasutan konfiguratsiooni " +#~ "vaikeväärtusi!\n" + +#~ msgid "Error saving SMS centers!" +#~ msgstr "Viga SMS keskuste salvestamisel!" + +#~ msgid "Couldn't open %s or /etc/gnokiirc, using default config!\n" +#~ msgstr "" +#~ "Ei suuda %s avada ega ka /etc/gnokiirc, kasutan konfiguratsiooni " +#~ "vaikeväärtusi!\n" #~ msgid "Logo file error.\n" #~ msgstr "Logo faili viga.\n" @@ -3763,18 +4090,12 @@ msgstr "" #~ msgid " usage: gnokiid {--help|--version}" #~ msgstr " kasutus: gnokiid {--help|--version}" -#~ msgid "%s: line %d: Can't get ME memory entry number %d! %d\n" -#~ msgstr "%s: rida %d: Ei saa kätte ME mälu asukoha numbrit %d! %d\n" - #~ msgid "%s: line %d: Can't get SM memory entry number %d! %d\n" #~ msgstr "%s: rida %d: Ei saa kätte SM mälu asukoha numbrit %d! %d\n" #~ msgid "0x16 Registration Response 0x%02x 0x%02x\n" #~ msgstr "0x16 Registreerimise vastus 0x%02x 0x%02x\n" -#~ msgid "Date" -#~ msgstr "Kuupäev" - #~ msgid "Groups names" #~ msgstr "Gruppide nimed" diff --git a/smsd/ChangeLog b/smsd/ChangeLog index 0edf8be..18e4e6f 100644 --- a/smsd/ChangeLog +++ b/smsd/ChangeLog @@ -1,7 +1,3 @@ * Fri 02 Feb 2001 Jan Derfinak - Fixed smsd to new capability code. - -* Mon Dec 3 2001 Pawel Kot -- Updated to the new libsms. -- Be more friendly to the other postgresql includes and libraries locations. -- Use libgnokii.so. +. diff --git a/smsd/Makefile b/smsd/Makefile index 7d737dc..2c3e041 100644 --- a/smsd/Makefile +++ b/smsd/Makefile @@ -1,9 +1,8 @@ # -# Makefile for the smsd. +# Makefile for the xGNOKII tool suite. # # Copyright (C) 1999 Hugh Blemings & Pavel Janík ml. & Jan Derfinak # 2000 Karel Zak -# $Id$ # TOPDIR=.. @@ -13,20 +12,13 @@ CFLAGS += $(PTHREAD_CFLAGS) \ `glib-config --cflags` LDFLAGS += $(PTHREAD_LIBS) \ - `glib-config --libs` - -LDFLAGS += -L$(TOPDIR) -lgnokii - -# Change this according to your system -# FIXME: detect it in configure -CFLAGS += -I/usr/include/pgsql -# CFLAGS += -I/usr/include/psql -LDFLAGS += -L/usr/lib/pgsql -lpq -# LDFLAGS += -L/usr/lib/psql -lpq -# LDFLAGS += -lpq + `glib-config --libs` -lpq \ + -L../common ifdef XPM_LIBS LDFLAGS +=$(XPM_LIBS) + LDLIBS += $(XPM_LIBS) + CFLAGS += $(XPM_CFLAGS) endif OBJS = db.o \ @@ -35,11 +27,25 @@ OBJS = db.o \ all: smsd +DB_DBNAME=sms + +.PHONY: db db_dump +db: sms.tables.sql + -dropdb $(DB_DBNAME) + createdb $(DB_DBNAME) + psql -f sms.tables.sql $(DB_DBNAME) +db_dump: + psql -c 'SELECT * FROM outbox' $(DB_DBNAME) +db_inbox: + psql -c 'SELECT * FROM inbox' $(DB_DBNAME) + +smsd: $(OBJS) $(TOPDIR)/common/gsm-filetypes.o $(TOPDIR)/common/libgnokii.a #$(TOPDIR)/common/data/DATA.o -smsd: $(OBJS) $(TOPDIR)/common/data/DATA.o $(TOPDIR)/common/gsm-filetypes.o +$(TOPDIR)/common/libgnokii.a: + $(MAKE) -C $(TOPDIR)/common libgnokii.a -$(TOPDIR)/common/data/DATA.o: - $(MAKE) -C $(TOPDIR)/common/data DATA.o +#$(TOPDIR)/common/data/DATA.o: +# $(MAKE) -C $(TOPDIR)/common/data DATA.o $(TOPDIR)/common/gsm-filetypes.o: $(MAKE) -C $(TOPDIR)/common gsm-filetypes.o diff --git a/smsd/db.c b/smsd/db.c index 8d553b2..204369f 100644 --- a/smsd/db.c +++ b/smsd/db.c @@ -13,12 +13,22 @@ */ +#define ATS_PRAHA 1 + #include #include -#include +#include +#include +#include +#include +#include +#include + #include "db.h" #include "smsd.h" #include "gsm-common.h" +#include "gsm-ringtones.h" +#include "gsm-filetypes.h" static PGconn *connIn = NULL; static PGconn *connOut = NULL; @@ -71,7 +81,7 @@ gint DB_InsertSMS (const GSM_SMSMessage * const data) buf = g_string_sized_new (128); g_string_sprintf (buf, "INSERT INTO inbox VALUES ('%s', '%02d-%02d-%02d %02d:%02d:%02d+01', 'now', '%s', 'f')", - data->RemoteNumber.number, data->Time.Year + 2000, data->Time.Month, + data->Sender, data->Time.Year + 2000, data->Time.Month, data->Time.Day, data->Time.Hour, data->Time.Minute, data->Time.Second, data->MessageText); res = PQexec(connIn, buf->str); @@ -87,6 +97,30 @@ gint DB_InsertSMS (const GSM_SMSMessage * const data) return (0); } +#define DBL_FieldString "id, number, text, hexencode, type, fromfile, netcode, udhpresent, longuseudh, eightbit, smsc" +enum DBL_Field { + DBLF_id, + DBLF_number, + DBLF_text, + DBLF_hexencode, + DBLF_type, + DBLF_fromfile, + DBLF_netcode, + DBLF_udhpresent, + DBLF_longuseudh, + DBLF_eightbit, + DBLF_smsc, + }; + +#define DBL_true "t" +#define DBL_false "f" + +static int DBL_safestrcasecmp(const char *s1,const char *s2) +{ + if (!s1 || !s2) + return((!!s1)-(!!s2)); + return(strcasecmp(s1,s2)); +} void DB_Look (void) { @@ -96,12 +130,13 @@ void DB_Look (void) buf = g_string_sized_new (128); +#ifndef ATS_PRAHA g_string_sprintf (buf, "BEGIN"); - res1 = PQexec(connOut, buf->str); PQclear (res1); +#endif - g_string_sprintf (buf, "SELECT id, number, text FROM outbox \ + g_string_sprintf (buf, "SELECT " DBL_FieldString " FROM outbox \ WHERE processed='f' FOR UPDATE"); res1 = PQexec(connOut, buf->str); @@ -119,34 +154,133 @@ void DB_Look (void) for (i = 0; i < PQntuples (res1); i++) { GSM_SMSMessage sms; + char *type = PQgetvalue (res1, i, DBLF_type); + bool fromfile = !DBL_safestrcasecmp(DBL_true, PQgetvalue (res1, i, DBLF_fromfile)); + char *smsc = PQgetvalue (res1, i, DBLF_smsc); + char *smsbuf = PQgetvalue (res1, i, DBLF_text); + size_t smsbuflen = strlen(smsbuf); + bool sendlogo; - sms.MessageCenter.No = 1; - sms.Type = SMS_Submit; - sms.DCS.Type = SMS_GeneralDataCoding; - sms.DCS.u.General.Compressed = false; - sms.DCS.u.General.Alphabet = SMS_DefaultAlphabet; - sms.DCS.u.General.Class = 0; - sms.Validity.VPF = SMS_RelativeFormat; - sms.Validity.u.Relative = 4320; /* 4320 minutes == 72 hours */ - sms.UDH_No = 0; - sms.Report = false; - - strncpy (sms.RemoteNumber.number, PQgetvalue (res1, i, 1), GSM_MAX_DESTINATION_LENGTH + 1); - sms.RemoteNumber.number[GSM_MAX_DESTINATION_LENGTH] = '\0'; - if (sms.RemoteNumber.number[0] == '+') sms.RemoteNumber.type = SMS_International; - else sms.RemoteNumber.type = SMS_Unknown; - - strncpy (sms.MessageText, PQgetvalue (res1, i, 2), GSM_MAX_SMS_LENGTH + 1); - sms.MessageText[GSM_MAX_SMS_LENGTH] = '\0'; + if (!smsc) + sms.MessageCenter.No = 1; + else { + sms.MessageCenter.No = 0; + if (strlen(smsc)+1 > sizeof(sms.MessageCenter.Number)) + continue; /* error */ + strcpy(sms.MessageCenter.Number, smsc); + } + + sms.Type = GST_MO; + sms.Class = -1; + sms.Compression = false; + sms.EightBit = !DBL_safestrcasecmp(DBL_true, PQgetvalue (res1, i, DBLF_eightbit)); + sms.Validity = 4320; + sms.UDHPresent = !DBL_safestrcasecmp(DBL_true, PQgetvalue (res1, i, DBLF_udhpresent)); + + if (!DBL_safestrcasecmp(DBL_true, PQgetvalue (res1, i, DBLF_hexencode))) { +char *d_end = (char *)SMS_BlockFromHex(smsbuf/*d*/, smsbuf/*s*/, smsbuflen); + + if (!d_end) + continue; + smsbuflen = d_end - smsbuf; + } + sendlogo=false; + if (!DBL_safestrcasecmp("ringtone" ,type)) { + SMS_SetupUDH(&sms, GSM_RingtoneUDH); + if (fromfile) { +GSM_Ringtone ringtone; +static char ringbuf[GSM_MAX_RINGTONE_PACKAGE_LENGTH]; +int ringbuflen=GSM_MAX_RINGTONE_PACKAGE_LENGTH; + + if (GSM_ReadRingtoneFile(smsbuf, &ringtone)) + continue; /* error */ + GSM_PackRingtone(&ringtone, ringbuf, &ringbuflen); + smsbuf=ringbuf; + smsbuflen=ringbuflen; + } + } + else if (!DBL_safestrcasecmp("oplogo" ,type)) { + SMS_SetupUDH(&sms, GSM_OpLogo); + sendlogo=true; + } + else if (!DBL_safestrcasecmp("calleridlogo",type)) { + SMS_SetupUDH(&sms, GSM_CallerIDLogo); + sendlogo=true; + } + else { /* "text" */ + if (fromfile) { +static char textbuf[GSM_MAX_CONCATENATED_SMS_LENGTH]; +int textbuflen; +int fd; + + if (-1==(fd=open(smsbuf,O_RDONLY))) + continue; /* error */ + if (-1==(textbuflen=read(fd,textbuf,sizeof(textbuf)))) + continue; /* error */ + close(fd); + smsbuf=textbuf; + smsbuflen=textbuflen; + } + if (sms.UDHPresent) { +u8 len=1+(*(u8 *)smsbuf); + + if (len>smsbuflen || len>sizeof(sms.UDH)) + g_print ("%d: UDH too long: UDHlen=%d, smsbuflen=%d, sizeof(sms.UDH)=%d !!!\n", __LINE__, + len, smsbuflen,sizeof(sms.UDH)); + else { + memcpy(sms.UDH,smsbuf,len); + memmove(smsbuf,smsbuf+len,smsbuflen-len); + smsbuflen-=len; + } + } + } + + if (sendlogo) { +GSM_Bitmap bitmap; +static u8 bin[sizeof(bitmap.bitmap) +64/*headers safety*/]; +u8 *d; +char *usernetcode=PQgetvalue (res1, i, DBLF_netcode); + + if (GE_NONE!=GSM_ReadBitmapFile(smsbuf, &bitmap)) + continue; /* error */ + + d=bin; + if (!DBL_safestrcasecmp("oplogo" ,type)) { + if (usernetcode) { + if (strlen(usernetcode)+1 > sizeof(bitmap.netcode)) + continue; /* error */ + strcpy(bitmap.netcode, usernetcode); + } + *d++ = ((bitmap.netcode[1] & 0x0f) << 4) | (bitmap.netcode[0] & 0xf); + *d++ = 0xf0 | (bitmap.netcode[2] & 0x0f); + *d++ = ((bitmap.netcode[5] & 0x0f) << 4) | (bitmap.netcode[4] & 0xf); + } + /* Set the logo size */ + *d++ = 0x00; /* RFU by Nokia */ + *d++ = bitmap.width; + *d++ = bitmap.height; + *d++ = 0x01; /* depth=number of grayscales */ + + memcpy(d,bitmap.bitmap,bitmap.size); + d+=bitmap.size; + + smsbuf=bin; + smsbuflen=d-bin; + } + + strncpy (sms.Destination, PQgetvalue (res1, i, DBLF_number), GSM_MAX_DESTINATION_LENGTH + 1); + sms.Destination[GSM_MAX_DESTINATION_LENGTH] = '\0'; + #ifdef XDEBUG - g_print ("%s, %s\n", sms.Destination, sms.MessageText); + g_print ("To: %s\n", sms.Destination); #endif - if (WriteSMS (&sms) != 0) + if (GE_SMSSENDOK == WriteSMS_deconcatenated (&sms, smsbuf, smsbuflen, + !DBL_safestrcasecmp(DBL_true, PQgetvalue (res1, i, DBLF_longuseudh)))) { g_string_sprintf (buf, "UPDATE outbox SET processed='t' WHERE id='%s'", - PQgetvalue (res1, i, 0)); + PQgetvalue (res1, i, DBLF_id)); res2 = PQexec(connOut, buf->str); if (!res2 || PQresultStatus (res2) != PGRES_COMMAND_OK) { @@ -159,9 +293,20 @@ void DB_Look (void) PQclear (res1); +#ifndef ATS_PRAHA g_string_sprintf (buf, "COMMIT"); res1 = PQexec(connOut, buf->str); + PQclear (res1); +#endif g_string_free(buf, TRUE); - PQclear (res1); + +#ifdef ATS_PRAHA + if (!access("/tmp/smsd-exit",F_OK)) { + g_print("/tmp/smsd-exit exists, terminating\n"); + if (unlink("/tmp/smsd-exit")) + g_print("/tmp/smsd-exit unlink failed: %s\n",strerror(errno)); + exit(0); + } +#endif } diff --git a/smsd/lowlevel.c b/smsd/lowlevel.c index ea1c394..ea36182 100644 --- a/smsd/lowlevel.c +++ b/smsd/lowlevel.c @@ -11,11 +11,8 @@ $Id$ $Log$ - Revision 1.1.1.2 2001/12/05 03:16:54 short - :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Tue Dec 4 22:45 CET 2001 - - Revision 1.5 2001/12/03 15:34:54 pkot - Update to libsms and new structure + Revision 1.1.1.3 2002/04/03 00:08:22 short + Found in "gnokii-working" directory, some November-patches version Revision 1.4 2001/05/30 14:36:47 pkot Fix smsd to use StateMachine and let it compile. @@ -36,10 +33,8 @@ #include "misc.h" #include "gsm-common.h" #include "gsm-api.h" -#include "phones/nk7110.h" -#include "phones/nk6100.h" -#include "phones/nk3110.h" -#include "phones/nk2110.h" +#include "fbus-6110.h" +#include "fbus-3810.h" #include "smsd.h" #include "lowlevel.h" @@ -136,7 +131,7 @@ static void InitModelInf (void) static GSM_Error fbusinit(bool enable_monitoring) { int count=0; - static GSM_Error error=GE_NOLINK; + GSM_Error error=GE_NOLINK; GSM_ConnectionType connection=GCT_Serial; static GSM_Statemachine sm; @@ -164,10 +159,12 @@ static GSM_Error fbusinit(bool enable_monitoring) g_print("After usleep. GSM_LinkOK: %d\n", *GSM_LinkOK); #endif - if (*GSM_LinkOK == true) - InitModelInf (); + if (*GSM_LinkOK != true) { + return (GE_NOLINK); + } - return *GSM_LinkOK; + InitModelInf (); + return(GE_NONE); } @@ -179,7 +176,7 @@ void InitPhoneMonitor (void) phoneMonitor.phone.imei = g_strdup (_("unknown")); phoneMonitor.supported = 0; phoneMonitor.working = FALSE; - phoneMonitor.sms.unRead = phoneMonitor.sms.number = 0; + phoneMonitor.sms.unRead = phoneMonitor.sms.used = phoneMonitor.sms.slots = 0; phoneMonitor.sms.messages = NULL; pthread_mutex_init (&smsMutex, NULL); pthread_cond_init (&smsCond, NULL); @@ -206,11 +203,12 @@ static inline void FreeArray (GSList **array) } -static void RefreshSMS (const gint number) +static void RefreshSMS (const gint slots) { GSM_Error error; GSM_SMSMessage *msg; register gint i; + gint unread = 0; # ifdef XDEBUG g_print ("RefreshSMS is running...\n"); @@ -218,41 +216,43 @@ static void RefreshSMS (const gint number) pthread_mutex_lock (&smsMutex); FreeArray (&(phoneMonitor.sms.messages)); - phoneMonitor.sms.number = 0; + phoneMonitor.sms.used = 0; // pthread_mutex_unlock (&smsMutex); - i = 0; - while (1) + for (i=1; i<=slots; i++) { msg = g_malloc (sizeof (GSM_SMSMessage)); msg->MemoryType = GMT_SM; - msg->Number = ++i; + msg->Location = i; if ((error = GSM->GetSMSMessage (msg)) == GE_NONE) { // pthread_mutex_lock (&smsMutex); phoneMonitor.sms.messages = g_slist_append (phoneMonitor.sms.messages, msg); - phoneMonitor.sms.number++; + phoneMonitor.sms.used++; + if (msg->Type == GST_MT && msg->Status == GSS_NOTSENTREAD) + unread++; // pthread_mutex_unlock (&smsMutex); - if (phoneMonitor.sms.number == number) - { - pthread_cond_signal (&smsCond); - pthread_mutex_unlock (&smsMutex); - return; - } } else if (error == GE_INVALIDSMSLOCATION) /* All positions are readed */ { g_free (msg); - pthread_cond_signal (&smsCond); - pthread_mutex_unlock (&smsMutex); break; } else g_free (msg); - usleep (750000); + /* FIXME: Why is any delay here? + */ + /* usleep (750000); */ } + /* Update it after the whole run as otherwise "Refreshing SMSes..." + * would collide with "Short Message received" message. + */ + phoneMonitor.sms.unRead = unread; + + pthread_cond_signal (&smsCond); + pthread_mutex_unlock (&smsMutex); } @@ -265,7 +265,7 @@ static gint A_SendSMSMessage (gpointer data) if (d) { pthread_mutex_lock (&sendSMSMutex); - error = d->status = GSM->SendSMSMessage (d->sms, 0); + error = d->status = GSM->SendSMSMessage (d->sms); pthread_cond_signal (&sendSMSCond); pthread_mutex_unlock (&sendSMSMutex); } @@ -309,7 +309,7 @@ gint (*DoAction[])(gpointer) = { void *Connect (void *a) { - GSM_SMSMemoryStatus SMSStatus = {0, 0}; + GSM_SMSStatus SMSStatus = {0, 0, 0}; PhoneEvent *event; GSM_Error error; @@ -318,7 +318,7 @@ void *Connect (void *a) g_print ("Initializing connection...\n"); # endif - while (!fbusinit (true)) + while (fbusinit (true)) sleep (1); # ifdef XDEBUG @@ -331,15 +331,29 @@ void *Connect (void *a) if (GSM->GetSMSStatus (&SMSStatus) == GE_NONE) { - if (phoneMonitor.sms.unRead != SMSStatus.Unread || - phoneMonitor.sms.number != SMSStatus.Number) + /* Change of "UnRead" shouldn't be interesting - user may have read some of his + * SMSes by the phone interface. + */ + if (phoneMonitor.sms.unRead != SMSStatus.UnRead || + phoneMonitor.sms.used != SMSStatus.Used || + phoneMonitor.sms.slots != SMSStatus.Slots) /* shouldn't change, just to be sure */ { + /* We are primarily interested in SMSStatus.Slots so try to fix it up if it is broken + */ + if (SMSStatus.UnRead > SMSStatus.Used) + SMSStatus.Used = SMSStatus.UnRead; + if (SMSStatus.Used > SMSStatus.Slots) + SMSStatus.Slots = SMSStatus.Used; + phoneMonitor.sms.slots = SMSStatus.Slots; /* shouldn't change, just to be sure */ + /* phoneMonitor.sms.{unRead,used} will be updated by RefreshSMS() + */ + phoneMonitor.working = TRUE; - RefreshSMS (SMSStatus.Number); + RefreshSMS (SMSStatus.Slots); phoneMonitor.working = FALSE; } - phoneMonitor.sms.unRead = SMSStatus.Unread; + phoneMonitor.sms.unRead = SMSStatus.UnRead; } while ((event = RemoveEvent ()) != NULL) @@ -349,7 +363,7 @@ void *Connect (void *a) # endif phoneMonitor.working = TRUE; if (event->event <= Event_Exit) - if ((error = DoAction[event->event] (event->data)) != GE_NONE) + if (((error = DoAction[event->event] (event->data)) != GE_NONE) && error != GE_SMSSENDOK) g_print (_("Event %d failed with return code %d!\n"), event->event, error); g_free (event); } diff --git a/smsd/lowlevel.h b/smsd/lowlevel.h index 78f2f9e..7f8d044 100644 --- a/smsd/lowlevel.h +++ b/smsd/lowlevel.h @@ -11,8 +11,8 @@ $Id$ $Log$ - Revision 1.1.1.1 2001/11/25 21:59:23 short - :pserver:cvs@pserver.samba.org:/cvsroot - gnokii - Sun Nov 25 22:56 CET 2001 + Revision 1.1.1.2 2002/04/03 00:08:22 short + Found in "gnokii-working" directory, some November-patches version Revision 1.2 2001/02/02 08:09:57 ja New dialogs for 6210/7110 in xgnokii. Fixed the smsd for new capabilty code. @@ -53,7 +53,8 @@ typedef struct { } phone; struct { gint unRead; - gint number; + gint used; + gint slots; GSList *messages; } sms; gint supported; diff --git a/smsd/sms-sendsms b/smsd/sms-sendsms new file mode 100755 index 0000000..ee41076 --- /dev/null +++ b/smsd/sms-sendsms @@ -0,0 +1,100 @@ +#! /usr/bin/perl +# +# $Id$ + +use strict; +use warnings; + +use Getopt::Long; +use Pg; + + +my($pg_conn,$pg_result); + +my($opt_db,$opt_sendtext,$opt_sendringtone,$opt_sendoplogo,$opt_sendcalleridlogo,$opt_fromfile,$opt_netcode,$opt_longtext,$opt_longudh,$opt_udhpresent,$opt_eightbit,$opt_smsc); + + +sub enbool +{ +my($ref)=@_; + + $$ref=($$ref ? "'t'" : "'f'"); +} + +sub ennull +{ +my($ref)=@_; + + $$ref=(defined($$ref) ? "'$$ref'" : "NULL"); +} + + +Getopt::Long::Configure("bundling"); + +$opt_db="dbname=sms"; + +die() if (!GetOptions( + "d|db" ,\$opt_db, + "sendtext" ,\$opt_sendtext, + "sendringtone" ,\$opt_sendringtone, + "sendoplogo" ,\$opt_sendoplogo, + "sendcalleridlogo" ,\$opt_sendcalleridlogo, + "fromfile!" ,\$opt_fromfile, + "netcode=s" ,\$opt_netcode, + "longtext" ,\$opt_longtext, + "longudh" ,\$opt_longudh, + "udh!" ,\$opt_udhpresent, + "8|eightbit" ,\$opt_eightbit, + "smsc=s" ,\$opt_smsc, + )); +my($type); +$type="ringtone" if $opt_sendringtone; +$type="oplogo" if $opt_sendoplogo; +$type="calleridlogo" if $opt_sendcalleridlogo; +$type="text" if !defined $type; + +$opt_eightbit=1 if $type ne "text"; + +die "Argument conflict" if 0 + || ($opt_longtext && $opt_longudh) + || (1 < defined($opt_sendtext)+defined($opt_sendringtone)+defined($opt_sendoplogo)+defined($opt_sendcalleridlogo)) + || ($type ne "text") && $opt_udhpresent + ; + +die "Destination number required" if !@ARGV; +my($destination)=shift @ARGV; + +undef $/; +die "Filename on commandline required" if $opt_fromfile && !@ARGV; +my($text)=($opt_fromfile ? shift(@ARGV) : ); +$text="" if !defined($text); +die "Message too long" if !$opt_longtext && !$opt_longudh && 160errorMessage() unless PGRES_CONNECTION_OK eq $pg_conn->status; + +enbool(\$opt_fromfile); +ennull(\$opt_netcode); +enbool(\$opt_udhpresent); +$opt_longudh=!$opt_longtext; +enbool(\$opt_longudh); +enbool(\$opt_eightbit); +ennull(\$opt_smsc); +enbool(\$hexencode); + +$pg_result=$pg_conn->exec( + "INSERT INTO outbox (number,text,hexencode,type,fromfile,netcode,udhpresent,longuseudh,eightbit,smsc)" + ." VALUES ('$destination','$hextext',$hexencode,'$type',$opt_fromfile,$opt_netcode,$opt_udhpresent,$opt_longudh,$opt_eightbit,$opt_smsc);"); +die $pg_conn->errorMessage() unless PGRES_COMMAND_OK eq $pg_result->resultStatus(); diff --git a/smsd/sms.tables.sql b/smsd/sms.tables.sql index c18568c..b4c61f5 100644 --- a/smsd/sms.tables.sql +++ b/smsd/sms.tables.sql @@ -10,6 +10,15 @@ CREATE TABLE "outbox" ( "id" serial, "number" character varying(20) NOT NULL, "insertdate" timestamp DEFAULT 'now' NOT NULL, - "text" character varying(160), + "text" text NOT NULL, + "hexencode" bool DEFAULT 'false' NOT NULL, + "type" character varying(20) DEFAULT 'text' NOT NULL, + "fromfile" bool DEFAULT 'false' NOT NULL, + "netcode" character varying(10) DEFAULT NULL NULL, + "udhpresent" bool DEFAULT 'false' NOT NULL, + "longuseudh" bool DEFAULT 'true' NOT NULL, + "eightbit" bool DEFAULT 'false' NOT NULL, + "smsc" character varying(20) DEFAULT NULL NULL, "processed" bool DEFAULT 'false' ); +CREATE INDEX outbox_processed ON "outbox" (processed); diff --git a/smsd/smsd.c b/smsd/smsd.c index ba18ace..bd66ea3 100644 --- a/smsd/smsd.c +++ b/smsd/smsd.c @@ -36,10 +36,8 @@ #include "gsm-common.h" #include "gsm-api.h" -#include "phones/nk7110.h" -#include "phones/nk6100.h" -#include "phones/nk3110.h" -#include "phones/nk2110.h" +#include "fbus-6110.h" +#include "fbus-3810.h" #include "cfgreader.h" #include "smsd.h" #include "lowlevel.h" @@ -171,15 +169,28 @@ gint WriteSMS (GSM_SMSMessage *sms) return (error); } +GSM_Error WriteSMS_deconcatenated(GSM_SMSMessage *sms,char *buf,size_t buflen,bool useudh) +{ + GSM_Deconcatenate_state SMS_Deconcatenate_state; + GSM_Error error; + + SMS_Deconcatenate_state.first=true; + while (SMS_Deconcatenate(&SMS_Deconcatenate_state,sms,buf,buflen,useudh)) { + /* Send the message. */ + if (GE_SMSSENDOK != (error = WriteSMS(sms))) + return(error); + } + return(GE_SMSSENDOK); +} static void ReadSMS (gpointer d, gpointer userData) { GSM_SMSMessage *data = (GSM_SMSMessage *) d; PhoneEvent *e; - if (data->Type == SMS_Deliver || data->Type == SMS_Delivery_Report) + if (data->Type == GST_MT || data->Type == GST_DR) { - if (data->Type == SMS_Delivery_Report) + if (data->Type == GST_DR) { #ifdef XDEBUG g_print ("Report\n"); diff --git a/smsd/smsd.h b/smsd/smsd.h index 3f52f80..68ee8ad 100644 --- a/smsd/smsd.h +++ b/smsd/smsd.h @@ -29,5 +29,6 @@ typedef struct { extern SmsdConfig smsdConfig; extern gint WriteSMS (GSM_SMSMessage *); +extern GSM_Error WriteSMS_deconcatenated(GSM_SMSMessage *sms,char *buf,size_t buflen,bool useudh); #endif diff --git a/utils/Makefile b/utils/Makefile index 04af119..e9220d3 100644 --- a/utils/Makefile +++ b/utils/Makefile @@ -13,38 +13,31 @@ OBJS = mgnokiidev.o all: mgnokiidev -mgnokiidev: $(OBJS) +mgnokiidev: $(OBJS) -makelib: $(OBJS) - $(CC) $(LDFLAGS) $(OBJS) -o mgnokiidev - clean: $(RM) $(OBJS) *~ depend mgnokiidev *.exe core *.bak -install: all +install: $(INSTALL) -d $(sbindir) $(INSTALL) mgnokiidev $(sbindir) $(INSTALL) todologo $(bindir) - $(INSTALL) sendsms $(bindir) - -install-strip: all + +install-strip: $(INSTALL) -d $(sbindir) $(INSTALL) -s mgnokiidev $(sbindir) $(INSTALL) todologo $(bindir) - $(INSTALL) sendsms $(bindir) - -install-suid: all + +install-suid: $(INSTALL) -d $(sbindir) $(INSTALL) -o root -g gnokii -m 4750 mgnokiidev $(sbindir) $(INSTALL) todologo $(bindir) - $(INSTALL) sendsms $(bindir) - -install-ss: all + +install-ss: $(INSTALL) -d $(sbindir) $(INSTALL) -o root -g gnokii -m 4750 -s mgnokiidev $(sbindir) $(INSTALL) todologo $(bindir) - $(INSTALL) sendsms $(bindir) - + depend dep: $(CC) $(CFLAGS) -MM *.c >depend diff --git a/utils/mgnokiidev.c b/utils/mgnokiidev.c index 78b2090..a8e59f7 100644 --- a/utils/mgnokiidev.c +++ b/utils/mgnokiidev.c @@ -6,11 +6,24 @@ A Linux/Unix toolset and driver for Nokia mobile phones. + Copyright (C) 1999, 2000 Hugh Blemings & Pavel Janík ml. + Released under the terms of the GNU GPL, see file COPYING for more details. Mgnokiidev gets passed a slave pty name by gnokiid and uses this information to create a symlink from the pty to /dev/gnokii. + $Log$ + Revision 1.1.1.3 2002/04/03 00:08:23 short + Found in "gnokii-working" directory, some November-patches version + + Revision 1.7 2001/09/14 12:38:00 pkot + More cleanups + + Revision 1.6 2000/12/27 10:54:15 pkot + Added Unix98 PTYs support (Michael Mráka). + + */ #include @@ -31,7 +44,7 @@ int main(int argc, char *argv[]) { - int count, err; + int count, err, aux; char dev_name[DEVLEN]; /* Check we have one and only one command line argument. */ @@ -49,7 +62,8 @@ int main(int argc, char *argv[]) strncpy(dev_name, argv[1], DEVLEN); /* Check for suspicious characters. */ - for (count = 0; count < strlen(dev_name); count ++) + aux = strlen(dev_name); + for (count = 0; count < aux; count ++) if (!(isalnum(dev_name[count]) || dev_name[count]=='/')) { fprintf(stderr, "Suspicious character at index %d in argument.\n", count); exit (-2); diff --git a/xgnokii/Makefile b/xgnokii/Makefile index c3e220b..50afb7c 100644 --- a/xgnokii/Makefile +++ b/xgnokii/Makefile @@ -1,23 +1,31 @@ # +# $Id$ +# # Makefile for the xGNOKII tool suite. # +# Copyright (C) 1999 Hugh Blemings & Pavel Janík ml. & Jan Derfinak +# 2000 Karel Zak +# TOPDIR=.. include $(TOPDIR)/Makefile.global -CFLAGS += -DXGNOKIIDOCSDIR=\"$(docdir)\" \ - $(PTHREAD_CFLAGS) \ - $(GTK_CFLAGS) - -LDLIBS += $(PTHREAD_LIBS) \ - $(GTK_LIBS) - ifdef XPM_LIBS - LDLIBS += $(XPM_LIBS) + LDFLAGS += $(XPM_LIBS) + LDLIBS += $(XPM_LIBS) + CFLAGS += $(XPM_CFLAGS) endif +CFLAGS += $(PTHREAD_CFLAGS) \ + $(GTK_CFLAGS) + +LDFLAGS += $(PTHREAD_LIBS) \ + $(GTK_LIBS) +LDLIBS += $(PTHREAD_LIBS) \ + $(GTK_LIBS) + OBJS = xgnokii.o \ xgnokii_common.o \ xgnokii_contacts.o \ @@ -29,46 +37,84 @@ OBJS = xgnokii.o \ xgnokii_xkeyb.o \ xgnokii_calendar.o \ xgnokii_logos.o \ - xgnokii_xring.o \ xgnokii_lowlevel.o \ xgnokii_data.o +HELP_DIR = docs/help + + all: xgnokii -xgnokii: $(OBJS) $(TOPDIR)/common/COMMON.o $(TOPDIR)/common/DATA.o $(TOPDIR)/common/gsm-filetypes.o - $(CC) $(LDFLAGS) $(TARGET_ARCH) $^ $(LOADLIBES) $(LDLIBS) -o $@ -$(TOPDIR)/common/COMMON.o: - $(MAKE) -C $(TOPDIR)/common COMMON.o +xgnokii: $(OBJS) $(TOPDIR)/common/gsm-filetypes.o $(TOPDIR)/common/libgnokii.a #$(TOPDIR)/common/data/DATA.o -$(TOPDIR)/common/DATA.o: - $(MAKE) -C $(TOPDIR)/common DATA.o +$(TOPDIR)/common/COMMON.o: + $(MAKE) -C $(TOPDIR)/common libgnokii.a -$(TOPDIR)/common/gsm-filetypes.o: - $(MAKE) -C $(TOPDIR)/common gsm-filetypes.o +#$(TOPDIR)/common/data/DATA.o: +# $(MAKE) -C $(TOPDIR)/common/data DATA.o -$(TOPDIR)/common/libmygnokii.so: - $(MAKE) -C $(TOPDIR)/common makelib - -xgnokiilib: $(OBJS) $(TOPDIR)/common/libmygnokii.so - $(CC) $(LDFLAGS) $(TARGET_ARCH) $(OBJS) -L$(TOPDIR)/common -lmygnokii $(LOADLIBES) $(LDLIBS) -o $@ +$(TOPDIR)/common/gsm-filetypes.o: + $(MAKE) -C $(TOPDIR)/common gsm-filetypes.o -makelib: xgnokiilib - clean: - $(RM) $(OBJS) *~ xpm/*~ depend xgnokii xgnokiilib + $(RM) $(OBJS) *~ xpm/*~ depend xgnokii install: all $(INSTALL) -d $(xbindir) $(INSTALL) xgnokii $(xbindir) - $(INSTALL) xgnokiilib $(xbindir)/xgnokii + $(INSTALL) -d $(xgnokii_libdir)/help + ( cd $(HELP_DIR); \ + $(FIND) . -type d \! -path "*CVS*" \ + -exec $(INSTALL) -d $(xgnokii_libdir)/help/{} \; ; \ + $(FIND) . -type f \! -path "*CVS*" \ + -exec $(INSTALL) -m 0444 {} $(xgnokii_libdir)/help/{} \; \ + ) + $(INSTALL) -m 0444 ../Docs/CREDITS $(xgnokii_libdir)/help/en_US + $(INSTALL) -m 0444 ../COPYING $(xgnokii_libdir)/help/en_US + $(INSTALL) -d $(xgnokii_libdir)/help/en_US/sample + $(INSTALL) -m 0444 ../Docs/sample/gnokiirc $(xgnokii_libdir)/help/en_US/sample + (cd $(xgnokii_libdir)/help; ln -sf en_US C; ln -sf en_US POSIX) $(INSTALL) -d $(xgnokii_libdir)/xpm + $(INSTALL) -m 0444 xpm/6110.xpm $(xgnokii_libdir)/xpm + $(INSTALL) -m 0444 xpm/6150.xpm $(xgnokii_libdir)/xpm + $(INSTALL) -m 0444 xpm/5110.xpm $(xgnokii_libdir)/xpm + $(INSTALL) -m 0444 xpm/Preview_6110.xpm $(xgnokii_libdir)/xpm + $(INSTALL) -m 0444 xpm/Preview_6150.xpm $(xgnokii_libdir)/xpm + $(INSTALL) -m 0444 xpm/Preview_6210.xpm $(xgnokii_libdir)/xpm + $(INSTALL) -m 0444 xpm/Preview_3310.xpm $(xgnokii_libdir)/xpm + $(INSTALL) -m 0444 xpm/Preview_5110.xpm $(xgnokii_libdir)/xpm + $(INSTALL) -m 0444 xpm/Preview_3210.xpm $(xgnokii_libdir)/xpm + $(INSTALL) -m 0444 xpm/Preview_6250.xpm $(xgnokii_libdir)/xpm + $(INSTALL) -m 0444 xpm/Preview_7110.xpm $(xgnokii_libdir)/xpm install-strip: all $(INSTALL) -d $(xbindir) $(INSTALL) -s xgnokii $(xbindir) - $(INSTALL) -s xgnokiilib $(xbindir)/xgnokii + $(INSTALL) -d $(xgnokii_libdir)/help + ( cd $(HELP_DIR); \ + $(FIND) . -type d \! -path "*CVS*" \ + -exec $(INSTALL) -d $(xgnokii_libdir)/help/{} \; ; \ + $(FIND) . -type f \! -path "*CVS*" \ + -exec $(INSTALL) -m 0444 {} $(xgnokii_libdir)/help/{} \; \ + ) + $(INSTALL) -m 0444 ../Docs/CREDITS $(xgnokii_libdir)/help/en_US + $(INSTALL) -m 0444 ../COPYING $(xgnokii_libdir)/help/en_US + $(INSTALL) -d $(xgnokii_libdir)/help/en_US/sample + $(INSTALL) -m 0444 ../Docs/sample/gnokiirc $(xgnokii_libdir)/help/en_US/sample + (cd $(xgnokii_libdir)/help; ln -sf en_US C; ln -sf en_US POSIX) $(INSTALL) -d $(xgnokii_libdir)/xpm + $(INSTALL) -m 0444 xpm/6110.xpm $(xgnokii_libdir)/xpm + $(INSTALL) -m 0444 xpm/6150.xpm $(xgnokii_libdir)/xpm + $(INSTALL) -m 0444 xpm/5110.xpm $(xgnokii_libdir)/xpm + $(INSTALL) -m 0444 xpm/Preview_6110.xpm $(xgnokii_libdir)/xpm + $(INSTALL) -m 0444 xpm/Preview_6150.xpm $(xgnokii_libdir)/xpm + $(INSTALL) -m 0444 xpm/Preview_6210.xpm $(xgnokii_libdir)/xpm + $(INSTALL) -m 0444 xpm/Preview_3310.xpm $(xgnokii_libdir)/xpm + $(INSTALL) -m 0444 xpm/Preview_5110.xpm $(xgnokii_libdir)/xpm + $(INSTALL) -m 0444 xpm/Preview_3210.xpm $(xgnokii_libdir)/xpm + $(INSTALL) -m 0444 xpm/Preview_6250.xpm $(xgnokii_libdir)/xpm + $(INSTALL) -m 0444 xpm/Preview_7110.xpm $(xgnokii_libdir)/xpm @echo "done" install-suid: all @@ -77,8 +123,30 @@ install-suid: all fi $(INSTALL) -d $(xbindir) $(INSTALL) -o root -g gnokii -m 0750 xgnokii $(xbindir) - $(INSTALL) -o root -g gnokii -m 0750 xgnokiilib $(xbindir)/xgnokii + $(INSTALL) -o root -g gnokii -d -m 0750 $(xgnokii_libdir)/help + ( cd $(HELP_DIR); \ + $(FIND) . -type d \! -path "*CVS*" \ + -exec $(INSTALL) -o root -g gnokii -d -m 0750 $(xgnokii_libdir)/help/{} \; ; \ + $(FIND) . -type f \! -path "*CVS*" \ + -exec $(INSTALL) -o root -g gnokii -m 0440 {} $(xgnokii_libdir)/help/{} \; \ + ) + $(INSTALL) -o root -g gnokii -m 0440 ../Docs/CREDITS $(xgnokii_libdir)/help/en_US + $(INSTALL) -o root -g gnokii -m 0440 ../COPYING $(xgnokii_libdir)/help/en_US + $(INSTALL) -o root -g gnokii -d -m 0750 $(xgnokii_libdir)/help/en_US/sample + $(INSTALL) -o root -g gnokii -m 0440 ../Docs/sample/gnokiirc $(xgnokii_libdir)/help/en_US/sample + (cd $(xgnokii_libdir)/help; ln -sf en_US C; ln -sf en_US POSIX) $(INSTALL) -o root -g gnokii -d -m 0750 $(xgnokii_libdir)/xpm + $(INSTALL) -o root -g gnokii -m 0440 xpm/6110.xpm $(xgnokii_libdir)/xpm + $(INSTALL) -o root -g gnokii -m 0440 xpm/6150.xpm $(xgnokii_libdir)/xpm + $(INSTALL) -o root -g gnokii -m 0440 xpm/5110.xpm $(xgnokii_libdir)/xpm + $(INSTALL) -o root -g gnokii -m 0440 xpm/Preview_6110.xpm $(xgnokii_libdir)/xpm + $(INSTALL) -o root -g gnokii -m 0440 xpm/Preview_6150.xpm $(xgnokii_libdir)/xpm + $(INSTALL) -o root -g gnokii -m 0440 xpm/Preview_6210.xpm $(xgnokii_libdir)/xpm + $(INSTALL) -o root -g gnokii -m 0440 xpm/Preview_3310.xpm $(xgnokii_libdir)/xpm + $(INSTALL) -o root -g gnokii -m 0440 xpm/Preview_5110.xpm $(xgnokii_libdir)/xpm + $(INSTALL) -o root -g gnokii -m 0440 xpm/Preview_3210.xpm $(xgnokii_libdir)/xpm + $(INSTALL) -o root -g gnokii -m 0440 xpm/Preview_6250.xpm $(xgnokii_libdir)/xpm + $(INSTALL) -o root -g gnokii -m 0440 xpm/Preview_7110.xpm $(xgnokii_libdir)/xpm @echo install-ss: all @@ -87,8 +155,30 @@ install-ss: all fi $(INSTALL) -o root -g gnokii -d $(xbindir) $(INSTALL) -o root -g gnokii -m 0750 -s xgnokii $(xbindir) - $(INSTALL) -o root -g gnokii -m 0750 -s xgnokiilib $(xbindir)/xgnokii + $(INSTALL) -o root -g gnokii -d -m 0750 $(xgnokii_libdir)/help + ( cd $(HELP_DIR); \ + $(FIND) . -type d \! -path "*CVS*" \ + -exec $(INSTALL) -o root -g gnokii -d -m 0750 $(xgnokii_libdir)/help/{} \; ; \ + $(FIND) . -type f \! -path "*CVS*" \ + -exec $(INSTALL) -o root -g gnokii -m 0440 {} $(xgnokii_libdir)/help/{} \; \ + ) + $(INSTALL) -o root -g gnokii -m 0440 ../Docs/CREDITS $(xgnokii_libdir)/help/en_US + $(INSTALL) -o root -g gnokii -m 0440 ../COPYING $(xgnokii_libdir)/help/en_US + $(INSTALL) -o root -g gnokii -d -m 0750 $(xgnokii_libdir)/help/en_US/sample + $(INSTALL) -o root -g gnokii -m 0440 ../Docs/sample/gnokiirc $(xgnokii_libdir)/help/en_US/sample + (cd $(xgnokii_libdir)/help; ln -sf en_US C; ln -sf en_US POSIX) $(INSTALL) -o root -g gnokii -d -m 0750 $(xgnokii_libdir)/xpm + $(INSTALL) -o root -g gnokii -m 0440 xpm/6110.xpm $(xgnokii_libdir)/xpm + $(INSTALL) -o root -g gnokii -m 0440 xpm/6150.xpm $(xgnokii_libdir)/xpm + $(INSTALL) -o root -g gnokii -m 0440 xpm/5110.xpm $(xgnokii_libdir)/xpm + $(INSTALL) -o root -g gnokii -m 0440 xpm/Preview_6110.xpm $(xgnokii_libdir)/xpm + $(INSTALL) -o root -g gnokii -m 0440 xpm/Preview_6150.xpm $(xgnokii_libdir)/xpm + $(INSTALL) -o root -g gnokii -m 0440 xpm/Preview_6210.xpm $(xgnokii_libdir)/xpm + $(INSTALL) -o root -g gnokii -m 0440 xpm/Preview_3310.xpm $(xgnokii_libdir)/xpm + $(INSTALL) -o root -g gnokii -m 0440 xpm/Preview_5110.xpm $(xgnokii_libdir)/xpm + $(INSTALL) -o root -g gnokii -m 0440 xpm/Preview_3210.xpm $(xgnokii_libdir)/xpm + $(INSTALL) -o root -g gnokii -m 0440 xpm/Preview_6250.xpm $(xgnokii_libdir)/xpm + $(INSTALL) -o root -g gnokii -m 0440 xpm/Preview_7110.xpm $(xgnokii_libdir)/xpm @echo depend dep: diff --git a/xgnokii/VERSION b/xgnokii/VERSION index 0b2c357..36b474b 100644 --- a/xgnokii/VERSION +++ b/xgnokii/VERSION @@ -1 +1 @@ -20000715 \ No newline at end of file +20010323 \ No newline at end of file diff --git a/xgnokii/xgnokii.c b/xgnokii/xgnokii.c index 233ebd6..05cc9fd 100644 --- a/xgnokii/xgnokii.c +++ b/xgnokii/xgnokii.c @@ -1,11 +1,58 @@ /* + $Id$ + X G N O K I I A Linux/Unix GUI for Nokia mobile phones. + Copyright (C) 1999 Pavel Janík ml., Hugh Blemings + & Ján Derfiòák . Released under the terms of the GNU GPL, see file COPYING for more details. + $Log$ + Revision 1.1.1.4 2002/04/03 00:08:26 short + Found in "gnokii-working" directory, some November-patches version + + Revision 1.38 2001/09/14 13:14:03 pkot + Xgnokii WM fixes (Martin Lucina) + + Revision 1.37 2001/06/27 23:52:52 pkot + 7110/6210 updates (Marian Jancar) + + Revision 1.36 2001/06/20 21:27:36 pkot + IrDA patch (Marian Jancar) + + Revision 1.35 2001/05/24 20:47:30 chris + More updating of 7110 code and some of xgnokii_lowlevel changed over. + + Revision 1.34 2001/03/23 08:24:56 ja + New preview for 6210 in xgnokii's logos module. + + Revision 1.33 2001/03/19 23:43:47 pkot + Solaris/BSD '#if defined' cleanup + + Revision 1.32 2001/03/13 01:21:39 pkot + *BSD updates (Bert Driehuis) + + Revision 1.31 2001/03/05 10:42:02 ja + Pavel Machek's vcard and finegrained indicators patch. + + Revision 1.30 2001/01/29 15:22:20 machek + Use integer as bitfield instead of struct of int:1. + + Be able to read phonebook saved in gnokii format from xgnokii. + + Revision 1.29 2001/01/15 21:10:20 ja + Better status reporting in xgnokii, fixed phone capabilities detection in xgnokii. + + Revision 1.28 2000/12/20 11:49:25 ja + Bringing back to life smsd. It was broken after last Pawel update. + + Revision 1.27 2000/12/19 16:18:21 pkot + configure script updates and added shared function for configfile reading + + */ #include /* for getenv */ @@ -33,7 +80,9 @@ #include "misc.h" #include "gsm-common.h" #include "gsm-api.h" -#include "files/cfgreader.h" +#include "fbus-6110.h" +#include "fbus-3810.h" +#include "cfgreader.h" #include "xgnokii.h" #include "xgnokii_common.h" #include "xgnokii_lowlevel.h" @@ -45,10 +94,8 @@ #include "xgnokii_xkeyb.h" #include "xgnokii_calendar.h" #include "xgnokii_logos.h" -#include "xgnokii_xring.h" #include "xgnokii_cfg.h" #include "xgnokii_data.h" -#include "newmodules/n6110.h" #include "xpm/logo.xpm" #include "xpm/background.xpm" @@ -105,15 +152,11 @@ gint max_phonebook_sim_number_length; /* Local variables */ static char *DefaultXGnokiiDir = XGNOKIIDIR; -static char *DefaultXGnokiiDocsDir = XGNOKIIDOCSDIR; static bool SMSSettingsInitialized = FALSE; static bool CallersGroupsInitialized = FALSE; -static bool SMSFoldersInitialized = FALSE; static gint hiddenCallDialog; static guint splashRemoveHandler; -GSM_SMSFolders folders; - static struct CallDialog { GtkWidget *dialog; GtkWidget *label; @@ -130,7 +173,7 @@ typedef struct { GtkWidget *model; GtkWidget *init; GtkWidget *bindir; - GtkWidget *serial, *infrared, *mbus; + GtkWidget *serial, *infrared, *irda; } ConnectionWidgets; typedef struct { @@ -145,7 +188,6 @@ typedef struct { typedef struct { GtkWidget *set; GtkWidget *number; - GtkWidget *defaultrecipient; GtkWidget *format; GtkWidget *validity; GSM_MessageCenter smsSetting[MAX_SMS_CENTER]; @@ -181,21 +223,11 @@ static GSM_MessageCenter tempMessageSettings; static inline void Help1 (GtkWidget *w, gpointer data) { - gchar *indx = g_strdup_printf ("/%s/gnokii/xgnokii/main/index.htm", xgnokiiConfig.locale); + gchar *indx = g_strdup_printf ("/help/%s/index.html", xgnokiiConfig.locale); Help (w, indx); g_free (indx); } -void GUI_InitSMSFoldersInf (void) -{ - if (SMSFoldersInitialized) - return; - - GSM->GetSMSFolders(&folders); - - SMSFoldersInitialized = TRUE; - GUIEventSend (GUI_EVENT_SMS_FOLDERS_CHANGED); -} void GUI_InitCallerGroupsInf (void) { @@ -217,7 +249,7 @@ void GUI_InitCallerGroupsInf (void) xgnokiiConfig.callerGroups[4] = g_strndup( _("Other"), MAX_CALLER_GROUP_LENGTH); xgnokiiConfig.callerGroups[5] = g_strndup( _("No group"), MAX_CALLER_GROUP_LENGTH); - if (GetModelFeature(FN_CALLERGROUPS)!=0) + if (phoneMonitor.supported & PM_CALLERGROUP) for (i = 0; i < 5; i++) { cg = (D_CallerGroup *) g_malloc (sizeof (D_CallerGroup)); @@ -254,6 +286,7 @@ static inline void DrawBackground (GtkWidget *data) 261, 96); } + int network_levels[] = { 152, 69, 11, 3, 138, 69, 11, 3, @@ -290,6 +323,7 @@ int battery_levels[] = { 92, 69, 11, 6 }; + static inline void DrawBattery (GtkWidget *data, int batterylevel) { int i; @@ -311,6 +345,7 @@ static inline void DrawBattery (GtkWidget *data, int batterylevel) } } + static inline void DrawSMS (GtkWidget *data) { gdk_draw_pixmap (Pixmap, @@ -332,11 +367,12 @@ static inline void DrawAlarm (GtkWidget *data) 9, 9); } + static inline void DrawText (GtkWidget *data, int at, char *text) { static GdkFont *Font; - Font = gdk_font_load ("-misc-fixed-medium-r-*-*-*-90-*-*-*-*-*-*"); + Font = gdk_font_load ("-misc-fixed-medium-r-*-*-*-90-*-*-*-*-iso8859-*"); gdk_draw_string (Pixmap, Font, GTK_WIDGET(data)->style->fg_gc[GTK_STATE_NORMAL], @@ -400,7 +436,7 @@ static gint Update (gpointer data) static gchar timeBuf[10]; static gchar *anonym = "anonymous"; static struct tm stm; - static gint smsNumber = 0; + static gint smsUsed = 0; static gint callTimerStart = 0; gint callTimer = 0; time_t t; @@ -409,20 +445,22 @@ static gint Update (gpointer data) /* The number of SMS messages before second */ - static int smsold=0; + static int smsUnRead=0; /* The number of second for we should display "Short Message Received" message */ static int smsreceived=-1; DrawBackground (data); - DrawNetwork(data, phoneMonitor.rfLevel); + DrawNetwork (data, phoneMonitor.rfLevel); - DrawBattery(data, phoneMonitor.batteryLevel); + if (phoneMonitor.powerSource == GPS_ACDC) + phoneMonitor.batteryLevel = ((gint) phoneMonitor.batteryLevel + 25) % 125; + DrawBattery (data, phoneMonitor.batteryLevel); if (phoneMonitor.alarm) DrawAlarm (data); - + if (phoneMonitor.working) DrawText (data, 25, phoneMonitor.working); @@ -431,15 +469,15 @@ static gint Update (gpointer data) { DrawSMS (data); - if (phoneMonitor.sms.unRead > smsold && smsold != -1) + if (phoneMonitor.sms.unRead > smsUnRead && smsUnRead != -1) smsreceived = 10; /* The message "Short Message Received" is displayed for 10s */ } - if (smsNumber != phoneMonitor.sms.number) + if (smsUsed != phoneMonitor.sms.used) GUIEventSend (GUI_EVENT_SMS_NUMBER_CHANGED); - smsold = phoneMonitor.sms.unRead; + smsUnRead = phoneMonitor.sms.unRead; - smsNumber = phoneMonitor.sms.number; + smsUsed = phoneMonitor.sms.used; pthread_mutex_unlock (&smsMutex); @@ -533,7 +571,7 @@ static void ParseSMSCenters (void) for (i = 0; i < xgnokiiConfig.smsSets; i++) { - gchar *row[5]; + gchar *row[4]; if (*(configDialogData.sms.smsSetting[i].Name) == '\0') row[0] = g_strdup_printf (_("Set %d"), i + 1); else @@ -608,11 +646,9 @@ static void ParseSMSCenters (void) break; } - row[4] = g_strdup (configDialogData.sms.smsSetting[i].DefaultRecipient); - gtk_clist_append( GTK_CLIST (SMSClist), row); - for (j = 0; j < 5; j++) + for (j = 0; j < 4; j++) g_free (row[j]); } @@ -702,14 +738,13 @@ void GUI_ShowOptions (void) gtk_entry_set_text (GTK_ENTRY (configDialogData.connection.bindir), xgnokiiConfig.bindir); - if (!strcmp(xgnokiiConfig.connection, "fbus")) + if(!strcmp(xgnokiiConfig.connection, "serial")) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (configDialogData.connection.serial), TRUE); - - if (!strcmp(xgnokiiConfig.connection, "infrared")) + } else if(!strcmp(xgnokiiConfig.connection, "infrared")) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (configDialogData.connection.infrared), TRUE); - - if (!strcmp(xgnokiiConfig.connection, "mbus")) - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (configDialogData.connection.mbus), TRUE); + } else { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (configDialogData.connection.irda), TRUE); + } /* Phone */ gtk_entry_set_text (GTK_ENTRY (configDialogData.phone.model), phoneMonitor.phone.model); @@ -746,7 +781,7 @@ void GUI_ShowOptions (void) else { xgnokiiConfig.alarmSupported = TRUE; - if (alarm->time.IsSet) + if (alarm->time.AlarmEnabled) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (configDialogData.alarm.alarmSwitch), TRUE); else gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (configDialogData.alarm.alarmSwitch), FALSE); @@ -756,7 +791,7 @@ void GUI_ShowOptions (void) g_free (alarm); /* SMS */ - if (GetModelFeature(FN_SMS)!=0) + if (phoneMonitor.supported & PM_SMS) { gtk_widget_show (sms_option_frame); GUI_InitSMSSettings (); @@ -766,7 +801,7 @@ void GUI_ShowOptions (void) /* BUSINESS CARD */ - if (GetModelFeature(FN_SMS)!=0) + if (phoneMonitor.supported & PM_SMS) { gtk_widget_show (user_option_frame); @@ -792,7 +827,7 @@ void GUI_ShowOptions (void) /* Groups */ - if (GetModelFeature(FN_CALLERGROUPS)!=0) + if (phoneMonitor.supported & PM_CALLERGROUP) { gtk_widget_show (cg_names_option_frame); GUI_InitCallerGroupsInf (); @@ -803,7 +838,7 @@ void GUI_ShowOptions (void) gtk_widget_hide (cg_names_option_frame); /* Mail */ - if (GetModelFeature(FN_SMS)!=0) + if (phoneMonitor.supported & PM_SMS) { gtk_widget_show (mail_option_frame); gtk_entry_set_text (GTK_ENTRY (configDialogData.mailbox), @@ -816,9 +851,6 @@ void GUI_ShowOptions (void) gtk_entry_set_text (GTK_ENTRY (configDialogData.help), xgnokiiConfig.helpviewer); - if (GetModelFeature(FN_SMSCDEFAULT)!=0) {} else - gtk_clist_set_column_visibility (GTK_CLIST (SMSClist), 4, (GetModelFeature(FN_SMSCDEFAULT)!=0)); - optionsDialogIsOpened = TRUE; gtk_widget_show (OptionsDialog); } @@ -844,10 +876,6 @@ static void MainExit (void) e->data = NULL; GUI_InsertEvent (e); pthread_join (monitor_th, NULL); - - //need to correctly close connection - GSM->Terminate(); - gtk_main_quit(); } @@ -856,37 +884,37 @@ static void ShowMenu (GdkEventButton *event) { GdkEventButton *bevent = (GdkEventButton *) event; - if (GetModelFeature(FN_KEYPRESS)!=0) + if (phoneMonitor.supported & PM_KEYBOARD) gtk_widget_show (xkeyb_menu_item); else gtk_widget_hide (xkeyb_menu_item); - if (GetModelFeature(FN_NETMONITOR)!=0) + if (phoneMonitor.supported & PM_NETMONITOR) gtk_widget_show (netmon_menu_item); else gtk_widget_hide (netmon_menu_item); - if (GetModelFeature(FN_SMS)!=0) + if (phoneMonitor.supported & PM_SMS) gtk_widget_show (sms_menu_item); else gtk_widget_hide (sms_menu_item); - if (GetModelFeature(FN_CALENDAR)!=0) + if (phoneMonitor.supported & PM_CALENDAR) gtk_widget_show (calendar_menu_item); else gtk_widget_hide (calendar_menu_item); - if (GetModelFeature(FN_DTMF)!=0) + if (phoneMonitor.supported & PM_DTMF) gtk_widget_show (dtmf_menu_item); else gtk_widget_hide (dtmf_menu_item); - if (GetModelFeature(FN_SPEEDDIAL)!=0) + if (phoneMonitor.supported & PM_SPEEDDIAL) gtk_widget_show (speedDial_menu_item); else gtk_widget_hide (speedDial_menu_item); - if (GetModelFeature(FN_DATACALLS)!=0) + if (phoneMonitor.supported & PM_DATA) gtk_widget_show (data_menu_item); else gtk_widget_hide (data_menu_item); @@ -920,7 +948,7 @@ static gint ButtonPressEvent (GtkWidget *widget, GdkEventButton *event) else if (event->x >= 190 && event->x <= 210 && event->y >= 70 && event->y <= 85) { - if (GetModelFeature(FN_SMS)==0) + if (!phoneMonitor.supported & PM_SMS) phoneMonitor.working = _("SMS not supported!"); else GUI_ShowSMS (); @@ -928,7 +956,7 @@ static gint ButtonPressEvent (GtkWidget *widget, GdkEventButton *event) else if (event->x >= 235 && event->x <= 248 && event->y >= 27 && event->y <= 75) { - if (GetModelFeature(FN_CALENDAR)==0) + if (!phoneMonitor.supported & PM_CALENDAR) phoneMonitor.working = _("Calendar not supported!"); else GUI_ShowCalendar (); @@ -979,7 +1007,7 @@ static void OptionsApplyCallback (GtkWidget *widget, gpointer data ) } /* SMS */ - if (GetModelFeature(FN_SMS)!=0) + if (phoneMonitor.supported & PM_SMS) { for (i = 0; i < xgnokiiConfig.smsSets; i++) xgnokiiConfig.smsSetting[i] = configDialogData.sms.smsSetting[i]; @@ -987,7 +1015,7 @@ static void OptionsApplyCallback (GtkWidget *widget, gpointer data ) } /* BUSINESS CARD */ - if (GetModelFeature(FN_SMS)!=0) + if (phoneMonitor.supported & PM_SMS) { g_free(xgnokiiConfig.user.name); xgnokiiConfig.user.name = g_strdup (gtk_entry_get_text(GTK_ENTRY (configDialogData.user.name))); @@ -1006,7 +1034,7 @@ static void OptionsApplyCallback (GtkWidget *widget, gpointer data ) } /* GROUPS */ - if (GetModelFeature(FN_CALLERGROUPS)!=0) + if (phoneMonitor.supported & PM_CALLERGROUP) { for ( i = 0; i < 6; i++) { @@ -1020,7 +1048,7 @@ static void OptionsApplyCallback (GtkWidget *widget, gpointer data ) } /* Mail */ - if (GetModelFeature(FN_SMS)!=0) + if (phoneMonitor.supported & PM_SMS) { g_free(xgnokiiConfig.mailbox); xgnokiiConfig.mailbox = g_strdup (gtk_entry_get_text(GTK_ENTRY (configDialogData.mailbox))); @@ -1052,7 +1080,7 @@ static void OptionsSaveCallback (GtkWidget *widget, gpointer data ) GUI_InsertEvent (e); } - if (GetModelFeature(FN_CALLERGROUPS)!=0) + if (phoneMonitor.supported & PM_CALLERGROUP) { cg = (D_CallerGroup *) g_malloc (sizeof (D_CallerGroup)); cg->number = 0; @@ -1150,13 +1178,7 @@ static GtkWidget *CreateMenu (void) gtk_signal_connect_object (GTK_OBJECT (logos_menu_item), "activate", GTK_SIGNAL_FUNC (GUI_ShowLogosWindow), NULL); gtk_widget_show(logos_menu_item); - - logos_menu_item = gtk_menu_item_new_with_label (_("Ringtones")); - gtk_menu_append (GTK_MENU (menu), logos_menu_item); - gtk_signal_connect_object (GTK_OBJECT (logos_menu_item), "activate", - GTK_SIGNAL_FUNC (GUI_ShowRingtonesWindow), NULL); - gtk_widget_show(logos_menu_item); - + dtmf_menu_item = gtk_menu_item_new_with_label (_("DTMF")); gtk_menu_append (GTK_MENU (menu), dtmf_menu_item); gtk_signal_connect_object (GTK_OBJECT (dtmf_menu_item), "activate", @@ -1216,7 +1238,7 @@ static GtkWidget *CreateAboutDialog (void) { GtkWidget *dialog; GtkWidget *button, *hbox, *label; - gchar buf[200]; + gchar buf[2000]; dialog = gtk_dialog_new (); gtk_window_set_title (GTK_WINDOW (dialog), _("About")); @@ -1236,8 +1258,12 @@ static GtkWidget *CreateAboutDialog (void) gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), hbox); gtk_widget_show (hbox); - g_snprintf (buf, 200, _("xgnokii version: %s\ngnokii version: %s\n\n\ -Copyright (C) 1999 Pavel Janík ml.,\nHugh Blemings & Jan Derfinak\n"), XVERSION, VERSION); + g_snprintf (buf, 2000, _("xgnokii version: %s\ngnokii version: %s\n\n\ +Copyright (C) 1999,2000 Pavel Janík ml.,\nHugh Blemings, Jan Derfinak and others\n\ +xgnokii is free software, covered by the GNU General Public License, and you are\n\ +welcome to change it and/or distribute copies of it under certain conditions.\n\ +There is absolutely no waranty for xgnokii. See GPL for details.\n"), + XVERSION, VERSION); label = gtk_label_new ((gchar *) buf); gtk_box_pack_start (GTK_BOX(hbox), label, FALSE, FALSE, 0); gtk_widget_show (label); @@ -1363,13 +1389,6 @@ static void OkEditSMSSetDialog (GtkWidget *w, gpointer data) configDialogData.sms.smsSetting[GPOINTER_TO_INT(GTK_CLIST (SMSClist)->selection->data)].Number[GSM_MAX_SMS_CENTER_LENGTH] = '\0'; - strncpy(configDialogData.sms.smsSetting - [GPOINTER_TO_INT(GTK_CLIST (SMSClist)->selection->data)].DefaultRecipient, - gtk_entry_get_text(GTK_ENTRY (configDialogData.sms.defaultrecipient)), - GSM_MAX_RECIPIENT_LENGTH); - configDialogData.sms.smsSetting[GPOINTER_TO_INT(GTK_CLIST (SMSClist)->selection->data)].DefaultRecipient[GSM_MAX_RECIPIENT_LENGTH] - = '\0'; - configDialogData.sms.smsSetting[GPOINTER_TO_INT(GTK_CLIST (SMSClist)->selection->data)].Format = tempMessageSettings.Format; @@ -1396,7 +1415,7 @@ static inline void EditSMSSetDialogClick (GtkWidget *clist, static void ShowEditSMSSetDialog (GtkWidget *w, gpointer data) { static GtkWidget *dialog = NULL; - GtkWidget *button, *label, *label2, *hbox, *hbox2, *menu, *item; + GtkWidget *button, *label, *hbox, *menu, *item; if (GTK_CLIST (SMSClist)->selection == NULL) return; @@ -1453,25 +1472,10 @@ static void ShowEditSMSSetDialog (GtkWidget *w, gpointer data) gtk_box_pack_end(GTK_BOX(hbox), configDialogData.sms.number, FALSE, FALSE, 2); gtk_widget_show (configDialogData.sms.number); - hbox2 = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox2, FALSE, FALSE, 9); - if (GetModelFeature(FN_SMSCDEFAULT)!=0) - gtk_widget_show (hbox2); - - label2 = gtk_label_new (_("Default recipient:")); - gtk_box_pack_start(GTK_BOX(hbox2), label2, FALSE, FALSE, 2); - if (GetModelFeature(FN_SMSCDEFAULT)!=0) - gtk_widget_show (label2); - - configDialogData.sms.defaultrecipient = gtk_entry_new_with_max_length(GSM_MAX_RECIPIENT_LENGTH - 1); - gtk_widget_set_usize (configDialogData.sms.defaultrecipient, 110, 22); - gtk_box_pack_end(GTK_BOX(hbox2), configDialogData.sms.defaultrecipient, FALSE, FALSE, 2); - if (GetModelFeature(FN_SMSCDEFAULT)!=0) - gtk_widget_show (configDialogData.sms.defaultrecipient); - hbox = gtk_hbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox, FALSE, FALSE, 9); gtk_widget_show (hbox); + label = gtk_label_new (_("Sending Format:")); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 2); gtk_widget_show (label); @@ -1579,10 +1583,6 @@ static void ShowEditSMSSetDialog (GtkWidget *w, gpointer data) configDialogData.sms.smsSetting [GPOINTER_TO_INT(GTK_CLIST (SMSClist)->selection->data)].Number); - gtk_entry_set_text (GTK_ENTRY (configDialogData.sms.defaultrecipient), - configDialogData.sms.smsSetting - [GPOINTER_TO_INT(GTK_CLIST (SMSClist)->selection->data)].DefaultRecipient); - switch (configDialogData.sms.smsSetting [GPOINTER_TO_INT(GTK_CLIST (SMSClist)->selection->data)].Format) { @@ -1665,7 +1665,7 @@ static GtkWidget *CreateOptionsDialog (void) GtkWidget *button, *hbox, *vbox, *label, *notebook, *frame, *clistScrolledWindow; register gint i; GtkAdjustment *adj; - gchar *titles[5] = { _("Set's name"), _("Center number"), _("Format"), _("Validity"), _("Default recipient")}; + gchar *titles[4] = { _("Set's name"), _("Center number"), _("Format"), _("Validity")}; dialog = gtk_dialog_new (); gtk_window_set_title (GTK_WINDOW (dialog), _("Options")); @@ -1779,22 +1779,22 @@ static GtkWidget *CreateOptionsDialog (void) gtk_widget_show (hbox); label = gtk_label_new (_("Connection:")); - gtk_box_pack_start (GTK_BOX(hbox), label, FALSE, FALSE, 3); + gtk_box_pack_start (GTK_BOX(hbox), label, FALSE, FALSE, 2); gtk_widget_show (label); configDialogData.connection.infrared = gtk_radio_button_new_with_label (NULL, _("infrared")); gtk_box_pack_end (GTK_BOX (hbox), configDialogData.connection.infrared, TRUE, FALSE, 2); gtk_widget_show (configDialogData.connection.infrared); - + configDialogData.connection.serial = gtk_radio_button_new_with_label ( - gtk_radio_button_group (GTK_RADIO_BUTTON (configDialogData.connection.infrared)), _("fbus")); + gtk_radio_button_group (GTK_RADIO_BUTTON (configDialogData.connection.infrared)), _("serial")); gtk_box_pack_end (GTK_BOX (hbox), configDialogData.connection.serial, TRUE, FALSE, 2); gtk_widget_show (configDialogData.connection.serial); - - configDialogData.connection.mbus = gtk_radio_button_new_with_label ( - gtk_radio_button_group (GTK_RADIO_BUTTON (configDialogData.connection.serial)), _("mbus")); - gtk_box_pack_end (GTK_BOX (hbox), configDialogData.connection.mbus, TRUE, FALSE, 2); - gtk_widget_show (configDialogData.connection.mbus); + + configDialogData.connection.irda = gtk_radio_button_new_with_label ( + gtk_radio_button_group (GTK_RADIO_BUTTON (configDialogData.connection.infrared)), _("irda")); + gtk_box_pack_end (GTK_BOX (hbox), configDialogData.connection.irda, TRUE, FALSE, 2); + gtk_widget_show (configDialogData.connection.irda); /*** Phone notebook ***/ frame = gtk_frame_new (_("Phone information")); @@ -1871,7 +1871,7 @@ static GtkWidget *CreateOptionsDialog (void) gtk_container_add (GTK_CONTAINER (vbox), hbox); gtk_widget_show (hbox); - label = gtk_label_new ("Names length:"); + label = gtk_label_new (_("Names length:")); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 2); gtk_widget_show (label); @@ -1879,7 +1879,7 @@ static GtkWidget *CreateOptionsDialog (void) gtk_container_add (GTK_CONTAINER (vbox), hbox); gtk_widget_show (hbox); - label = gtk_label_new ("SIM:"); + label = gtk_label_new (_("SIM:")); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 2); gtk_widget_show (label); @@ -1897,7 +1897,7 @@ static GtkWidget *CreateOptionsDialog (void) gtk_box_pack_end (GTK_BOX (hbox), configDialogData.phone.phoneNameLen, FALSE, FALSE, 2); gtk_widget_show (configDialogData.phone.phoneNameLen); - label = gtk_label_new ("Phone:"); + label = gtk_label_new (_("Phone:")); gtk_box_pack_end (GTK_BOX (hbox), label, FALSE, FALSE, 2); gtk_widget_show (label); @@ -1950,7 +1950,7 @@ static GtkWidget *CreateOptionsDialog (void) label = gtk_label_new (_("SMS")); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), sms_option_frame, label); - SMSClist = gtk_clist_new_with_titles (5, titles); + SMSClist = gtk_clist_new_with_titles (4, titles); gtk_clist_set_shadow_type (GTK_CLIST (SMSClist), GTK_SHADOW_OUT); gtk_clist_column_titles_passive (GTK_CLIST (SMSClist)); gtk_clist_set_auto_sort (GTK_CLIST (SMSClist), FALSE); @@ -1959,7 +1959,6 @@ static GtkWidget *CreateOptionsDialog (void) gtk_clist_set_column_width (GTK_CLIST (SMSClist), 1, 115); gtk_clist_set_column_width (GTK_CLIST (SMSClist), 2, 40); gtk_clist_set_column_width (GTK_CLIST (SMSClist), 3, 55); - gtk_clist_set_column_width (GTK_CLIST (SMSClist), 4, 100); // gtk_clist_set_column_justification (GTK_CLIST (SMSClist), 1, GTK_JUSTIFY_RIGHT); clistScrolledWindow = gtk_scrolled_window_new (NULL, NULL); @@ -1970,7 +1969,6 @@ static GtkWidget *CreateOptionsDialog (void) TRUE, TRUE, 10); gtk_widget_show (SMSClist); - gtk_widget_show (clistScrolledWindow); hbox = gtk_hbox_new (FALSE, 0); @@ -2286,6 +2284,8 @@ static void TopLevelWindow (void) struct sigaction act; GUI_MainWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL); + gtk_window_set_wmclass (GTK_WINDOW (GUI_MainWindow), "MainWindow", "Xgnokii"); +/* gtk_window_set_decorated (GTK_WINDOW (GUI_MainWindow), GTK_FALSE); */ gtk_widget_realize (GUI_MainWindow); BackgroundPixmap = gdk_pixmap_create_from_xpm_d (GUI_MainWindow->window, &mask, &GUI_MainWindow->style->white, (gchar **) XPM_background); @@ -2341,7 +2341,6 @@ static void TopLevelWindow (void) GUI_CreateCalendarWindow (); GUI_CreateLogosWindow (); GUI_CreateDataWindow(); - GUI_CreateRingtonesWindow (); CreateErrorDialog (&errorDialog, GUI_MainWindow); CreateInfoDialog (&infoDialog, GUI_MainWindow); CreateInCallDialog (); @@ -2351,7 +2350,7 @@ static void TopLevelWindow (void) act.sa_flags = SA_NOCLDSTOP; sigaction (SIGCHLD, &act, NULL); -#if defined(__svr4__) || defined(__FreeBSD__) +#if __unices__ act.sa_handler = SIG_IGN; sigemptyset (&(act.sa_mask)); sigaction (SIGALRM, &act, NULL); @@ -2416,33 +2415,45 @@ static gint RemoveSplash (GtkWidget *Win) static void ReadConfig (void) { - /* Read config file */ - if (CFG_ReadConfig(&xgnokiiConfig.model, &xgnokiiConfig.port, - &xgnokiiConfig.initlength, &xgnokiiConfig.connection, - &xgnokiiConfig.bindir, &xgnokiiConfig.synchronizetime,false) < 0) { - exit(-1); - } - -#ifndef WIN32 +#ifdef WIN32 + xgnokiiConfig.locale = ""; +#else if ((xgnokiiConfig.locale = getenv ("LC_ALL")) == NULL) if ((xgnokiiConfig.locale = getenv ("LC_MESSAGES")) == NULL) if ((xgnokiiConfig.locale = getenv ("LANG")) == NULL) xgnokiiConfig.locale = "POSIX"; #endif - + if (readconfig(&xgnokiiConfig.model, &xgnokiiConfig.port, + &xgnokiiConfig.initlength, &xgnokiiConfig.connection, + &xgnokiiConfig.bindir) < 0) + { + exit(-1); + } + GUI_ReadXConfig(); max_phonebook_name_length = atoi (xgnokiiConfig.maxPhoneLen); max_phonebook_sim_name_length = atoi (xgnokiiConfig.maxSIMLen); #ifndef WIN32 xgnokiiConfig.xgnokiidir = DefaultXGnokiiDir; - xgnokiiConfig.xgnokiidocsdir = DefaultXGnokiiDocsDir; + +#if 0 + if (strstr(FB38_Information.Models, xgnokiiConfig.model) != NULL) + { + max_phonebook_number_length = 30; + max_phonebook_sim_number_length = 30; + } + else +#endif #endif - if (CheckModel (N6110_Information, xgnokiiConfig.model, CurrentConnectionType)) { - max_phonebook_number_length = N6110_MAX_PHONEBOOK_NUMBER_LENGTH; - max_phonebook_sim_number_length = N6110_MAX_PHONEBOOK_NUMBER_LENGTH; +#if 0 + if (strstr(FB61_Information.Models, xgnokiiConfig.model) != NULL) + { + max_phonebook_number_length = FB61_MAX_PHONEBOOK_NUMBER_LENGTH; + max_phonebook_sim_number_length = FB61_MAX_PHONEBOOK_NUMBER_LENGTH; } else +#endif { max_phonebook_number_length = max_phonebook_sim_number_length = GSM_MAX_PHONEBOOK_NUMBER_LENGTH; } @@ -2477,5 +2488,5 @@ int main (int argc, char *argv[]) gtk_main (); - return(0); + return (0); } diff --git a/xgnokii/xgnokii.h b/xgnokii/xgnokii.h index ad79075..d1ed2ec 100644 --- a/xgnokii/xgnokii.h +++ b/xgnokii/xgnokii.h @@ -3,9 +3,14 @@ X G N O K I I A Linux/Unix GUI for Nokia mobile phones. + Copyright (C) 1999 Pavel Janík ml., Hugh Blemings + & Ján Derfiòák . Released under the terms of the GNU GPL, see file COPYING for more details. + Last modification: Wed Apr 26 2000 + Modified by Jan Derfinak + */ #ifndef XGNOKII_H @@ -14,7 +19,7 @@ #include #include "config.h" #include "misc.h" -#include "gsm-sms.h" +#include "gsm-common.h" #define MAX_CALLER_GROUP_LENGTH 10 #define MAX_SMS_CENTER 10 @@ -35,10 +40,8 @@ typedef struct { gchar *model; /* Model from .gnokiirc file. */ gchar *port; /* Serial port from .gnokiirc file */ gchar *connection; /* Connection type from .gnokiirc file */ - gchar *synchronizetime; gchar *bindir; gchar *xgnokiidir; - gchar *xgnokiidocsdir; gchar *helpviewer; /* Program to showing help files */ gchar *mailbox; /* Mailbox, where we can save SMS's */ gchar *maxSIMLen; /* Max length of names on SIM card */ @@ -58,10 +61,8 @@ extern gint max_phonebook_name_length; extern gint max_phonebook_number_length; extern gint max_phonebook_sim_name_length; extern gint max_phonebook_sim_number_length; -extern GSM_SMSFolders folders; extern void GUI_InitCallerGroupsInf (void); extern void GUI_InitSMSSettings (void); -extern void GUI_InitSMSFoldersInf (void); extern void GUI_ShowAbout (void); #endif /* XGNOKII_H */ diff --git a/xgnokii/xgnokii_calendar.c b/xgnokii/xgnokii_calendar.c index 6c64386..c0741e2 100644 --- a/xgnokii/xgnokii_calendar.c +++ b/xgnokii/xgnokii_calendar.c @@ -3,9 +3,14 @@ X G N O K I I A Linux/Unix GUI for Nokia mobile phones. + Copyright (C) 1999 Pavel Janík ml., Hugh Blemings + & Ján Derfiòák . Released under the terms of the GNU GPL, see file COPYING for more details. + Last modification: Tue Nov 28 1999 + Modified by Jan Derfinak + */ #include @@ -112,7 +117,7 @@ static inline void CloseCalendar (GtkWidget *w, gpointer data) inline void GUI_ShowCalendar () { - if (GetModelFeature(FN_CALENDAR)!=0) + if (phoneMonitor.supported & PM_CALENDAR) gtk_widget_show (GUI_CalendarWindow); } @@ -1289,10 +1294,10 @@ static GtkItemFactoryEntry menu_items[] = { { NULL, NULL, NULL, 0, ""}, { NULL, "W", CloseCalendar, 0, NULL}, { NULL, NULL, NULL, 0, ""}, - { NULL, "N", AddReminder, 0, NULL}, - { NULL, "C", AddCall, 0, NULL}, - { NULL, "M", AddMeeting, 0, NULL}, - { NULL, "B", AddBirthday, 0, NULL}, + { NULL, "N", NULL, 0, NULL}, + { NULL, "C", NULL, 0, NULL}, + { NULL, "M", NULL, 0, NULL}, + { NULL, "B", NULL, 0, NULL}, { NULL, NULL, NULL, 0, NULL}, { NULL, "D", DeleteNote, 0, NULL}, { NULL, NULL, NULL, 0, ""}, diff --git a/xgnokii/xgnokii_calendar.h b/xgnokii/xgnokii_calendar.h index d0c8b8f..a4c5b91 100644 --- a/xgnokii/xgnokii_calendar.h +++ b/xgnokii/xgnokii_calendar.h @@ -3,9 +3,14 @@ X G N O K I I A Linux/Unix GUI for Nokia mobile phones. + Copyright (C) 1999 Pavel Janík ml., Hugh Blemings + & Ján Derfiòák . Released under the terms of the GNU GPL, see file COPYING for more details. + Last modification: Sun Apr 31 2000 + Modified by Jan Derfinak + */ #ifndef XGNOKII_CALENDAR_H diff --git a/xgnokii/xgnokii_cfg.c b/xgnokii/xgnokii_cfg.c index c4cf9cb..7286ce1 100644 --- a/xgnokii/xgnokii_cfg.c +++ b/xgnokii/xgnokii_cfg.c @@ -3,9 +3,14 @@ X G N O K I I A Linux/Unix GUI for Nokia mobile phones. + Copyright (C) 1999 Pavel Janík ml., Hugh Blemings + & Ján Derfiòák . Released under the terms of the GNU GPL, see file COPYING for more details. + Last modification: Mon Oct 10 1999 + Modified by Jan Derfinak + */ #include diff --git a/xgnokii/xgnokii_cfg.h b/xgnokii/xgnokii_cfg.h index f258a19..75dfab9 100644 --- a/xgnokii/xgnokii_cfg.h +++ b/xgnokii/xgnokii_cfg.h @@ -3,9 +3,14 @@ X G N O K I I A Linux/Unix GUI for Nokia mobile phones. + Copyright (C) 1999 Pavel Janík ml., Hugh Blemings + & Ján Derfiòák . Released under the terms of the GNU GPL, see file COPYING for more details. + Last modification: Mon Oct 10 1999 + Modified by Jan Derfinak + */ #ifndef XGNOKII_CFG_H diff --git a/xgnokii/xgnokii_common.c b/xgnokii/xgnokii_common.c index 9f7acd4..10748f0 100644 --- a/xgnokii/xgnokii_common.c +++ b/xgnokii/xgnokii_common.c @@ -3,9 +3,14 @@ X G N O K I I A Linux/Unix GUI for Nokia mobile phones. + Copyright (C) 1999 Pavel Janík ml., Hugh Blemings + & Ján Derfiòák . Released under the terms of the GNU GPL, see file COPYING for more details. + Last modification: Mon May 01 2000 + Modified by Jan Derfinak + */ #ifndef WIN32 @@ -23,6 +28,7 @@ #include "xpm/stop.xpm" #include "xpm/info.xpm" + typedef struct { GUIEventType type; void (*func)(void); @@ -243,7 +249,7 @@ void Help (const GtkWidget *w, const gpointer data) { gchar buf[255] = "file:"; - strncat (buf, xgnokiiConfig.xgnokiidocsdir, 255 - strlen (buf)); + strncat (buf, xgnokiiConfig.xgnokiidir, 255 - strlen (buf)); buf[254] = '\0'; strncat (buf, (gchar *) data, 255 - strlen (buf)); buf[254] = '\0'; diff --git a/xgnokii/xgnokii_common.h b/xgnokii/xgnokii_common.h index e90439a..e594a38 100644 --- a/xgnokii/xgnokii_common.h +++ b/xgnokii/xgnokii_common.h @@ -3,9 +3,14 @@ X G N O K I I A Linux/Unix GUI for Nokia mobile phones. + Copyright (C) 1999 Pavel Janík ml., Hugh Blemings + & Ján Derfiòák . Released under the terms of the GNU GPL, see file COPYING for more details. + Last modification: Mon May 01 2000 + Modified by Jan Derfinak + */ #ifndef XGNOKII_COMMON_H @@ -19,6 +24,12 @@ typedef struct { gint column; } SortColumn; +/* typedef struct { + gchar *model; + gchar *number; +} Model; +*/ + typedef struct { GtkWidget *dialog; GtkWidget *text; @@ -45,7 +56,6 @@ typedef enum { GUI_EVENT_SMS_NUMBER_CHANGED, GUI_EVENT_SMS_CENTERS_CHANGED, GUI_EVENT_NETMON_CHANGED, - GUI_EVENT_SMS_FOLDERS_CHANGED } GUIEventType; extern void CancelDialog (const GtkWidget *, const gpointer); @@ -60,15 +70,6 @@ extern gint LaunchProcess (const gchar *, const gchar *, const gint, extern void RemoveZombie (const gint); extern void Help (const GtkWidget *, const gpointer); extern gint strrncmp (const gchar * const, const gchar * const, size_t); -extern gchar *GetModel (const gchar *); -extern bool CallerGroupSupported (const gchar *); -extern bool NetmonitorSupported (const gchar *); -extern bool KeyboardSupported (const gchar *); -extern bool SMSSupported (const gchar *); -extern bool CalendarSupported (const gchar *); -extern bool DTMFSupported (const gchar *); -extern bool DataSupported (const gchar *); -extern bool SpeedDialSupported (const gchar *); extern void GUI_Refresh (void); extern void SetSortColumn (GtkWidget *, SortColumn *); extern void GUIEventAdd (GUIEventType, void (*)(void)); diff --git a/xgnokii/xgnokii_contacts.c b/xgnokii/xgnokii_contacts.c index 39ef62b..cf8289a 100644 --- a/xgnokii/xgnokii_contacts.c +++ b/xgnokii/xgnokii_contacts.c @@ -3,11 +3,39 @@ X G N O K I I A Linux/Unix GUI for Nokia mobile phones. + Copyright (C) 1999 Pavel Janík ml., Hugh Blemings + & Ján Derfiòák . Released under the terms of the GNU GPL, see file COPYING for more details. $Id$ + $Log$ + Revision 1.1.1.5 2002/04/03 00:08:28 short + Found in "gnokii-working" directory, some November-patches version + + Revision 1.30 2001/09/14 13:14:04 pkot + Xgnokii WM fixes (Martin Lucina) + + Revision 1.29 2001/03/23 08:24:56 ja + New preview for 6210 in xgnokii's logos module. + + Revision 1.28 2001/03/19 23:43:47 pkot + Solaris/BSD '#if defined' cleanup + + Revision 1.27 2001/03/13 01:21:39 pkot + *BSD updates (Bert Driehuis) + + Revision 1.26 2001/03/05 10:42:03 ja + Pavel Machek's vcard and finegrained indicators patch. + + Revision 1.25 2001/02/12 15:13:46 chris + Fixed my bug in xgnokii_contacts.c and added to tekram.c + + Revision 1.24 2001/02/02 08:09:57 ja + New dialogs for 6210/7110 in xgnokii. Fixed the smsd for new capabilty code. + + */ @@ -32,7 +60,6 @@ #endif #include -#include "gsm-api.h" #include "gsm-common.h" #include "xgnokii_contacts.h" #include "xgnokii_lowlevel.h" @@ -251,7 +278,7 @@ static void OkEditEntryDialog (GtkWidget *widget, gpointer data) max_phonebook_name_length); entry->entry.Name[max_phonebook_name_length] = '\0'; - if (GetModelFeature(FN_PHONEBOOK)==F_PBK71INT) + if (phoneMonitor.supported & PM_EXTPBK) { } else @@ -297,7 +324,7 @@ because you save it into SIM memory!")); gtk_widget_show (errorDialog.dialog); } - if (GetModelFeature(FN_PHONEBOOK)==F_PBK71INT) + if (phoneMonitor.supported & PM_EXTPBK) { } else @@ -331,7 +358,7 @@ because you save it into SIM memory!")); max_phonebook_name_length); ((EditEntryData*) data)->pbEntry->entry.Name[max_phonebook_name_length] = '\0'; - if (GetModelFeature(FN_PHONEBOOK)==F_PBK71INT) + if (phoneMonitor.supported & PM_EXTPBK) { } else @@ -356,7 +383,7 @@ because you save it into SIM memory!")); gtk_widget_show (errorDialog.dialog); } - if (GetModelFeature(FN_PHONEBOOK)==F_PBK71INT) + if (phoneMonitor.supported & PM_EXTPBK) { } else @@ -393,7 +420,7 @@ because you save it into SIM memory!")); clist_row[2] = "P"; else clist_row[2] = "S"; - if (GetModelFeature(FN_CALLERGROUPS)!=0) + if (phoneMonitor.supported & PM_CALLERGROUP) clist_row[3] = xgnokiiConfig.callerGroups[((EditEntryData*) data)->pbEntry->entry.Group]; else clist_row[3] = ""; @@ -473,7 +500,7 @@ static void OkNewEntryDialog(GtkWidget *widget, gpointer data ) max_phonebook_name_length); entry->entry.Name[max_phonebook_name_length] = '\0'; - if (GetModelFeature(FN_PHONEBOOK)==F_PBK71INT) + if (phoneMonitor.supported & PM_EXTPBK) { } else @@ -511,7 +538,7 @@ because you save it into SIM memory!")); gtk_widget_show (errorDialog.dialog); } - if (GetModelFeature(FN_PHONEBOOK)==F_PBK71INT) + if (phoneMonitor.supported & PM_EXTPBK) { } else @@ -537,7 +564,7 @@ because you save it into SIM memory!")); max_phonebook_name_length); ((EditEntryData*) data)->pbEntry->entry.Name[max_phonebook_name_length] = '\0'; - if (GetModelFeature(FN_PHONEBOOK)==F_PBK71INT) + if (phoneMonitor.supported & PM_EXTPBK) { } else @@ -562,7 +589,7 @@ because you save it into SIM memory!")); gtk_widget_show (errorDialog.dialog); } - if (GetModelFeature(FN_PHONEBOOK)==F_PBK71INT) + if (phoneMonitor.supported & PM_EXTPBK) { } else @@ -605,7 +632,7 @@ because you save it into SIM memory!")); clist_row[2] = "P"; else clist_row[2] = "S"; - if (GetModelFeature(FN_CALLERGROUPS)!=0) + if (phoneMonitor.supported & PM_CALLERGROUP) clist_row[3] = xgnokiiConfig.callerGroups[((EditEntryData*) data)->pbEntry->entry.Group]; else clist_row[3] = ""; @@ -704,7 +731,7 @@ static void OkChangeEntryDialog( GtkWidget *widget, gpointer data) clist_row[2] = "P"; else clist_row[2] = "S"; - if (GetModelFeature(FN_CALLERGROUPS)!=0) + if (phoneMonitor.supported & PM_CALLERGROUP) clist_row[3] = xgnokiiConfig.callerGroups[newPbEntry->entry.Group]; else clist_row[3] = ""; @@ -1077,7 +1104,7 @@ static void CreateEditDialog (EditEntryData *editEntryData, gchar *title, gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 2); gtk_widget_show (label); - if (GetModelFeature(FN_PHONEBOOK)==F_PBK71INT) + if (phoneMonitor.supported & PM_EXTPBK) { button = gtk_button_new (); editEntryData->number = gtk_label_new (""); @@ -1097,7 +1124,7 @@ static void CreateEditDialog (EditEntryData *editEntryData, gchar *title, gtk_widget_show (editEntryData->number); } -/* if (GetModelFeature(FN_PHONEBOOK)==F_PBK71INT) { +/* if (phoneMonitor.supported & PM_EXTPBK) { hbox = gtk_hbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER (GTK_DIALOG (editEntryData->dialog)->vbox), hbox); @@ -1160,7 +1187,7 @@ static void EditPbEntry(PhonebookEntry *pbEntry, gint row) gtk_entry_set_text (GTK_ENTRY (editEditEntryData.name), pbEntry->entry.Name); - if (GetModelFeature(FN_PHONEBOOK)==F_PBK71INT) + if (phoneMonitor.supported & PM_EXTPBK) gtk_label_set_text (GTK_LABEL (editEditEntryData.number), pbEntry->entry.Number); else gtk_entry_set_text (GTK_ENTRY (editEditEntryData.number), pbEntry->entry.Number); @@ -1173,7 +1200,7 @@ static void EditPbEntry(PhonebookEntry *pbEntry, gint row) gtk_option_menu_set_history( GTK_OPTION_MENU (editEditEntryData.group), pbEntry->entry.Group); - if (GetModelFeature(FN_CALLERGROUPS)!=0) + if (phoneMonitor.supported & PM_CALLERGROUP) { gtk_widget_show (editEditEntryData.group); gtk_widget_show (editEditEntryData.groupLabel); @@ -1253,7 +1280,7 @@ void NewPbEntry(PhonebookEntry *pbEntry) gtk_entry_set_text (GTK_ENTRY (newEditEntryData.name), ""); - if (GetModelFeature(FN_PHONEBOOK)==F_PBK71INT) + if (phoneMonitor.supported & PM_EXTPBK) gtk_label_set_text (GTK_LABEL (newEditEntryData.number), ""); else gtk_entry_set_text (GTK_ENTRY (newEditEntryData.number), ""); @@ -1266,7 +1293,7 @@ void NewPbEntry(PhonebookEntry *pbEntry) gtk_option_menu_set_history( GTK_OPTION_MENU (newEditEntryData.group), pbEntry->entry.Group); - if (GetModelFeature(FN_CALLERGROUPS)!=0) + if (phoneMonitor.supported & PM_CALLERGROUP) { gtk_widget_show (newEditEntryData.group); gtk_widget_show (newEditEntryData.groupLabel); @@ -1297,7 +1324,7 @@ void DuplicatePbEntry (PhonebookEntry *pbEntry) gtk_entry_set_text (GTK_ENTRY (duplicateEditEntryData.name), pbEntry->entry.Name); - if (GetModelFeature(FN_PHONEBOOK)==F_PBK71INT) + if (phoneMonitor.supported & PM_EXTPBK) gtk_label_set_text (GTK_LABEL (duplicateEditEntryData.number), pbEntry->entry.Number); else gtk_entry_set_text (GTK_ENTRY (duplicateEditEntryData.number), pbEntry->entry.Number); @@ -1310,7 +1337,7 @@ void DuplicatePbEntry (PhonebookEntry *pbEntry) gtk_option_menu_set_history( GTK_OPTION_MENU (duplicateEditEntryData.group), pbEntry->entry.Group); - if (GetModelFeature(FN_CALLERGROUPS)!=0) + if (phoneMonitor.supported & PM_CALLERGROUP) { gtk_widget_show (duplicateEditEntryData.group); gtk_widget_show (duplicateEditEntryData.groupLabel); @@ -2030,7 +2057,7 @@ void GUI_RefreshContacts (void) row[2] = "P"; else row[2] = "S"; - if (GetModelFeature(FN_CALLERGROUPS)!=0) + if (phoneMonitor.supported & PM_CALLERGROUP) row[3] = xgnokiiConfig.callerGroups[pbEntry->entry.Group]; else row[3] = ""; @@ -2220,7 +2247,6 @@ Setting max SIM entries to 100!\n")); mla->min = 1; mla->max = memoryStatus.MaxME; mla->type = GMT_ME; - mla->used = memoryStatus.UsedME; //MW mla->InsertEntry = InsertPBEntryME; mla->ReadFailed = ReadFailedPBEntry; @@ -2243,7 +2269,6 @@ Setting max SIM entries to 100!\n")); mla->min = 1; mla->max = memoryStatus.MaxSM; mla->type = GMT_SM; - mla->used = memoryStatus.UsedSM; //MW mla->InsertEntry = InsertPBEntrySM; mla->ReadFailed = ReadFailedPBEntry; @@ -2327,7 +2352,7 @@ inline void GUI_ShowContacts (void) GUI_Refresh (); GUI_InitCallerGroupsInf (); } - gtk_clist_set_column_visibility (GTK_CLIST (clist), 3, (GetModelFeature(FN_CALLERGROUPS)!=0)); + gtk_clist_set_column_visibility (GTK_CLIST (clist), 3, phoneMonitor.supported & PM_CALLERGROUP); GUI_RefreshContacts (); gtk_widget_show (GUI_ContactsWindow); // if (!contactsMemoryInitialized) @@ -2361,7 +2386,7 @@ static void ExportVCARD (FILE *f) fprintf (f, "X_GSM_CALLERGROUP:%d\n", pbEntry->entry.Group); /* Add ext. pbk info if required */ - if (GetModelFeature(FN_PHONEBOOK)==F_PBK71INT) + if (phoneMonitor.supported & PM_EXTPBK) for (j = 0; j < pbEntry->entry.SubEntriesCount; j++) { if (pbEntry->entry.SubEntries[j].EntryType == GSM_Number) @@ -2420,7 +2445,7 @@ static void ExportNative (FILE *f) strcat (buf, buf2); /* Add ext. pbk info if required */ - if (GetModelFeature(FN_PHONEBOOK)==F_PBK71INT) + if (phoneMonitor.supported & PM_EXTPBK) { for (j = 0; j < pbEntry->entry.SubEntriesCount; j++) if (pbEntry->entry.SubEntries[j].EntryType==GSM_Number) @@ -3120,7 +3145,7 @@ SelectContactData *GUI_SelectContactDialog (void) gtk_clist_set_column_width (GTK_CLIST(selectContactData.clist), 1, 115); gtk_clist_set_column_width (GTK_CLIST(selectContactData.clist), 3, 70); gtk_clist_set_column_justification (GTK_CLIST(selectContactData.clist), 2, GTK_JUSTIFY_CENTER); - gtk_clist_set_column_visibility (GTK_CLIST(selectContactData.clist), 3, (GetModelFeature(FN_CALLERGROUPS)!=0)); + gtk_clist_set_column_visibility (GTK_CLIST(selectContactData.clist), 3, phoneMonitor.supported & PM_CALLERGROUP); for (i = 0; i < 4; i++) { @@ -3174,7 +3199,7 @@ SelectContactData *GUI_SelectContactDialog (void) row[2] = "P"; else row[2] = "S"; - if (GetModelFeature(FN_CALLERGROUPS)!=0) + if (phoneMonitor.supported & PM_CALLERGROUP) row[3] = xgnokiiConfig.callerGroups[pbEntry->entry.Group]; else row[3] = ""; @@ -3275,6 +3300,7 @@ void GUI_CreateContactsWindow (void) InitMainMenu (); contactsMemoryInitialized = FALSE; GUI_ContactsWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL); + gtk_window_set_wmclass (GTK_WINDOW (GUI_ContactsWindow), "ContactsWindow", "Xgnokii"); gtk_window_set_title (GTK_WINDOW (GUI_ContactsWindow), _("Contacts")); gtk_widget_set_usize (GTK_WIDGET (GUI_ContactsWindow), 436, 220); //gtk_container_set_border_width (GTK_CONTAINER (GUI_ContactsWindow), 10); @@ -3370,7 +3396,7 @@ void GUI_CreateContactsWindow (void) gtk_clist_set_column_width (GTK_CLIST (clist), 1, 115); gtk_clist_set_column_width (GTK_CLIST (clist), 3, 70); gtk_clist_set_column_justification (GTK_CLIST (clist), 2, GTK_JUSTIFY_CENTER); -// gtk_clist_set_column_visibility (GTK_CLIST (clist), 3, (GetModelFeature(FN_CALLERGROUPS)!=0)); +// gtk_clist_set_column_visibility (GTK_CLIST (clist), 3, phoneMonitor.supported & PM_CALLERGROUP); for (i = 0; i < 4; i++) { diff --git a/xgnokii/xgnokii_contacts.h b/xgnokii/xgnokii_contacts.h index 66a4dcf..49c6641 100644 --- a/xgnokii/xgnokii_contacts.h +++ b/xgnokii/xgnokii_contacts.h @@ -3,11 +3,21 @@ X G N O K I I A Linux/Unix GUI for Nokia mobile phones. + Copyright (C) 1999 Pavel Janík ml., Hugh Blemings + & Ján Derfiòák . Released under the terms of the GNU GPL, see file COPYING for more details. $Id$ + $Log$ + Revision 1.1.1.4 2002/04/03 00:08:28 short + Found in "gnokii-working" directory, some November-patches version + + Revision 1.12 2001/02/02 08:09:57 ja + New dialogs for 6210/7110 in xgnokii. Fixed the smsd for new capabilty code. + + */ #ifndef XGNOKII_CONTACTS_H diff --git a/xgnokii/xgnokii_data.c b/xgnokii/xgnokii_data.c index fb0aa34..f6a65e8 100644 --- a/xgnokii/xgnokii_data.c +++ b/xgnokii/xgnokii_data.c @@ -3,9 +3,14 @@ X G N O K I I A Linux/Unix GUI for Nokia mobile phones. + Copyright (C) 1999 Pavel Janík ml., Hugh Blemings + & Ján Derfiòák . Released under the terms of the GNU GPL, see file COPYING for more details. + Last modification: Tues 13 June 2000 + Modified by Chris Kemp + */ #include @@ -24,7 +29,7 @@ static GtkWidget *label = NULL; static inline void Help1 (GtkWidget *w, gpointer data) { - gchar *indx = g_strdup_printf ("/%s/gnokii/xgnokii/data/index.htm", xgnokiiConfig.locale); + gchar *indx = g_strdup_printf ("/help/%s/windows/data/index.html", xgnokiiConfig.locale); Help (w, indx); g_free (indx); } @@ -47,12 +52,14 @@ static void UpdateStatus (void) inline void GUI_ShowData (void) { - if (GetModelFeature(FN_DATACALLS)==0) + if (!phoneMonitor.supported & PM_DATA) return; if (TerminateThread) { +#if 0 VM_Terminate (); +#endif enabled = false; TerminateThread = false; } @@ -70,7 +77,9 @@ inline void GUI_HideData(void) static inline void DisableData (GtkWidget *widget, gpointer data ) { +#if 0 VM_Terminate (); +#endif enabled = false; UpdateStatus (); } @@ -81,9 +90,10 @@ static inline void EnableData (GtkWidget *widget, { TerminateThread = false; +#if 0 VM_Initialise (xgnokiiConfig.model, xgnokiiConfig.port, - 0, 0, xgnokiiConfig.bindir, false, false, - xgnokiiConfig.synchronizetime); + 0, 0, xgnokiiConfig.bindir, false, false); +#endif enabled = true; UpdateStatus (); } @@ -94,6 +104,7 @@ void GUI_CreateDataWindow (void) GtkWidget *button, *hbox, *vbox; GUI_DataWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL); + gtk_window_set_wmclass (GTK_WINDOW (GUI_DataWindow), "DataWindow", "Xgnokii"); gtk_window_set_title (GTK_WINDOW (GUI_DataWindow), _("Virtual Modem")); gtk_container_set_border_width (GTK_CONTAINER (GUI_DataWindow), 10); gtk_signal_connect (GTK_OBJECT (GUI_DataWindow), "delete_event", diff --git a/xgnokii/xgnokii_data.h b/xgnokii/xgnokii_data.h index 75c33a3..d71a331 100644 --- a/xgnokii/xgnokii_data.h +++ b/xgnokii/xgnokii_data.h @@ -3,9 +3,14 @@ X G N O K I I A Linux/Unix GUI for Nokia mobile phones. + Copyright (C) 1999 Pavel Janík ml., Hugh Blemings + & Ján Derfiòák . Released under the terms of the GNU GPL, see file COPYING for more details. + Last modification: Tue Nov 27 1999 + Modified by Jan Derfinak + */ #ifndef XGNOKII_DATA_H diff --git a/xgnokii/xgnokii_dtmf.c b/xgnokii/xgnokii_dtmf.c index 7022db8..54ee4bc 100644 --- a/xgnokii/xgnokii_dtmf.c +++ b/xgnokii/xgnokii_dtmf.c @@ -3,9 +3,14 @@ X G N O K I I A Linux/Unix GUI for Nokia mobile phones. + Copyright (C) 1999 Pavel Janík ml., Hugh Blemings + & Ján Derfiòák . Released under the terms of the GNU GPL, see file COPYING for more details. + Last modification: Sun Apr 30 2000 + Modified by Jan Derfinak + */ #include @@ -28,7 +33,7 @@ static gchar *saveFileName; static inline void Help1 (GtkWidget *w, gpointer data) { - gchar *indx = g_strdup_printf ("/%s/gnokii/xgnokii/dtmf/index.htm", xgnokiiConfig.locale); + gchar *indx = g_strdup_printf ("/help/%s/windows/dtmf/index.html", xgnokiiConfig.locale); Help (w, indx); g_free (indx); } @@ -237,6 +242,7 @@ void GUI_CreateDTMFWindow () InitMainMenu (); GUI_DTMFWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL); + gtk_window_set_wmclass (GTK_WINDOW (GUI_DTMFWindow), "DTMFWindow", "Xgnokii"); gtk_window_set_title (GTK_WINDOW (GUI_DTMFWindow), _("Dial Tone")); //gtk_widget_set_usize (GTK_WIDGET (GUI_DTMFWindow), 436, 220); gtk_signal_connect (GTK_OBJECT (GUI_DTMFWindow), "delete_event", diff --git a/xgnokii/xgnokii_dtmf.h b/xgnokii/xgnokii_dtmf.h index 2bc2649..737c1f0 100644 --- a/xgnokii/xgnokii_dtmf.h +++ b/xgnokii/xgnokii_dtmf.h @@ -3,9 +3,14 @@ X G N O K I I A Linux/Unix GUI for Nokia mobile phones. + Copyright (C) 1999 Pavel Janík ml., Hugh Blemings + & Ján Derfiòák . Released under the terms of the GNU GPL, see file COPYING for more details. + Last modification: Tue Nov 27 1999 + Modified by Jan Derfinak + */ #ifndef XGNOKII_DTMF_H diff --git a/xgnokii/xgnokii_logos.c b/xgnokii/xgnokii_logos.c index 61a6ae9..edbc4ce 100644 --- a/xgnokii/xgnokii_logos.c +++ b/xgnokii/xgnokii_logos.c @@ -1,16 +1,47 @@ +/* + + $Id$ + + X G N O K I I + + A Linux/Unix GUI for Nokia mobile phones. + Copyright (C) 1999 Pavel Janík ml., Hugh Blemings + & Ján Derfiòák . + + Released under the terms of the GNU GPL, see file COPYING for more details. + + $Log$ + Revision 1.1.1.5 2002/04/03 00:08:33 short + Found in "gnokii-working" directory, some November-patches version + + Revision 1.9 2001/09/14 12:53:00 pkot + New preview logos. + Localization fixes. + Set valid operator on logos xgnokii screen. + + Revision 1.8 2001/05/24 20:47:31 chris + More updating of 7110 code and some of xgnokii_lowlevel changed over. + + Revision 1.7 2001/03/23 08:24:56 ja + New preview for 6210 in xgnokii's logos module. + + +*/ + +#include #include #include #include #include #include #include -#include #include "misc.h" #include "gsm-common.h" #include "gsm-api.h" +#include "cfgreader.h" #include "gsm-networks.h" -#include "files/gsm-filetypes.h" +#include "gsm-filetypes.h" #include "gsm-bitmaps.h" #include "xgnokii_logos.h" @@ -28,7 +59,10 @@ #include "xpm/New.xpm" #include "xpm/Send.xpm" +#include "xpm/SendSMS.xpm" #include "xpm/Read.xpm" +#include "xpm/Open.xpm" +#include "xpm/Save.xpm" #include "xpm/Edit_invert.xpm" #include "xpm/Edit_flip_horizontal.xpm" @@ -40,36 +74,37 @@ #include "xpm/Tool_filled_rectangle.xpm" extern GSM_Network GSM_Networks[]; +extern GSM_Statemachine xgnokii_statemachine; /* from xgnokii_lowlevel.c */ -static GtkWidget *GUI_LogosWindow; +GtkWidget *GUI_LogosWindow; -static ErrorDialog errorDialog = {NULL, NULL}; -static InfoDialog infoDialog = {NULL, NULL}; +ErrorDialog errorDialog = {NULL, NULL}; +InfoDialog infoDialog = {NULL, NULL}; /* stuff for drawingArea */ -static GtkWidget *drawingArea = NULL; -static GdkPixmap *drawingPixmap = NULL; -static GdkPixmap *greenPointPixmap, *blackPointPixmap; -static int drawingAreaWidth, drawingAreaHeight; /* in pixels */ -static int mouseButtonPushed = 0; +GtkWidget *drawingArea = NULL; +GdkPixmap *drawingPixmap = NULL; +GdkPixmap *greenPointPixmap, *blackPointPixmap; +int drawingAreaWidth, drawingAreaHeight; /* in pixels */ +int mouseButtonPushed = 0; /* stuff for previewArea */ -static GtkWidget *previewArea = NULL; -static GdkPixmap *previewPixmap = NULL; -static GdkPixmap *greenPixelPixmap; -static int previewPixmapWidth, previewPixmapHeight; -static int previewAvailable = 1, showPreviewErrorDialog = 1; -static int previewPixmapNumber = 0; +GtkWidget *previewArea = NULL; +GdkPixmap *previewPixmap = NULL; +GdkPixmap *greenPixelPixmap; +int previewPixmapWidth, previewPixmapHeight; +int previewAvailable = 1, showPreviewErrorDialog = 1; +int previewPixmapNumber = 0; -static GSM_Bitmap bitmap, oldBitmap; -static GSM_NetworkInfo networkInfo; +GSM_Bitmap bitmap, oldBitmap; +GSM_NetworkInfo networkInfo; /* widgets for toolbar - some, need global variables */ -static GtkWidget *buttonStartup, *buttonOperator, *buttonCaller, *buttonPicture; -static GtkWidget *networkCombo, *callerCombo; +GtkWidget *buttonStartup, *buttonOperator, *buttonCaller; +GtkWidget *networkCombo, *callerCombo; -static int activeTool = TOOL_BRUSH; -static int toolStartX, toolStartY, toolLastX, toolLastY; +int activeTool = TOOL_BRUSH; +int toolStartX, toolStartY, toolLastX, toolLastY; /* tools for drawing */ static GtkWidget *buttonBrush, *buttonLine, *buttonRectangle; @@ -212,6 +247,7 @@ GdkPixmap *GetPreviewPixmap (GtkWidget *widget) { pixmap = gdk_pixmap_create_from_xpm(widget->window,&mask, &widget->style->bg[GTK_STATE_NORMAL], file); + g_free(file); return pixmap; @@ -225,8 +261,7 @@ void SetPreviewPoint(GtkWidget *widget, int x, int y, int update) { if (!previewAvailable) return; /* there is difference between positiong of startupLogo and others */ - if (bitmap.type != GSM_StartupLogo && bitmap.type != GSM_7110StartupLogo && - bitmap.type != GSM_6210StartupLogo) { + if (bitmap.type != GSM_StartupLogo) { x += PREVIEWJUMPX; y += PREVIEWJUMPY; } @@ -253,8 +288,7 @@ void ClearPreviewPoint(GtkWidget *widget, int x, int y, int update) { if (!previewAvailable) return; /* there is difference between positiong of startupLogo and others */ - if (bitmap.type != GSM_StartupLogo && bitmap.type != GSM_7110StartupLogo && - bitmap.type != GSM_6210StartupLogo) { + if (bitmap.type != GSM_StartupLogo) { x += PREVIEWJUMPX; y += PREVIEWJUMPY; } @@ -282,7 +316,7 @@ int IsPoint(int x, int y) { } void SetPoint(GtkWidget *widget, int x, int y, int update) { - + /* difference between settings points in startupLogo and others */ GSM_SetPointBitmap(&bitmap,x,y); /* draw point to pixmap */ @@ -307,7 +341,7 @@ void SetPoint(GtkWidget *widget, int x, int y, int update) { } void ClearPoint(GtkWidget *widget, int x, int y, int update) { - + /* difference between settings points in startupLogo and others */ GSM_ClearPointBitmap(&bitmap,x,y); /* clear point from pixmap */ @@ -341,8 +375,7 @@ void UpdatePointsRectangle(GtkWidget *widget, int x1, int y1, int x2, int y2) { GdkRectangle updateRect; int x, y, dx = 0, dy = 0; - if (bitmap.type != GSM_StartupLogo && bitmap.type != GSM_7110StartupLogo && - bitmap.type != GSM_6210StartupLogo) { + if (bitmap.type != GSM_StartupLogo) { dx = PREVIEWJUMPX; dy = PREVIEWJUMPY; } @@ -411,9 +444,8 @@ void UpdatePreviewPoints (void) { int x, y, dx = 0, dy = 0; if (!previewPixmap || !previewAvailable) return; - - if (bitmap.type != GSM_StartupLogo && bitmap.type != GSM_7110StartupLogo && - bitmap.type != GSM_6210StartupLogo) { + + if (bitmap.type != GSM_StartupLogo) { dx = PREVIEWJUMPX; dy = PREVIEWJUMPY; } @@ -453,97 +485,81 @@ void ToolBrush(GtkWidget *widget, int column, int row, int button) { } /* TOOL - LINE */ -/* going to rewrite to Bresenham algorithm */ -static void ToolLineUpdate(GtkWidget *widget, int column, int row) { - double delta, y, x; - int i, x1, y1, x2, y2; - - if (abs(toolStartX-toolLastX) >= abs(toolStartY-toolLastY)) { - if (toolStartX > toolLastX) { - x1 = toolLastX; - x2 = toolStartX; - y1 = toolLastY; - y2 = toolStartY; - } else { - x1 = toolStartX; - x2 = toolLastX; - y1 = toolStartY; - y2 = toolLastY; - } - - delta = ((double)(y2-y1))/((double)(x2-x1)); - y = (double)y1; - for (i = x1;i <= x2;i++) { - if (!GSM_IsPointBitmap(&oldBitmap,i,(int)y)) ClearPoint(widget,i,(int)y,0); - y += delta; - } - } else { - if (toolStartY > toolLastY) { - x1 = toolLastX; - x2 = toolStartX; - y1 = toolLastY; - y2 = toolStartY; - } else { - x1 = toolStartX; - x2 = toolLastX; - y1 = toolStartY; - y2 = toolLastY; - } - delta = ((double)(x2-x1))/((double)(y2-y1)); - - x = (double)x1; - for (i = y1;i <= y2;i++) { - if (!GSM_IsPointBitmap(&oldBitmap,(int)x,i)) ClearPoint(widget,(int)x,i,0); - x += delta; - } - } - - if (abs(toolStartX-column) >= abs(toolStartY-row)) { - if (toolStartX > column) { - x1 = column; - x2 = toolStartX; - y1 = row; - y2 = toolStartY; - } else { - x1 = toolStartX; - x2 = column; - y1 = toolStartY; - y2 = row; - } - - delta = ((double)(y2-y1))/((double)(x2-x1)); - y = (double)y1; - for (i = x1;i <= x2;i++) { - SetPoint(widget,i,(int)y,0); - y += delta; - } - } else { - if (toolStartY > row) { - x1 = column; - x2 = toolStartX; - y1 = row; - y2 = toolStartY; - } else { - x1 = toolStartX; - x2 = column; - y1 = toolStartY; - y2 = row; - } - delta = ((double)(x2-x1))/((double)(y2-y1)); +/* this function clear or draw a line on the screen USED BY TOOLLINEUPDATE */ +void ToolLine(GtkWidget *widget, int x1, int y1, int x2, int y2, int draw) { + int udx, udy, dx, dy, error, loop, xadd, yadd; + + dx = x2 - x1; /* x delta */ + dy = y2 - y1; /* y delta */ + + udx = abs(dx); /* unsigned x delta */ + udy = abs(dy); /* unsigned y delta */ + + if (dx < 0) { xadd = -1; } else { xadd = 1; } /* set directions */ + if (dy < 0) { yadd = -1; } else { yadd = 1; } + + error = 0; + loop = 0; + if (udx > udy) { /* delta X > delta Y */ + do { + error += udy; + + if (error >= udx) { /* is time to move up or down? */ + error -= udx; + y1 += yadd; + } + loop++; + if (draw == 1) { + SetPoint(widget,x1,y1,0); + } else { + /* now clearing line before drawing new one, we must check */ + /* if there is a point in oldBitmap which saves bitmap before */ + /* we starting drawing new line */ + if (!GSM_IsPointBitmap(&oldBitmap,x1,y1)) { + ClearPoint(widget,x1,y1,0); + } + } + x1 += xadd; /* move horizontally */ + } while (loop < udx); /* repeat for x length */ + } else { + do { + error += udx; + if (error >= udy) { /* is time to move left or right? */ + error -= udy; + x1 += xadd; + } + loop++; + if (draw == 1) { + SetPoint(widget,x1,y1,0); + } else { + /* check comment in delta X > delta Y */ + if (!GSM_IsPointBitmap(&oldBitmap,x1,y1)) { + ClearPoint(widget,x1,y1,0); + } + } + y1 += yadd; /* move vertically */ + } while (loop < udy); /* repeat for y length */ + } +} - x = (double)x1; - for (i = y1;i <= y2;i++) { - SetPoint(widget,(int)x,i,0); - x += delta; - } - } +/* going to rewrite to Bresenham algorithm */ +void ToolLineUpdate(GtkWidget *widget, int column, int row) { + /* clear old line */ + ToolLine(widget,toolStartX,toolStartY,toolLastX,toolLastY,0); + /* draw new one */ + ToolLine(widget,toolStartX,toolStartY,column,row,1); } /* TOOL - FILLED RECT */ -static void ToolFilledRectangleUpdate(GtkWidget *widget, int column, int row) { + +/* FIXME - going to rewrite for optimalized version, clearing and */ +/* drawing new parts only before clearing and drawing whole */ +/* filled rectangle - it's too slow on diskless terminal ;(( */ +void ToolFilledRectangleUpdate(GtkWidget *widget, int column, int row) { int i, j, x1, y1, x2, y2; + /* swap Xs to x1 < x2 */ if (toolStartX > toolLastX) { x1 = toolLastX; x2 = toolStartX; @@ -552,6 +568,7 @@ static void ToolFilledRectangleUpdate(GtkWidget *widget, int column, int row) { x2 = toolLastX; } + /* swap Ys to y1 < y2 */ if (toolStartY > toolLastY) { y1 = toolLastY; y2 = toolStartY; @@ -560,10 +577,12 @@ static void ToolFilledRectangleUpdate(GtkWidget *widget, int column, int row) { y2 = toolLastY; } + /* clear one now */ for (j = y1;j <= y2;j++) for (i = x1;i <= x2;i++) if (!GSM_IsPointBitmap(&oldBitmap,i,j)) ClearPoint(widget,i,j,0); + /* swap Xs to x1 < x2 */ if (toolStartX > column) { x1 = column; x2 = toolStartX; @@ -572,6 +591,7 @@ static void ToolFilledRectangleUpdate(GtkWidget *widget, int column, int row) { x2 = column; } + /* swap Ys to y1 < y2 */ if (toolStartY > row) { y1 = row; y2 = toolStartY; @@ -580,16 +600,18 @@ static void ToolFilledRectangleUpdate(GtkWidget *widget, int column, int row) { y2 = row; } + /* draw new one */ for (j = y1;j <= y2;j++) for (i = x1;i <= x2;i++) SetPoint(widget,i,j,0); } /* TOOL - RECTANGLE */ -static void ToolRectangleUpdate(GtkWidget *widget, int column, int row) { +void ToolRectangleUpdate(GtkWidget *widget, int column, int row) { int i, j, x1, y1, x2, y2; /* clear old rectangle */ + /* swap Xs to x1 < x2 */ if (toolStartX > toolLastX) { x1 = toolLastX; x2 = toolStartX; @@ -598,6 +620,7 @@ static void ToolRectangleUpdate(GtkWidget *widget, int column, int row) { x2 = toolLastX; } + /* swap Ys to y1 < y2 */ if (toolStartY > toolLastY) { y1 = toolLastY; y2 = toolStartY; @@ -606,6 +629,7 @@ static void ToolRectangleUpdate(GtkWidget *widget, int column, int row) { y2 = toolLastY; } + /* clear old one */ for (i = x1;i <= x2;i++) { if (!GSM_IsPointBitmap(&oldBitmap,i,y1)) ClearPoint(widget,i,y1,0); if (!GSM_IsPointBitmap(&oldBitmap,i,y2)) ClearPoint(widget,i,y2,0); @@ -617,6 +641,7 @@ static void ToolRectangleUpdate(GtkWidget *widget, int column, int row) { } /* draw new rectangle */ + /* swap Xs to x1 < x2 */ if (toolStartX > column) { x1 = column; x2 = toolStartX; @@ -625,6 +650,7 @@ static void ToolRectangleUpdate(GtkWidget *widget, int column, int row) { x2 = column; } + /* swap Ys to y1 < y2 */ if (toolStartY > row) { y1 = row; y2 = toolStartY; @@ -633,6 +659,7 @@ static void ToolRectangleUpdate(GtkWidget *widget, int column, int row) { y2 = row; } + /* draw new one */ for (i = x1;i <= x2;i++) { if (!IsPoint(i,y1)) SetPoint(widget,i,y1,0); if (!IsPoint(i,y2)) SetPoint(widget,i,y2,0); @@ -644,20 +671,24 @@ static void ToolRectangleUpdate(GtkWidget *widget, int column, int row) { } } -static void UpdateToolScreen(GtkWidget *widget, int x1, int y1, int x2, int y2) { +/* this update tools actions on the screen - this is for optimalization */ +/* eg. for faster redrawing tools actions - we do not need redraw pixel */ +/* by pixel. Faster is redraw whole rectangle which contains all changes */ +void UpdateToolScreen(GtkWidget *widget, int x1, int y1, int x2, int y2) { GdkRectangle updateRect; /* update preview area */ - updateRect.x = PREVIEWSTARTX+x1; - updateRect.y = PREVIEWSTARTY+y1; - if (bitmap.type != GSM_StartupLogo && bitmap.type != GSM_7110StartupLogo && - bitmap.type != GSM_6210StartupLogo) { - updateRect.x += PREVIEWJUMPX; - updateRect.y += PREVIEWJUMPY; - } - updateRect.width = x2-x1+1; - updateRect.height = y2-y1+1; - gtk_widget_draw(previewArea,&updateRect); + if (previewAvailable) { + updateRect.x = PREVIEWSTARTX+x1; + updateRect.y = PREVIEWSTARTY+y1; + if (bitmap.type != GSM_StartupLogo) { + updateRect.x += PREVIEWJUMPX; + updateRect.y += PREVIEWJUMPY; + } + updateRect.width = x2-x1+1; + updateRect.height = y2-y1+1; + gtk_widget_draw(previewArea,&updateRect); + } /* update drawing area */ updateRect.x = x1 * (POINTSIZE+1); @@ -672,7 +703,7 @@ static void UpdateToolScreen(GtkWidget *widget, int x1, int y1, int x2, int y2) * ************************************* */ -static gint PreviewAreaButtonPressEvent(GtkWidget *widget, GdkEventButton *event) { +gint PreviewAreaButtonPressEvent(GtkWidget *widget, GdkEventButton *event) { previewPixmapNumber = (previewPixmapNumber % 8) + 1; gtk_drawing_area_size(GTK_DRAWING_AREA(previewArea), @@ -681,7 +712,7 @@ static gint PreviewAreaButtonPressEvent(GtkWidget *widget, GdkEventButton *event return TRUE; } -static gint PreviewAreaConfigureEvent(GtkWidget *widget, GdkEventConfigure *event) { +gint PreviewAreaConfigureEvent(GtkWidget *widget, GdkEventConfigure *event) { if (previewPixmap) gdk_pixmap_unref(previewPixmap); previewPixmap = GetPreviewPixmap(widget); @@ -690,7 +721,7 @@ static gint PreviewAreaConfigureEvent(GtkWidget *widget, GdkEventConfigure *even return TRUE; } -static gint PreviewAreaExposeEvent(GtkWidget *widget, GdkEventExpose *event) { +gint PreviewAreaExposeEvent(GtkWidget *widget, GdkEventExpose *event) { /* got previewPixmap? */ if (previewPixmap) /* yes - simply redraw some rectangle */ @@ -706,7 +737,7 @@ static gint PreviewAreaExposeEvent(GtkWidget *widget, GdkEventExpose *event) { * ******************************** */ -static gint DrawingAreaButtonPressEvent(GtkWidget *widget, GdkEventButton *event) { +gint DrawingAreaButtonPressEvent(GtkWidget *widget, GdkEventButton *event) { /* got drawingPixmap? */ if (drawingPixmap == NULL) return TRUE; @@ -769,14 +800,14 @@ static gint DrawingAreaButtonPressEvent(GtkWidget *widget, GdkEventButton *event return TRUE; } -static gint DrawingAreaButtonReleaseEvent(GtkWidget *widget, GdkEventButton *event) { +gint DrawingAreaButtonReleaseEvent(GtkWidget *widget, GdkEventButton *event) { if (event->button == 1) mouseButtonPushed = 0; return TRUE; } -static gint DrawingAreaMotionNotifyEvent(GtkWidget *widget, GdkEventMotion *event) { +gint DrawingAreaMotionNotifyEvent(GtkWidget *widget, GdkEventMotion *event) { int x,y; GdkModifierType state; @@ -840,7 +871,7 @@ static gint DrawingAreaMotionNotifyEvent(GtkWidget *widget, GdkEventMotion *even } /* configureEvent? -> event when someone resize windows, ... */ -static gint DrawingAreaConfigureEvent(GtkWidget *widget, GdkEventConfigure *event) { +gint DrawingAreaConfigureEvent(GtkWidget *widget, GdkEventConfigure *event) { int x, y; /* got drawingPixmap? */ if (drawingPixmap) gdk_pixmap_unref(drawingPixmap); /* got, erase it */ @@ -862,7 +893,7 @@ static gint DrawingAreaConfigureEvent(GtkWidget *widget, GdkEventConfigure *even return TRUE; } -static gint DrawingAreaExposeEvent(GtkWidget *widget, GdkEventExpose *event) { +gint DrawingAreaExposeEvent(GtkWidget *widget, GdkEventExpose *event) { /* got drawingPixmap? */ if (drawingPixmap) /* got - draw it */ @@ -878,7 +909,7 @@ static gint DrawingAreaExposeEvent(GtkWidget *widget, GdkEventExpose *event) { * ***************************************** */ -static void GetNetworkInfoEvent(GtkWidget *widget) { +void GetNetworkInfoEvent(GtkWidget *widget) { GSM_Error error; PhoneEvent *e = (PhoneEvent *)g_malloc(sizeof(PhoneEvent)); D_NetworkInfo *data = (D_NetworkInfo *)g_malloc(sizeof(D_NetworkInfo)); @@ -909,9 +940,9 @@ static void GetNetworkInfoEvent(GtkWidget *widget) { GSM_GetNetworkName(networkInfo.NetworkCode)); } -static void GetLogoEvent(GtkWidget *widget) { - int i; +void GetLogoEvent(GtkWidget *widget) { GSM_Error error; + int i; PhoneEvent *e = (PhoneEvent *) g_malloc(sizeof(PhoneEvent)); D_Bitmap *data = (D_Bitmap *)g_malloc(sizeof(D_Bitmap)); char *operator = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(networkCombo)->entry)); @@ -921,12 +952,12 @@ static void GetLogoEvent(GtkWidget *widget) { data->bitmap = &bitmap; e->event = Event_GetBitmap; e->data = data; - if (GetModelFeature(FN_CALLERGROUPS)!=0) { + if (phoneMonitor.supported & PM_CALLERGROUP) { for (i = 0;i < 6;i++) if (strcmp(gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(callerCombo)->entry)), xgnokiiConfig.callerGroups[i]) == 0) bitmap.number = i; } - + /* launch event and wait for result */ GUI_InsertEvent(e); pthread_mutex_lock(&getBitmapMutex); @@ -947,7 +978,7 @@ static void GetLogoEvent(GtkWidget *widget) { } } -static void SetLogoEvent(GtkWidget *widget) { +void SetLogoEvent(GtkWidget *widget) { GSM_Error error; PhoneEvent *e = (PhoneEvent *)g_malloc(sizeof(PhoneEvent)); D_Bitmap *data = (D_Bitmap *)g_malloc(sizeof(D_Bitmap)); @@ -961,15 +992,12 @@ static void SetLogoEvent(GtkWidget *widget) { /* above condition must be there, because if you launch logos before * callerGroups are available, you will see segfault - callerGroups not initialized */ - if (GetModelFeature(FN_CALLERGROUPS)!=0) { + if (phoneMonitor.supported & PM_CALLERGROUP) { for (i = 0;i < 6;i++) if (strcmp(gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(callerCombo)->entry)), xgnokiiConfig.callerGroups[i]) == 0) bitmap.number = i; } } - if (bitmap.type == GSM_StartupLogo) { - bitmap.number=0; - } data->bitmap = &bitmap; e->event = Event_SetBitmap; @@ -992,16 +1020,174 @@ static void SetLogoEvent(GtkWidget *widget) { } } +typedef struct { + GtkWidget *dialog; + GtkWidget *entry; +} SendLogoDialog; +static SendLogoDialog sendLogoDialog = {NULL, NULL}; + +static void OkSendLogoDialog(GtkWidget *w, gpointer gtkdata) +{ + GSM_SMSMessage SMS; + GSM_Error error; + + char Data[7] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + + PhoneEvent *e = (PhoneEvent *)g_malloc(sizeof(PhoneEvent)); + D_SMSMessage *data = (D_SMSMessage *)g_malloc(sizeof(D_SMSMessage)); + char *number = gtk_entry_get_text(GTK_ENTRY(sendLogoDialog.entry)); + char *operator = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(networkCombo)->entry)); + char *opcode = GSM_GetNetworkCode(operator); + int i; + + int current=0; + + /* Default settings for SMS message: + - no delivery report + - Class Message 1 + - no compression + - 8 bit data + - SMSC no. 1 + - validity 3 days + - set UserDataHeaderIndicator + */ + + SMS.Type = GST_MO; + SMS.Class = 1; + SMS.Compression = false; + SMS.EightBit = true; + SMS.MessageCenter = xgnokiiConfig.smsSetting[0]; /* we need to at least set .Format ! */ + SMS.MessageCenter.No = 0; + SMS.Validity = 4320; /* 4320 minutes == 72 hours */ + SMS_SetupUDH(&SMS,bitmap.type); + + /* prepare data */ + + switch (bitmap.type) { + + case GSM_CallerLogo: + /* below condition must be there, because if you launch logos before + * callerGroups are available, you will see segfault - callerGroups not initialized + */ + if (phoneMonitor.supported & PM_CALLERGROUP) { + for (i = 0;i < 6;i++) + if (strcmp(gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(callerCombo)->entry)), + xgnokiiConfig.callerGroups[i]) == 0) bitmap.number = i; + } + break; + + case GSM_OperatorLogo: + opcode=GSM_GetNetworkCode(operator); + Data[current++] = ((opcode[1] & 0x0f) << 4) | (opcode[0] & 0xf); + Data[current++] = 0xf0 | (opcode[2] & 0x0f); + Data[current++] = ((opcode[5] & 0x0f) << 4) | (opcode[4] & 0xf); + break; + + default: /* unsupported */ + g_free(e); + g_free(data); + return; + } + + strncpy(SMS.Destination,number,sizeof(SMS.Destination)); + SMS.Destination[sizeof(SMS.Destination)-1]='\0'; + + /* Set the logo size */ + current++; + Data[current++] = bitmap.width; + Data[current++] = bitmap.height; + + Data[current++] = 0x01; + + memcpy(SMS.MessageText,Data,current); + memcpy(SMS.MessageText+current,bitmap.bitmap,bitmap.size); + SMS.MessageTextLength = current+bitmap.size; + + data->sms = &SMS; + e->event = Event_SendSMSMessage; + e->data = data; + + /* launch event and wait for result */ + GUI_InsertEvent(e); + pthread_mutex_lock (&sendSMSMutex); + pthread_cond_wait (&sendSMSCond, &sendSMSMutex); + pthread_mutex_unlock (&sendSMSMutex); + error = data->status; + g_free(data); + + /* watch for errors */ + if (error != GE_SMSSENDOK) { + gchar *buf = g_strdup_printf(_("Error sending bitmap\n(error=%d)"),error); + gtk_label_set_text(GTK_LABEL(errorDialog.text),buf); + gtk_widget_show(errorDialog.dialog); + g_free(buf); + } + + gtk_widget_hide (((SendLogoDialog *) gtkdata)->dialog); +} + +/* Here would be appropriate xgnokii_sms/ShowSelectContactsDialog() + * (and the multi-recipient handling code). + * I haven't implemented yet any such code as the whole XGnokii has broken + * design of hand-coded GTK+ GUI (even w/o any Gnome features) instead of Glade. + * The right solution is to drop 95% of XGNokii code, not to write yet another + * insane +2% of hand-coded GUI code. + */ +void SendLogoEvent(GtkWidget *widget) +{ + if (sendLogoDialog.dialog == NULL) + { + GtkWidget *button, *label; + + sendLogoDialog.dialog = gtk_dialog_new (); + gtk_window_set_title (GTK_WINDOW (sendLogoDialog.dialog), _("Send logo")); + gtk_window_set_modal(GTK_WINDOW (sendLogoDialog.dialog), TRUE); + gtk_container_set_border_width (GTK_CONTAINER (sendLogoDialog.dialog), 10); + gtk_signal_connect (GTK_OBJECT (sendLogoDialog.dialog), "delete_event", + GTK_SIGNAL_FUNC (DeleteEvent), NULL); + + button = gtk_button_new_with_label (_("Send")); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (sendLogoDialog.dialog)->action_area), + button, TRUE, TRUE, 10); + gtk_signal_connect (GTK_OBJECT (button), "clicked", + GTK_SIGNAL_FUNC (OkSendLogoDialog), (gpointer) &sendLogoDialog); + GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); + gtk_widget_grab_default (button); + gtk_widget_show (button); + + button = gtk_button_new_with_label (_("Cancel")); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (sendLogoDialog.dialog)->action_area), + button, TRUE, TRUE, 10); + gtk_signal_connect (GTK_OBJECT (button), "clicked", + GTK_SIGNAL_FUNC (CancelDialog), (gpointer) sendLogoDialog.dialog); + gtk_widget_show (button); + + gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (sendLogoDialog.dialog)->vbox), 5); + + label = gtk_label_new (_("Number:")); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (sendLogoDialog.dialog)->vbox), label, FALSE, FALSE, 5); + gtk_widget_show (label); + + sendLogoDialog.entry = gtk_entry_new_with_max_length (GSM_MAX_PHONEBOOK_NUMBER_LENGTH); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (sendLogoDialog.dialog)->vbox), sendLogoDialog.entry, FALSE, FALSE, 5); + gtk_widget_show (sendLogoDialog.entry); + } + + gtk_entry_set_text (GTK_ENTRY (sendLogoDialog.entry), ""); + + gtk_widget_show (sendLogoDialog.dialog); +} + static void ClearLogoEvent(GtkWidget *widget) { - bitmap.size=GSM_GetBitmapSize(&bitmap); + // bitmap.size=bitmap.width*bitmap.height/8; GSM_ClearBitmap(&bitmap); UpdatePoints(widget); } -static void InvertLogoEvent(GtkWidget *widget) { +void InvertLogoEvent(GtkWidget *widget) { int column, row; for (column = 0;column < bitmap.width;column++) @@ -1014,12 +1200,12 @@ static void InvertLogoEvent(GtkWidget *widget) { UpdatePoints(widget); } -static void UpLogoEvent(GtkWidget *widget) { +void UpLogoEvent(GtkWidget *widget) { int column, row; GSM_Bitmap tbitmap; - tbitmap=bitmap; + memcpy(&tbitmap,&bitmap,sizeof(GSM_Bitmap)); for (row = 0;row < bitmap.height-1;row++) for (column = 0;column < bitmap.width;column++) @@ -1030,19 +1216,19 @@ static void UpLogoEvent(GtkWidget *widget) { for (column = 0;column < bitmap.width;column++) if (GSM_IsPointBitmap(&tbitmap,column,0)) - GSM_SetPointBitmap(&bitmap,column,row); + GSM_SetPointBitmap(&bitmap,column,bitmap.height-1); else - GSM_ClearPointBitmap(&bitmap,column,row); + GSM_ClearPointBitmap(&bitmap,column,bitmap.height-1); UpdatePoints(widget); } -static void DownLogoEvent(GtkWidget *widget) { +void DownLogoEvent(GtkWidget *widget) { int column, row; GSM_Bitmap tbitmap; - tbitmap=bitmap; + memcpy(&tbitmap,&bitmap,sizeof(GSM_Bitmap)); for (row = bitmap.height-1;row > 0;row--) for (column = 0;column < bitmap.width;column++) @@ -1060,12 +1246,12 @@ static void DownLogoEvent(GtkWidget *widget) { UpdatePoints(widget); } -static void LeftLogoEvent(GtkWidget *widget) { +void LeftLogoEvent(GtkWidget *widget) { int column, row; GSM_Bitmap tbitmap; - tbitmap=bitmap; + memcpy(&tbitmap,&bitmap,sizeof(GSM_Bitmap)); for (column = 0; column < bitmap.width-1;column++) for (row = 0;row < bitmap.height;row++) @@ -1083,12 +1269,12 @@ static void LeftLogoEvent(GtkWidget *widget) { UpdatePoints(widget); } -static void RightLogoEvent(GtkWidget *widget) { +void RightLogoEvent(GtkWidget *widget) { int column, row; GSM_Bitmap tbitmap; - tbitmap=bitmap; + memcpy(&tbitmap,&bitmap,sizeof(GSM_Bitmap)); for (column = bitmap.width-1;column > 0;column--) for (row = 0;row < bitmap.height;row++) @@ -1106,7 +1292,7 @@ static void RightLogoEvent(GtkWidget *widget) { UpdatePoints(widget); } -static void FlipVerticalLogoEvent(GtkWidget *widget) { +void FlipVerticalLogoEvent(GtkWidget *widget) { int row, column, temp; for (row = 0;row < (bitmap.height/2);row++) @@ -1126,7 +1312,7 @@ static void FlipVerticalLogoEvent(GtkWidget *widget) { UpdatePoints(widget); } -static void FlipHorizontalLogoEvent(GtkWidget *widget) { +void FlipHorizontalLogoEvent(GtkWidget *widget) { int row, column, temp; for (row = 0;row < bitmap.height;row++) @@ -1148,7 +1334,7 @@ static void FlipHorizontalLogoEvent(GtkWidget *widget) { } /* this is launched when tool was changed */ -static gint ToolTypeEvent(GtkWidget *widget) { +gint ToolTypeEvent(GtkWidget *widget) { if (GTK_TOGGLE_BUTTON(buttonBrush)->active) activeTool = TOOL_BRUSH; else if (GTK_TOGGLE_BUTTON(buttonLine)->active) activeTool = TOOL_LINE; else if (GTK_TOGGLE_BUTTON(buttonRectangle)->active) activeTool = TOOL_RECTANGLE; else @@ -1159,53 +1345,33 @@ static gint ToolTypeEvent(GtkWidget *widget) { } /* this is launched when logo type was change by buttons on toolbar */ -static gint LogoTypeEvent(GtkWidget *widget) { +gint LogoTypeEvent(GtkWidget *widget) { int clear = 0; /* is startupLogo? */ - if (GTK_TOGGLE_BUTTON(buttonStartup)->active && - bitmap.type != GSM_StartupLogo && bitmap.type != GSM_6210StartupLogo && - bitmap.type != GSM_7110StartupLogo) { - /* look for old bitmap type, clean if another */ - clear = 1; - - if (!strcmp(xgnokiiConfig.model,"7110")) { - GSM_ResizeBitmap(&bitmap,GSM_7110StartupLogo); - } else if (!strcmp(xgnokiiConfig.model,"6210") || !strcmp(xgnokiiConfig.model,"6250")) { - GSM_ResizeBitmap(&bitmap,GSM_6210StartupLogo); - } else { - GSM_ResizeBitmap(&bitmap,GSM_StartupLogo); - } - } - - /* new type is PictureImage */ - if (GTK_TOGGLE_BUTTON(buttonPicture)->active && bitmap.type != GSM_PictureImage) { + /* Resize and clear anyway - CK */ + if (GTK_TOGGLE_BUTTON(buttonStartup)->active) { /* look for old bitmap type, clean if another */ clear = 1; - GSM_ResizeBitmap(&bitmap,GSM_PictureImage); + GSM_ResizeBitmap(&bitmap,GSM_StartupLogo, &xgnokii_statemachine.Phone.Info); } - - /* new type is callerLogo */ - if (GTK_TOGGLE_BUTTON(buttonCaller)->active && bitmap.type != GSM_CallerLogo) { - /* previous was startup or Picture ? clear and draw batteries, signal, ... */ - if (bitmap.type != GSM_OperatorLogo) clear = 1; - GSM_ResizeBitmap(&bitmap,GSM_CallerLogo); + + /* has phone support for callerGroups? */ + if (phoneMonitor.supported & PM_CALLERGROUP) { + if (GTK_TOGGLE_BUTTON(buttonCaller)->active && bitmap.type != GSM_CallerLogo) { + /* previous was startup? clear and draw batteries, signal, ... */ + /* Clear anyway for 7110...CK */ + clear = 1; + GSM_ResizeBitmap(&bitmap,GSM_CallerLogo, &xgnokii_statemachine.Phone.Info); + } } /* is new type operatorLogo? */ - if (GTK_TOGGLE_BUTTON(buttonOperator)->active && bitmap.type != GSM_OperatorLogo && - bitmap.type != GSM_7110OperatorLogo) { - - /* previous startup or Picture ? clear and draw batteries, signal, ... */ - if (bitmap.type != GSM_CallerLogo) clear = 1; - - if (!strcmp(xgnokiiConfig.model,"7110")) { - GSM_ResizeBitmap(&bitmap,GSM_7110OperatorLogo); - } else if (!strcmp(xgnokiiConfig.model,"6210") || !strcmp(xgnokiiConfig.model,"6250")) { - GSM_ResizeBitmap(&bitmap,GSM_7110OperatorLogo); - } else { - GSM_ResizeBitmap(&bitmap,GSM_OperatorLogo); - } + if (GTK_TOGGLE_BUTTON(buttonOperator)->active && bitmap.type != GSM_OperatorLogo) { + /* previous startup? clear and draw batteries, signal, ... */ + /* Clear anyway for 7110..CK */ + clear = 1; + GSM_ResizeBitmap(&bitmap,GSM_OperatorLogo, &xgnokii_statemachine.Phone.Info); } /* must clear? */ @@ -1227,7 +1393,7 @@ static gint LogoTypeEvent(GtkWidget *widget) { return 0; } -static inline void CloseLogosWindow (void) { +inline void CloseLogosWindow (void) { gtk_widget_hide(GUI_LogosWindow); } @@ -1297,7 +1463,7 @@ void ImportFileSelected(GtkWidget *w, GtkFileSelection *fs) gtk_widget_show(errorDialog.dialog); g_free(buf); return; - } + } else fclose(f); error=GSM_ReadBitmapFile(fileName,&tbitmap); if (error!=GE_NONE) { @@ -1313,42 +1479,19 @@ void ImportFileSelected(GtkWidget *w, GtkFileSelection *fs) gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(buttonStartup),false); gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(buttonOperator),false); gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(buttonCaller),false); - gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(buttonPicture),false); - - if (tbitmap.type==GSM_OperatorLogo || tbitmap.type==GSM_7110OperatorLogo) gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(buttonOperator),true); - if (tbitmap.type==GSM_StartupLogo || tbitmap.type==GSM_7110StartupLogo || tbitmap.type==GSM_6210StartupLogo) gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(buttonStartup),true); + + if (tbitmap.type==GSM_OperatorLogo) gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(buttonOperator),true); + if (tbitmap.type==GSM_StartupLogo) gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(buttonStartup),true); if (tbitmap.type==GSM_CallerLogo) gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(buttonCaller),true); - if (tbitmap.type==GSM_PictureImage) gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(buttonPicture),true); memcpy(&bitmap,&tbitmap,sizeof(GSM_Bitmap)); - - if (!strcmp(xgnokiiConfig.model,"7110")) { //7110 - if (bitmap.type==GSM_StartupLogo || bitmap.type==GSM_6210StartupLogo) - GSM_ResizeBitmap(&bitmap,GSM_7110StartupLogo); - - if (bitmap.type==GSM_OperatorLogo) - GSM_ResizeBitmap(&bitmap,GSM_7110OperatorLogo); - - } else if (!strcmp(xgnokiiConfig.model,"6210") || !strcmp(xgnokiiConfig.model,"6250")) { //6210,6250 - if (bitmap.type==GSM_StartupLogo || bitmap.type==GSM_7110StartupLogo) - GSM_ResizeBitmap(&bitmap,GSM_6210StartupLogo); - - if (bitmap.type==GSM_OperatorLogo) - GSM_ResizeBitmap(&bitmap,GSM_7110OperatorLogo); - - } else { - if (bitmap.type==GSM_6210StartupLogo || bitmap.type==GSM_7110StartupLogo) - GSM_ResizeBitmap(&bitmap,GSM_StartupLogo); - if (bitmap.type==GSM_7110OperatorLogo) - GSM_ResizeBitmap(&bitmap,GSM_OperatorLogo); - } UpdatePoints(drawingArea); } void SaveLogoAs(GtkWidget *widget) { - FileSelection=gtk_file_selection_new ("Save logo as ..."); + FileSelection=gtk_file_selection_new (_("Save logo as ...")); gtk_signal_connect ( GTK_OBJECT (GTK_FILE_SELECTION (FileSelection)->ok_button), @@ -1375,7 +1518,7 @@ void SaveLogo(GtkWidget *widget) void OpenLogo(GtkWidget *widget) { - FileSelection=gtk_file_selection_new ("Open logo..."); + FileSelection=gtk_file_selection_new (_("Open logo...")); gtk_signal_connect ( GTK_OBJECT (GTK_FILE_SELECTION (FileSelection)->ok_button), @@ -1400,6 +1543,7 @@ static GtkItemFactoryEntry logosMenuItems[] = { { NULL, "G", GetNetworkInfoEvent, 0, NULL}, { NULL, NULL, GetLogoEvent, 0, NULL}, { NULL, "T", SetLogoEvent, 0, NULL}, + { NULL, "N", SendLogoEvent, 0, NULL}, { NULL, NULL, NULL, 0, ""}, { NULL, "W", CloseLogosWindow, 0, NULL}, { NULL, NULL, NULL, 0, ""}, @@ -1415,7 +1559,7 @@ static GtkItemFactoryEntry logosMenuItems[] = { { NULL, "V", FlipVerticalLogoEvent, 0, NULL}, }; -static void InitLogosMenu (void) { +void InitLogosMenu (void) { logosMenuItems[0].path = g_strdup(_("/_File")); logosMenuItems[1].path = g_strdup(_("/File/_Open")); logosMenuItems[2].path = g_strdup(_("/File/_Save")); @@ -1424,19 +1568,20 @@ static void InitLogosMenu (void) { logosMenuItems[5].path = g_strdup(_("/File/_Get operator")); logosMenuItems[6].path = g_strdup(_("/File/Get _logo")); logosMenuItems[7].path = g_strdup(_("/File/Se_t logo")); - logosMenuItems[8].path = g_strdup(_("/File/Sep2")); - logosMenuItems[9].path = g_strdup(_("/File/_Close")); - logosMenuItems[10].path = g_strdup(_("/_Edit")); - logosMenuItems[11].path = g_strdup(_("/Edit/_Clear")); - logosMenuItems[12].path = g_strdup(_("/Edit/_Invert")); - logosMenuItems[13].path = g_strdup(_("/Edit/Sep3")); - logosMenuItems[14].path = g_strdup(_("/Edit/_Up logo")); - logosMenuItems[15].path = g_strdup(_("/Edit/_Down logo")); - logosMenuItems[16].path = g_strdup(_("/Edit/_Left logo")); - logosMenuItems[17].path = g_strdup(_("/Edit/_Right logo")); - logosMenuItems[18].path = g_strdup(_("/Edit/Sep4")); - logosMenuItems[19].path = g_strdup(_("/Edit/Flip _horizontal")); - logosMenuItems[20].path = g_strdup(_("/Edit/Flip _vertical")); + logosMenuItems[8].path = g_strdup(_("/File/Se_nd logo")); + logosMenuItems[9].path = g_strdup(_("/File/Sep2")); + logosMenuItems[10].path = g_strdup(_("/File/_Close")); + logosMenuItems[11].path = g_strdup(_("/_Edit")); + logosMenuItems[12].path = g_strdup(_("/Edit/_Clear")); + logosMenuItems[13].path = g_strdup(_("/Edit/_Invert")); + logosMenuItems[14].path = g_strdup(_("/Edit/Sep3")); + logosMenuItems[15].path = g_strdup(_("/Edit/_Up logo")); + logosMenuItems[16].path = g_strdup(_("/Edit/_Down logo")); + logosMenuItems[17].path = g_strdup(_("/Edit/_Left logo")); + logosMenuItems[18].path = g_strdup(_("/Edit/_Right logo")); + logosMenuItems[19].path = g_strdup(_("/Edit/Sep4")); + logosMenuItems[20].path = g_strdup(_("/Edit/Flip _horizontal")); + logosMenuItems[21].path = g_strdup(_("/Edit/Flip _vertical")); } void GUI_CreateLogosWindow (void) { @@ -1462,101 +1607,110 @@ void GUI_CreateLogosWindow (void) { /* realize top level window for logos */ GUI_LogosWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_window_set_policy(GTK_WINDOW(GUI_LogosWindow),1,1,1); - gtk_window_set_title(GTK_WINDOW(GUI_LogosWindow),_("Logos")); - gtk_signal_connect(GTK_OBJECT(GUI_LogosWindow),"delete_event", - GTK_SIGNAL_FUNC(DeleteEvent),NULL); + gtk_window_set_wmclass(GTK_WINDOW(GUI_LogosWindow), "LogosWindow", "Xgnokii"); + gtk_window_set_policy(GTK_WINDOW(GUI_LogosWindow), 1, 1, 1); + gtk_window_set_title(GTK_WINDOW(GUI_LogosWindow), _("Logos")); + gtk_signal_connect(GTK_OBJECT(GUI_LogosWindow), "delete_event", + GTK_SIGNAL_FUNC(DeleteEvent), NULL); gtk_widget_realize(GUI_LogosWindow); - CreateErrorDialog(&errorDialog,GUI_LogosWindow); - CreateInfoDialog(&infoDialog,GUI_LogosWindow); + CreateErrorDialog(&errorDialog, GUI_LogosWindow); + CreateInfoDialog(&infoDialog, GUI_LogosWindow); accelGroup = gtk_accel_group_new(); - gtk_accel_group_attach(accelGroup,GTK_OBJECT(GUI_LogosWindow)); + gtk_accel_group_attach(accelGroup, GTK_OBJECT(GUI_LogosWindow)); /* create main vbox */ - vbox = gtk_vbox_new(FALSE,1); - gtk_container_add(GTK_CONTAINER(GUI_LogosWindow),vbox); + vbox = gtk_vbox_new(FALSE, 1); + gtk_container_add(GTK_CONTAINER(GUI_LogosWindow), vbox); gtk_widget_show(vbox); - itemFactory = gtk_item_factory_new(GTK_TYPE_MENU_BAR,"
",accelGroup); - gtk_item_factory_create_items(itemFactory,nMenuItems,logosMenuItems,NULL); - menuBar = gtk_item_factory_get_widget(itemFactory,"
"); + itemFactory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "
", accelGroup); + gtk_item_factory_create_items(itemFactory, nMenuItems, logosMenuItems, NULL); + menuBar = gtk_item_factory_get_widget(itemFactory, "
"); - gtk_box_pack_start(GTK_BOX(vbox),menuBar,FALSE,FALSE,0); + gtk_box_pack_start(GTK_BOX(vbox), menuBar, FALSE, FALSE, 0); gtk_widget_show(menuBar); /* toolbar */ - toolBar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL,GTK_TOOLBAR_ICONS); - gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolBar),GTK_RELIEF_NORMAL); - gtk_toolbar_set_style(GTK_TOOLBAR(toolBar),GTK_TOOLBAR_ICONS); + toolBar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_ICONS); + gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolBar), GTK_RELIEF_NORMAL); + gtk_toolbar_set_style(GTK_TOOLBAR(toolBar), GTK_TOOLBAR_ICONS); - gtk_toolbar_append_item(GTK_TOOLBAR(toolBar),NULL,"Clear logo",NULL, - NewPixmap(New_xpm,GUI_LogosWindow->window, + gtk_toolbar_append_item(GTK_TOOLBAR(toolBar), NULL, _("Clear logo"), NULL, + NewPixmap(New_xpm, GUI_LogosWindow->window, &GUI_LogosWindow->style->bg[GTK_STATE_NORMAL]), - (GtkSignalFunc)ClearLogoEvent,toolBar); + (GtkSignalFunc)ClearLogoEvent, toolBar); gtk_toolbar_append_space(GTK_TOOLBAR(toolBar)); - gtk_toolbar_append_item(GTK_TOOLBAR(toolBar),NULL,"Get logo",NULL, - NewPixmap(Read_xpm,GUI_LogosWindow->window, + gtk_toolbar_append_item(GTK_TOOLBAR(toolBar), NULL, _("Get logo"), NULL, + NewPixmap(Read_xpm, GUI_LogosWindow->window, &GUI_LogosWindow->style->bg[GTK_STATE_NORMAL]), - (GtkSignalFunc)GetLogoEvent,toolBar); + (GtkSignalFunc)GetLogoEvent, toolBar); - gtk_toolbar_append_item(GTK_TOOLBAR(toolBar),NULL,"Set logo",NULL, - NewPixmap(Send_xpm,GUI_LogosWindow->window, + gtk_toolbar_append_item(GTK_TOOLBAR(toolBar), NULL, _("Set logo"), NULL, + NewPixmap(Send_xpm, GUI_LogosWindow->window, &GUI_LogosWindow->style->bg[GTK_STATE_NORMAL]), - (GtkSignalFunc)SetLogoEvent,toolBar); + (GtkSignalFunc)SetLogoEvent, toolBar); + + gtk_toolbar_append_item(GTK_TOOLBAR(toolBar), NULL, _("Send logo"), NULL, + NewPixmap(SendSMS_xpm, GUI_LogosWindow->window, + &GUI_LogosWindow->style->bg[GTK_STATE_NORMAL]), + (GtkSignalFunc)SendLogoEvent, toolBar); gtk_toolbar_append_space(GTK_TOOLBAR(toolBar)); + gtk_toolbar_append_item (GTK_TOOLBAR (toolBar), NULL, _("Import from file"), NULL, + NewPixmap(Open_xpm, GUI_LogosWindow->window, + &GUI_LogosWindow->style->bg[GTK_STATE_NORMAL]), + (GtkSignalFunc) OpenLogo, NULL); + gtk_toolbar_append_item (GTK_TOOLBAR (toolBar), NULL, _("Export to file"), NULL, + NewPixmap(Save_xpm, GUI_LogosWindow->window, + &GUI_LogosWindow->style->bg[GTK_STATE_NORMAL]), + (GtkSignalFunc) SaveLogo, NULL); + + gtk_toolbar_append_space (GTK_TOOLBAR (toolBar)); + buttonStartup = gtk_toolbar_append_element(GTK_TOOLBAR(toolBar), - GTK_TOOLBAR_CHILD_RADIOBUTTON,NULL,NULL,"Startup logo", - "",NewPixmap(Startup_logo_xpm,GUI_LogosWindow->window, + GTK_TOOLBAR_CHILD_RADIOBUTTON, NULL, NULL, _("Startup logo"), + "", NewPixmap(Startup_logo_xpm, GUI_LogosWindow->window, &GUI_LogosWindow->style->bg[GTK_STATE_NORMAL]), - GTK_SIGNAL_FUNC(LogoTypeEvent),NULL); + GTK_SIGNAL_FUNC(LogoTypeEvent), NULL); buttonOperator = gtk_toolbar_append_element(GTK_TOOLBAR(toolBar), - GTK_TOOLBAR_CHILD_RADIOBUTTON,buttonStartup,NULL,"Operator logo", - "",NewPixmap(Operator_logo_xpm,GUI_LogosWindow->window, + GTK_TOOLBAR_CHILD_RADIOBUTTON, buttonStartup, NULL, _("Operator logo"), + "", NewPixmap(Operator_logo_xpm, GUI_LogosWindow->window, &GUI_LogosWindow->style->bg[GTK_STATE_NORMAL]), - GTK_SIGNAL_FUNC(LogoTypeEvent),NULL); + GTK_SIGNAL_FUNC(LogoTypeEvent), NULL); buttonCaller = gtk_toolbar_append_element(GTK_TOOLBAR(toolBar), GTK_TOOLBAR_CHILD_RADIOBUTTON, buttonOperator, - NULL,"Caller logo", - "",NewPixmap(Caller_logo_xpm,GUI_LogosWindow->window, + NULL, _("Caller logo"), + "", NewPixmap(Caller_logo_xpm, GUI_LogosWindow->window, &GUI_LogosWindow->style->bg[GTK_STATE_NORMAL]), - GTK_SIGNAL_FUNC(LogoTypeEvent),NULL); - - buttonPicture = gtk_toolbar_append_element(GTK_TOOLBAR(toolBar), - GTK_TOOLBAR_CHILD_RADIOBUTTON, - buttonOperator, - NULL,"Picture image", - "",NewPixmap(Caller_logo_xpm,GUI_LogosWindow->window, - &GUI_LogosWindow->style->bg[GTK_STATE_NORMAL]), - GTK_SIGNAL_FUNC(LogoTypeEvent),NULL); + GTK_SIGNAL_FUNC(LogoTypeEvent), NULL); gtk_toolbar_append_space(GTK_TOOLBAR(toolBar)); networkCombo = gtk_combo_new(); - gtk_combo_set_use_arrows_always(GTK_COMBO(networkCombo),1); - while (strcmp(GSM_Networks[i].Name,"unknown")) - glistNetwork = g_list_insert_sorted(glistNetwork,GSM_Networks[i++].Name, + gtk_combo_set_use_arrows_always(GTK_COMBO(networkCombo), 1); + while (strcmp(GSM_Networks[i].Name, "unknown")) + glistNetwork = g_list_insert_sorted(glistNetwork, GSM_Networks[i++].Name, (GCompareFunc)strcmp); - gtk_combo_set_popdown_strings(GTK_COMBO(networkCombo),glistNetwork); - gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(networkCombo)->entry),FALSE); - gtk_toolbar_append_widget(GTK_TOOLBAR(toolBar),networkCombo,"",""); + gtk_combo_set_popdown_strings(GTK_COMBO(networkCombo), glistNetwork); + gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(networkCombo)->entry), FALSE); + gtk_toolbar_append_widget(GTK_TOOLBAR(toolBar), networkCombo, "", ""); gtk_widget_show(networkCombo); g_list_free(glistNetwork); callerCombo = gtk_combo_new(); - gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(callerCombo)->entry),FALSE); - gtk_toolbar_append_widget(GTK_TOOLBAR(toolBar),callerCombo,"",""); + gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(callerCombo)->entry), FALSE); + gtk_toolbar_append_widget(GTK_TOOLBAR(toolBar), callerCombo, "", ""); gtk_widget_show(callerCombo); - gtk_box_pack_start(GTK_BOX(vbox),toolBar,FALSE,FALSE,0); + gtk_box_pack_start(GTK_BOX(vbox), toolBar, FALSE, FALSE, 0); gtk_widget_show(toolBar); /* vertical separator */ @@ -1571,17 +1725,10 @@ void GUI_CreateLogosWindow (void) { /* set GSM_Bitmap width,height needed for creating drawinArea * we are starting, default is startupLogo */ - bitmap.type = GSM_7110StartupLogo; - bitmap.height = 65; - bitmap.width = 96; + bitmap.type = GSM_StartupLogo; + bitmap.height = 48; + bitmap.width = 84; bitmap.size = bitmap.height * bitmap.width / 8; - if (!strcmp(xgnokiiConfig.model,"7110")) { //7110 - GSM_ResizeBitmap(&bitmap,GSM_7110StartupLogo); - } else if (!strcmp(xgnokiiConfig.model,"6210") || !strcmp(xgnokiiConfig.model,"6250")) { //6210,6250 - GSM_ResizeBitmap(&bitmap,GSM_6210StartupLogo); - } else { - GSM_ResizeBitmap(&bitmap,GSM_StartupLogo); - } drawingAreaWidth = bitmap.width * (POINTSIZE+1)+1; drawingAreaHeight = bitmap.height * (POINTSIZE+1)+1; @@ -1652,47 +1799,47 @@ void GUI_CreateLogosWindow (void) { gtk_toolbar_set_style(GTK_TOOLBAR(vertToolBar),GTK_TOOLBAR_ICONS); buttonBrush = gtk_toolbar_append_element(GTK_TOOLBAR(vertToolBar), - GTK_TOOLBAR_CHILD_RADIOBUTTON,NULL,NULL,"Brush tool", - "",NewPixmap(Tool_brush_xpm,GUI_LogosWindow->window, + GTK_TOOLBAR_CHILD_RADIOBUTTON, NULL, NULL, _("Brush tool"), + "", NewPixmap(Tool_brush_xpm, GUI_LogosWindow->window, &GUI_LogosWindow->style->bg[GTK_STATE_NORMAL]), - GTK_SIGNAL_FUNC(ToolTypeEvent),NULL); + GTK_SIGNAL_FUNC(ToolTypeEvent), NULL); buttonLine = gtk_toolbar_append_element(GTK_TOOLBAR(vertToolBar), - GTK_TOOLBAR_CHILD_RADIOBUTTON,buttonBrush,NULL,"Line tool", - "",NewPixmap(Tool_line_xpm,GUI_LogosWindow->window, + GTK_TOOLBAR_CHILD_RADIOBUTTON, buttonBrush, NULL, _("Line tool"), + "", NewPixmap(Tool_line_xpm, GUI_LogosWindow->window, &GUI_LogosWindow->style->bg[GTK_STATE_NORMAL]), - GTK_SIGNAL_FUNC(ToolTypeEvent),NULL); + GTK_SIGNAL_FUNC(ToolTypeEvent), NULL); buttonRectangle = gtk_toolbar_append_element(GTK_TOOLBAR(vertToolBar), - GTK_TOOLBAR_CHILD_RADIOBUTTON,buttonLine,NULL,"Rectangle tool", - "",NewPixmap(Tool_rectangle_xpm,GUI_LogosWindow->window, + GTK_TOOLBAR_CHILD_RADIOBUTTON, buttonLine, NULL, _("Rectangle tool"), + "", NewPixmap(Tool_rectangle_xpm, GUI_LogosWindow->window, &GUI_LogosWindow->style->bg[GTK_STATE_NORMAL]), - GTK_SIGNAL_FUNC(ToolTypeEvent),NULL); + GTK_SIGNAL_FUNC(ToolTypeEvent), NULL); buttonFilledRectangle = gtk_toolbar_append_element(GTK_TOOLBAR(vertToolBar), - GTK_TOOLBAR_CHILD_RADIOBUTTON,buttonRectangle,NULL, - "Filled rectangle tool", - "",NewPixmap(Tool_filled_rectangle_xpm, + GTK_TOOLBAR_CHILD_RADIOBUTTON, buttonRectangle, NULL, + _("Filled rectangle tool"), + "", NewPixmap(Tool_filled_rectangle_xpm, GUI_LogosWindow->window, &GUI_LogosWindow->style->bg[GTK_STATE_NORMAL]), - GTK_SIGNAL_FUNC(ToolTypeEvent),NULL); + GTK_SIGNAL_FUNC(ToolTypeEvent), NULL); gtk_toolbar_append_space(GTK_TOOLBAR(vertToolBar)); - gtk_toolbar_append_item(GTK_TOOLBAR(vertToolBar),NULL,"Invert logo",NULL, - NewPixmap(Edit_invert_xpm,GUI_LogosWindow->window, + gtk_toolbar_append_item(GTK_TOOLBAR(vertToolBar), NULL, _("Invert logo"), NULL, + NewPixmap(Edit_invert_xpm, GUI_LogosWindow->window, &GUI_LogosWindow->style->bg[GTK_STATE_NORMAL]), - (GtkSignalFunc)InvertLogoEvent,vertToolBar); + (GtkSignalFunc)InvertLogoEvent, vertToolBar); - gtk_toolbar_append_item(GTK_TOOLBAR(vertToolBar),NULL,"Horizontal flip",NULL, - NewPixmap(Edit_flip_horizontal_xpm,GUI_LogosWindow->window, + gtk_toolbar_append_item(GTK_TOOLBAR(vertToolBar), NULL, _("Horizontal flip"), NULL, + NewPixmap(Edit_flip_horizontal_xpm, GUI_LogosWindow->window, &GUI_LogosWindow->style->bg[GTK_STATE_NORMAL]), - (GtkSignalFunc)FlipHorizontalLogoEvent,vertToolBar); + (GtkSignalFunc)FlipHorizontalLogoEvent, vertToolBar); - gtk_toolbar_append_item(GTK_TOOLBAR(vertToolBar),NULL,"Vertical flip",NULL, - NewPixmap(Edit_flip_vertical_xpm,GUI_LogosWindow->window, + gtk_toolbar_append_item(GTK_TOOLBAR(vertToolBar), NULL, _("Vertical flip"), NULL, + NewPixmap(Edit_flip_vertical_xpm, GUI_LogosWindow->window, &GUI_LogosWindow->style->bg[GTK_STATE_NORMAL]), - (GtkSignalFunc)FlipVerticalLogoEvent,vertToolBar); + (GtkSignalFunc)FlipVerticalLogoEvent, vertToolBar); gtk_box_pack_start(GTK_BOX(hbox),vertToolBar,FALSE,FALSE,0); @@ -1715,17 +1862,26 @@ void GUI_RefreshLogosGroupsCombo (void) { } void GUI_ShowLogosWindow (void) { + /* Set network name taken from the phone */ + GetNetworkInfoEvent(NULL); + /* if phone support caller groups, read callerGroups names */ + if (phoneMonitor.supported & PM_CALLERGROUP) { + if (xgnokiiConfig.callerGroups[0] == NULL) { + GUI_Refresh(); + GUI_InitCallerGroupsInf (); + } + if (!callersGroupsInitialized) GUI_RefreshLogosGroupsCombo (); + gtk_widget_show(buttonCaller); + gtk_widget_show(callerCombo); + } else { + /* if not supported, hide widget for handling callerGroups */ + gtk_widget_hide(buttonCaller); + gtk_widget_hide(callerCombo); + } - gtk_widget_show(buttonCaller); - gtk_widget_show(callerCombo); - - if (xgnokiiConfig.callerGroups[0] == NULL) { - GUI_Refresh(); - GUI_InitCallerGroupsInf (); - } + /* Call to reset Startup logo size */ + LogoTypeEvent(GUI_LogosWindow); - if (!callersGroupsInitialized) GUI_RefreshLogosGroupsCombo (); - gtk_widget_show(GUI_LogosWindow); if (!previewAvailable && showPreviewErrorDialog) { diff --git a/xgnokii/xgnokii_lowlevel.c b/xgnokii/xgnokii_lowlevel.c index 78a9ba4..528a433 100644 --- a/xgnokii/xgnokii_lowlevel.c +++ b/xgnokii/xgnokii_lowlevel.c @@ -1,21 +1,72 @@ /* + $Id$ + X G N O K I I A Linux/Unix GUI for Nokia mobile phones. + Copyright (C) 1999 Pavel Janík ml., Hugh Blemings + & Ján Derfiòák . Released under the terms of the GNU GPL, see file COPYING for more details. + $Log$ + Revision 1.1.1.4 2002/04/03 00:08:33 short + Found in "gnokii-working" directory, some November-patches version + + Revision 1.19 2001/09/14 13:09:26 pkot + Xgnokii calendar updates + + Revision 1.18 2001/06/20 21:27:36 pkot + IrDA patch (Martin Jancar) + + Revision 1.17 2001/06/10 11:40:06 machek + xgnokii converted to new structure w.r.t. SMS messages. + + Revision 1.16 2001/05/24 20:47:31 chris + More updating of 7110 code and some of xgnokii_lowlevel changed over. + + Revision 1.15 2001/03/23 08:24:57 ja + New preview for 6210 in xgnokii's logos module. + + Revision 1.14 2001/03/21 23:36:09 chris + Added the statemachine + This will break gnokii --identify and --monitor except for 6210/7110 + + Revision 1.13 2001/03/05 10:42:03 ja + Pavel Machek's vcard and finegrained indicators patch. + + Revision 1.12 2001/02/02 08:09:57 ja + New dialogs for 6210/7110 in xgnokii. Fixed the smsd for new capabilty code. + + Revision 1.11 2001/01/29 15:22:20 machek + Use integer as bitfield instead of struct of int:1. + + Be able to read phonebook saved in gnokii format from xgnokii. + + Revision 1.10 2001/01/17 02:54:56 chris + More 7110 work. Use with care! (eg it is not possible to delete phonebook entries) + I can now edit my phonebook in xgnokii but it is 'work in progress'. + + Revision 1.9 2001/01/15 21:10:20 ja + Better status reporting in xgnokii, fixed phone capabilities detection in xgnokii. + + */ #include #include #include #include +#include "misc.h" +#include "gsm-common.h" #include "gsm-api.h" +#include "fbus-6110.h" +#include "fbus-3810.h" #include "xgnokii_lowlevel.h" #include "xgnokii.h" -#include "xgnokii_common.h" +#include "gsm-statemachine.h" +//#include "xgnokii_common.h" pthread_t monitor_th; PhoneMonitor phoneMonitor; @@ -26,6 +77,8 @@ pthread_cond_t calendarCond; pthread_mutex_t smsMutex; pthread_mutex_t sendSMSMutex; pthread_cond_t sendSMSCond; +pthread_mutex_t saveSMSMutex; +pthread_cond_t saveSMSCond; pthread_mutex_t callMutex; pthread_mutex_t netMonMutex; pthread_mutex_t speedDialMutex; @@ -45,13 +98,13 @@ pthread_cond_t getNetworkInfoCond; static pthread_mutex_t eventsMutex; static GSList *ScheduledEvents = NULL; +/* This symbol must be export as it is (mis)used by xgnokii_logos.c + */ +GSM_Statemachine xgnokii_statemachine; + inline void GUI_InsertEvent (PhoneEvent *event) { - while (phoneMonitor.working) { - usleep(1); - } - # ifdef XDEBUG g_print ("Inserting Event: %d\n", event->event); # endif @@ -85,21 +138,27 @@ static void InitModelInf (void) gchar buf[64]; GSM_Error error; register gint i = 0; + GSM_Data data; - while ((error = GSM->GetModel(buf)) != GE_NONE && i++ < 15) + GSM_DataClear(&data); + data.Model=buf; + while ((error = SM_Functions(GOP_GetModel,&data,&xgnokii_statemachine)) != GE_NONE && i++ < 15) sleep(1); if (error == GE_NONE) { g_free (phoneMonitor.phone.model); phoneMonitor.phone.version = g_strdup (buf); - phoneMonitor.phone.model = GetModelName (buf); + phoneMonitor.phone.model = GetModel (buf); if (phoneMonitor.phone.model == NULL) phoneMonitor.phone.model = g_strdup (_("unknown")); + + phoneMonitor.supported = GetPhoneModel(buf)->flags; } i = 0; - while ((error = GSM->GetRevision (buf)) != GE_NONE && i++ < 5) + data.Revision=buf; + while ((error = SM_Functions(GOP_GetRevision,&data,&xgnokii_statemachine)) != GE_NONE && i++ < 5) sleep(1); if (error == GE_NONE) @@ -109,7 +168,8 @@ static void InitModelInf (void) } i = 0; - while ((error = GSM->GetIMEI (buf)) != GE_NONE && i++ < 5) + data.Imei=buf; + while ((error = SM_Functions(GOP_GetImei,&data,&xgnokii_statemachine)) != GE_NONE && i++ < 5) sleep(1); if (error == GE_NONE) @@ -127,23 +187,24 @@ static void InitModelInf (void) #endif } + static GSM_Error fbusinit(bool enable_monitoring) { int count=0; - static GSM_Error error=GE_NOLINK; + GSM_Error error=GE_NOLINK; + GSM_ConnectionType connection=GCT_Serial; -#ifndef WIN32 - if (strcmp(GetMygnokiiVersion(),VERSION)!=0) - fprintf(stderr,_("WARNING: version of installed libmygnokii.so (%s) is different to version of xgnokii (%s)\n"),GetMygnokiiVersion(),VERSION); -#endif + if (!strcmp(xgnokiiConfig.connection, "infrared")) + connection = GCT_Infrared; + + if (!strcmp(xgnokiiConfig.connection, "irda")) + connection = GCT_Irda; /* Initialise the code for the GSM interface. */ + if (error == GE_NOLINK) error = GSM_Initialise (xgnokiiConfig.model, xgnokiiConfig.port, - xgnokiiConfig.initlength, - GetConnectionTypeFromString(xgnokiiConfig.connection), - RLP_DisplayF96Frame, - xgnokiiConfig.synchronizetime); + xgnokiiConfig.initlength, connection, NULL /*RLP_DisplayF96Frame*/, &xgnokii_statemachine); #ifdef XDEBUG g_print ("fbusinit: error %d\n", error); @@ -161,10 +222,12 @@ static GSM_Error fbusinit(bool enable_monitoring) g_print("After usleep. GSM_LinkOK: %d\n", *GSM_LinkOK); #endif - if (*GSM_LinkOK == true) - InitModelInf (); + if (*GSM_LinkOK != true) { + return (GE_NOLINK); + } - return *GSM_LinkOK; + InitModelInf (); + return(GE_NONE); } @@ -174,11 +237,12 @@ void GUI_InitPhoneMonitor (void) phoneMonitor.phone.version = phoneMonitor.phone.model; phoneMonitor.phone.revision = g_strdup (_("unknown")); phoneMonitor.phone.imei = g_strdup (_("unknown")); + phoneMonitor.supported = 0; phoneMonitor.rfLevel = phoneMonitor.batteryLevel = -1; phoneMonitor.powerSource = GPS_BATTERY; - phoneMonitor.working = FALSE; + phoneMonitor.working = NULL; phoneMonitor.alarm = FALSE; - phoneMonitor.sms.unRead = phoneMonitor.sms.number = phoneMonitor.sms.number2 = 0; + phoneMonitor.sms.unRead = phoneMonitor.sms.used = phoneMonitor.sms.slots = 0; phoneMonitor.sms.messages = NULL; phoneMonitor.call.callInProgress = CS_Idle; *phoneMonitor.call.callNum = '\0'; @@ -192,6 +256,8 @@ void GUI_InitPhoneMonitor (void) pthread_mutex_init (&smsMutex, NULL); pthread_mutex_init (&sendSMSMutex, NULL); pthread_cond_init (&sendSMSCond, NULL); + pthread_mutex_init (&saveSMSMutex, NULL); + pthread_cond_init (&saveSMSCond, NULL); pthread_mutex_init (&callMutex, NULL); pthread_mutex_init (&eventsMutex, NULL); pthread_mutex_init (&callMutex, NULL); @@ -228,11 +294,12 @@ static inline void FreeArray (GSList **array) } -void RefreshSMS (const gint number) +static void RefreshSMS (const gint slots) { GSM_Error error; GSM_SMSMessage *msg; register gint i; + gint unread = 0; # ifdef XDEBUG g_print ("RefreshSMS is running...\n"); @@ -240,51 +307,43 @@ void RefreshSMS (const gint number) pthread_mutex_lock (&smsMutex); FreeArray (&(phoneMonitor.sms.messages)); - phoneMonitor.sms.number = 0; - phoneMonitor.sms.number2 = 0; + phoneMonitor.sms.used = 0; pthread_mutex_unlock (&smsMutex); - i = 1; - while (1) + for (i=1; i<=slots; i++) { + GSM_Data gdat; + GSM_DataClear(&gdat); msg = g_malloc (sizeof (GSM_SMSMessage)); msg->MemoryType = GMT_SM; msg->Location = i; -#ifdef XDEBUG - fprintf(stdout, _("test: %d %i %i %i\n"),msg->Location,phoneMonitor.sms.number,phoneMonitor.sms.number2,number); -#endif - pthread_mutex_lock (&smsMutex); - if( GetModelFeature(FN_SMS)==F_SMS71 ) msg->Location = 0; /* read next sms for 6210/7110 */ - error = GSM->GetSMSMessage (msg); - pthread_mutex_unlock (&smsMutex); - switch (error) { - case GE_NONE: - pthread_mutex_lock (&smsMutex); -#ifdef XDEBUG - fprintf(stdout, _("Refresh SMS: g_slist_append: sms message")); - fprintf(stdout, _(" Location: %d"),msg->Location); - fprintf(stdout, _(" folder: %d"),msg->folder); - if ( msg-> SMSData) fprintf(stdout, _(" SMSData true\n")); - else fprintf(stdout, _(" SMSData false\n")); -#endif - /* RTH: unread sms from folder 0 to INBOX */ - phoneMonitor.sms.messages = g_slist_append (phoneMonitor.sms.messages, msg); - phoneMonitor.sms.number++; - phoneMonitor.sms.number2++; - pthread_mutex_unlock (&smsMutex); - if (phoneMonitor.sms.number2 == number) return; - break; - case GE_SMSTOOLONG: /* Picture Image in 7110 comp phone */ - g_free (msg); - phoneMonitor.sms.number2++; - if (phoneMonitor.sms.number2 == number) return; - break; - default: - g_free (msg); - break; + gdat.SMSMessage = msg; + + if ((error = SM_Functions(GOP_GetSMS, &gdat, &xgnokii_statemachine)) == GE_NONE) + { + pthread_mutex_lock (&smsMutex); + phoneMonitor.sms.messages = g_slist_append (phoneMonitor.sms.messages, msg); + phoneMonitor.sms.used++; + if (msg->Type == GST_MT && msg->Status == GSS_NOTSENTREAD) + unread++; + pthread_mutex_unlock (&smsMutex); } - i++; + else if (error == GE_INVALIDSMSLOCATION) /* All positions are readed */ + { + g_free (msg); + break; + } + else + g_free (msg); + + /* FIXME: Why is any delay here? + */ + /* usleep (750000); */ } + /* Update it after the whole run as otherwise "Refreshing SMSes..." + * would collide with "Short Message received" message. + */ + phoneMonitor.sms.unRead = unread; } @@ -292,13 +351,16 @@ static gint A_GetMemoryStatus (gpointer data) { GSM_Error error; D_MemoryStatus *ms = (D_MemoryStatus *) data; + GSM_Data gdat; error = ms->status = GE_UNKNOWN; if (ms) { + GSM_DataClear(&gdat); pthread_mutex_lock (&memoryMutex); - error = ms->status = GSM->GetMemoryStatus (&(ms->memoryStatus)); + gdat.MemoryStatus=&(ms->memoryStatus); + error = ms->status = SM_Functions(GOP_GetMemoryStatus,&gdat,&xgnokii_statemachine); pthread_cond_signal (&memoryCond); pthread_mutex_unlock (&memoryMutex); } @@ -311,13 +373,16 @@ static gint A_GetMemoryLocation (gpointer data) { GSM_Error error; D_MemoryLocation *ml = (D_MemoryLocation *) data; + GSM_Data gdat; error = ml->status = GE_UNKNOWN; if (ml) { + GSM_DataClear(&gdat); pthread_mutex_lock (&memoryMutex); - error = ml->status = GSM->GetMemoryLocation (ml->entry); + gdat.PhonebookEntry=(ml->entry); + error = ml->status = SM_Functions(GOP_ReadPhonebook,&gdat,&xgnokii_statemachine); pthread_cond_signal (&memoryCond); pthread_mutex_unlock (&memoryMutex); } @@ -332,46 +397,51 @@ static gint A_GetMemoryLocationAll (gpointer data) GSM_Error error; D_MemoryLocationAll *mla = (D_MemoryLocationAll *) data; register gint i; - gint readed=0; + GSM_Data gdat; error = mla->status = GE_NONE; entry.MemoryType = mla->type; + GSM_DataClear(&gdat); + gdat.PhonebookEntry=&entry; pthread_mutex_lock (&memoryMutex); for (i = mla->min; i <= mla->max; i++) { entry.Location = i; - if (readedused) { - error = GSM->GetMemoryLocation (&entry); - if (error != GE_NONE) - { - gint err_count = 0; + error = SM_Functions(GOP_ReadPhonebook,&gdat,&xgnokii_statemachine); + if (error != GE_NONE && error!=GE_INVALIDPHBOOKLOCATION) + { + gint err_count = 0; - while (error != GE_NONE && - error != GE_INVALIDPHBOOKLOCATION && error != GE_UNKNOWN) //n7110.c + while (error != GE_NONE) + { + g_print (_("%s: line %d: Can't get memory entry number %d from memory %d! %d\n"), + __FILE__, __LINE__, i, entry.MemoryType, error); + if (err_count++ > 3) { - g_print (_("%s: line %d: Can't get memory entry number %d from memory %d! %d\n"), - __FILE__, __LINE__, i, entry.MemoryType, error); - if (err_count++ > 3) - { - mla->ReadFailed (i); - mla->status = error; - pthread_cond_signal (&memoryCond); - pthread_mutex_unlock (&memoryMutex); - return (error); - } - - error = GSM->GetMemoryLocation (&entry); - sleep (2); + mla->ReadFailed (i); + mla->status = error; + pthread_cond_signal (&memoryCond); + pthread_mutex_unlock (&memoryMutex); + return (error); } + + error = SM_Functions(GOP_ReadPhonebook,&gdat,&xgnokii_statemachine); + sleep (2); } - - if (strcmp(entry.Number, "\0") || strcmp(entry.Name, "\0")) - readed++; + } - } else { - entry.Number[0]='\0'; - entry.Name[0]='\0'; + /* If the phonebook location was invalid - just fill up the rest */ + /* This works on a 7110 anyway...*/ + + if (error==GE_INVALIDPHBOOKLOCATION) { + entry.Empty=true; + entry.Name[0]=0; + entry.Number[0]=0; + for (i = mla->min; i <= mla->max; i++) { + error = mla->InsertEntry (&entry); + if (error != GE_NONE) break; + } } error = mla->InsertEntry (&entry); @@ -389,13 +459,17 @@ static gint A_WriteMemoryLocation (gpointer data) { GSM_Error error; D_MemoryLocation *ml = (D_MemoryLocation *) data; + GSM_Data gdat; error = ml->status = GE_UNKNOWN; + GSM_DataClear(&gdat); + gdat.PhonebookEntry=(ml->entry); + if (ml) { pthread_mutex_lock (&memoryMutex); - error = ml->status = GSM->WritePhonebookLocation (ml->entry); + error = ml->status = SM_Functions(GOP_WritePhonebook,&gdat,&xgnokii_statemachine); pthread_cond_signal (&memoryCond); pthread_mutex_unlock (&memoryMutex); } @@ -497,6 +571,7 @@ static gint A_GetCalendarNoteAll (gpointer data) return (e); } + static gint A_WriteCalendarNote (gpointer data) { GSM_Error error; @@ -535,6 +610,7 @@ static gint A_GetCallerGroup (gpointer data) GSM_Bitmap bitmap; GSM_Error error; D_CallerGroup *cg = (D_CallerGroup *) data; + GSM_Data gdat; error = cg->status = GE_UNKNOWN; @@ -544,7 +620,9 @@ static gint A_GetCallerGroup (gpointer data) bitmap.number = cg->number; pthread_mutex_lock (&callerGroupMutex); - error = cg->status = GSM->GetBitmap (&bitmap); + GSM_DataClear(&gdat); + gdat.Bitmap=&bitmap; + error = cg->status = SM_Functions(GOP_GetBitmap,&gdat,&xgnokii_statemachine); strncpy (cg->text, bitmap.text, 256); cg->text[255] = '\0'; pthread_cond_signal (&callerGroupCond); @@ -636,6 +714,24 @@ static gint A_SendSMSMessage (gpointer data) } +static gint A_SaveSMSMessage (gpointer data) +{ + D_SMSMessage *d = (D_SMSMessage *) data; + GSM_Error error; + + error = d->status = GE_UNKNOWN; + if (d) + { + pthread_mutex_lock (&saveSMSMutex); + error = d->status = GSM->SaveSMSMessage (d->sms); + pthread_cond_signal (&saveSMSCond); + pthread_mutex_unlock (&saveSMSMutex); + } + + return (error); +} + + static gint A_DeleteSMSMessage (gpointer data) { GSM_SMSMessage *sms = (GSM_SMSMessage *) data; @@ -643,7 +739,10 @@ static gint A_DeleteSMSMessage (gpointer data) if (sms) { - error = GSM->DeleteSMSMessage(sms); + GSM_Data gdat; + GSM_DataClear(&gdat); + gdat.SMSMessage = sms; + error = SM_Functions(GOP_DeleteSMS, &gdat, &xgnokii_statemachine); g_free (sms); } @@ -753,10 +852,11 @@ static gint A_GetAlarm (gpointer data) D_Alarm *a = (D_Alarm *) data; GSM_Error error; - error = a->status = GE_UNKNOWN; + error = GE_UNKNOWN; - if (a) + if (a && GSM) { + a->status = GE_UNKNOWN; pthread_mutex_lock (&alarmMutex); error = a->status = GSM->GetAlarm (0, &(a->time)); pthread_cond_signal (&alarmCond); @@ -790,7 +890,9 @@ static gint A_SendKeyStroke (gpointer data) if (buf) { - GSM->PressKey(buf[1], buf[0]); +#if 0 + FB61_TX_SendMessage(0x07, 0x0c, buf); +#endif g_free (buf); } @@ -800,9 +902,12 @@ static gint A_SendKeyStroke (gpointer data) static gint A_GetBitmap(gpointer data) { GSM_Error error; D_Bitmap *d = (D_Bitmap *)data; + GSM_Data gdat; + GSM_DataClear(&gdat); pthread_mutex_lock(&getBitmapMutex); - error = d->status = GSM->GetBitmap(d->bitmap); + gdat.Bitmap=d->bitmap; + error = d->status = SM_Functions(GOP_GetBitmap,&gdat,&xgnokii_statemachine); pthread_cond_signal(&getBitmapCond); pthread_mutex_unlock(&getBitmapMutex); return error; @@ -812,19 +917,24 @@ static gint A_SetBitmap(gpointer data) { GSM_Error error; D_Bitmap *d = (D_Bitmap *)data; GSM_Bitmap bitmap; + GSM_Data gdat; + GSM_DataClear(&gdat); pthread_mutex_lock(&setBitmapMutex); if (d->bitmap->type == GSM_CallerLogo) { bitmap.type = d->bitmap->type; bitmap.number = d->bitmap->number; - error = d->status = GSM->GetBitmap(&bitmap); + gdat.Bitmap=&bitmap; + error = d->status = SM_Functions(GOP_GetBitmap,&gdat,&xgnokii_statemachine); if (error == GE_NONE) { strncpy(d->bitmap->text,bitmap.text,sizeof(bitmap.text)); d->bitmap->ringtone = bitmap.ringtone; - error = d->status = GSM->SetBitmap(d->bitmap); + gdat.Bitmap=d->bitmap; + error = d->status = SM_Functions(GOP_SetBitmap,&gdat,&xgnokii_statemachine); } } else { - error = d->status = GSM->SetBitmap(d->bitmap); + gdat.Bitmap=d->bitmap; + error = d->status = SM_Functions(GOP_SetBitmap,&gdat,&xgnokii_statemachine); } pthread_cond_signal(&setBitmapCond); pthread_mutex_unlock(&setBitmapMutex); @@ -834,9 +944,13 @@ static gint A_SetBitmap(gpointer data) { static gint A_GetNetworkInfo(gpointer data) { GSM_Error error; D_NetworkInfo *d = (D_NetworkInfo *)data; + GSM_Data gdat; + + GSM_DataClear(&gdat); pthread_mutex_lock(&getNetworkInfoMutex); - error = d->status = GSM->GetNetworkInfo(d->info); + gdat.NetworkInfo=d->info; + error = d->status = SM_Functions(GOP_GetNetworkInfo,&gdat,&xgnokii_statemachine); pthread_cond_signal(&getNetworkInfoCond); pthread_mutex_unlock(&getNetworkInfoMutex); return error; @@ -864,6 +978,7 @@ gint (*DoAction[])(gpointer) = { A_GetSMSCenter, A_SetSMSCenter, A_SendSMSMessage, + A_SaveSMSMessage, A_DeleteSMSMessage, A_GetSpeedDial, A_SendSpeedDial, @@ -880,111 +995,148 @@ gint (*DoAction[])(gpointer) = { A_Exit }; + void *GUI_Connect (void *a) { /* Define required unit types for RF and Battery level meters. */ - GSM_RFUnits rf_units = GRF_Arbitrary; - GSM_BatteryUnits batt_units = GBU_Arbitrary; + GSM_RFUnits rf_units = GRF_Percentage; + GSM_BatteryUnits batt_units = GBU_Percentage; GSM_DateTime Alarm; + GSM_SMSStatus SMSStatus = {0, 0, 0}; gchar number[INCALL_NUMBER_LENGTH]; - PhoneEvent *event=NULL; + PhoneEvent *event; GSM_Error error; gint status; + GSM_Data data; + GSM_DataClear(&data); # ifdef XDEBUG g_print ("Initializing connection...\n"); # endif phoneMonitor.working = _("Connecting..."); - while (!fbusinit (true)) + while (fbusinit (true)) sleep (1); # ifdef XDEBUG g_print ("Phone connected. Starting monitoring...\n"); # endif + sleep(1); + + data.RFLevel=&phoneMonitor.rfLevel; + data.RFUnits=&rf_units; + data.PowerSource=&phoneMonitor.powerSource; + data.BatteryUnits=&batt_units; + data.BatteryLevel=&phoneMonitor.batteryLevel; + data.DateTime=&Alarm; + data.SMSStatus=&SMSStatus; + data.IncomingCallNr=number; + while (1) { - if (event != NULL) { - phoneMonitor.working = _("Working..."); - } else { - phoneMonitor.working = NULL; + phoneMonitor.working = NULL; - if (GSM->GetRFLevel (&rf_units, &phoneMonitor.rfLevel) != GE_NONE) - phoneMonitor.rfLevel = -1; + /* FIXME - this loop goes mad on my 7110 - so I've put in a usleep */ + usleep(50000); - if (rf_units == GRF_Arbitrary) - phoneMonitor.rfLevel *= 25; + if (SM_Functions(GOP_GetRFLevel,&data,&xgnokii_statemachine) != GE_NONE) + phoneMonitor.rfLevel = -1; - if (GSM->GetPowerSource (&phoneMonitor.powerSource) == GE_NONE - && phoneMonitor.powerSource == GPS_ACDC) - phoneMonitor.batteryLevel = ((gint) phoneMonitor.batteryLevel + 25) % 125; - else + if (rf_units == GRF_Arbitrary) + phoneMonitor.rfLevel *= 25; + + if (SM_Functions(GOP_GetPowersource,&data,&xgnokii_statemachine) == GE_NONE + && phoneMonitor.powerSource == GPS_ACDC) + { + if (phoneMonitor.batteryLevel < 0 || phoneMonitor.batteryLevel > 100) + phoneMonitor.batteryLevel = 100; + } + else { + if (SM_Functions(GOP_GetBatteryLevel,&data,&xgnokii_statemachine) != GE_NONE) + phoneMonitor.batteryLevel = -1; + if (batt_units == GBU_Arbitrary) + phoneMonitor.batteryLevel *= 25; + } + + if (SM_Functions(GOP_GetAlarm,&data,&xgnokii_statemachine) == GE_NONE && Alarm.AlarmEnabled != 0) + phoneMonitor.alarm = TRUE; + else + phoneMonitor.alarm = FALSE; + + if (SM_Functions(GOP_GetSMSStatus,&data,&xgnokii_statemachine) == GE_NONE) + { + /* Change of "UnRead" shouldn't be interesting - user may have read some of his + * SMSes by the phone interface. + */ + if (phoneMonitor.sms.unRead != SMSStatus.UnRead || + phoneMonitor.sms.used != SMSStatus.Used || + phoneMonitor.sms.slots != SMSStatus.Slots) /* shouldn't change, just to be sure */ { - if (GSM->GetBatteryLevel (&batt_units, &phoneMonitor.batteryLevel) != GE_NONE) - phoneMonitor.batteryLevel = -1; - if (batt_units == GBU_Arbitrary) - phoneMonitor.batteryLevel *= 25; + /* We are primarily interested in SMSStatus.Slots so try to fix it up if it is broken + */ + if (SMSStatus.UnRead > SMSStatus.Used) + SMSStatus.Used = SMSStatus.UnRead; + if (SMSStatus.Used > SMSStatus.Slots) + SMSStatus.Slots = SMSStatus.Used; + phoneMonitor.sms.slots = SMSStatus.Slots; /* shouldn't change, just to be sure */ + /* phoneMonitor.sms.{unRead,used} will be updated by RefreshSMS() + */ + + phoneMonitor.working = _("Refreshing SMSes..."); + RefreshSMS (SMSStatus.Slots); + phoneMonitor.working = NULL; } - if (GSM->GetAlarm (0, &Alarm) == GE_NONE && Alarm.IsSet != 0) - phoneMonitor.alarm = TRUE; - else - phoneMonitor.alarm = FALSE; + } - if (GSM->GetIncomingCallNr (number) == GE_NONE) - { + if (SM_Functions(GOP_GetIncomingCallNr,&data,&xgnokii_statemachine) == GE_NONE) + { # ifdef XDEBUG - g_print ("Call in progress: %s\n", phoneMonitor.call.callNum); + g_print ("Call in progress: %s\n", phoneMonitor.call.callNum); # endif - if (GSM->GetDisplayStatus (&status)==GE_NONE) { - if (status & (1<GetDisplayStatus (&status); + if (status & (1<NetMonitor (phoneMonitor.netmonitor.number, - phoneMonitor.netmonitor.screen); - GSM->NetMonitor (3, phoneMonitor.netmonitor.screen3); - GSM->NetMonitor (4, phoneMonitor.netmonitor.screen4); - GSM->NetMonitor (5, phoneMonitor.netmonitor.screen5); - } else { - *phoneMonitor.netmonitor.screen = *phoneMonitor.netmonitor.screen3 = - *phoneMonitor.netmonitor.screen4 = *phoneMonitor.netmonitor.screen5 = '\0'; + pthread_mutex_lock (&callMutex); + phoneMonitor.call.callInProgress = CS_Waiting; + strncpy (phoneMonitor.call.callNum, number, INCALL_NUMBER_LENGTH); + pthread_mutex_unlock (&callMutex); } - pthread_mutex_unlock (&netMonMutex); } + else + { + pthread_mutex_lock (&callMutex); + phoneMonitor.call.callInProgress = CS_Idle; + *phoneMonitor.call.callNum = '\0'; + pthread_mutex_unlock (&callMutex); + } + + pthread_mutex_lock (&netMonMutex); + if (phoneMonitor.netmonitor.number) + { + GSM->NetMonitor (phoneMonitor.netmonitor.number, + phoneMonitor.netmonitor.screen); + GSM->NetMonitor (3, phoneMonitor.netmonitor.screen3); + GSM->NetMonitor (4, phoneMonitor.netmonitor.screen4); + GSM->NetMonitor (5, phoneMonitor.netmonitor.screen5); + } + else + { + *phoneMonitor.netmonitor.screen = *phoneMonitor.netmonitor.screen3 = + *phoneMonitor.netmonitor.screen4 = *phoneMonitor.netmonitor.screen5 = '\0'; + } + pthread_mutex_unlock (&netMonMutex); + while ((event = RemoveEvent ()) != NULL) { # ifdef XDEBUG diff --git a/xgnokii/xgnokii_lowlevel.h b/xgnokii/xgnokii_lowlevel.h index 44201fd..a0d8e2b 100644 --- a/xgnokii/xgnokii_lowlevel.h +++ b/xgnokii/xgnokii_lowlevel.h @@ -1,11 +1,38 @@ /* + $Id$ + X G N O K I I A Linux/Unix GUI for Nokia mobile phones. + Copyright (C) 1999 Pavel Janík ml., Hugh Blemings + & Ján Derfiòák . Released under the terms of the GNU GPL, see file COPYING for more details. + $Log$ + Revision 1.1.1.4 2002/04/03 00:08:33 short + Found in "gnokii-working" directory, some November-patches version + + Revision 1.9 2001/09/14 13:09:26 pkot + Xgnokii calendar updates + + Revision 1.8 2001/02/02 08:09:57 ja + New dialogs for 6210/7110 in xgnokii. Fixed the smsd for new capabilty code. + + Revision 1.7 2001/01/29 15:22:22 machek + Use integer as bitfield instead of struct of int:1. + + Be able to read phonebook saved in gnokii format from xgnokii. + + Revision 1.6 2001/01/17 02:54:57 chris + More 7110 work. Use with care! (eg it is not possible to delete phonebook entries) + I can now edit my phonebook in xgnokii but it is 'work in progress'. + + Revision 1.5 2001/01/15 21:10:20 ja + Better status reporting in xgnokii, fixed phone capabilities detection in xgnokii. + + */ #ifndef XGNOKII_LOWLEVEL_H @@ -13,7 +40,7 @@ #include #include -#include "gsm-api.h" +#include "gsm-common.h" #define INCALL_NUMBER_LENGTH 20 #define NETMON_SCREEN_LENGTH 60 @@ -39,6 +66,7 @@ typedef enum { Event_GetSMSCenter, Event_SetSMSCenter, Event_SendSMSMessage, + Event_SaveSMSMessage, Event_DeleteSMSMessage, Event_GetSpeedDial, Event_SendSpeedDial, @@ -99,7 +127,6 @@ typedef struct { typedef struct { gint min; gint max; - gint used; GSM_MemoryType type; gint status; gint (*InsertEntry)(GSM_PhonebookEntry *); @@ -141,8 +168,8 @@ typedef struct { } phone; struct { gint unRead; - gint number; - gint number2; + gint used; + gint slots; GSList *messages; } sms; struct { @@ -156,6 +183,7 @@ typedef struct { gchar screen4[NETMON_SCREEN_LENGTH]; gchar screen5[NETMON_SCREEN_LENGTH]; } netmonitor; + gint supported; } PhoneMonitor; extern pthread_t monitor_th; @@ -167,6 +195,8 @@ extern pthread_cond_t calendarCond; extern pthread_mutex_t smsMutex; extern pthread_mutex_t sendSMSMutex; extern pthread_cond_t sendSMSCond; +extern pthread_mutex_t saveSMSMutex; +extern pthread_cond_t saveSMSCond; extern pthread_mutex_t callMutex; extern pthread_mutex_t netMonMutex; extern pthread_mutex_t speedDialMutex; @@ -187,6 +217,4 @@ extern void GUI_InitPhoneMonitor (void); extern void *GUI_Connect (void *a); extern void GUI_InsertEvent (PhoneEvent *event); -extern void RefreshSMS (const gint number); - #endif diff --git a/xgnokii/xgnokii_netmon.c b/xgnokii/xgnokii_netmon.c index 30a7be0..53b846d 100644 --- a/xgnokii/xgnokii_netmon.c +++ b/xgnokii/xgnokii_netmon.c @@ -3,9 +3,14 @@ X G N O K I I A Linux/Unix GUI for Nokia mobile phones. + Copyright (C) 1999 Pavel Janík ml., Hugh Blemings + & Ján Derfiòák . Released under the terms of the GNU GPL, see file COPYING for more details. + Last modification: Sun Apr 30 2000 + Modified by Jan Derfinak + */ #ifndef WIN32 @@ -30,7 +35,7 @@ static GtkWidget *tableProgress[7]; static inline void Help1 (GtkWidget *w, gpointer data) { - gchar *indx = g_strdup_printf ("/%s/gnokii/xgnokii/netmon/index.htm", xgnokiiConfig.locale); + gchar *indx = g_strdup_printf ("/help/%s/windows/netmon/index.html", xgnokiiConfig.locale); Help (w, indx); g_free (indx); } @@ -309,6 +314,7 @@ void GUI_CreateNetmonWindow () InitMainMenu (); GUI_NetmonWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL); + gtk_window_set_wmclass (GTK_WINDOW (GUI_NetmonWindow), "NetmonWindow", "Xgnokii"); gtk_window_set_title (GTK_WINDOW (GUI_NetmonWindow), _("Net Monitor")); //gtk_widget_set_usize (GTK_WIDGET (GUI_NetmonWindow), 436, 220); gtk_signal_connect (GTK_OBJECT (GUI_NetmonWindow), "delete_event", diff --git a/xgnokii/xgnokii_netmon.h b/xgnokii/xgnokii_netmon.h index c226f13..f3c57b9 100644 --- a/xgnokii/xgnokii_netmon.h +++ b/xgnokii/xgnokii_netmon.h @@ -3,9 +3,14 @@ X G N O K I I A Linux/Unix GUI for Nokia mobile phones. + Copyright (C) 1999 Pavel Janík ml., Hugh Blemings + & Ján Derfiòák . Released under the terms of the GNU GPL, see file COPYING for more details. + Last modification: Tue Nov 16 1999 + Modified by Jan Derfinak + */ #ifndef XGNOKII_NETMON_H diff --git a/xgnokii/xgnokii_sms.c b/xgnokii/xgnokii_sms.c index a9726b9..185cc3b 100644 --- a/xgnokii/xgnokii_sms.c +++ b/xgnokii/xgnokii_sms.c @@ -3,9 +3,14 @@ X G N O K I I A Linux/Unix GUI for Nokia mobile phones. + Copyright (C) 1999 Pavel Janík ml., Hugh Blemings + & Ján Derfiòák . Released under the terms of the GNU GPL, see file COPYING for more details. + Last modification: Sun Apr 30 2000 + Modified by Jan Derfinak + */ #include #include @@ -19,8 +24,6 @@ #include #include "misc.h" #include "gsm-api.h" -#include "gsm-datetime.h" -#include "gsm-sms.h" #include "xgnokii_common.h" #include "xgnokii.h" #include "xgnokii_lowlevel.h" @@ -44,6 +47,7 @@ typedef struct { gint validity; gint class; gchar sender[GSM_MAX_SENDER_LENGTH + 1]; + gchar destination[GSM_MAX_DESTINATION_LENGTH + 1]; } MessagePointers; typedef struct { @@ -68,26 +72,23 @@ typedef struct { GtkWidget *status; GtkWidget *report; GtkWidget *longSMS; - GtkWidget *class; GtkWidget *smscOptionMenu; GtkTooltips *addrTip; gint center; GSList *addressLine; } SendSMSWidget; -int prev_num_of_folders=0; - static GtkWidget *GUI_SMSWindow; static SMSWidget SMS = {NULL, NULL, NULL}; -static SendSMSWidget sendSMS = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL}; +static SendSMSWidget sendSMS = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL}; static ErrorDialog errorDialog = {NULL, NULL}; static InfoDialog infoDialog = {NULL, NULL}; static QuestMark questMark; -static GtkWidget *treeFolderItem[MAX_SMS_FOLDERS], *subTree; + static inline void Help1 (GtkWidget *w, gpointer data) { - gchar *indx = g_strdup_printf ("/%s/gnokii/xgnokii/sms/index.htm", xgnokiiConfig.locale); + gchar *indx = g_strdup_printf ("/help/%s/windows/sms/index.html", xgnokiiConfig.locale); Help (w, indx); g_free (indx); } @@ -206,105 +207,141 @@ static inline void DestroyMsgPtrs (gpointer data) } -static void InsertFolderElement (gpointer d, gpointer userData) +static void InsertInboxElement (gpointer d, gpointer userData) { GSM_SMSMessage *data = (GSM_SMSMessage *) d; MessagePointers *msgPtrs; GSM_DateTime *dt; - if (data->folder == SMS.currentBox) + if (data->Type == GST_MT || data->Type == GST_DR) { - gchar *row[4]; - - if (data->Type == GST_DR) +/* if (data->Type == GST_MT && data->UDHType == GSM_ConcatenatedMessages) { - row[0] = g_strdup (_("report")); - dt = &(data->SMSCTime); + //FIX ME + + msgPtrs = (MessagePointers *) g_malloc (sizeof (MessagePointers)); + msgPtrs->count = data->UDH[4]; + msgPtrs->number = data->UDH[5]; + msgPtrs->validity = data->Validity; + msgPtrs->class = data->Class; + strcpy (msgPtrs->sender, data->Sender); + msgPtrs->msgPtr = (gint *) g_malloc (msgPtrs->count * sizeof (gint)); + *(msgPtrs->msgPtr + msgPtrs->number - 1) = data->MessageNumber; } - else + else */ { + gchar *row[4]; + + if (data->Type == GST_DR) + { + row[0] = g_strdup (_("report")); + dt = &(data->SMSCTime); + } + else if (data->Status) + { + row[0] = g_strdup (_("read")); dt = &(data->Time); - switch (data->Status) - { - case GSS_SENTREAD: - if (data->folder==0) //GST_INBOX - row[0] = g_strdup (_("read")); - else - row[0] = g_strdup (_("sent")); - break; - case GSS_NOTSENTREAD: - if (data->folder==0) //GST_INBOX - row[0] = g_strdup (_("unread")); - else - row[0] = g_strdup (_("not sent")); - break; - case GSS_UNKNOWN: - row[0] = g_strdup (_("not known :-(")); - break; - case GSS_TEMPLATE: - row[0] = g_strdup (_("template")); - break; - default: - row[0] = g_strdup (_("unknown")); - break; - } - } + } + else + { + row[0] = g_strdup (_("unread")); + dt = &(data->Time); + } - if (data->SMSData) { if (dt->Timezone) - row[1] = g_strdup_printf ("%s %02d/%02d/%02d %02d:%02d:%02d %c%02d00", - DayOfWeek(dt->Year, dt->Month, dt->Day), + row[1] = g_strdup_printf ("%02d/%02d/%02d %02d:%02d:%02d %c%02d00", dt->Day, dt->Month, dt->Year, dt->Hour, dt->Minute, dt->Second, dt->Timezone > 0 ? '+' : '-', abs (dt->Timezone)); else - row[1] = g_strdup_printf ("%s %02d/%02d/%02d %02d:%02d:%02d", - DayOfWeek(dt->Year, dt->Month, dt->Day), + row[1] = g_strdup_printf ("%02d/%02d/%02d %02d:%02d:%02d", dt->Day, dt->Month, dt->Year, dt->Hour, dt->Minute, dt->Second); - } else { - row[1] = g_strdup_printf ("unknown"); - } - - row[2] = GUI_GetName (data->Sender); - if (row[2] == NULL || row[2][0]==0) row[2] = data->Sender; - row[3] = data->MessageText; + row[2] = GUI_GetName (data->Sender); + if (row[2] == NULL) + row[2] = data->Sender; + row[3] = data->MessageText; - msgPtrs = (MessagePointers *) g_malloc (sizeof (MessagePointers)); - msgPtrs->validity = data->Validity; - msgPtrs->class = data->Class; - strcpy (msgPtrs->sender, data->Sender); - -// if (data->UDHType == GSM_ConcatenatedMessages) -// { -// msgPtrs->count = data->UDH[5]; -// msgPtrs->number = data->UDH[4]; -// msgPtrs->msgPtr = (gint *) g_malloc (msgPtrs->count * sizeof (gint)); -// *(msgPtrs->msgPtr + msgPtrs->number - 1) = data->MessageNumber; -// } else { + gtk_clist_append (GTK_CLIST (SMS.smsClist), row); + msgPtrs = (MessagePointers *) g_malloc (sizeof (MessagePointers)); msgPtrs->count = msgPtrs->number = 1; + msgPtrs->validity = data->Validity; + msgPtrs->class = data->Class; + strcpy (msgPtrs->sender, data->Sender); + msgPtrs->destination[0]='\0'; msgPtrs->msgPtr = (gint *) g_malloc (sizeof (gint)); *(msgPtrs->msgPtr) = data->MessageNumber; - - gtk_clist_append (GTK_CLIST (SMS.smsClist), row); gtk_clist_set_row_data_full (GTK_CLIST (SMS.smsClist), SMS.row_i++, msgPtrs, DestroyMsgPtrs); -// } + g_free (row[0]); + g_free (row[1]); + } + } +} + + +static inline void RefreshInbox (void) +{ + gtk_clist_freeze (GTK_CLIST (SMS.smsClist)); + gtk_clist_clear (GTK_CLIST (SMS.smsClist)); + gtk_clist_set_column_title(GTK_CLIST (SMS.smsClist), 2/*column*/, _("Sender")); + SMS.row_i = 0; + g_slist_foreach (phoneMonitor.sms.messages, InsertInboxElement, (gpointer) NULL); + + gtk_clist_sort (GTK_CLIST (SMS.smsClist)); + gtk_clist_thaw (GTK_CLIST (SMS.smsClist)); +} + + +static void InsertOutboxElement (gpointer d, gpointer userData) +{ + GSM_SMSMessage *data = (GSM_SMSMessage *) d; + MessagePointers *msgPtrs; + + if (data->Type == GST_MO) + { + gchar *row[4]; + + if (data->Status) + row[0] = g_strdup (_("sent")); + else + row[0] = g_strdup (_("unsent")); + + row[1] = g_strdup (""); /* time */ + + row[2] = GUI_GetName (data->Destination); + if (row[2] == NULL) + row[2] = data->Destination; + + row[3] = data->MessageText; + + gtk_clist_append( GTK_CLIST (SMS.smsClist), row); + msgPtrs = (MessagePointers *) g_malloc (sizeof (MessagePointers)); + msgPtrs->count = msgPtrs->number = 1; + msgPtrs->validity = data->Validity; + msgPtrs->class = data->Class; + msgPtrs->sender[0]='\0'; + strcpy (msgPtrs->destination, data->Destination); + msgPtrs->msgPtr = (gint *) g_malloc (sizeof (gint)); + *(msgPtrs->msgPtr) = data->MessageNumber; + gtk_clist_set_row_data_full (GTK_CLIST (SMS.smsClist), SMS.row_i++, + msgPtrs, DestroyMsgPtrs); g_free (row[0]); g_free (row[1]); } } -static inline void RefreshFolder (void) + +static inline void RefreshOutbox (void) { gtk_clist_freeze (GTK_CLIST (SMS.smsClist)); - gtk_clist_clear (GTK_CLIST (SMS.smsClist)); + gtk_clist_set_column_title(GTK_CLIST (SMS.smsClist), 2/*column*/, _("Destination")); SMS.row_i = 0; - g_slist_foreach (phoneMonitor.sms.messages, InsertFolderElement, (gpointer) NULL); + g_slist_foreach (phoneMonitor.sms.messages, InsertOutboxElement, (gpointer) NULL); gtk_clist_sort (GTK_CLIST (SMS.smsClist)); gtk_clist_thaw (GTK_CLIST (SMS.smsClist)); @@ -316,7 +353,10 @@ inline void GUI_RefreshMessageWindow (void) if (!GTK_WIDGET_VISIBLE (GUI_SMSWindow)) return; - RefreshFolder(); + if (SMS.currentBox) + RefreshOutbox (); + else + RefreshInbox (); } @@ -342,7 +382,7 @@ static void ClickEntry (GtkWidget *clist, gtk_text_forward_delete (GTK_TEXT (SMS.smsText), gtk_text_get_length (GTK_TEXT (SMS.smsText))); gtk_text_insert (GTK_TEXT (SMS.smsText), NULL, &(SMS.colour), NULL, - _("From: "), -1); + (SMS.currentBox ? _("To: ") : _("From: ")), -1); gtk_clist_get_text (GTK_CLIST (clist), row, 2, &buf); gtk_text_insert (GTK_TEXT (SMS.smsText), NULL, &(SMS.smsText->style->black), NULL, buf, -1); @@ -367,27 +407,6 @@ static void ClickEntry (GtkWidget *clist, inline void GUI_ShowSMS (void) { - int i,j; - - GUI_InitSMSFoldersInf(); - - for (i=1;iprev_num_of_folders) { - treeFolderItem[i-1] = gtk_tree_item_new_with_label (_(folders.Folder[i-1].Name)); - gtk_tree_append (GTK_TREE (subTree), treeFolderItem[i-1]); - gtk_signal_connect (GTK_OBJECT (treeFolderItem[i-1]), "select", - GTK_SIGNAL_FUNC (SelectTreeItem), GINT_TO_POINTER (i-1)); - gtk_widget_show (treeFolderItem[i-1]); - } else { - gtk_widget_set_name(treeFolderItem[i-1],_(folders.Folder[i-1].Name)); - } - } - - for (j=i+1;jGetSMSStatus (&SMSStatus) == GE_NONE) { - if (phoneMonitor.sms.unRead != SMSStatus.UnRead || - phoneMonitor.sms.number2 != SMSStatus.Number) - { - phoneMonitor.working = _("Refreshing SMSes..."); -#ifdef XDEBUG - printf("Refreshing %d SMSes...\n",SMSStatus.Number); -#endif - RefreshSMS (SMSStatus.Number); - phoneMonitor.working = NULL; - } - - phoneMonitor.sms.unRead = SMSStatus.UnRead; - } -} static void DeleteSMS (void) { @@ -911,6 +908,7 @@ static void ShowSelectContactsDialog (void) GTK_SIGNAL_FUNC (CancelSelectContactDialog), (gpointer) r); } +typedef gint (*SaveSendSMSCore_func)(GSM_SMSMessage *sms); static gint SendSMSCore (GSM_SMSMessage *sms) { @@ -951,12 +949,53 @@ static gint SendSMSCore (GSM_SMSMessage *sms) return (error); } +static gint SaveSMSCore (GSM_SMSMessage *sms) +{ + GSM_Error error; + PhoneEvent *e = (PhoneEvent *) g_malloc (sizeof (PhoneEvent)); + D_SMSMessage *m = (D_SMSMessage *) g_malloc (sizeof (D_SMSMessage)); + + /* FIXME: Give user a choice of choosing target memory type, currently + * we implicitely always force SIM storage. + */ + sms->MemoryType = GMT_SM; + + m->sms = sms; + e->event = Event_SaveSMSMessage; + e->data = m; + GUI_InsertEvent (e); + pthread_mutex_lock (&saveSMSMutex); + pthread_cond_wait (&saveSMSCond, &saveSMSMutex); + pthread_mutex_unlock (&saveSMSMutex); -static void SendSMS (void) +#ifdef XDEBUG + g_print ("Address: %s\nText: %s\nDelivery report: %d\nSMS Center: %d\n", + sms->Destination, + sms->MessageText, + GTK_TOGGLE_BUTTON (sendSMS.report)->active, + sendSMS.center); +#endif + + error = m->status; + g_free (m); + + if (error != GE_NONE) + { + gchar *buf = g_strdup_printf (_("SMS save of message to %s failed\n(error=%d)"), + sms->Destination, error); + gtk_label_set_text (GTK_LABEL(errorDialog.text), buf); + gtk_widget_show (errorDialog.dialog); + g_free (buf); + } + else + g_print ("Message saved, destination to: %s\n", sms->Destination); + + return (error); +} + +static void SaveSendSMS (SaveSendSMSCore_func corefunc) { - GSM_UDH UDHType; - GSM_MultiSMSMessage Multisms; - int chars_read; + GSM_SMSMessage sms; AddressPar aps; GSList *r; gchar *text, *number; @@ -964,7 +1003,8 @@ static void SendSMS (void) gchar *buf; gint l; gint longSMS; - register gint i = 0, j; + register gint i = 0; + GSM_Deconcatenate_state SMS_Deconcatenate_state; if (CheckAddressMain ()) { @@ -992,46 +1032,44 @@ static void SendSMS (void) else number = addresses[i]; - chars_read=strlen(text); - UDHType = GSM_NoUDH; - if (l > GSM_MAX_SMS_LENGTH && longSMS) UDHType = GSM_ConcatenatedMessages; - if (UDHType == GSM_NoUDH && chars_read>160) chars_read=160; + sms.MessageCenter = xgnokiiConfig.smsSetting[sendSMS.center]; + sms.MessageCenter.No = 0; - GSM_MakeMultiPartSMS2(&Multisms,text,chars_read,UDHType,GSM_Coding_Default); - - for (j=0;jactive) + sms.Type = GST_DR; + else + sms.Type = GST_MO; - if (GTK_TOGGLE_BUTTON (sendSMS.report)->active) Multisms.SMS[j].Type = GST_DR; + sms.Class = -1; + sms.Compression = false; + sms.EightBit = false; + sms.Validity = sms.MessageCenter.Validity; + sms.UDHPresent = false; - if (GTK_TOGGLE_BUTTON (sendSMS.class)->active) Multisms.SMS[j].Class = 0; + strncpy (sms.Destination, number, GSM_MAX_DESTINATION_LENGTH + 1); + sms.Destination[GSM_MAX_DESTINATION_LENGTH] = '\0'; - Multisms.SMS[j].Validity = Multisms.SMS[j].MessageCenter.Validity; + buf = g_strdup_printf ((corefunc==SendSMSCore ? _("Sending SMS to %s ...\n") : _("Saving SMS to %s ...\n")), + sms.Destination); + gtk_label_set_text (GTK_LABEL (infoDialog.text), buf); + gtk_widget_show_now (infoDialog.dialog); + g_free (buf); + GUI_Refresh (); - strncpy (Multisms.SMS[j].Destination, number, GSM_MAX_DESTINATION_LENGTH + 1); - Multisms.SMS[j].Destination[GSM_MAX_DESTINATION_LENGTH] = '\0'; + SMS_Deconcatenate_state.first=true; + while (SMS_Deconcatenate(&SMS_Deconcatenate_state,&sms,text,l,longSMS)) { - buf = g_strdup_printf (_("Sending SMS to %s (%d/%d) ...\n"), - Multisms.SMS[j].Destination, j + 1, Multisms.number); - gtk_label_set_text (GTK_LABEL (infoDialog.text), buf); - gtk_widget_show_now (infoDialog.dialog); - g_free (buf); - GUI_Refresh (); + (void) (*corefunc)(&sms); /* errors ignored, ugh */ - if (SendSMSCore (&Multisms.SMS[j]) != GE_SMSSENDOK) - { - gtk_widget_hide (infoDialog.dialog); - GUI_Refresh (); - break; - } + /* Here the sleep have no meaning. + * If it is required by some backend phone driver, it should be done THERE! + */ + /* sleep(1); */ + } - gtk_widget_hide (infoDialog.dialog); - GUI_Refresh (); + gtk_widget_hide (infoDialog.dialog); + GUI_Refresh (); - sleep (1); - } - i++; } @@ -1040,11 +1078,20 @@ static void SendSMS (void) g_free (text); } +static void SendSMS (void) +{ + SaveSendSMS(SendSMSCore); +} + +static void SaveSMS (void) +{ + SaveSendSMS(SaveSMSCore); +} static GtkItemFactoryEntry send_menu_items[] = { { NULL, NULL, NULL, 0, ""}, { NULL, "X", SendSMS, 0, NULL}, - { NULL, "S", NULL, 0, NULL}, + { NULL, "S", SaveSMS, 0, NULL}, { NULL, NULL, NULL, 0, ""}, { NULL, "N", CheckAddress, 0, NULL}, { NULL, "C", ShowSelectContactsDialog, 0, NULL}, @@ -1092,6 +1139,7 @@ static void CreateSMSSendWindow (void) InitSendMenu (); sendSMS.SMSSendWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL); + gtk_window_set_wmclass (GTK_WINDOW(sendSMS.SMSSendWindow), "SMSSendWindow", "Xgnokii"); //gtk_widget_set_usize (GTK_WIDGET (sendSMS.SMSSendWindow), 436, 220); gtk_signal_connect (GTK_OBJECT (sendSMS.SMSSendWindow), "delete_event", @@ -1129,7 +1177,7 @@ static void CreateSMSSendWindow (void) gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), NULL, _("Save message to outbox"), NULL, NewPixmap(Send_xpm, GUI_SMSWindow->window, &GUI_SMSWindow->style->bg[GTK_STATE_NORMAL]), - (GtkSignalFunc) NULL, NULL); + (GtkSignalFunc) SaveSMS, NULL); gtk_toolbar_append_space (GTK_TOOLBAR (toolbar)); @@ -1226,10 +1274,6 @@ static void CreateSMSSendWindow (void) gtk_box_pack_start (GTK_BOX (vbox), sendSMS.longSMS, FALSE, FALSE, 3); gtk_widget_show (sendSMS.longSMS); - sendSMS.class = gtk_check_button_new_with_label (_("Send as Flash SMS (Class 0)")); - gtk_box_pack_start (GTK_BOX (vbox), sendSMS.class, FALSE, FALSE, 3); - gtk_widget_show (sendSMS.class); - label = gtk_label_new (_("SMS Center:")); gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 1); gtk_widget_show (label); @@ -1313,6 +1357,7 @@ static void ReplySMS (void) gchar *buf; // GSList *r; // GSM_SMSMessage msg; + MessagePointers *msgPtrs; if (GTK_CLIST (SMS.smsClist)->selection == NULL) return; @@ -1340,9 +1385,15 @@ static void ReplySMS (void) //r = g_slist_find_custom (SMS.messages, &msg, CompareSMSMessageLocation); //if (r) - gtk_entry_set_text (GTK_ENTRY (sendSMS.addr), - ((MessagePointers *) gtk_clist_get_row_data(GTK_CLIST (SMS.smsClist), - GPOINTER_TO_INT (GTK_CLIST (SMS.smsClist)->selection->data)))->sender); + msgPtrs = ((MessagePointers *) gtk_clist_get_row_data(GTK_CLIST (SMS.smsClist), + GPOINTER_TO_INT (GTK_CLIST (SMS.smsClist)->selection->data))); + + /* We don't have GSM_SMSMessageType stored in MessagePointers so we just + * look at both the "sender" and "destination", shouldn't matter. + * Anyway to "Reply" to Outbox message is a bit weird, the icon/menu should + * be automatically changed when switched to the Outbox mode. Not my business. + */ + gtk_entry_set_text (GTK_ENTRY (sendSMS.addr), (msgPtrs->sender[0] ? msgPtrs->sender : msgPtrs->destination)); CheckAddressMain (); RefreshSMSStatus (); @@ -1427,8 +1478,6 @@ static void NewBC (void) static GtkItemFactoryEntry menu_items[] = { { NULL, NULL, NULL, 0, ""}, - { NULL, NULL, ReadFromPhone, 0, NULL}, - { NULL, NULL, NULL, 0, ""}, { NULL, "S", NULL, 0, NULL}, { NULL, "M", SaveToMailbox, 0, NULL}, { NULL, NULL, NULL, 0, ""}, @@ -1451,8 +1500,6 @@ static void InitMainMenu (void) register gint i = 0; menu_items[i++].path = g_strdup (_("/_File")); - menu_items[i++].path = g_strdup (_("/File/Read from phone")); - menu_items[i++].path = g_strdup (_("/File/Sep0")); menu_items[i++].path = g_strdup (_("/File/_Save")); menu_items[i++].path = g_strdup (_("/File/Save to mailbo_x")); menu_items[i++].path = g_strdup (_("/File/Sep1")); @@ -1480,14 +1527,16 @@ void GUI_CreateSMSWindow (void) GtkWidget *toolbar; GtkWidget *scrolledWindow; GtkWidget *vpaned, *hpaned; - GtkWidget *tree, *treeSMSItem; + GtkWidget *tree, *treeSMSItem, *treeInboxItem, *treeOutboxItem, *subTree; SortColumn *sColumn; GdkColormap *cmap; register gint i; gchar *titles[4] = { _("Status"), _("Date / Time"), _("Sender"), _("Message")}; + InitMainMenu (); GUI_SMSWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL); + gtk_window_set_wmclass (GTK_WINDOW (GUI_SMSWindow), "SMSWindow", "Xgnokii"); gtk_window_set_title (GTK_WINDOW (GUI_SMSWindow), _("Short Message Service")); //gtk_widget_set_usize (GTK_WIDGET (GUI_SMSWindow), 436, 220); gtk_signal_connect (GTK_OBJECT (GUI_SMSWindow), "delete_event", @@ -1571,6 +1620,18 @@ void GUI_CreateSMSWindow (void) gtk_tree_set_view_mode (GTK_TREE (subTree), GTK_TREE_VIEW_ITEM); gtk_tree_item_set_subtree (GTK_TREE_ITEM (treeSMSItem), subTree); + treeInboxItem = gtk_tree_item_new_with_label (_("Inbox")); + gtk_tree_append (GTK_TREE (subTree), treeInboxItem); + gtk_signal_connect (GTK_OBJECT (treeInboxItem), "select", + GTK_SIGNAL_FUNC (SelectTreeItem), GINT_TO_POINTER (0)); + gtk_widget_show (treeInboxItem); + + treeOutboxItem = gtk_tree_item_new_with_label (_("Outbox")); + gtk_tree_append (GTK_TREE (subTree), treeOutboxItem); + gtk_signal_connect (GTK_OBJECT (treeOutboxItem), "select", + GTK_SIGNAL_FUNC (SelectTreeItem), GINT_TO_POINTER (1)); + gtk_widget_show (treeOutboxItem); + scrolledWindow = gtk_scrolled_window_new (NULL, NULL); gtk_widget_set_usize (scrolledWindow, 75, 80); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledWindow), @@ -1583,6 +1644,7 @@ void GUI_CreateSMSWindow (void) tree); gtk_widget_show (scrolledWindow); + /* Message viewer */ SMS.smsText = gtk_text_new (NULL, NULL); gtk_text_set_editable (GTK_TEXT (SMS.smsText), FALSE); diff --git a/xgnokii/xgnokii_sms.h b/xgnokii/xgnokii_sms.h index d03398c..d40dea1 100644 --- a/xgnokii/xgnokii_sms.h +++ b/xgnokii/xgnokii_sms.h @@ -3,9 +3,14 @@ X G N O K I I A Linux/Unix GUI for Nokia mobile phones. + Copyright (C) 1999 Pavel Janík ml., Hugh Blemings + & Ján Derfiòák . Released under the terms of the GNU GPL, see file COPYING for more details. + Last modification: Tue Nov 27 1999 + Modified by Jan Derfinak + */ #ifndef XGNOKII_SMS_H diff --git a/xgnokii/xgnokii_speed.c b/xgnokii/xgnokii_speed.c index d4bb32b..51db1e5 100644 --- a/xgnokii/xgnokii_speed.c +++ b/xgnokii/xgnokii_speed.c @@ -3,9 +3,14 @@ X G N O K I I A Linux/Unix GUI for Nokia mobile phones. + Copyright (C) 1999 Pavel Janík ml., Hugh Blemings + & Ján Derfiòák . Released under the terms of the GNU GPL, see file COPYING for more details. + Last modification: Sun Apr 30 2000 + Modified by Jan Derfinak + */ @@ -38,7 +43,7 @@ static bool speedDialInitialized; static inline void Help1 (GtkWidget *w, gpointer data) { - gchar *indx = g_strdup_printf ("/%s/gnokii/xgnokii/speeddial/index.htm", xgnokiiConfig.locale); + gchar *indx = g_strdup_printf ("/help/%s/windows/speeddial/index.html", xgnokiiConfig.locale); Help (w, indx); g_free (indx); } @@ -551,6 +556,7 @@ void GUI_CreateSpeedDialWindow (void) InitMainMenu (); GUI_SpeedDialWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL); + gtk_window_set_wmclass (GTK_WINDOW (GUI_SpeedDialWindow), "SpeedDialWindow", "Xgnokii"); gtk_window_set_title (GTK_WINDOW (GUI_SpeedDialWindow), _("Speed Dial")); gtk_widget_set_usize (GTK_WIDGET (GUI_SpeedDialWindow), 332, 220); //gtk_container_set_border_width (GTK_CONTAINER (GUI_SpeedDialWindow), 10); diff --git a/xgnokii/xgnokii_speed.h b/xgnokii/xgnokii_speed.h index a454bf5..7be5249 100644 --- a/xgnokii/xgnokii_speed.h +++ b/xgnokii/xgnokii_speed.h @@ -3,9 +3,14 @@ X G N O K I I A Linux/Unix GUI for Nokia mobile phones. + Copyright (C) 1999 Pavel Janík ml., Hugh Blemings + & Ján Derfiòák . Released under the terms of the GNU GPL, see file COPYING for more details. + Last modification: Sun Dec 26 1999 + Modified by Jan Derfinak + */ #ifndef XGNOKII_SPEED_H diff --git a/xgnokii/xgnokii_xkeyb.c b/xgnokii/xgnokii_xkeyb.c index 3ecf9f6..42fc7f8 100644 --- a/xgnokii/xgnokii_xkeyb.c +++ b/xgnokii/xgnokii_xkeyb.c @@ -3,14 +3,20 @@ X G N O K I I A Linux/Unix GUI for Nokia mobile phones. + Copyright (C) 1999 Pavel Janík ml., Hugh Blemings + & Ján Derfiòák . Released under the terms of the GNU GPL, see file COPYING for more details. + Last modification: Sun May 14 2000 + Modified by Jan Derfinak + */ #include #include #include "misc.h" +#include "fbus-6110.h" #include "xgnokii_common.h" #include "xgnokii.h" #include "xgnokii_lowlevel.h" @@ -30,79 +36,79 @@ static ErrorDialog errorDialog = {NULL, NULL}; static ButtonT *button = NULL; static ButtonT button_6110[30] = { - { 103, 91, 114, 107, PHONEKEY_POWER }, /* Power */ - { 28, 240, 54, 263, PHONEKEY_MENU }, /* Menu */ - { 84, 240, 110, 263, PHONEKEY_NAMES }, /* Names */ - { 58, 245, 82, 258, PHONEKEY_UP }, /* Up */ - { 55, 263, 85, 276, PHONEKEY_DOWN }, /* Down */ - { 22, 271, 50, 289, PHONEKEY_GREEN }, /* Green */ - { 91, 271, 115, 289, PHONEKEY_RED }, /* Red */ - { 18, 294, 44, 310, PHONEKEY_1 }, /* 1 */ - { 56, 294, 85, 310, PHONEKEY_2 }, /* 2 */ - { 98, 294, 121, 310, PHONEKEY_3 }, /* 3 */ - { 18, 317, 44, 333, PHONEKEY_4 }, /* 4 */ - { 56, 317, 85, 333, PHONEKEY_5 }, /* 5 */ - { 98, 317, 121, 333, PHONEKEY_6 }, /* 6 */ - { 18, 342, 44, 356, PHONEKEY_7 }, /* 7 */ - { 56, 342, 85, 356, PHONEKEY_8 }, /* 8 */ - { 98, 342, 121, 356, PHONEKEY_9 }, /* 9 */ - { 18, 365, 44, 380, PHONEKEY_ASTERISK }, /* * */ - { 56, 365, 85, 380, PHONEKEY_0 }, /* 0 */ - { 98, 365, 121, 380, PHONEKEY_HASH }, /* # */ - { 1, 138, 10, 150, PHONEKEY_INCREASEVOLUME }, /* Volume + */ - { 1, 165, 10, 176, PHONEKEY_DECREASEVOLUME }, /* Volume - */ + { 103, 91, 114, 107, 0x0d }, /* Power */ + { 28, 240, 54, 263, 0x19 }, /* Menu */ + { 84, 240, 110, 263, 0x1a }, /* Names */ + { 58, 245, 82, 258, 0x17 }, /* Up */ + { 55, 263, 85, 276, 0x18 }, /* Down */ + { 22, 271, 50, 289, 0x0e }, /* Green */ + { 91, 271, 115, 289, 0x0f }, /* Red */ + { 18, 294, 44, 310, 0x01 }, /* 1 */ + { 56, 294, 85, 310, 0x02 }, /* 2 */ + { 98, 294, 121, 310, 0x03 }, /* 3 */ + { 18, 317, 44, 333, 0x04 }, /* 4 */ + { 56, 317, 85, 333, 0x05 }, /* 5 */ + { 98, 317, 121, 333, 0x06 }, /* 6 */ + { 18, 342, 44, 356, 0x07 }, /* 7 */ + { 56, 342, 85, 356, 0x08 }, /* 8 */ + { 98, 342, 121, 356, 0x09 }, /* 9 */ + { 18, 365, 44, 380, 0x0c }, /* * */ + { 56, 365, 85, 380, 0x0a }, /* 0 */ + { 98, 365, 121, 380, 0x0b }, /* # */ + { 1, 138, 10, 150, 0x10 } , /* Volume + */ + { 1, 165, 10, 176, 0x11 } , /* Volume - */ { 0, 0, 0, 0, 0x00 } }; static ButtonT button_6150[30] = { - { 99, 78, 114, 93, PHONEKEY_POWER }, /* Power */ - { 20, 223, 49, 245, PHONEKEY_MENU }, /* Menu */ - { 90, 223, 120, 245, PHONEKEY_NAMES }, /* Names */ - { 59, 230, 83, 247, PHONEKEY_UP }, /* Up */ - { 56, 249, 84, 265, PHONEKEY_DOWN }, /* Down */ - { 14, 254, 51, 273, PHONEKEY_GREEN }, /* Green */ - { 90, 255, 126, 273, PHONEKEY_RED }, /* Red */ - { 18, 281, 53, 299, PHONEKEY_1 }, /* 1 */ - { 55, 280, 86, 299, PHONEKEY_2 }, /* 2 */ - { 90, 281, 122, 299, PHONEKEY_3 }, /* 3 */ - { 18, 303, 53, 323, PHONEKEY_4 }, /* 4 */ - { 55, 303, 87, 323, PHONEKEY_5 }, /* 5 */ - { 90, 303, 122, 323, PHONEKEY_6 }, /* 6 */ - { 18, 327, 53, 346, PHONEKEY_7 }, /* 7 */ - { 53, 327, 87, 346, PHONEKEY_8 }, /* 8 */ - { 90, 327, 122, 346, PHONEKEY_9 }, /* 9 */ - { 18, 349, 53, 370, PHONEKEY_ASTERISK }, /* * */ - { 56, 349, 87, 370, PHONEKEY_0 }, /* 0 */ - { 98, 349, 122, 370, PHONEKEY_HASH }, /* # */ - { 2, 131, 10, 147, PHONEKEY_INCREASEVOLUME }, /* Volume + */ - { 2, 155, 10, 173, PHONEKEY_DECREASEVOLUME }, /* Volume - */ + { 99, 78, 114, 93, 0x0d }, /* Power */ + { 20, 223, 49, 245, 0x19 }, /* Menu */ + { 90, 223, 120, 245, 0x1a }, /* Names */ + { 59, 230, 83, 247, 0x17 }, /* Up */ + { 56, 249, 84, 265, 0x18 }, /* Down */ + { 14, 254, 51, 273, 0x0e }, /* Green */ + { 90, 255, 126, 273, 0x0f }, /* Red */ + { 18, 281, 53, 299, 0x01 }, /* 1 */ + { 55, 280, 86, 299, 0x02 }, /* 2 */ + { 90, 281, 122, 299, 0x03 }, /* 3 */ + { 18, 303, 53, 323, 0x04 }, /* 4 */ + { 55, 303, 87, 323, 0x05 }, /* 5 */ + { 90, 303, 122, 323, 0x06 }, /* 6 */ + { 18, 327, 53, 346, 0x07 }, /* 7 */ + { 53, 327, 87, 346, 0x08 }, /* 8 */ + { 90, 327, 122, 346, 0x09 }, /* 9 */ + { 18, 349, 53, 370, 0x0c }, /* * */ + { 56, 349, 87, 370, 0x0a }, /* 0 */ + { 98, 349, 122, 370, 0x0b }, /* # */ + { 2, 131, 10, 147, 0x10 }, /* Volume + */ + { 2, 155, 10, 173, 0x11 }, /* Volume - */ { 0, 0, 0, 0, 0x00 } }; static ButtonT button_5110[30] = { - { 100, 85, 114, 99, PHONEKEY_POWER }, /* Power */ - { 50, 240, 85, 265, PHONEKEY_MENU }, /* Menu */ - { 20, 240, 45, 260, PHONEKEY_NAMES }, /* Names */ - { 100, 240, 117, 258, PHONEKEY_UP }, /* Up */ - { 93, 267, 112, 287, PHONEKEY_DOWN }, /* Down */ - { 14, 294, 44, 312, PHONEKEY_1 }, /* 1 */ - { 54, 294, 83, 312, PHONEKEY_2 }, /* 2 */ - { 94, 294, 122, 312, PHONEKEY_3 }, /* 3 */ - { 14, 320, 44, 338, PHONEKEY_4 }, /* 4 */ - { 54, 320, 83, 338, PHONEKEY_5 }, /* 5 */ - { 94, 320, 122, 338, PHONEKEY_6 }, /* 6 */ - { 14, 345, 44, 363, PHONEKEY_7 }, /* 7 */ - { 54, 345, 83, 363, PHONEKEY_8 }, /* 8 */ - { 94, 345, 122, 363, PHONEKEY_9 }, /* 9 */ - { 18, 374, 49, 389, PHONEKEY_ASTERISK }, /* * */ - { 53, 371, 82, 387, PHONEKEY_0 }, /* 0 */ - { 96, 374, 119, 389, PHONEKEY_HASH }, /* # */ + { 100, 85, 114, 99, 0x0d }, /* Power */ + { 50, 240, 85, 265, 0x19 }, /* Menu */ + { 20, 240, 45, 260, 0x1a }, /* Names */ + { 100, 240, 117, 258, 0x17 }, /* Up */ + { 93, 267, 112, 287, 0x18 }, /* Down */ + { 14, 294, 44, 312, 0x01 }, /* 1 */ + { 54, 294, 83, 312, 0x02 }, /* 2 */ + { 94, 294, 122, 312, 0x03 }, /* 3 */ + { 14, 320, 44, 338, 0x04 }, /* 4 */ + { 54, 320, 83, 338, 0x05 }, /* 5 */ + { 94, 320, 122, 338, 0x06 }, /* 6 */ + { 14, 345, 44, 363, 0x07 }, /* 7 */ + { 54, 345, 83, 363, 0x08 }, /* 8 */ + { 94, 345, 122, 363, 0x09 }, /* 9 */ + { 18, 374, 49, 389, 0x0c }, /* * */ + { 53, 371, 82, 387, 0x0a }, /* 0 */ + { 96, 374, 119, 389, 0x0b }, /* # */ { 0, 0, 0, 0, 0x00 } }; static inline void Help1 (GtkWidget *w, gpointer data) { - gchar *indx = g_strdup_printf ("/%s/gnokii/xgnokii/xkeyb/index.htm", xgnokiiConfig.locale); + gchar *indx = g_strdup_printf ("/help/%s/windows/xkeyb/index.html", xgnokiiConfig.locale); Help (w, indx); g_free (indx); } @@ -184,7 +190,7 @@ void GUI_ShowXkeyb (void) static gint ButtonEvent (GtkWidget *widget, GdkEventButton *event) { - unsigned char req[] = {0x00,0x00}; + unsigned char req[] = {FB61_FRAME_HEADER, 0x42, 0x01, 0x00, 0x01}; register gint i = 0; if (button == NULL) @@ -194,9 +200,9 @@ static gint ButtonEvent (GtkWidget *widget, GdkEventButton *event) return TRUE; if (event->type == GDK_BUTTON_PRESS) - req[0] = PRESSPHONEKEY; + req[4] = 0x01; else if (event->type == GDK_BUTTON_RELEASE) - req[0] = RELEASEPHONEKEY; + req[4] = 0x02; else return TRUE; @@ -210,7 +216,7 @@ static gint ButtonEvent (GtkWidget *widget, GdkEventButton *event) { PhoneEvent *e = g_malloc (sizeof (PhoneEvent)); - req[1]=button[i].code; + req[5]=button[i].code; e->event = Event_SendKeyStroke; e->data = g_memdup (req, sizeof (req)); GUI_InsertEvent (e); @@ -251,6 +257,7 @@ void GUI_CreateXkeybWindow (void) InitMainMenu (); GUI_XkeybWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL); + gtk_window_set_wmclass (GTK_WINDOW (GUI_XkeybWindow), "XkeybWindow", "Xgnokii"); gtk_window_set_title (GTK_WINDOW (GUI_XkeybWindow), _("XGnokii Keyboard")); //gtk_widget_set_usize (GTK_WIDGET (GUI_XkeybWindow), 436, 220); gtk_signal_connect (GTK_OBJECT (GUI_XkeybWindow), "delete_event", diff --git a/xgnokii/xgnokii_xkeyb.h b/xgnokii/xgnokii_xkeyb.h index 6060e09..b2544bd 100644 --- a/xgnokii/xgnokii_xkeyb.h +++ b/xgnokii/xgnokii_xkeyb.h @@ -3,9 +3,14 @@ X G N O K I I A Linux/Unix GUI for Nokia mobile phones. + Copyright (C) 1999 Pavel Janík ml., Hugh Blemings + & Ján Derfiòák . Released under the terms of the GNU GPL, see file COPYING for more details. + Last modification: Sun Mar 19 2000 + Modified by Jan Derfinak + */ #ifndef XGNOKII_XKEYB_H -- 1.8.3.1