id
int64 0
755k
| file_name
stringlengths 3
109
| file_path
stringlengths 13
185
| content
stringlengths 31
9.38M
| size
int64 31
9.38M
| language
stringclasses 1
value | extension
stringclasses 11
values | total_lines
int64 1
340k
| avg_line_length
float64 2.18
149k
| max_line_length
int64 7
2.22M
| alphanum_fraction
float64 0
1
| repo_name
stringlengths 6
65
| repo_stars
int64 100
47.3k
| repo_forks
int64 0
12k
| repo_open_issues
int64 0
3.4k
| repo_license
stringclasses 9
values | repo_extraction_date
stringclasses 92
values | exact_duplicates_redpajama
bool 2
classes | near_duplicates_redpajama
bool 2
classes | exact_duplicates_githubcode
bool 2
classes | exact_duplicates_stackv2
bool 1
class | exact_duplicates_stackv1
bool 2
classes | near_duplicates_githubcode
bool 2
classes | near_duplicates_stackv1
bool 2
classes | near_duplicates_stackv2
bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
750,954
|
player_highlight_repeat.h
|
anonbeat_guayadeque/src/images/player_highlight_repeat.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// 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 3, 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; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
const unsigned char guImage_player_highlight_repeat[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x1e,
0x08, 0x06, 0x00, 0x00, 0x00, 0x3b, 0x30, 0xae, 0xa2, 0x00, 0x00, 0x00,
0x04, 0x73, 0x42, 0x49, 0x54, 0x08, 0x08, 0x08, 0x08, 0x7c, 0x08, 0x64,
0x88, 0x00, 0x00, 0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x14,
0xc3, 0x00, 0x00, 0x14, 0xc3, 0x01, 0x15, 0x70, 0x4d, 0x42, 0x00, 0x00,
0x00, 0x19, 0x74, 0x45, 0x58, 0x74, 0x53, 0x6f, 0x66, 0x74, 0x77, 0x61,
0x72, 0x65, 0x00, 0x77, 0x77, 0x77, 0x2e, 0x69, 0x6e, 0x6b, 0x73, 0x63,
0x61, 0x70, 0x65, 0x2e, 0x6f, 0x72, 0x67, 0x9b, 0xee, 0x3c, 0x1a, 0x00,
0x00, 0x04, 0x7b, 0x49, 0x44, 0x41, 0x54, 0x48, 0x89, 0xad, 0xd7, 0x7f,
0xc8, 0x9e, 0x65, 0x15, 0x07, 0xf0, 0xcf, 0xf3, 0xf8, 0xea, 0xa6, 0x35,
0x2c, 0xc1, 0x1f, 0xcb, 0x59, 0x20, 0x09, 0x19, 0xf8, 0x87, 0x59, 0x69,
0xe9, 0xea, 0x21, 0x8d, 0x82, 0x66, 0xcc, 0x54, 0x14, 0x21, 0x6c, 0xf3,
0x9f, 0x74, 0x45, 0xd9, 0xd0, 0x30, 0x8a, 0xf3, 0x1c, 0x33, 0x41, 0x6a,
0x45, 0x2c, 0x26, 0x46, 0x34, 0x89, 0x52, 0xe6, 0x96, 0xb6, 0x2c, 0x10,
0x45, 0xdc, 0x2d, 0x54, 0x96, 0xf6, 0x83, 0x85, 0x49, 0xe0, 0xa8, 0xe6,
0x6c, 0x25, 0x88, 0x8b, 0xd4, 0x52, 0xdb, 0x7b, 0xf5, 0xc7, 0x75, 0x3f,
0x6f, 0xf7, 0x6e, 0x9f, 0xe7, 0x7d, 0x1d, 0xf4, 0x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0x0f,
0xb7, 0xe0, 0x71, 0xeb, 0x99, 0xd1, 0x68, 0x74, 0x4f, 0x6b, 0xd0, 0x35,
0x58, 0x3b, 0x1a, 0x8d, 0xfe, 0xd4, 0x34, 0xcd, 0x93, 0xd3, 0x94, 0x37,
0x4d, 0x33, 0x6d, 0x58, 0x44, 0x5c, 0xa0, 0x46, 0xf3, 0x87, 0xd4, 0x26,
0x6f, 0x43, 0xdf, 0xc0, 0xc5, 0x1a, 0xfa, 0x8b, 0xf1, 0x75, 0xbc, 0x19,
0x0f, 0xab, 0x79, 0x77, 0x67, 0x66, 0x3e, 0x37, 0x43, 0xfe, 0x58, 0xb5,
0x91, 0x5f, 0x8f, 0xf3, 0xd5, 0x40, 0xfa, 0x5c, 0x66, 0xfe, 0x70, 0x9a,
0xfc, 0x52, 0x57, 0x98, 0xe5, 0xf8, 0xb4, 0xda, 0x8d, 0x9c, 0xe8, 0x7f,
0x57, 0x98, 0x7d, 0x6a, 0x95, 0xa1, 0xe6, 0xde, 0x55, 0x6a, 0x00, 0x1e,
0xa9, 0x9e, 0xd3, 0x4d, 0xd8, 0xdc, 0xdd, 0xa6, 0xc3, 0x22, 0xee, 0x18,
0x30, 0xc4, 0xb9, 0x0e, 0xbd, 0xb4, 0x9d, 0xa4, 0x56, 0xad, 0xfd, 0x0e,
0xbd, 0xb4, 0xfd, 0xac, 0x7f, 0x6b, 0x98, 0x86, 0xff, 0x02, 0xde, 0xd7,
0xee, 0x40, 0x9a, 0xbf, 0x96, 0xc5, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45,
0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
| 8,987
|
C++
|
.h
| 130
| 66.484615
| 86
| 0.651688
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,955
|
player_highlight_gapless.h
|
anonbeat_guayadeque/src/images/player_highlight_gapless.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// 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 3, 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; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
const unsigned char guImage_player_highlight_gapless[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x1e,
0x08, 0x06, 0x00, 0x00, 0x00, 0x3b, 0x30, 0xae, 0xa2, 0x00, 0x00, 0x00,
0x04, 0x73, 0x42, 0x49, 0x54, 0x08, 0x08, 0x08, 0x08, 0x7c, 0x08, 0x64,
0x88, 0x00, 0x00, 0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x13,
0xc6, 0x00, 0x00, 0x13, 0xc6, 0x01, 0xf8, 0x22, 0x00, 0xbf, 0x00, 0x00,
0x00, 0x19, 0x74, 0x45, 0x58, 0x74, 0x53, 0x6f, 0x66, 0x74, 0x77, 0x61,
0x72, 0x65, 0x00, 0x77, 0x77, 0x77, 0x2e, 0x69, 0x6e, 0x6b, 0x73, 0x63,
0x61, 0x70, 0x65, 0x2e, 0x6f, 0x72, 0x67, 0x9b, 0xee, 0x3c, 0x1a, 0x00,
0x00, 0x03, 0x02, 0x49, 0x44, 0x41, 0x54, 0x48, 0x89, 0xb5, 0xd7, 0x4f,
0x88, 0x96, 0x55, 0x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xe8, 0x09, 0x73, 0x93, 0x45, 0x0c, 0xcb, 0x22, 0x3f,
0x22, 0xdf, 0x53, 0xbd, 0x8f, 0xb6, 0x59, 0x59, 0x01, 0x17, 0x4a, 0x29,
0x97, 0x07, 0xf1, 0xf7, 0x2f, 0xa8, 0x01, 0x44, 0xa1, 0xac, 0x14, 0x27,
0x22, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60,
0x82
};
| 6,664
|
C++
|
.h
| 99
| 64.777778
| 86
| 0.649657
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| false
| false
|
750,956
|
tiny_mv_playlists.h
|
anonbeat_guayadeque/src/images/tiny_mv_playlists.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// 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 3, 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; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
const unsigned char guImage_tiny_mv_playlists[] = {
0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D,
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10,
0x08, 0x06, 0x00, 0x00, 0x00, 0x1F, 0xF3, 0xFF, 0x61, 0x00, 0x00, 0x00,
0x04, 0x67, 0x41, 0x4D, 0x41, 0x00, 0x00, 0xB1, 0x8F, 0x0B, 0xFC, 0x61,
0x05, 0x00, 0x00, 0x00, 0x06, 0x62, 0x4B, 0x47, 0x44, 0x00, 0xFF, 0x00,
0xFF, 0x00, 0xFF, 0xA0, 0xBD, 0xA7, 0x93, 0x00, 0x00, 0x00, 0x09, 0x70,
0x48, 0x59, 0x73, 0x00, 0x00, 0x0D, 0xD7, 0x00, 0x00, 0x0D, 0xD7, 0x01,
0x42, 0x28, 0x9B, 0x78, 0x00, 0x00, 0x00, 0x07, 0x74, 0x49, 0x4D, 0x45,
0x07, 0xDB, 0x0A, 0x19, 0x17, 0x19, 0x01, 0x26, 0xE2, 0x6A, 0x83, 0x00,
0x00, 0x00, 0xA3, 0x49, 0x44, 0x41, 0x54, 0x38, 0xCB, 0xED, 0xD0, 0x31,
0x0A, 0x82, 0x50, 0x00, 0xC6, 0xF1, 0xBF, 0xA1, 0x85, 0x43, 0x4E, 0xB9,
0x54, 0x90, 0x47, 0xC8, 0xBC, 0xC8, 0x7B, 0x67, 0x09, 0xEA, 0x0C, 0x05,
0x45, 0xD0, 0x41, 0x7C, 0x27, 0x79, 0x08, 0x45, 0xB3, 0x81, 0x34, 0xDB,
0x64, 0x92, 0x64, 0x43, 0x04, 0x0E, 0x6F, 0x91, 0xA0, 0xC9, 0xDF, 0xF8,
0x4D, 0x1F, 0x7F, 0x0B, 0x60, 0xB5, 0x5E, 0xC6, 0xCF, 0xAA, 0x12, 0x00,
0x8E, 0x6D, 0xAB, 0xED, 0x66, 0x27, 0x9B, 0x9B, 0x49, 0x5D, 0xBF, 0xD4,
0x61, 0x7F, 0x94, 0x3D, 0x00, 0xAD, 0x13, 0xB1, 0x88, 0x42, 0xC2, 0x68,
0x8E, 0xD6, 0x89, 0xF8, 0x6E, 0x93, 0xE9, 0x18, 0xDF, 0x1F, 0xE1, 0x79,
0x43, 0x06, 0x83, 0x3E, 0x50, 0x53, 0x96, 0x0F, 0xF2, 0x7B, 0xCE, 0xF9,
0x74, 0x11, 0x00, 0x16, 0x40, 0x10, 0xCC, 0xE2, 0xA2, 0x28, 0x04, 0x80,
0xEB, 0xBA, 0x2A, 0x4D, 0xAF, 0xB2, 0xB9, 0x99, 0x38, 0x8E, 0xAD, 0xB2,
0xEC, 0x26, 0xF9, 0x95, 0xD5, 0x35, 0xF8, 0x3C, 0x30, 0x69, 0xD5, 0xC0,
0xA4, 0x55, 0x03, 0x93, 0xAE, 0xC1, 0x1F, 0x1B, 0xBC, 0x01, 0x9A, 0x40,
0xAD, 0x91, 0x53, 0xEA, 0x7E, 0xEC, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45,
0x4E, 0x44, 0xAE, 0x42, 0x60, 0x82,
};
| 2,864
|
C++
|
.h
| 48
| 58.666667
| 86
| 0.649858
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,957
|
default_lastfm_image.h
|
anonbeat_guayadeque/src/images/default_lastfm_image.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// 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 3, 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; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
const unsigned char guImage_default_lastfm_image[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49,
0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x32, 0x08, 0x06,
0x00, 0x00, 0x00, 0x1e, 0x3f, 0x88, 0xb1, 0x00, 0x00, 0x00, 0x01, 0x73, 0x52,
0x47, 0x42, 0x00, 0xae, 0xce, 0x1c, 0xe9, 0x00, 0x00, 0x00, 0x06, 0x62, 0x4b,
0x47, 0x44, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0xa0, 0xbd, 0xa7, 0x93, 0x00,
0x00, 0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x0b, 0x13, 0x00, 0x00,
0x0b, 0x13, 0x01, 0x00, 0x9a, 0x9c, 0x18, 0x00, 0x00, 0x00, 0x07, 0x74, 0x49,
0x4d, 0x45, 0x07, 0xd9, 0x01, 0x10, 0x12, 0x2e, 0x39, 0xdf, 0x3c, 0x6f, 0x52,
0x00, 0x00, 0x05, 0x34, 0x49, 0x44, 0x41, 0x54, 0x68, 0xde, 0xed, 0x98, 0x4f,
0x68, 0x5c, 0x45, 0x1c, 0xc7, 0xbf, 0x33, 0x6f, 0xf7, 0x95, 0x8d, 0x09, 0x6d,
0x93, 0x6d, 0x97, 0x24, 0xbb, 0x4d, 0x57, 0xd9, 0x84, 0xb0, 0x2d, 0xe9, 0x6e,
0x12, 0xc9, 0xda, 0x52, 0x1b, 0x4f, 0x2a, 0x4a, 0x05, 0xa1, 0xe2, 0xc1, 0x82,
0x85, 0xe2, 0xa1, 0xbd, 0xa8, 0x95, 0x1e, 0xc4, 0x82, 0xa0, 0x1e, 0xf4, 0x20,
0x5e, 0x45, 0xa9, 0xd2, 0x9b, 0x28, 0x82, 0x42, 0x8f, 0x4d, 0x84, 0x40, 0x84,
0xfe, 0x09, 0x6d, 0x93, 0x4d, 0x62, 0xb2, 0x26, 0xdb, 0x97, 0x66, 0xe9, 0x66,
0x31, 0xb1, 0x49, 0x36, 0x79, 0xf3, 0x66, 0xe6, 0xe7, 0xc1, 0xf7, 0x4a, 0xac,
0x35, 0x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x37, 0x37, 0x37, 0x97, 0x1e, 0xc4, 0x71, 0x9c, 0xf3, 0x42, 0x08, 0x1d,
0x0c, 0x06, 0x3f, 0x39, 0x76, 0xec, 0xd8, 0x07, 0x99, 0x4c, 0x66, 0x0e, 0x00,
0x8e, 0x1c, 0x39, 0xb2, 0xec, 0x38, 0x6f, 0xb1, 0x55, 0x55, 0x55, 0xb2, 0xbd,
0xbd, 0xfd, 0x3c, 0x63, 0xec, 0xb8, 0x52, 0xca, 0x9e, 0x9d, 0x9d, 0x3d, 0x89,
0x52, 0x8b, 0x88, 0x42, 0x5d, 0x5d, 0x5d, 0x3d, 0xe9, 0x74, 0xfa, 0x84, 0xf7,
0x01, 0xb6, 0x1e, 0x75, 0x75, 0x75, 0x79, 0x45, 0xf5, 0x54, 0x77, 0x77, 0xf7,
0x68, 0xc9, 0x41, 0x0a, 0x85, 0x42, 0x60, 0x66, 0x66, 0x26, 0xe8, 0xb9, 0xd2,
0x46, 0x74, 0xe3, 0xc6, 0x0d, 0x2f, 0x38, 0xd5, 0x25, 0x85, 0x98, 0x9a, 0x9a,
0x7a, 0xf0, 0x7b, 0x78, 0x78, 0xf8, 0x5f, 0xbd, 0x2f, 0xf6, 0x6e, 0x2a, 0xcb,
0x2a, 0xab, 0xac, 0xb2, 0xca, 0x2a, 0xab, 0xd4, 0xfa, 0x03, 0x22, 0xdb, 0x83,
0x34, 0x18, 0x6c, 0x96, 0x05, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44,
0xae, 0x42, 0x60, 0x82
};
| 9,862
|
C++
|
.h
| 136
| 71.514706
| 86
| 0.668003
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,958
|
player_normal_ban.h
|
anonbeat_guayadeque/src/images/player_normal_ban.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// 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 3, 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; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
const unsigned char guImage_player_normal_ban[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x1e,
0x08, 0x06, 0x00, 0x00, 0x00, 0x3b, 0x30, 0xae, 0xa2, 0x00, 0x00, 0x00,
0x04, 0x73, 0x42, 0x49, 0x54, 0x08, 0x08, 0x08, 0x08, 0x7c, 0x08, 0x64,
0x88, 0x00, 0x00, 0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x13,
0xc6, 0x00, 0x00, 0x13, 0xc6, 0x01, 0xf8, 0x22, 0x00, 0xbf, 0x00, 0x00,
0x00, 0x19, 0x74, 0x45, 0x58, 0x74, 0x53, 0x6f, 0x66, 0x74, 0x77, 0x61,
0x72, 0x65, 0x00, 0x77, 0x77, 0x77, 0x2e, 0x69, 0x6e, 0x6b, 0x73, 0x63,
0x61, 0x70, 0x65, 0x2e, 0x6f, 0x72, 0x67, 0x9b, 0xee, 0x3c, 0x1a, 0x00,
0x00, 0x06, 0xaa, 0x49, 0x44, 0x41, 0x54, 0x48, 0x89, 0xc5, 0x57, 0x5d,
0x68, 0x13, 0xe9, 0x1a, 0x7e, 0xbe, 0x99, 0x64, 0x32, 0x89, 0xf9, 0xd1,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b, 0x76, 0xc1, 0xe7, 0xf3, 0xe1, 0xe0, 0xc1,
0x83, 0xff, 0x95, 0xa1, 0xaf, 0xe2, 0xff, 0xf2, 0x0b, 0xb3, 0x05, 0xff,
0xf3, 0x9f, 0xb6, 0x7f, 0x03, 0x3f, 0xfa, 0xd1, 0xb7, 0xa4, 0x07, 0x88,
0x25, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60,
0x82
};
| 12,429
|
C++
|
.h
| 177
| 67.480226
| 86
| 0.653118
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,959
|
doc_new.h
|
anonbeat_guayadeque/src/images/doc_new.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// 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 3, 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; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
const unsigned char guImage_doc_new[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49,
0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x18, 0x08, 0x06,
0x00, 0x00, 0x00, 0xe0, 0x77, 0x3d, 0xf8, 0x00, 0x00, 0x00, 0x04, 0x67, 0x41,
0x4d, 0x41, 0x00, 0x00, 0xb1, 0x8f, 0x0b, 0xfc, 0x61, 0x05, 0x00, 0x00, 0x00,
0x01, 0x73, 0x52, 0x47, 0x42, 0x00, 0xae, 0xce, 0x1c, 0xe9, 0x00, 0x00, 0x00,
0x20, 0x63, 0x48, 0x52, 0x4d, 0x00, 0x00, 0x7a, 0x26, 0x00, 0x00, 0x80, 0x84,
0x00, 0x00, 0xfa, 0x00, 0x00, 0x00, 0x80, 0xe8, 0x00, 0x00, 0x75, 0x30, 0x00,
0x00, 0xea, 0x60, 0x00, 0x00, 0x3a, 0x98, 0x00, 0x00, 0x17, 0x70, 0x9c, 0xba,
0x51, 0x3c, 0x00, 0x00, 0x00, 0x06, 0x62, 0x4b, 0x47, 0x44, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xf9, 0x43, 0xbb, 0x7f, 0x00, 0x00, 0x00, 0x09, 0x70, 0x48,
0x59, 0x73, 0x00, 0x00, 0x0b, 0x87, 0x00, 0x00, 0x0b, 0x87, 0x01, 0x93, 0x40,
0x87, 0x53, 0x00, 0x00, 0x03, 0xab, 0x49, 0x44, 0x41, 0x54, 0x48, 0xc7, 0xb5,
0x95, 0x4d, 0x6f, 0x1b, 0x55, 0x14, 0x86, 0x9f, 0x33, 0x1f, 0xb5, 0xe3, 0x89,
0xed, 0xd8, 0x6a, 0x48, 0x21, 0x40, 0x9b, 0xa4, 0x28, 0x69, 0xd2, 0x02, 0xaa,
0x4a, 0x85, 0x58, 0x74, 0x41, 0x05, 0xcb, 0x4a, 0x2c, 0xf8, 0x0d, 0x2c, 0x2a,
0x55, 0xac, 0x58, 0xc1, 0x0f, 0x60, 0xd1, 0x1f, 0xc0, 0x0a, 0x09, 0x14, 0x81,
0xc4, 0xa6, 0x5d, 0xa3, 0x56, 0xa2, 0x0b, 0x3e, 0xba, 0xe9, 0x22, 0x1f, 0x6a,
0x48, 0x0c, 0x0d, 0x69, 0x4b, 0x5a, 0x37, 0x4e, 0x6c, 0x67, 0xfc, 0x35, 0xe3,
0x7b, 0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 0x62, 0xf4, 0x78, 0xf9,
0x01, 0xc8, 0x6d, 0x2f, 0xbb, 0xd8, 0xda, 0x07, 0x48, 0x24, 0xb2, 0xc4, 0x8a,
0xab, 0x10, 0xa2, 0x27, 0x87, 0x32, 0x09, 0x84, 0xa0, 0x16, 0xf6, 0xf8, 0x67,
0x88, 0x6c, 0x61, 0x74, 0x17, 0x34, 0xc0, 0x7d, 0xed, 0x2d, 0x54, 0x87, 0xb1,
0xa4, 0x48, 0xb5, 0x5a, 0x07, 0xb8, 0xe3, 0x65, 0x17, 0xff, 0x4c, 0xf2, 0x1e,
0x30, 0x9a, 0x65, 0xed, 0x01, 0x92, 0x33, 0x49, 0xe4, 0x65, 0x14, 0x0f, 0x24,
0x03, 0x92, 0x43, 0xd9, 0x01, 0xf5, 0x23, 0x28, 0x0e, 0xaa, 0x1e, 0x96, 0x7d,
0x92, 0xd2, 0x03, 0x9b, 0x4b, 0x97, 0xbe, 0xfe, 0xb9, 0xbf, 0x2f, 0x7d, 0x00,
0x13, 0x27, 0xb3, 0x62, 0xfd, 0x13, 0x80, 0x20, 0x02, 0x42, 0x01, 0xe4, 0x02,
0x4a, 0x15, 0x61, 0x0b, 0xa8, 0xa0, 0x74, 0x81, 0x3c, 0x2a, 0x23, 0xd8, 0xce,
0x34, 0xf5, 0xda, 0x06, 0x83, 0x71, 0xa0, 0x07, 0xfd, 0xc9, 0x7b, 0x23, 0xa9,
0x46, 0x52, 0x08, 0x63, 0x20, 0x63, 0xd1, 0xb7, 0xb1, 0x59, 0x54, 0x15, 0x91,
0xd4, 0xa1, 0x1e, 0x39, 0xd0, 0x83, 0xa3, 0x92, 0x47, 0xc3, 0xea, 0xab, 0x8c,
0x3d, 0xc7, 0x4b, 0x62, 0x52, 0xf3, 0x1c, 0xc0, 0x20, 0xbd, 0xdf, 0x0e, 0xfd,
0x8b, 0xda, 0xef, 0x95, 0x78, 0xde, 0x3b, 0x28, 0x9f, 0x53, 0x01, 0x68, 0x57,
0x35, 0x3a, 0xb2, 0x55, 0x15, 0x95, 0x68, 0x63, 0x82, 0x02, 0x02, 0x2a, 0x68,
0xd2, 0xf4, 0x81, 0x7d, 0x08, 0x92, 0x6c, 0xb0, 0x7b, 0x14, 0x20, 0xd5, 0x09,
0x82, 0x5b, 0x6b, 0xa5, 0xd5, 0x0f, 0x4f, 0x4f, 0xbd, 0x71, 0xe0, 0x46, 0xfb,
0xb7, 0x50, 0x55, 0xd6, 0x4a, 0xab, 0x84, 0x61, 0x78, 0x0b, 0x48, 0x01, 0xed,
0x41, 0xc0, 0xe8, 0xfc, 0xb7, 0xdf, 0xcd, 0x37, 0xfc, 0xe6, 0xf0, 0xf0, 0x70,
0xe6, 0x5d, 0xd5, 0x3e, 0x87, 0x27, 0x97, 0xf2, 0xa1, 0x52, 0x2a, 0xaa, 0x20,
0x22, 0x66, 0x77, 0xd7, 0xff, 0xf5, 0xc6, 0x8d, 0x9b, 0xf3, 0xc4, 0xf7, 0x00,
0xd1, 0xd5, 0xd1, 0xab, 0x36, 0x05, 0xbc, 0x42, 0x74, 0x0a, 0xbe, 0x48, 0x04,
0x71, 0xf2, 0xf6, 0x0b, 0xe6, 0xf9, 0xef, 0xf1, 0x0f, 0xa6, 0x24, 0xc4, 0x41,
0x6d, 0x7a, 0xc6, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae,
0x42, 0x60, 0x82
};
| 7,737
|
C++
|
.h
| 109
| 69.981651
| 86
| 0.665574
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,960
|
exit.h
|
anonbeat_guayadeque/src/images/exit.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// 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 3, 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; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
const unsigned char guImage_exit[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49,
0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x18, 0x08, 0x06,
0x00, 0x00, 0x00, 0xe0, 0x77, 0x3d, 0xf8, 0x00, 0x00, 0x00, 0x06, 0x62, 0x4b,
0x47, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x43, 0xbb, 0x7f, 0x00,
0x00, 0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x0b, 0x13, 0x00, 0x00,
0x0b, 0x13, 0x01, 0x00, 0x9a, 0x9c, 0x18, 0x00, 0x00, 0x03, 0x47, 0x49, 0x44,
0x41, 0x54, 0x48, 0xc7, 0xcd, 0x95, 0x5f, 0x68, 0x5b, 0x55, 0x1c, 0xc7, 0x3f,
0xbf, 0xf3, 0x3b, 0x37, 0x49, 0x9b, 0xa4, 0x4d, 0x6a, 0x59, 0x67, 0x62, 0x57,
0xcc, 0x8a, 0x2d, 0x0e, 0x7c, 0x18, 0x32, 0x0b, 0x13, 0xe7, 0x93, 0xef, 0x03,
0xb1, 0x20, 0x08, 0x8a, 0x3e, 0xe9, 0x83, 0x20, 0x6c, 0x0f, 0x3a, 0x61, 0xe2,
0xc3, 0x14, 0x75, 0xe2, 0x43, 0x5f, 0xa4, 0xf6, 0xa1, 0x4c, 0x37, 0x7c, 0xa9,
0x30, 0xa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1, 0x11,
0xbe, 0xfa, 0x7d, 0x10, 0x0c, 0x34, 0xb5, 0xff, 0xad, 0xab, 0xf6, 0x38, 0xfa,
0x9b, 0x9e, 0xe5, 0x08, 0xd7, 0x07, 0x78, 0x02, 0x1f, 0x0c, 0x9d, 0xdc, 0x98,
0xfc, 0xbf, 0x8c, 0xbf, 0x00, 0xb7, 0xbb, 0xf9, 0x46, 0x03, 0x30, 0x30, 0xa4,
0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
| 6,696
|
C++
|
.h
| 95
| 69.484211
| 86
| 0.66399
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,961
|
player_light_vol_low.h
|
anonbeat_guayadeque/src/images/player_light_vol_low.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// 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 3, 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; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
const unsigned char guImage_player_light_vol_low[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x1e,
0x08, 0x06, 0x00, 0x00, 0x00, 0x3b, 0x30, 0xae, 0xa2, 0x00, 0x00, 0x00,
0x04, 0x73, 0x42, 0x49, 0x54, 0x08, 0x08, 0x08, 0x08, 0x7c, 0x08, 0x64,
0x88, 0x00, 0x00, 0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x13,
0xc6, 0x00, 0x00, 0x13, 0xc6, 0x01, 0xf8, 0x22, 0x00, 0xbf, 0x00, 0x00,
0x00, 0x19, 0x74, 0x45, 0x58, 0x74, 0x53, 0x6f, 0x66, 0x74, 0x77, 0x61,
0x72, 0x65, 0x00, 0x77, 0x77, 0x77, 0x2e, 0x69, 0x6e, 0x6b, 0x73, 0x63,
0x61, 0x70, 0x65, 0x2e, 0x6f, 0x72, 0x67, 0x9b, 0xee, 0x3c, 0x1a, 0x00,
0x00, 0x06, 0x54, 0x49, 0x44, 0x41, 0x54, 0x48, 0x89, 0xad, 0x97, 0x5d,
0x6c, 0x13, 0xd9, 0x19, 0x86, 0xdf, 0x33, 0xe3, 0x4c, 0x1c, 0x7b, 0x32,
0x63, 0x1b, 0xc7, 0x76, 0x9c, 0xa0, 0xae, 0x61, 0x77, 0x05, 0x44, 0x60,
0x1b, 0x96, 0x0a, 0x91, 0x80, 0x12, 0xb2, 0x8a, 0x04, 0x4e, 0x40, 0xaa,
0xb6, 0x90, 0xaa, 0x6a, 0xef, 0xba, 0x2d, 0x94, 0xd2, 0x6d, 0x2f, 0x2a,
0xad, 0xb4, 0xbd, 0xa9, 0xda, 0x5e, 0xf4, 0xa6, 0xea, 0xb6, 0xfc, 0x48,
0xbd, 0x6a, 0x45, 0xd9, 0x86, 0x2e, 0xd5, 0x92, 0x38, 0xa9, 0x94, 0x2e,
0x46, 0xd0, 0x44, 0xa0, 0x5d, 0x76, 0xd7, 0x76, 0x94, 0x48, 0x80, 0x15,
0xe4, 0x26, 0xf8, 0x3f, 0x36, 0x67, 0x3c, 0x78, 0xb0, 0x65, 0xe7, 0xf4,
0x62, 0x19, 0xd6, 0x8d, 0x1c, 0xe2, 0x54, 0x7d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0xfa, 0x85, 0x69, 0xf0, 0x10, 0x32, 0xbe, 0xac, 0x56, 0xec,
0x89, 0x44, 0xa2, 0xbb, 0x50, 0x28, 0xb8, 0x00, 0xc0, 0x6a, 0xb5, 0xa6,
0xdc, 0x6e, 0xf7, 0xb2, 0x24, 0x49, 0x39, 0x00, 0x39, 0x42, 0x08, 0x6d,
0xc6, 0xef, 0x3f, 0x60, 0xf2, 0xd0, 0x62, 0x02, 0x82, 0x25, 0x3d, 0x00,
0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
| 11,900
|
C++
|
.h
| 169
| 67.686391
| 86
| 0.652971
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,962
|
tiny_status_pending.h
|
anonbeat_guayadeque/src/images/tiny_status_pending.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// 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 3, 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; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
const unsigned char guImage_tiny_status_pending[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10,
0x08, 0x06, 0x00, 0x00, 0x00, 0x1f, 0xf3, 0xff, 0x61, 0x00, 0x00, 0x00,
0x06, 0x62, 0x4b, 0x47, 0x44, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0xa0,
0xbd, 0xa7, 0x93, 0x00, 0x00, 0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00,
0x00, 0x0b, 0x13, 0x00, 0x00, 0x0b, 0x13, 0x01, 0x00, 0x9a, 0x9c, 0x18,
0x00, 0x00, 0x00, 0x07, 0x74, 0x49, 0x4d, 0x45, 0x07, 0xd6, 0x07, 0x03,
0x10, 0x2e, 0x26, 0x6d, 0x0a, 0x09, 0xcd, 0x00, 0x00, 0x00, 0x0f, 0x74,
0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x00, 0x69,
0x64, 0x20, 0x6c, 0x6f, 0x67, 0x6f, 0x86, 0xc6, 0x77, 0xb9, 0x00, 0x00,
0x02, 0x7a, 0x49, 0x44, 0x41, 0x54, 0x38, 0xcb, 0xad, 0x93, 0xcf, 0x4b,
0xd3, 0x71, 0x18, 0xc7, 0x5f, 0xfb, 0x6e, 0x3a, 0x37, 0x15, 0xdd, 0xd7,
0x4d, 0xc6, 0x06, 0xea, 0x6c, 0xe5, 0x94, 0x88, 0x9a, 0x96, 0x75, 0x13,
0xba, 0x18, 0x75, 0x28, 0x82, 0x0e, 0x21, 0xb1, 0x20, 0x41, 0xf3, 0x0f,
0xe8, 0x10, 0xd1, 0x21, 0xea, 0xdc, 0x4d, 0xbd, 0x94, 0x87, 0x1d, 0x04,
0x0f, 0x59, 0x81, 0x7a, 0x0a, 0x0f, 0x15, 0x49, 0x68, 0x29, 0x42, 0x22,
0x8b, 0x2d, 0x61, 0xe3, 0xdb, 0x36, 0x36, 0x75, 0x6b, 0xfe, 0xd8, 0xf7,
0xf3, 0xf9, 0x74, 0xd0, 0x24, 0xed, 0x16, 0x3e, 0xf0, 0x5c, 0x1e, 0xde,
0xcf, 0x9b, 0x87, 0xe7,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0x82,
};
| 5,758
|
C++
|
.h
| 88
| 64.431818
| 86
| 0.663139
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,963
|
player_normal_vol_hi.h
|
anonbeat_guayadeque/src/images/player_normal_vol_hi.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// 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 3, 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; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
const unsigned char guImage_player_normal_vol_hi[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x1e,
0x08, 0x06, 0x00, 0x00, 0x00, 0x3b, 0x30, 0xae, 0xa2, 0x00, 0x00, 0x00,
0x04, 0x73, 0x42, 0x49, 0x54, 0x08, 0x08, 0x08, 0x08, 0x7c, 0x08, 0x64,
0x88, 0x00, 0x00, 0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x13,
0xc6, 0x00, 0x00, 0x13, 0xc6, 0x01, 0xf8, 0x22, 0x00, 0xbf, 0x00, 0x00,
0x00, 0x19, 0x74, 0x45, 0x58, 0x74, 0x53, 0x6f, 0x66, 0x74, 0x77, 0x61,
0x72, 0x65, 0x00,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9e, 0x3d, 0x53,
0xd8, 0xed, 0xf6, 0x10, 0x6f, 0x79, 0x03, 0xc3, 0x30, 0x83, 0x2c, 0xcb,
0x9a, 0xa2, 0xa3, 0xa3, 0x0d, 0x9b, 0x37, 0x6f, 0xd6, 0x27, 0x25, 0x25,
0x99, 0xf0, 0xfa, 0x91, 0xf9, 0xe9, 0x57, 0x7d, 0xc2, 0x4c, 0xb0, 0x08,
0x29, 0x80, 0x10, 0x00, 0x53, 0x01, 0xb0, 0x00, 0x04, 0x5e, 0x97, 0x1b,
0x80, 0x1d, 0xc0, 0x4b, 0x00, 0x83, 0x84, 0x10, 0xdb, 0x64, 0xf2, 0xfd,
0x0f, 0x4b, 0x9f, 0xa3, 0x40, 0xe3, 0xfb, 0x19, 0x8e, 0x00, 0x00, 0x00,
0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
| 14,627
|
C++
|
.h
| 206
| 68.223301
| 86
| 0.653814
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,964
|
player_light_gapless.h
|
anonbeat_guayadeque/src/images/player_light_gapless.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// 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 3, 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; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
const unsigned char guImage_player_light_gapless[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x1e,
0x08, 0x06, 0x00, 0x00, 0x00, 0x3b, 0x30, 0xae, 0xa2, 0x00, 0x00, 0x00,
0x04, 0x73, 0x42, 0x49, 0x54, 0x08, 0x08, 0x08, 0x08, 0x7c, 0x08, 0x64,
0x88, 0x00, 0x00, 0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x13,
0xc6, 0x00, 0x00, 0x13, 0xc6, 0x01, 0xf8, 0x22, 0x00, 0xbf, 0x00, 0x00,
0x00, 0x19, 0x74, 0x45, 0x58, 0x74, 0x53, 0x6f, 0x66, 0x74, 0x77, 0x61,
0x72, 0x65, 0x00, 0x77, 0x77, 0x77, 0x2e, 0x69, 0x6e, 0x6b, 0x73, 0x63,
0x61, 0x70, 0x65, 0x2e, 0x6f, 0x72, 0x67, 0x9b, 0xee, 0x3c, 0x1a, 0x00,
0x00, 0x05, 0x04, 0x49, 0x44, 0x41, 0x54, 0x48, 0x89, 0xad, 0x97, 0x4d,
0x6c, 0x13, 0x47, 0x18, 0x86, 0xdf, 0x6f, 0x09, 0xc6, 0x8e, 0x37, 0x9e,
0x10, 0xd6, 0x3f, 0xda, 0xa4, 0x55, 0x1c, 0xa5, 0x08, 0x14, 0xe5, 0x07,
0xda, 0xa8, 0x07, 0x03, 0x0a, 0xf1, 0xad, 0x31, 0x04, 0x71, 0x41, 0x84,
0x1e, 0x2a, 0xda, 0x0b, 0xb4, 0x22, 0x55, 0xaf, 0xa8, 0xc7, 0xde, 0xf9,
0x51, 0x53, 0xa4, 0x56, 0xbd, 0x20, 0x05, 0x2e, 0x45, 0x71, 0xed, 0x9c,
0x4a, 0x52, 0x97, 0x18, 0x50, 0x5b, 0x04, 0x76, 0x22, 0x10, 0x2d, 0x21,
0x96, 0xaa, 0x64,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, 0x96, 0x65, 0x75, 0x00, 0x10, 0x44, 0x51, 0x1c, 0x3f,
0x70, 0xe0, 0xc0, 0xd0, 0xfe, 0xfd, 0xfb, 0x27, 0xd6, 0x97, 0xd7, 0x16,
0x78, 0x0d, 0x2e, 0x00, 0x68, 0x9c, 0x9a, 0x9a, 0x3a, 0x3c, 0x3d, 0x3d,
0x1d, 0xd5, 0x75, 0x3d, 0x52, 0xa9, 0x54, 0xf6, 0x6e, 0xb0, 0x8e, 0xbb,
0x5c, 0xae, 0x3f, 0xeb, 0xeb, 0xeb, 0xd3, 0x2d, 0x2d, 0x2d, 0x63, 0x6b,
0x4f, 0x66, 0xee, 0x3f, 0xfd, 0xc2, 0x6c, 0xf0, 0x11, 0x0c, 0x80, 0x64,
0x18, 0x86, 0xa4, 0x28, 0x4a, 0x53, 0xa9, 0x54, 0x0a, 0x01, 0x2f, 0x02,
0x5f, 0x96, 0xe5, 0x59, 0x9f, 0xcf, 0xa7, 0x01, 0xd0, 0x88, 0x48, 0xb7,
0xe3, 0xf7, 0x37, 0xd4, 0x7e, 0x56, 0xb8, 0xa4, 0xb4, 0x9e, 0x9e, 0x00,
0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
| 9,828
|
C++
|
.h
| 141
| 67.028369
| 86
| 0.652111
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,965
|
player_normal_pause.h
|
anonbeat_guayadeque/src/images/player_normal_pause.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// 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 3, 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; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
const unsigned char guImage_player_normal_pause[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x22,
0x08, 0x06, 0x00, 0x00, 0x00, 0x3a, 0x47, 0x0b, 0xc2, 0x00, 0x00, 0x00,
0x04, 0x73, 0x42, 0x49, 0x54, 0x08, 0x08, 0x08, 0x08, 0x7c, 0x08, 0x64,
0x88, 0x00, 0x00, 0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x16,
0x69, 0x00, 0x00, 0x16, 0x69, 0x01, 0x6d, 0x04, 0xee, 0xee, 0x00, 0x00,
0x00, 0x19, 0x74, 0x45, 0x58, 0x74, 0x53, 0x6f, 0x66, 0x74, 0x77, 0x61,
0x72, 0x65, 0x00, 0x77, 0x77, 0x77, 0x2e, 0x69, 0x6e, 0x6b, 0x73, 0x63,
0x61, 0x70, 0x65, 0x2e, 0x6f, 0x72, 0x67, 0x9b, 0xee, 0x3c, 0x1a, 0x00,
0x00, 0x06, 0xa7, 0x49, 0x44, 0x41, 0x54, 0x58, 0x85, 0xbd, 0x98, 0x6b,
0x6c, 0x13, 0x57, 0x16, 0xc7, 0xcf, 0x9d, 0xa4, 0xb1, 0x63, 0x4f, 0x68,
0x62, 0xe3, 0xd8, 0x43, 0xec, 0xc4, 0x4d, 0x96, 0x52, 0x15, 0x95, 0xb6,
0x0b, 0x24, 0x82, 0x38, 0x43, 0xf8, 0x80, 0x63, 0x40, 0x31, 0x34, 0x8d,
0xca, 0xae, 0x50, 0x40, 0x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 0xa4, 0xd8, 0x13,
0x27, 0x4e, 0x7c, 0x52, 0x54, 0x54, 0xf4, 0xa9, 0xc5, 0x62, 0x69, 0x06,
0x80, 0x52, 0x00, 0x00, 0x02, 0x63, 0x9c, 0x77, 0xf6, 0xec, 0x59, 0x45,
0x24, 0x12, 0x59, 0xad, 0x52, 0xa9, 0x2e, 0xa5, 0x07, 0xfd, 0x5e, 0xaa,
0xab, 0xab, 0xbb, 0x34, 0x37, 0x37, 0xb7, 0xa6, 0xb7, 0xb7, 0x77, 0x33,
0xc6, 0x38, 0x8f, 0x00, 0x00, 0xa1, 0xcd, 0x66, 0xab, 0xe5, 0x70, 0x38,
0xbe, 0xc3, 0x87, 0x0f, 0x7f, 0x99, 0x2d, 0x10, 0xad, 0x56, 0xfb, 0x79,
0x5e, 0x5e, 0x5e, 0x60, 0x78, 0x78, 0xb8, 0x16, 0x00, 0x04, 0x04, 0x00,
0x14, 0xfa, 0x7c, 0xbe, 0x57, 0x45, 0x22, 0xd1, 0x18, 0xfb, 0xa5, 0xfa,
0xbd, 0xc5, 0xe5, 0x72, 0xb1, 0x48, 0x24, 0x1a, 0xf3, 0x7a, 0xbd, 0xaf,
0x00, 0x40, 0x21, 0x11, 0x8b, 0xc5, 0xc8, 0x68, 0x34, 0x5a, 0x26, 0x95,
0x4a, 0x1f, 0x64, 0x0b, 0x22, 0x25, 0x8a, 0xa2, 0x1e, 0x44, 0xa3, 0xd1,
0xf2, 0x58, 0x2c, 0x56, 0x40, 0x58, 0xad, 0x56, 0x29, 0xc6, 0x38, 0x4f,
0x2a, 0x95, 0xba, 0xb3, 0x0d, 0x52, 0x56, 0x56, 0x36, 0x89, 0x31, 0xce,
0xb3, 0xd9, 0x6c, 0x25, 0x44, 0xaa, 0x9e, 0x28, 0x2c, 0x2c, 0x8c, 0x64,
0x1b, 0x24, 0x95, 0xd3, 0xef, 0xf7, 0xaf, 0x20, 0x96, 0x73, 0xce, 0x96,
0x08, 0xa1, 0x50, 0x38, 0x0b,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d4, 0x00, 0x00,
0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
| 12,411
|
C++
|
.h
| 176
| 67.778409
| 86
| 0.653208
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| true
| false
|
750,966
|
player_tiny_red_stop.h
|
anonbeat_guayadeque/src/images/player_tiny_red_stop.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// 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 3, 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; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
const unsigned char guImage_player_tiny_red_stop[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10,
0x08, 0x06, 0x00, 0x00, 0x00, 0x1f, 0xf3, 0xff, 0x61, 0x00, 0x00, 0x00,
0x04, 0x73, 0x42, 0x49, 0x54, 0x08, 0x08, 0x08, 0x08, 0x7c, 0x08, 0x64,
0x88, 0x00, 0x00, 0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x0a,
0x59, 0x00, 0x00, 0x0a, 0x59, 0x01, 0x03, 0x7a, 0x73, 0x1e, 0x00, 0x00,
0x00, 0x19, 0x74, 0x45, 0x58, 0x74, 0x53, 0x6f, 0x66, 0x74, 0x77, 0x61,
0x72, 0x65, 0x00, 0x77, 0x77, 0x77, 0x2e, 0x69, 0x6e, 0x6b, 0x73, 0x63,
0x61, 0x70, 0x65, 0x2e, 0x6f, 0x72, 0x67, 0x9b, 0xee, 0x3c, 0x1a, 0x00,
0x00, 0x01, 0xbb, 0x49, 0x44, 0x41, 0x54, 0x38, 0x8d, 0xad, 0x93, 0xb1,
0x6b, 0xdb, 0x40, 0x14, 0x87, 0x7f, 0xa7, 0x26, 0x9c, 0x8c, 0x71, 0x04,
0x1a, 0x2c, 0x0e, 0x65, 0x0a, 0x6d, 0x36, 0x87, 0x80, 0x0a, 0x1a, 0xa2,
0x40, 0x36, 0x41, 0xe9, 0x9a, 0x45, 0x90, 0x3f, 0x20, 0x93, 0xdb, 0xa5,
0x43, 0x97, 0x14, 0x0c, 0x5d, 0x53, 0x4f, 0x19, 0x3d, 0x04, 0x54, 0x48,
0xd6, 0x62, 0xc8, 0x16, 0x1c, 0x61, 0x08, 0x54, 0x10, 0x62, 0xc8, 0xd0,
0x96, 0x04, 0x82, 0xc4, 0x21, 0x0f, 0x06, 0x61, 0x8c, 0x7b, 0x84, 0xf0,
0xba, 0x24, 0xae, 0x52, 0xec, 0x82, 0x69, 0xbf, 0xf5, 0xf7, 0xbe, 0xc7,
0xdd, 0xbb, 0x7b, 0x8c, 0x88, 0x50, 0x24, 0x4d, 0xd3, 0x55, 0xc6, 0x58,
0x60, 0x18, 0x86, 0xc3, 0x39, 0x77, 0x00, 0x40, 0x29, 0x15, 0xe7, 0x79,
0x1e, 0x13, 0x51, 0x68, 0xdb, 0xf6, 0xb7, 0x62, 0x3d, 0x2b, 0x34, 0x60,
0x52, 0xca, 0xba, 0x65, 0x59, 0x1f, 0x7f, 0x1c, 0x1f, 0x97, 0xfa, 0xa7,
0xa7, 0x18, 0x5d, 0x5e, 0x02, 0x00, 0xca, 0x6b, 0x6b, 0xa8, 0x6e, 0x6d,
0xe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x68, 0x4a, 0xa9, 0xb8, 0x5c, 0xab, 0xcd, 0x2d, 0x96,
0x6b, 0x35, 0x28, 0xa5, 0x62, 0x2d, 0xcf, 0xf3, 0xb8, 0xea, 0x79, 0x93,
0x80, 0xee, 0xee, 0x66, 0x4a, 0xc5, 0xac, 0xea, 0x79, 0x18, 0x0e, 0x87,
0x5f, 0x17, 0x88, 0x28, 0xb4, 0x5d, 0xf7, 0x9d, 0x15, 0x04, 0xa5, 0x2c,
0x0c, 0x71, 0xd3, 0x6a, 0x61, 0x61, 0x69, 0x69, 0xea, 0x33, 0xde, 0xb4,
0x5a, 0x00, 0x00, 0x2b, 0x08, 0x60, 0xbb, 0xee, 0x58, 0x4a, 0xf9, 0xf9,
0x9f, 0x3f, 0x92, 0x06, 0x00, 0x42, 0x88, 0x26, 0xe9, 0x7a, 0x7b, 0xa3,
0xd3, 0x81, 0xe9, 0xfb, 0x33, 0x65, 0xd3, 0xf7, 0xb1, 0xd1, 0xe9, 0x80,
0x74, 0xbd, 0xfd, 0xb0, 0x0f, 0xff, 0x6f, 0x99, 0x26, 0xcc, 0xbb, 0xce,
0xbf, 0x00, 0x57, 0x18, 0x0f, 0x10, 0x0b, 0x8f, 0x83, 0xd6, 0x00, 0x00,
0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
| 4,642
|
C++
|
.h
| 71
| 63.028169
| 86
| 0.645811
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,968
|
player_light_muted.h
|
anonbeat_guayadeque/src/images/player_light_muted.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// 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 3, 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; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
const unsigned char guImage_player_light_muted[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x1e,
0x08, 0x06, 0x00, 0x00, 0x00, 0x3b, 0x30, 0xae, 0xa2, 0x00, 0x00, 0x00,
0x04, 0x73, 0x42, 0x49, 0x54, 0x08, 0x08, 0x08, 0x08, 0x7c, 0x08, 0x64,
0x88, 0x00, 0x00, 0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x13,
0xc6, 0x00, 0x00, 0x13, 0xc6, 0x01, 0xf8, 0x22, 0x00, 0xbf, 0x00, 0x00,
0x00, 0x19, 0x74, 0x45, 0x58, 0x74, 0x53, 0x6f, 0x66, 0x74, 0x77, 0x61,
0x72, 0x65, 0x00, 0x77, 0x77, 0x77, 0x2e, 0x69, 0x6e, 0x6b, 0x73, 0x63,
0x61, 0x70, 0x65, 0x2e, 0x6f, 0x72, 0x67, 0x9b, 0xee, 0x3c, 0x1a, 0x00,
0x00, 0x06, 0xfe, 0x49, 0x44, 0x41, 0x54, 0x48, 0x89, 0xad, 0x97, 0x5b,
0x4c, 0x1b, 0xd9, 0x19, 0xc7, 0xff, 0x67, 0xec, 0x0c, 0xd8, 0x18, 0x8f,
0x6d, 0x7c, 0x19, 0x6c, 0x10, 0x4b, 0x42, 0x9b, 0x8b, 0x15, 0x30, 0xa4,
0xdb, 0xa0, 0x40, 0x50, 0x08, 0x2b, 0x94, 0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xcf, 0xeb, 0x74, 0xba, 0xde,
0xea, 0xea, 0xea, 0x0b, 0x3b, 0x77, 0xee, 0xfc, 0x87, 0xf2, 0x4d, 0x37,
0x0c, 0x5e, 0x86, 0x73, 0x00, 0x1c, 0x23, 0x23, 0x23, 0xfb, 0x43, 0xa1,
0x50, 0x13, 0xa5, 0xb4, 0x6e, 0x7e, 0x7e, 0xfe, 0xab, 0xab, 0xf8, 0x31,
0x9e, 0xe7, 0x1f, 0x1a, 0x0c, 0x86, 0xfe, 0xad, 0x5b, 0xb7, 0x2a, 0x47,
0xe6, 0xe9, 0xff, 0xf4, 0x0b, 0xb3, 0xca, 0x20, 0x04, 0x7c, 0x99, 0xad,
0x98, 0x23, 0x91, 0x48, 0x49, 0x3a, 0x9d, 0x16, 0x01, 0xc0, 0x68, 0x34,
0x46, 0xed, 0x76, 0xfb, 0xa4, 0x5e, 0xaf, 0x4f, 0x02, 0x48, 0x12, 0x42,
0xe8, 0x46, 0xe2, 0xfd, 0x07, 0x57, 0x01, 0x1a, 0x69, 0xe6, 0x2d, 0x5c,
0x7e, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60,
0x82
};
| 12,948
|
C++
|
.h
| 184
| 67.619565
| 86
| 0.653322
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,969
|
player_tiny_light_stop.h
|
anonbeat_guayadeque/src/images/player_tiny_light_stop.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// 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 3, 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; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
const unsigned char guImage_player_tiny_light_stop[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10,
0x08, 0x06, 0x00, 0x00, 0x00, 0x1f, 0xf3, 0xff, 0x61, 0x00, 0x00, 0x00,
0x04, 0x73, 0x42, 0x49, 0x54, 0x08, 0x08, 0x08, 0x08, 0x7c, 0x08, 0x64,
0x88, 0x00, 0x00, 0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x07,
0x62, 0x00, 0x00, 0x07, 0x62, 0x01, 0x38, 0x7a, 0x99, 0xdb, 0x00, 0x00,
0x00, 0x19, 0x74, 0x45, 0x58, 0x74, 0x53, 0x6f, 0x66, 0x74, 0x77, 0x61,
0x72, 0x65, 0x00, 0x77, 0x77, 0x77, 0x2e, 0x69, 0x6e, 0x6b, 0x73, 0x63,
0x61, 0x70, 0x65, 0x2e, 0x6f, 0x72, 0x67, 0x9b, 0xee, 0x3c, 0x1a, 0x00,
0x00, 0x01, 0x60, 0x49, 0x44, 0x41, 0x54, 0x38, 0x8d, 0xad, 0x93, 0xb1,
0x6a, 0x02, 0x41, 0x10, 0x86, 0xbf, 0x3b, 0x0e, 0x61, 0x85, 0xe5, 0x10,
0x41, 0x6c, 0x5c, 0xd8, 0xc6, 0xf2, 0x08, 0x5c, 0x7a, 0x7b, 0xc9, 0x0b,
0xc4, 0x97, 0x30, 0x69, 0x52, 0xe4, 0x01, 0xd2, 0x26, 0x79, 0x09, 0xf3,
0x02, 0x21, 0xbd, 0x5c, 0x1b, 0x21, 0x5c, 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,
0x94, 0xd7, 0x2e, 0x10, 0x2e, 0x97, 0xcb, 0x7d, 0xd1, 0xe1, 0xe4, 0xaa,
0xaa, 0xb9, 0x92, 0xb9, 0x74, 0x81, 0x70, 0xf7, 0xda, 0xe7, 0xa8, 0x64,
0xc2, 0xd3, 0xe3, 0x7e, 0x29, 0x17, 0x98, 0xf8, 0xbe, 0x7f, 0x36, 0x58,
0x32, 0x13, 0x17, 0x98, 0x34, 0x1a, 0x8d, 0x7d, 0x22, 0xcf, 0xf3, 0x93,
0x50, 0x35, 0x57, 0x32, 0xef, 0x1e, 0x30, 0x92, 0x52, 0xde, 0x29, 0xa5,
0x84, 0x31, 0x86, 0x24, 0x49, 0xf0, 0x3c, 0xef, 0xe8, 0x37, 0x26, 0x49,
0x02, 0x80, 0x52, 0x0a, 0x29, 0x65, 0x06, 0xbc, 0xec, 0x36, 0xf1, 0xc6,
0x5a, 0xfb, 0x38, 0x1e, 0x8f, 0xc9, 0xb2, 0xec, 0x47, 0xeb, 0x42, 0x08,
0x7a, 0xbd, 0x1e, 0x9e, 0xe7, 0xdd, 0x02, 0x4f, 0x7f, 0x5e, 0xe5, 0x7f,
0x3b, 0xa6, 0xaa, 0xce, 0x3a, 0xe7, 0x2f, 0xfb, 0x70, 0xb3, 0xfd, 0x59,
0x8f, 0x59, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae,
0x42, 0x60, 0x82
};
| 4,084
|
C++
|
.h
| 64
| 61.53125
| 86
| 0.644279
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,970
|
player_light_love.h
|
anonbeat_guayadeque/src/images/player_light_love.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// 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 3, 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; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
const unsigned char guImage_player_light_love[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x1e,
0x08, 0x06, 0x00, 0x00, 0x00, 0x3b, 0x30, 0xae, 0xa2, 0x00, 0x00, 0x00,
0x04, 0x73, 0x42, 0x49, 0x54, 0x08, 0x08, 0x08, 0x08, 0x7c, 0x08, 0x64,
0x88, 0x00, 0x00, 0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x13,
0xc6, 0x00, 0x00, 0x13, 0xc6, 0x01, 0xf8, 0x22, 0x00, 0xbf, 0x00, 0x00,
0x00, 0x19, 0x74, 0x45, 0x58, 0x74, 0x53, 0x6f, 0x66, 0x74, 0x77, 0x61,
0x72, 0x65, 0x00, 0x77, 0x77, 0x77, 0x2e, 0x69, 0x6e, 0x6b, 0x73, 0x63,
0x61, 0x70, 0x65, 0x2e, 0x6f, 0x72, 0x67, 0x9b, 0xee, 0x3c, 0x1a, 0x00,
0x00, 0x04, 0xf9, 0x49, 0x44, 0x41, 0x54, 0x48, 0x89, 0xc5, 0x57, 0xcb,
0x6e, 0xdb, 0x46, 0x14, 0x3d, 0x33, 0x1c, 0x92, 0x1a, 0x3d, 0x46, 0x35,
0x69, 0x59, 0x88, 0x29, 0xc8, 0x02, 0x1c, 0xa3, 0x09, 0xb2, 0xcd,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0xa6, 0xaa, 0x2a, 0x76,
0x76, 0x76, 0x50, 0x2c, 0x16, 0x33, 0x53, 0x37, 0xeb, 0xf6, 0xcb, 0x1a,
0x72, 0xd6, 0x94, 0x3b, 0x3b, 0x3b, 0x50, 0x55, 0x15, 0x8e, 0xe3, 0x3c,
0x9b, 0x57, 0x9c, 0x97, 0x8a, 0xbd, 0x0f, 0x1f, 0x3e, 0xa0, 0xdf, 0xef,
0xdf, 0x58, 0x7b, 0x31, 0xc6, 0x50, 0xad, 0x56, 0x71, 0xeb, 0xd6, 0xad,
0xeb, 0x89, 0xbd, 0xd9, 0xde, 0xbc, 0xbc, 0x1d, 0x8d, 0x46, 0xe8, 0x74,
0x3a, 0x70, 0x5d, 0xf7, 0x4a, 0xb5, 0x49, 0x08, 0x81, 0x10, 0x02, 0xb5,
0x5a, 0x0d, 0xe5, 0x72, 0xf9, 0x46, 0xf2, 0x36, 0xc5, 0x45, 0x41, 0x3f,
0x99, 0x4c, 0xe0, 0x38, 0x0e, 0x3c, 0xcf, 0x43, 0x18, 0x86, 0xa9, 0x20,
0x50, 0x14, 0x05, 0x8c, 0x31, 0x94, 0x4a, 0x25, 0x18, 0x86, 0x81, 0x42,
0xa1, 0xf0, 0x9f, 0x05, 0x7d, 0x8a, 0xff, 0xe5, 0x15, 0xe6, 0x02, 0xbe,
0xf8, 0x4b, 0xdb, 0xdf, 0xc3, 0x01, 0xd5, 0xc1, 0xbe, 0x3b, 0xea, 0x6b,
0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
| 9,757
|
C++
|
.h
| 140
| 67.021429
| 86
| 0.65197
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,971
|
player_highlight_love.h
|
anonbeat_guayadeque/src/images/player_highlight_love.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// 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 3, 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; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
const unsigned char guImage_player_highlight_love[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x1e,
0x08, 0x06, 0x00, 0x00, 0x00, 0x3b, 0x30, 0xae, 0xa2, 0x00, 0x00, 0x00,
0x04, 0x73, 0x42, 0x49, 0x54, 0x08, 0x08, 0x08, 0x08, 0x7c, 0x08, 0x64,
0x88, 0x00, 0x00, 0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x13,
0xc6, 0x00, 0x00, 0x13, 0xc6, 0x01, 0xf8, 0x22, 0x00, 0xbf, 0x00, 0x00,
0x00, 0x19, 0x74, 0x45, 0x58, 0x74, 0x53, 0x6f, 0x66, 0x74, 0x77, 0x61,
0x72, 0x65, 0x00, 0x77, 0x77, 0x77, 0x2e, 0x69, 0x6e, 0x6b, 0x73, 0x63,
0x61, 0x70, 0x65, 0x2e, 0x6f, 0x72, 0x67, 0x9b, 0xee, 0x3c, 0x1a, 0x00,
0x00, 0x06, 0x8d, 0x49, 0x44, 0x41, 0x54, 0x48, 0x89, 0xc5, 0x97, 0x5d,
0x68, 0x5b, 0xe7, 0x19, 0xc7, 0x7f, 0xe7, 0xd5,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fc, 0xcf, 0x3f, 0xda, 0xfe, 0x05,
0x50, 0xe1, 0xd7, 0xc0, 0x4d, 0xa9, 0xbc, 0x4e, 0x00, 0x00, 0x00, 0x00,
0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82
};
| 12,253
|
C++
|
.h
| 174
| 67.683908
| 86
| 0.6532
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,972
|
player_light_smart.h
|
anonbeat_guayadeque/src/images/player_light_smart.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// 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 3, 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; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
const unsigned char guImage_player_light_smart[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x1e,
0x08, 0x06, 0x00, 0x00, 0x00, 0x3b, 0x30, 0xae, 0xa2, 0x00, 0x00, 0x00,
0x04, 0x73, 0x42, 0x49, 0x54, 0x08, 0x08, 0x08, 0x08, 0x7c, 0x08, 0x64,
0x88, 0x00, 0x00, 0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x13,
0xc6, 0x00, 0x00, 0x13, 0xc6, 0x01, 0xf8, 0x22, 0x00, 0xbf, 0x00, 0x00,
0x00, 0x19, 0x74, 0x45, 0x58, 0x74, 0x53, 0x6f, 0x66, 0x74, 0x77, 0x61,
0x72, 0x65, 0x00, 0x77, 0x77, 0x77, 0x2e, 0x69, 0x6e, 0x6b, 0x73, 0x63,
0x61, 0x70, 0x65, 0x2e, 0x6f, 0x72, 0x67, 0x9b, 0xee, 0x3c, 0x1a, 0x00,
0x00, 0x06, 0xf0, 0x49, 0x44, 0x41, 0x54, 0x48, 0x89, 0xad, 0x57, 0x6d,
0x4c, 0x5b, 0xd7, 0x19, 0x7e, 0xcf, 0xc5, 0xdf, 0x36, 0xf7, 0xd8, 0xc6,
0xd8, 0xc6, 0x26, 0x01, 0x62, 0x8a, 0x92, 0xd0, 0xf1, 0x31, 0x95, 0x68,
0x8b, 0x69, 0x06, 0xf1, 0x86, 0x44, 0x1c, 0x48, 0x3a, 0xb1, 0x80, 0x34,
0xad, 0x7f, 0xb7, 0x64, 0xcd, 0xd6, 0xad, 0x3f, 0xb6, 0x4a, 0xeb, 0xa4,
0xad, 0x5b, 0x27, 0x55, 0x93, 0xd6, 0x8f, 0x41, 0xf6, 0x67, 0x52, 0x56,
0x95, 0x54, 0x28, 0x52, 0x9b, 0xcb, 0x47, 0x26, 0x31, 0x42, 0x02, 0x85,
0x36, 0x22, 0x54, 0xb1, 0x63, 0x81, 0x14, 0x95, 0x38, 0xb1, 0x62, 0xfc,
0xdd, 0x6b, 0x8e, 0x7d, 0xfd, 0x19, 0xf0, 0xd9, 0x8f, 0xda, 0x9d, 0xe3,
0xda, 0xc0, 0xa6, 0x3d, 0xbf, 0xee, 0x79, 0xcf, 0x39, 0xcf, 0x73, 0xce,
0x79, 0xcf, 0x7d, 0xef, 0x73, 0x11, 0xec, 0x03, 0x94, 0x52, 0x04, 0x00,
0x18, 0x00, 0x6a, 0x78, 0x9e, 0xd7, 0x07, 0x02, 0x81, 0x7a, 0x42, 0x88,
0x01, 0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.912088
| 86
| 0.653336
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,973
|
Config.h
|
anonbeat_guayadeque/src/config/Config.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// 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 3, 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; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __CONFIG_H__
#define __CONFIG_H__
#include "Collections.h"
#include "ConfigConsts.h"
#include "Settings.h"
#include <wx/wx.h>
#include <wx/fileconf.h>
#include <wx/tokenzr.h>
#include <wx/xml/xml.h>
namespace Guayadeque {
WX_DEFINE_ARRAY_PTR( wxEvtHandler *, guEvtHandlerArray );
wxDECLARE_EVENT( guConfigUpdatedEvent, wxCommandEvent );
class guMediaCollectionArray;
class guTrack;
class guTrackArray;
// -------------------------------------------------------------------------------- //
class guConfig
{
protected :
wxXmlDocument * m_XmlDocument;
wxXmlNode * m_RootNode;
wxString m_FileName;
wxMutex m_ConfigMutex;
guEvtHandlerArray m_Objects;
wxMutex m_ObjectsMutex;
bool m_IgnoreLayouts;
int m_Version;
inline wxXmlNode * FindNode( const wxString &category );
bool LoadFile( const wxString &filename );
bool LoadWithBackup( const wxString &filename );
bool AddBackupFile( const wxString &filename );
public :
guConfig( const wxString &conffile = guPATH_CONFIG_FILENAME );
virtual ~guConfig();
static guConfig * Get( void );
void Set( guConfig * config );
int Version( void ) { return m_Version; }
void Flush( void );
long ReadNum( const wxString &keyname, long defval = 0, const wxString &category = wxEmptyString );
bool WriteNum( const wxString &keyname, long value = 0, const wxString &category = wxEmptyString );
bool ReadBool( const wxString &keyname, bool defval = true, const wxString &category = wxEmptyString );
bool WriteBool( const wxString &keyname, bool value, const wxString &category = wxEmptyString );
wxString ReadStr( const wxString &keyname, const wxString &defval, const wxString &category = wxEmptyString );
bool WriteStr( const wxString &keyname, const wxString &value, const wxString &category = wxEmptyString );
wxArrayString ReadAStr( const wxString &Key, const wxString &defval, const wxString &category = wxEmptyString );
bool WriteAStr( const wxString &Key, const wxArrayString &value, const wxString &category = wxEmptyString, bool ResetGroup = true );
#if wxUSE_STL
bool WriteAStr( const wxString &Key, const wxSortedArrayString &value, const wxString &category = wxEmptyString, bool ResetGroup = true );
#endif
wxArrayInt ReadANum( const wxString &Key, const int defval, const wxString &category = wxEmptyString );
bool WriteANum( const wxString &Key, const wxArrayInt &value, const wxString &category = wxEmptyString, bool ResetGroup = true );
void DeleteCategory( const wxString &category );
int LoadCollections( guMediaCollectionArray * collections, const int type = wxNOT_FOUND );
void SaveCollections( guMediaCollectionArray * collections, const bool resetgroup = true );
bool SavePlaylistTracks( const guTrackArray &tracks, const int currenttrack );
int LoadPlaylistTracks( guTrackArray &tracks );
void RegisterObject( wxEvtHandler * object );
void UnRegisterObject( wxEvtHandler * object );
void SendConfigChangedEvent( const int flags = 0 );
bool GetIgnoreLayouts( void ) { return m_IgnoreLayouts; }
void SetIgnoreLayouts( const bool ignorelayouts ) { m_IgnoreLayouts = ignorelayouts; }
};
// -------------------------------------------------------------------------------- //
wxString inline escape_configlist_str( const wxString &val )
{
wxString RetVal = val;
RetVal.Replace( wxT( ":" ), wxT( "_$&" ) );
RetVal.Replace( wxT( ";" ), wxT( "_&$" ) );
RetVal.Replace( wxT( "," ), wxT( "$_&" ) );
return RetVal;
}
// -------------------------------------------------------------------------------- //
wxString inline unescape_configlist_str( const wxString &val )
{
wxString RetVal = val;
RetVal.Replace( wxT( "_$&" ), wxT( ":" ) );
RetVal.Replace( wxT( "_&$" ), wxT( ";" ) );
RetVal.Replace( wxT( "$_&" ), wxT( "," ) );
return RetVal;
}
}
#endif
// -------------------------------------------------------------------------------- //
| 5,527
|
C++
|
.h
| 104
| 49.961538
| 157
| 0.590437
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,974
|
ConfigConsts.h
|
anonbeat_guayadeque/src/config/ConfigConsts.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// 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 3, 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; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __CONFIGCONSTS_H__
#define __CONFIGCONSTS_H__
#include <wx/string.h>
namespace Guayadeque {
// Accelerators
#define CONFIG_PATH_ACCELERATORS "accelerators"
#define CONFIG_KEY_ACCELERATORS_ACCELKEY "AccelKey"
// AudioCd
#define CONFIG_PATH_AUDIOCD "audiocd"
#define CONFIG_KEY_AUDIOCD_ORDER "Order"
#define CONFIG_KEY_AUDIOCD_ORDERDESC "OrderDesc"
// Commands
#define CONFIG_PATH_COMMANDS_EXECS "commands/execs"
#define CONFIG_PATH_COMMANDS_NAMES "commands/names"
#define CONFIG_KEY_COMMANDS_EXEC "Exec"
#define CONFIG_KEY_COMMANDS_NAME "Name"
// CopyTo
#define CONFIG_PATH_COPYTO "copyto/options"
#define CONFIG_KEY_COPYTO_OPTION "Option"
// Crossfader
#define CONFIG_PATH_CROSSFADER "crossfader"
#define CONFIG_KEY_CROSSFADER_FORCE_GAPLESS "ForceGapless"
#define CONFIG_KEY_CROSSFADER_FADEOUT_TIME "FadeOutTime"
#define CONFIG_KEY_CROSSFADER_FADEIN_TIME "FadeInTime"
#define CONFIG_KEY_CROSSFADER_FADEIN_VOL_START "FadeInVolStar"
#define CONFIG_KEY_CROSSFADER_FADEIN_VOL_TRIGER "FadeInVolTriger"
// Equalizer
#define CONFIG_PATH_EQUALIZER "equalizer"
#define CONFIG_KEY_EQUALIZER_POS_X "PosX"
#define CONFIG_KEY_EQUALIZER_POS_Y "PosY"
#define CONFIG_KEY_EQUALIZER_WIDTH "Width"
#define CONFIG_KEY_EQUALIZER_HEIGHT "Height"
#define CONFIG_KEY_EQUALIZER_LAST_PRESET "LastEqPreset"
#define CONFIG_KEY_EQUALIZER_BAND "Band"
// File Browser
#define CONFIG_PATH_FILE_BROWSER "filebrowser"
#define CONFIG_KEY_FILE_BROWSER_SHOW_LIB_PATHS "ShowLibPaths"
#define CONFIG_KEY_FILE_BROWSER_ORDER "Order"
#define CONFIG_KEY_FILE_BROWSER_ORDERDESC "OrderDesc"
#define CONFIG_KEY_FILE_BROWSER_VISIBLE_PANELS "VisiblePanels"
#define CONFIG_KEY_FILE_BROWSER_LAST_LAYOUT "LastLayout"
#define CONFIG_KEY_FILE_BROWSER_PATH "Path"
#define CONFIG_PATH_FILE_BROWSER_COLUMNS_IDS "filebrowser/columns/ids"
#define CONFIG_PATH_FILE_BROWSER_COLUMNS_WIDTHS "filebrowser/columns/widths"
#define CONFIG_PATH_FILE_BROWSER_COLUMNS_SHOWS "filebrowser/columns/shows"
// File Renamer
#define CONFIG_PATH_FILE_RENAMER "filebrowser/filerenamer"
#define CONFIG_KEY_FILE_RENAMER_POS_X "PosX"
#define CONFIG_KEY_FILE_RENAMER_POS_Y "PosY"
#define CONFIG_KEY_FILE_RENAMER_SIZE_WIDTH "SizeWidth"
#define CONFIG_KEY_FILE_RENAMER_SIZE_HEIGHT "SizeHeight"
#define CONFIG_KEY_FILE_RENAMER_PATTERN "Pattern"
// General
#define CONFIG_PATH_GENERAL "general"
#define CONFIG_KEY_GENERAL_ACTION_ENQUEUE "DefaultActionEnqueue"
#define CONFIG_KEY_GENERAL_BROWSER_COMMAND "BrowserCommand"
#define CONFIG_KEY_GENERAL_BUFFER_SIZE "BufferSize"
#define CONFIG_KEY_GENERAL_CLOSE_TO_TASKBAR "CloseToTaskBar"
#define CONFIG_KEY_GENERAL_COVER_FRAME "CoverFrame"
#define CONFIG_KEY_GENERAL_COVER_SEARCH_ENGINE "CoverSearchEngine"
#define CONFIG_KEY_GENERAL_CURRENT_TRACK_POS "CurrentTrackPos"
#define CONFIG_KEY_GENERAL_DROP_FILES_CLEAR_PLAYLIST "DropFilesClearPlaylist"
#define CONFIG_KEY_GENERAL_EMBED_TO_FILES "EmbedToFiles"
#define CONFIG_KEY_GENERAL_INSTANT_TEXT_SEARCH "InstantTextSearchEnabled"
#define CONFIG_KEY_GENERAL_LANGUAGE "Language"
#define CONFIG_KEY_GENERAL_LAST_UPDATE "LastUpdate"
#define CONFIG_KEY_GENERAL_LOAD_DEFAULT_LAYOUTS "LoadDefaultLayouts"
#define CONFIG_KEY_GENERAL_MIN_SAVE_PLAYL_POST_LENGTH "MinSavePlayPosLength"
#define CONFIG_KEY_GENERAL_NOTIFICATION_TIME "NotificationsTime"
//#define CONFIG_KEY_GENERAL_PLAYER_LOOP "PlayerLoop"
//#define CONFIG_KEY_GENERAL_PLAYER_SMART "PlayerSmart"
#define CONFIG_KEY_GENERAL_PLAYER_PLAYMODE "PlayerPlayMode"
#define CONFIG_KEY_GENERAL_PLAYER_VOLUME "PlayerCurVol"
#define CONFIG_KEY_GENERAL_PLAYER_VOLUME_VISIBLE "PlayerVolumeVisible"
#define CONFIG_KEY_GENERAL_RANDOM_MODE_ON_EMPTY_PLAYLIST "RndModeOnEmptyPlayList"
#define CONFIG_KEY_GENERAL_RANDOM_PLAY_ON_EMPTY_PLAYLIST "RndPlayOnEmptyPlayList"
#define CONFIG_KEY_GENERAL_REPLAY_GAIN_MODE "ReplayGainMode"
#define CONFIG_KEY_GENERAL_REPLAY_GAIN_PREAMP "ReplayGainPreAmp"
#define CONFIG_KEY_GENERAL_SAVE_CURRENT_TRACK_POSITION "SaveCurrentTrackPos"
#define CONFIG_KEY_GENERAL_SHOW_CLOSE_BUTTON "ShowPaneCloseButton"
#define CONFIG_KEY_GENERAL_SHOW_CLOSE_CONFIRM "ShowCloseConfirm"
#define CONFIG_KEY_GENERAL_SHOW_NOTIFICATIONS "ShowNotifications"
#define CONFIG_KEY_GENERAL_EQ_ENABLED "EqualizerEnabled"
#define CONFIG_KEY_GENERAL_VOLUME_ENABLED "VolumeColtrolsEnabled"
#define CONFIG_KEY_GENERAL_SHOW_REV_TIME "ShowRevTime"
#define CONFIG_KEY_GENERAL_SHOW_SPLASH_SCREEN "ShowSplashScreen"
#define CONFIG_KEY_GENERAL_SHOW_TASK_BAR_ICON "ShowTaskBarIcon"
#define CONFIG_KEY_GENERAL_SOUND_MENU_INTEGRATE "SoundMenuIntegration"
#define CONFIG_KEY_GENERAL_START_MINIMIZED "StartMinimized"
#define CONFIG_KEY_GENERAL_TEXT_SEARCH_ENTER "TextSearchEnterRelax"
// Import Files
#define CONFIG_PATH_IMPORT_FILES_POSITION "positions/import_files/position"
#define CONFIG_KEY_IMPORT_FILES_POS_X "PosX"
#define CONFIG_KEY_IMPORT_FILES_POS_Y "PosY"
#define CONFIG_KEY_IMPORT_FILES_WIDTH "Width"
#define CONFIG_KEY_IMPORT_FILES_HEIGHT "Height"
// Jamendo
#define CONFIG_PATH_JAMENDO "jamendo"
#define CONFIG_KEY_JAMENDO_AUDIOFORMAT "AudioFormat"
#define CONFIG_KEY_JAMENDO_TORRENT_COMMAND "TorrentCommand"
#define CONFIG_KEY_JAMENDO_LAST_UPDATE "LastUpdate"
#define CONFIG_KEY_JAMENDO_NEED_UPGRADE "NeedUpgrade"
#define CONFIG_PATH_JAMENDO_GENRES "jamendo/genres"
#define CONFIG_KEY_JAMENDO_GENRES_GENRE "Genre"
// LastFm
#define CONFIG_PATH_LASTFM "lastfm"
#define CONFIG_KEY_LASTFM_USERNAME "UserName"
#define CONFIG_KEY_LASTFM_PASSWORD "Password"
#define CONFIG_KEY_LASTFM_ENABLED "SubmitEnabled"
#define CONFIG_KEY_LASTFM_SESSIONKEY "SessionKey"
#define CONFIG_KEY_LASTFM_LANGUAGE "Language"
#define CONFIG_KEY_LASTFM_SHOW_LONG_BIO "ShowLongBioText"
#define CONFIG_KEY_LASTFM_SHOW_ARTIST_INFO "ShowArtistInfo"
#define CONFIG_KEY_LASTFM_SHOW_ALBUMS "ShowAlbums"
#define CONFIG_KEY_LASTFM_SHOW_TOP_TRACKS "ShowTopTracks"
#define CONFIG_KEY_LASTFM_SHOW_ARTISTS "ShowArtists"
#define CONFIG_KEY_LASTFM_SHOW_TRACKS "ShowTracks"
#define CONFIG_KEY_LASTFM_SHOW_EVENTS "ShowEvents"
#define CONFIG_KEY_LASTFM_FOLLOW_PLAYER "FollowPlayer"
// LibreFm
#define CONFIG_PATH_LIBREFM "librefm"
#define CONFIG_KEY_LIBREFM_USERNAME "UserName"
#define CONFIG_KEY_LIBREFM_PASSWORD "Password"
#define CONFIG_KEY_LIBREFM_ENABLED "SubmitEnabled"
// Lyrics
#define CONFIG_PATH_LYRICS "lyrics"
#define CONFIG_PATH_LYRICS_DISGENRES "lyrics/disgenres"
#define CONFIG_KEY_LYRICS_DISGENRE "DisGenre"
#define CONFIG_KEY_LYRICS_FOLLOW_PLAYER "FollowPlayer"
#define CONFIG_KEY_LYRICS_TEXT_ALIGN "TextAlign"
#define CONFIG_KEY_LYRICS_FONT "Font"
// Magnatune
#define CONFIG_PATH_MAGNATUNE "magnatune"
#define CONFIG_KEY_MAGNATUNE_LAST_UPDATE "LastUpdate"
#define CONFIG_KEY_MAGNATUNE_MEMBERSHIP "MemberShip"
#define CONFIG_KEY_MAGNATUNE_USERNAME "UserName"
#define CONFIG_KEY_MAGNATUNE_PASSWORD "Password"
#define CONFIG_KEY_MAGNATUNE_NEED_UPGRADE "NeedUpgrade"
#define CONFIG_KEY_MAGNATUNE_AUDIO_FORMAT "AudioFormat"
#define CONFIG_KEY_MAGNATUNE_DOWNLOAD_FORMAT "DownloadFormat"
#define CONFIG_PATH_MAGNATUNE_GENRES "magnatune/genres"
#define CONFIG_PATH_MAGNATUNE_GENRELIST "magnatune/genrelist"
#define CONFIG_KEY_MAGNATUNE_GENRES_GENRE "Genre"
// Main Sources
#define CONFIG_PATH_MAIN_SOURCES "mainsources"
#define CONFIG_KEY_MAIN_SOURCES_LOCAL_MUSIC "LocalMusic"
#define CONFIG_KEY_MAIN_SOURCES_ONLINE_MUSIC "OnlineMusic"
#define CONFIG_KEY_MAIN_SOURCES_PORTABLE_DEVICES "PortableDevices"
#define CONFIG_KEY_MAIN_SOURCES_CONTEXT "ContextExpanded"
// MainWindow
#define CONFIG_PATH_MAIN_WINDOW "mainwindow"
#define CONFIG_KEY_MAIN_WINDOW_VISIBLE_PANELS "VisiblePanels"
#define CONFIG_KEY_MAIN_WINDOW_NOTEBOOK_LAYOUT "NotebookLayout"
#define CONFIG_KEY_MAIN_WINDOW_LAST_LAYOUT "LastLayout"
#define CONFIG_KEY_MAIN_WINDOW_FULLSCREEN "ShowFullScreen"
#define CONFIG_KEY_MAIN_WINDOW_STATUS_BAR "ShowStatusBar"
#define CONFIG_KEY_MAIN_WINDOW_CAPTIONS "ShowCaptions"
#define CONFIG_PATH_MAIN_WINDOW_FULLSCREEN "mainwindow/fullscreen"
#define CONFIG_KEY_MAIN_WINDOW_FULLSCREEN_LAST_LAYOUT "LastLayout"
#define CONFIG_KEY_MAIN_WINDOW_FULLSCREEN_VISIBLE_PANELS "VisiblePanels"
#define CONFIG_PATH_MAIN_WINDOW_POSITIONS "mainwindow/positions"
#define CONFIG_KEY_MAIN_WINDOW_POSITIONS_POSX "PosX"
#define CONFIG_KEY_MAIN_WINDOW_POSITIONS_POSY "PosY"
#define CONFIG_KEY_MAIN_WINDOW_POSITIONS_WIDTH "Width"
#define CONFIG_KEY_MAIN_WINDOW_POSITIONS_HEIGHT "Height"
#define CONFIG_PATH_MAIN_WINDOW_NOTEBOOK "mainwindow/notebook"
#define CONFIG_KEY_MAIN_WINDOW_NOTEBOOK_LAST_LAYOUT "LastLayout"
// Playback
#define CONFIG_PATH_PLAYBACK "playback"
#define CONFIG_KEY_PLAYBACK_OUTPUT_DEVICE "OutputDevice"
#define CONFIG_KEY_PLAYBACK_OUTPUT_DEVICE_NAME "OutputDeviceName"
#define CONFIG_KEY_PLAYBACK_NUM_TRACKS_TO_ADD "NumTracksToAdd"
#define CONFIG_KEY_PLAYBACK_MAX_TRACKS_PLAYED "MaxTracksPlayed"
#define CONFIG_KEY_PLAYBACK_MIN_TRACKS_PLAY "MinTracksToPlay"
#define CONFIG_KEY_PLAYBACK_DEL_TRACKS_PLAYED "DelTracksPlayed"
#define CONFIG_KEY_PLAYBACK_SMART_FILTER_ARTISTS "SmartFilterArtists"
#define CONFIG_KEY_PLAYBACK_SMART_FILTER_TRACKS "SmartFilterTracks"
#define CONFIG_KEY_PLAYBACK_PLAYLIST_ALLOW_FILTER "PlayListAllowFilter"
#define CONFIG_KEY_PLAYBACK_PLAYLIST_DENY_FILTER "PlayListDenyFilter"
#define CONFIG_KEY_PLAYBCK_SILENCE_DETECTOR "SilenceDetector"
#define CONFIG_KEY_PLAYBCK_SILENCE_LEVEL "SilenceLevel"
#define CONFIG_KEY_PLAYBCK_SILENCE_AT_END "SilenceAtEnd"
#define CONFIG_KEY_PLAYBCK_SILENCE_END_TIME "SilenceEndTime"
// Playlist
#define CONFIG_PATH_PLAYLIST "playlist"
#define CONFIG_KEY_PLAYLIST_SAVE_ON_CLOSE "SaveOnClose"
#define CONFIG_PATH_PLAYLIST_NOWPLAYING "playlist/nowplaying"
#define CONFIG_KEY_PLAYLIST_CURITEM "CurItem"
// Podcasts
#define CONFIG_PATH_PODCASTS "podcasts"
#define CONFIG_KEY_PODCASTS_PATH "Path"
#define CONFIG_KEY_PODCASTS_UPDATE "Update"
#define CONFIG_KEY_PODCASTS_LASTUPDATE "LastPodcastUpdate"
#define CONFIG_KEY_PODCASTS_UPDATEPERIOD "UpdatePeriod"
#define CONFIG_KEY_PODCASTS_DELETE "Delete"
#define CONFIG_KEY_PODCASTS_DELETETIME "DeleteTime"
#define CONFIG_KEY_PODCASTS_DELETEPERIOD "DeletePeriod"
#define CONFIG_KEY_PODCASTS_DELETEPLAYED "DeletePlayed"
#define CONFIG_KEY_PODCASTS_VISIBLE_PANELS "VisiblePanels"
#define CONFIG_KEY_PODCASTS_LASTLAYOUT "LastLayout"
#define CONFIG_KEY_PODCASTS_ORDER "Order"
#define CONFIG_KEY_PODCASTS_ORDERDESC "OrderDesc"
// Positions
#define CONFIG_PATH_POSITIONS "positions"
#define CONFIG_KEY_POSITIONS_LABELEDIT_POSX "LabelEditPosX"
#define CONFIG_KEY_POSITIONS_LABELEDIT_POSY "LabelEditPosX"
#define CONFIG_KEY_POSITIONS_LABELEDIT_WIDTH "LabelEditWidth"
#define CONFIG_KEY_POSITIONS_LABELEDIT_HEIGHT "LabelEditHeight"
#define CONFIG_KEY_POSITIONS_LABELEDIT_SASHPOS "LabelEditSashPos"
#define CONFIG_KEY_POSITIONS_PMPROPERTIES_POSX "PMPropertiesPosX"
#define CONFIG_KEY_POSITIONS_PMPROPERTIES_POSY "PMPropertiesPosY"
#define CONFIG_KEY_POSITIONS_PMPROPERTIES_WIDTH "PMPropertiesWidth"
#define CONFIG_KEY_POSITIONS_PMPROPERTIES_HEIGHT "PMPropertiesHeight"
#define CONFIG_KEY_POSITIONS_TRACKEDIT_POSX "TrackEditPosX"
#define CONFIG_KEY_POSITIONS_TRACKEDIT_POSY "TrackEditPosY"
#define CONFIG_KEY_POSITIONS_TRACKEDIT_WIDTH "TrackEditWidth"
#define CONFIG_KEY_POSITIONS_TRACKEDIT_HEIGHT "TrackEditHeight"
#define CONFIG_KEY_POSITIONS_TRACKEDIT_SASHPOS "TrackEditSashPos"
// Preferences
#define CONFIG_PATH_PREFERENCES "preferences"
#define CONFIG_KEY_PREFERENCES_POSX "PosX"
#define CONFIG_KEY_PREFERENCES_POSY "PosY"
#define CONFIG_KEY_PREFERENCES_WIDTH "Width"
#define CONFIG_KEY_PREFERENCES_HEIGHT "Height"
#define CONFIG_KEY_PREFERENCES_LAST_PAGE "LastPage"
// Radios
#define CONFIG_PATH_RADIOS "radios"
#define CONFIG_KEY_RADIOS_STATIONS_ORDER "StationsOrder"
#define CONFIG_KEY_RADIOS_STATIONS_ORDERDESC "StationsOrderDesc"
#define CONFIG_KEY_RADIOS_MIN_BITRATE "MinBitrate"
#define CONFIG_KEY_RADIOS_VISIBLE_PANELS "VisiblePanels"
#define CONFIG_KEY_RADIOS_LAST_LAYOUT "LastLayout"
// Record
#define CONFIG_PATH_RECORD "record"
#define CONFIG_KEY_RECORD_ENABLED "Enabled"
#define CONFIG_KEY_RECORD_PATH "Path"
#define CONFIG_KEY_RECORD_FORMAT "Format"
#define CONFIG_KEY_RECORD_QUALITY "Quality"
#define CONFIG_KEY_RECORD_SPLIT "Split"
#define CONFIG_KEY_RECORD_DELETE "DeleteTracks"
#define CONFIG_KEY_RECORD_DELETE_TIME "DeleteTime"
// Search Filters
#define CONFIG_PATH_SEARCH_FILTERS "searchfilters"
#define CONFIG_KEY_SEARCH_FILTERS_FILTER "Filter"
// Search Links
#define CONFIG_PATH_SEARCHLINKS_LINKS "searchlinks/links"
#define CONFIG_PATH_SEARCHLINKS_NAMES "searchlinks/names"
#define CONFIG_KEY_SEARCHLINKS_LINK "Link"
#define CONFIG_KEY_SEARCHLINKS_NAME "Name"
// Proxy
#define CONFIG_PATH_PROXY "proxy"
#define CONFIG_KEY_PROXY_ENABLED "enabled"
#define CONFIG_KEY_PROXY_HOSTNAME "hostname"
#define CONFIG_KEY_PROXY_PORT "port"
#define CONFIG_KEY_PROXY_USERNAME "username"
#define CONFIG_KEY_PROXY_PASSWORD "password"
}
#endif
// -------------------------------------------------------------------------------- //
| 17,754
|
C++
|
.h
| 280
| 62.175
| 90
| 0.630478
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,975
|
Http.h
|
anonbeat_guayadeque/src/network/Http.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// 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 3, 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; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __HTTP_H__
#define __HTTP_H__
#include "Curl.h"
namespace Guayadeque {
// -------------------------------------------------------------------------------- //
class guHttp : public guCurl
{
public:
guHttp( const wxString &url = wxEmptyString );
virtual ~guHttp();
void AddHeader( const wxString &key, const wxString &value );
bool Post( const char * buffer, size_t size, const wxString &url = wxEmptyString );
bool Post( wxInputStream &buffer, const wxString &url = wxEmptyString );
bool Get( const wxString &filename, const wxString &url = wxEmptyString );
size_t Get( char * &buffer, const wxString &url = wxEmptyString );
bool Get( wxOutputStream &buffer, const wxString &url = wxEmptyString );
};
}
#endif
// -------------------------------------------------------------------------------- //
| 2,066
|
C++
|
.h
| 41
| 47.121951
| 109
| 0.535127
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,976
|
Curl.h
|
anonbeat_guayadeque/src/network/Curl.h
|
// -------------------------------------------------------------------------------- //
// Copyright (C) 2008-2023 J.Rios anonbeat@gmail.com
//
// 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 3, 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; see the file LICENSE. If not, write to
// the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
// Boston, MA 02110-1301 USA.
//
// http://www.gnu.org/copyleft/gpl.html
//
// -------------------------------------------------------------------------------- //
#ifndef __CURL_H__
#define __CURL_H__
#include <wx/string.h>
#include <wx/mstream.h>
#include <curl/curl.h>
namespace Guayadeque {
#define wxCHARBUFFER_ISEMPTY( x ) ( strlen( x ) == 0 )
#define CURL_VERBOSE_MODE 0L
#define CURL_FOLLOW_LOCATIONS 1L
#define CURL_MAX_REDIRS 3L
#define CURL_NO_SIGNALS 1L
// -------------------------------------------------------------------------------- //
class guCurl
{
protected:
CURL * m_CurlHandle;
wxCharBuffer m_Url;
int m_Port;
wxCharBuffer m_User;
wxCharBuffer m_Password;
wxCharBuffer m_CurlUserPass;
long m_ResCode;
wxCharBuffer m_ResHeader;
wxCharBuffer m_ResData;
struct curl_slist * m_CurlHeaders;
wxArrayString m_ReqHeaders;
bool m_UseProxy;
wxCharBuffer m_ProxyHost;
int m_ProxyPort;
wxCharBuffer m_ProxyUser;
wxCharBuffer m_ProxyPassword;
wxCharBuffer m_CurlProxyUserPass;
char m_ErrorBuffer[ CURL_ERROR_SIZE ];
protected :
virtual void SetDefaultOptions( const wxString &url );
virtual void SetHeaders();
virtual void CleanHeaders();
virtual void ResetResVars();
bool SetStringReadOption( const wxCharBuffer &str );
bool SetStringWriteOption( const wxCharBuffer &str );
bool SetStreamReadOption( const wxInputStream &stream );
bool SetStreamWriteOption( const wxOutputStream &stream );
public :
guCurl( const wxString &url = wxEmptyString );
virtual ~guCurl();
static void CurlInit(); // Must be called once before any curl use
static void CurlDone(); // Must be called once on application close
bool InitHandle();
bool CleanupHandle();
bool ReInitHandle();
void ResetHandle();
bool Perform();
void SetUrl( const wxString &url );
wxString GetUrl() const;
void SetPort( const long &port );
long GetPort() const;
void SetUsername( const wxString &username );
wxString GetUsername() const;
void SetPassword( const wxString &password );
wxString GetPassword() const;
wxString GetResHeader() const;
wxString GetResData() const;
long GetResCode() const;
void SetUseProxy( const bool useproxy );
bool GetUseProxy() const;
void SetProxyHost( const wxString &proxyhost );
wxString GetProxyHost() const;
void SetProxyPort( const long &proxyport );
long GetProxyPort() const;
void SetProxyUser( const wxString &proxyuser );
wxString GetProxyUser() const;
void SetProxyPassword( const wxString &proxypass );
wxString GetProxyPassword() const;
bool SetOption( CURLoption option, long value );
bool SetOption( CURLoption option, wxCharBuffer &value );
bool SetOption( CURLoption option, void * value );
bool GetInfo( CURLINFO info, long * value );
};
}
#endif
// -------------------------------------------------------------------------------- //
| 5,042
|
C++
|
.h
| 102
| 44.352941
| 92
| 0.509031
|
anonbeat/guayadeque
| 130
| 29
| 42
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,978
|
log.cpp
|
iwamatsu_slim/log.cpp
|
#include "log.h"
#include <iostream>
bool
LogUnit::openLog(const char * filename)
{
if (logFile.is_open()) {
cerr << APPNAME
<< ": opening a new Log file, while another is already open"
<< endl;
logFile.close();
}
logFile.open(filename, ios_base::app);
return !(logFile.fail());
}
void
LogUnit::closeLog()
{
if (logFile.is_open())
logFile.close();
}
| 370
|
C++
|
.cpp
| 20
| 16.5
| 63
| 0.685879
|
iwamatsu/slim
| 124
| 35
| 16
|
GPL-2.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
750,979
|
app.cpp
|
iwamatsu_slim/app.cpp
|
/* SLiM - Simple Login Manager
* Copyright (C) 1997, 1998 Per Liden
* Copyright (C) 2004-06 Simone Rota <sip@varlock.com>
* Copyright (C) 2004-06 Johannes Winkelmann <jw@tks6.net>
*
* 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.
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdint.h>
#include <cstring>
#include <cstdio>
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include "app.h"
#include "numlock.h"
#include "util.h"
#ifdef HAVE_SHADOW
#include <shadow.h>
#endif
using namespace std;
#ifdef USE_PAM
#include <string>
int conv(int num_msg, const struct pam_message **msg,
struct pam_response **resp, void *appdata_ptr)
{
*resp = (struct pam_response *) calloc(num_msg, sizeof(struct pam_response));
Panel* panel = *static_cast<Panel**>(appdata_ptr);
int result = PAM_SUCCESS;
int i;
for (i = 0; i < num_msg; i++) {
(*resp)[i].resp = 0;
(*resp)[i].resp_retcodei = 0;
switch (msg[i]->msg_style) {
case PAM_PROMPT_ECHO_ON:
/* We assume PAM is asking for the username */
panel->EventHandler(Panel::Get_Name);
switch (panel->getAction()) {
case Panel::Suspend:
case Panel::Halt:
case Panel::Reboot:
(*resp)[i].resp=strdup("root");
break;
case Panel::Console:
case Panel::Exit:
case Panel::Login:
(*resp)[i].resp=strdup(panel->GetName().c_str());
break;
default:
break;
}
break;
case PAM_PROMPT_ECHO_OFF:
/* We assume PAM is asking for the password */
switch (panel->getAction()) {
case Panel::Console:
case Panel::Exit:
/* We should leave now! */
result = PAM_CONV_ERR;
break;
default:
panel->EventHandler(Panel::Get_Passwd);
(*resp)[i].resp=strdup(panel->GetPasswd().c_str());
break;
}
break;
case PAM_ERROR_MSG:
case PAM_TEXT_INFO:
/* We simply write these to the log
TODO: Maybe we should simply ignore them */
logStream << APPNAME << ": " << msg[i]->msg << endl;
break;
}
if (result!=PAM_SUCCESS) break;
}
if (result != PAM_SUCCESS) {
for (i = 0; i < num_msg; i++) {
if ((*resp)[i].resp == 0)
continue;
free((*resp)[i].resp);
(*resp)[i].resp = 0;
}
free(*resp);
*resp = 0;
}
return result;
}
#endif
extern App* LoginApp;
int xioerror(Display *disp)
{
LoginApp->RestartServer();
return 0;
}
void CatchSignal(int sig)
{
logStream << APPNAME << ": unexpected signal " << sig << endl;
if (LoginApp->isServerStarted())
LoginApp->StopServer();
LoginApp->RemoveLock();
exit(ERR_EXIT);
}
void User1Signal(int sig)
{
signal(sig, User1Signal);
}
#ifdef USE_PAM
App::App(int argc, char** argv)
: pam(conv, static_cast<void*>(&LoginPanel)),
#else
App::App(int argc, char** argv)
:
#endif
mcookiesize(32) /* Must be divisible by 4 */
{
int tmp;
ServerPID = -1;
testing = false;
serverStarted = false;
mcookie = string(App::mcookiesize, 'a');
daemonmode = false;
force_nodaemon = false;
firstlogin = true;
Dpy = NULL;
/* Parse command line
Note: we force a option for nodaemon switch to handle "-nodaemon" */
while ((tmp = getopt(argc, argv, "vhp:n:d?")) != EOF) {
switch (tmp) {
case 'p': /* Test theme */
testtheme = optarg;
testing = true;
if (testtheme == NULL) {
logStream << "The -p option requires an argument" << endl;
exit(ERR_EXIT);
}
break;
case 'd': /* Daemon mode */
daemonmode = true;
break;
case 'n': /* Daemon mode */
daemonmode = false;
force_nodaemon = true;
break;
case 'v': /* Version */
std::cout << APPNAME << " version " << VERSION << endl;
exit(OK_EXIT);
break;
case '?': /* Illegal */
logStream << endl;
case 'h': /* Help */
logStream << "usage: " << APPNAME << " [option ...]" << endl
<< "options:" << endl
<< " -d: daemon mode" << endl
<< " -nodaemon: no-daemon mode" << endl
<< " -v: show version" << endl
<< " -p /path/to/theme/dir: preview theme" << endl;
exit(OK_EXIT);
break;
}
}
#ifndef XNEST_DEBUG
if (getuid() != 0 && !testing) {
logStream << APPNAME << ": only root can run this program" << endl;
exit(ERR_EXIT);
}
#endif /* XNEST_DEBUG */
}
void App::Run()
{
DisplayName = DISPLAY;
#ifdef XNEST_DEBUG
char* p = getenv("DISPLAY");
if (p && p[0]) {
DisplayName = p;
cout << "Using display name " << DisplayName << endl;
}
#endif
/* Read configuration and theme */
cfg = new Cfg;
cfg->readConf(CFGFILE);
string themebase = "";
string themefile = "";
string themedir = "";
themeName = "";
if (testing) {
themeName = testtheme;
} else {
themebase = string(THEMESDIR) + "/";
themeName = cfg->getOption("current_theme");
string::size_type pos;
if ((pos = themeName.find(",")) != string::npos) {
/* input is a set */
themeName = findValidRandomTheme(themeName);
if (themeName == "") {
themeName = "default";
}
}
}
#ifdef USE_PAM
try {
pam.start("slim");
pam.set_item(PAM::Authenticator::TTY, DisplayName);
pam.set_item(PAM::Authenticator::Requestor, "root");
} catch(PAM::Exception& e) {
logStream << APPNAME << ": " << e << endl;
exit(ERR_EXIT);
}
#endif
bool loaded = false;
while (!loaded) {
themedir = themebase + themeName;
themefile = themedir + THEMESFILE;
if (!cfg->readConf(themefile)) {
if (themeName == "default") {
logStream << APPNAME << ": Failed to open default theme file "
<< themefile << endl;
exit(ERR_EXIT);
} else {
logStream << APPNAME << ": Invalid theme in config: "
<< themeName << endl;
themeName = "default";
}
} else {
loaded = true;
}
}
if (!testing) {
/* Create lock file */
LoginApp->GetLock();
/* Start x-server */
setenv("DISPLAY", DisplayName, 1);
signal(SIGQUIT, CatchSignal);
signal(SIGTERM, CatchSignal);
signal(SIGKILL, CatchSignal);
signal(SIGINT, CatchSignal);
signal(SIGHUP, CatchSignal);
signal(SIGPIPE, CatchSignal);
signal(SIGUSR1, User1Signal);
#ifndef XNEST_DEBUG
if (!force_nodaemon && cfg->getOption("daemon") == "yes") {
daemonmode = true;
}
/* Daemonize */
if (daemonmode) {
if (daemon(0, 0) == -1) {
logStream << APPNAME << ": " << strerror(errno) << endl;
exit(ERR_EXIT);
}
}
OpenLog();
if (daemonmode)
UpdatePid();
CreateServerAuth();
StartServer();
#endif
}
/* Open display */
if ((Dpy = XOpenDisplay(DisplayName)) == 0) {
logStream << APPNAME << ": could not open display '"
<< DisplayName << "'" << endl;
if (!testing) StopServer();
exit(ERR_EXIT);
}
/* Get screen and root window */
Scr = DefaultScreen(Dpy);
Root = RootWindow(Dpy, Scr);
// Intern _XROOTPMAP_ID property
BackgroundPixmapId = XInternAtom(Dpy, "_XROOTPMAP_ID", False);
/* for tests we use a standard window */
if (testing) {
Window RealRoot = RootWindow(Dpy, Scr);
Root = XCreateSimpleWindow(Dpy, RealRoot, 0, 0, 1280, 1024, 0, 0, 0);
XMapWindow(Dpy, Root);
XFlush(Dpy);
} else {
blankScreen();
}
HideCursor();
/* Create panel */
LoginPanel = new Panel(Dpy, Scr, Root, cfg, themedir, Panel::Mode_DM);
bool firstloop = true; /* 1st time panel is shown (for automatic username) */
bool focuspass = cfg->getOption("focus_password")=="yes";
bool autologin = cfg->getOption("auto_login")=="yes";
if (firstlogin && cfg->getOption("default_user") != "") {
LoginPanel->SetName(cfg->getOption("default_user"));
#ifdef USE_PAM
pam.set_item(PAM::Authenticator::User, cfg->getOption("default_user").c_str());
#endif
firstlogin = false;
if (autologin) {
Login();
}
}
/* Set NumLock */
string numlock = cfg->getOption("numlock");
if (numlock == "on") {
NumLock::setOn(Dpy);
} else if (numlock == "off") {
NumLock::setOff(Dpy);
}
/* Start looping */
int panelclosed = 1;
Panel::ActionType Action;
while (1) {
if (panelclosed) {
/* Init root */
setBackground(themedir);
/* Close all clients */
if (!testing) {
KillAllClients(False);
KillAllClients(True);
}
/* Show panel */
LoginPanel->OpenPanel();
}
LoginPanel->Reset();
if (firstloop && cfg->getOption("default_user") != "")
LoginPanel->SetName(cfg->getOption("default_user"));
if (firstloop)
LoginPanel->SwitchSession();
if (!AuthenticateUser(focuspass && firstloop)) {
panelclosed = 0;
firstloop = false;
LoginPanel->ClearPanel();
XBell(Dpy, 100);
continue;
}
firstloop = false;
Action = LoginPanel->getAction();
/* for themes test we just quit */
if (testing)
Action = Panel::Exit;
panelclosed = 1;
LoginPanel->ClosePanel();
switch (Action) {
case Panel::Login:
Login();
break;
case Panel::Console:
Console();
break;
case Panel::Reboot:
Reboot();
break;
case Panel::Halt:
Halt();
break;
case Panel::Suspend:
Suspend();
break;
case Panel::Exit:
Exit();
break;
default:
break;
}
}
}
#ifdef USE_PAM
bool App::AuthenticateUser(bool focuspass)
{
/* Reset the username */
try{
if (!focuspass)
pam.set_item(PAM::Authenticator::User, 0);
pam.authenticate();
} catch(PAM::Auth_Exception& e) {
switch (LoginPanel->getAction()) {
case Panel::Exit:
case Panel::Console:
return true; /* <--- This is simply fake! */
default:
break;
}
logStream << APPNAME << ": " << e << endl;
return false;
} catch(PAM::Exception& e) {
logStream << APPNAME << ": " << e << endl;
exit(ERR_EXIT);
}
return true;
}
#else
bool App::AuthenticateUser(bool focuspass)
{
if (!focuspass) {
LoginPanel->EventHandler(Panel::Get_Name);
switch (LoginPanel->getAction()) {
case Panel::Exit:
case Panel::Console:
logStream << APPNAME << ": Got a special command ("
<< LoginPanel->GetName() << ")" << endl;
return true; /* <--- This is simply fake! */
default:
break;
}
}
LoginPanel->EventHandler(Panel::Get_Passwd);
char *encrypted, *correct;
struct passwd *pw;
switch (LoginPanel->getAction()) {
case Panel::Suspend:
case Panel::Halt:
case Panel::Reboot:
pw = getpwnam("root");
break;
case Panel::Console:
case Panel::Exit:
case Panel::Login:
pw = getpwnam(LoginPanel->GetName().c_str());
break;
}
endpwent();
if (pw == 0)
return false;
#ifdef HAVE_SHADOW
struct spwd *sp = getspnam(pw->pw_name);
endspent();
if (sp)
correct = sp->sp_pwdp;
else
#endif /* HAVE_SHADOW */
correct = pw->pw_passwd;
if (correct == 0 || correct[0] == '\0')
return true;
encrypted = crypt(LoginPanel->GetPasswd().c_str(), correct);
return ((encrypted && strcmp(encrypted, correct) == 0) ? true : false);
}
#endif
int App::GetServerPID()
{
return ServerPID;
}
/* Hide the cursor */
void App::HideCursor()
{
if (cfg->getOption("hidecursor") == "true") {
XColor black;
char cursordata[1];
Pixmap cursorpixmap;
Cursor cursor;
cursordata[0]=0;
cursorpixmap=XCreateBitmapFromData(Dpy,Root,cursordata,1,1);
black.red=0;
black.green=0;
black.blue=0;
cursor=XCreatePixmapCursor(Dpy,cursorpixmap,cursorpixmap,&black,&black,0,0);
XDefineCursor(Dpy,Root,cursor);
}
}
void App::Login()
{
struct passwd *pw;
pid_t pid;
#ifdef USE_PAM
try{
pam.open_session();
pw = getpwnam(static_cast<const char*>(pam.get_item(PAM::Authenticator::User)));
} catch(PAM::Cred_Exception& e) {
/* Credentials couldn't be established */
logStream << APPNAME << ": " << e << endl;
return;
} catch(PAM::Exception& e) {
logStream << APPNAME << ": " << e << endl;
exit(ERR_EXIT);
}
#else
pw = getpwnam(LoginPanel->GetName().c_str());
#endif
endpwent();
if (pw == 0)
return;
if (pw->pw_shell[0] == '\0') {
setusershell();
strcpy(pw->pw_shell, getusershell());
endusershell();
}
/* Setup the environment */
char* term = getenv("TERM");
string maildir = _PATH_MAILDIR;
maildir.append("/");
maildir.append(pw->pw_name);
string xauthority = pw->pw_dir;
xauthority.append("/.Xauthority");
#ifdef USE_PAM
/* Setup the PAM environment */
try{
if (term) pam.setenv("TERM", term);
pam.setenv("HOME", pw->pw_dir);
pam.setenv("PWD", pw->pw_dir);
pam.setenv("SHELL", pw->pw_shell);
pam.setenv("USER", pw->pw_name);
pam.setenv("LOGNAME", pw->pw_name);
pam.setenv("PATH", cfg->getOption("default_path").c_str());
pam.setenv("DISPLAY", DisplayName);
pam.setenv("MAIL", maildir.c_str());
pam.setenv("XAUTHORITY", xauthority.c_str());
} catch(PAM::Exception& e) {
logStream << APPNAME << ": " << e << endl;
exit(ERR_EXIT);
}
#endif
#ifdef USE_CONSOLEKIT
/* Setup the ConsoleKit session */
try {
ck.open_session(DisplayName, pw->pw_uid);
}
catch(Ck::Exception &e) {
logStream << APPNAME << ": " << e << endl;
exit(ERR_EXIT);
}
#endif
/* Create new process */
pid = fork();
if (pid == 0) {
#ifdef USE_PAM
/* Get a copy of the environment and close the child's copy */
/* of the PAM-handle. */
char** child_env = pam.getenvlist();
# ifdef USE_CONSOLEKIT
char** old_env = child_env;
/* Grow the copy of the environment for the session cookie */
int n;
for (n = 0; child_env[n] != NULL ; n++);
n++;
child_env = static_cast<char**>(malloc(sizeof(char*)*n));
memcpy(child_env, old_env, sizeof(char*)*n+1);
child_env[n - 1] = StrConcat("XDG_SESSION_COOKIE=", ck.get_xdg_session_cookie());
child_env[n] = NULL;
# endif /* USE_CONSOLEKIT */
#else
# ifdef USE_CONSOLEKIT
const int Num_Of_Variables = 12; /* Number of env. variables + 1 */
# else
const int Num_Of_Variables = 11; /* Number of env. variables + 1 */
# endif /* USE_CONSOLEKIT */
char** child_env = static_cast<char**>(malloc(sizeof(char*)*Num_Of_Variables));
int n = 0;
if (term) child_env[n++]=StrConcat("TERM=", term);
child_env[n++]=StrConcat("HOME=", pw->pw_dir);
child_env[n++]=StrConcat("PWD=", pw->pw_dir);
child_env[n++]=StrConcat("SHELL=", pw->pw_shell);
child_env[n++]=StrConcat("USER=", pw->pw_name);
child_env[n++]=StrConcat("LOGNAME=", pw->pw_name);
child_env[n++]=StrConcat("PATH=", cfg->getOption("default_path").c_str());
child_env[n++]=StrConcat("DISPLAY=", DisplayName);
child_env[n++]=StrConcat("MAIL=", maildir.c_str());
child_env[n++]=StrConcat("XAUTHORITY=", xauthority.c_str());
# ifdef USE_CONSOLEKIT
child_env[n++]=StrConcat("XDG_SESSION_COOKIE=", ck.get_xdg_session_cookie());
# endif /* USE_CONSOLEKIT */
child_env[n++]=0;
#endif
/* Login process starts here */
SwitchUser Su(pw, cfg, DisplayName, child_env);
string session = LoginPanel->getSession();
string loginCommand = cfg->getOption("login_cmd");
replaceVariables(loginCommand, SESSION_VAR, session);
replaceVariables(loginCommand, THEME_VAR, themeName);
string sessStart = cfg->getOption("sessionstart_cmd");
if (sessStart != "") {
replaceVariables(sessStart, USER_VAR, pw->pw_name);
system(sessStart.c_str());
}
Su.Login(loginCommand.c_str(), mcookie.c_str());
_exit(OK_EXIT);
}
#ifndef XNEST_DEBUG
CloseLog();
#endif
/* Wait until user is logging out (login process terminates) */
pid_t wpid = -1;
int status;
while (wpid != pid) {
wpid = wait(&status);
if (wpid == ServerPID)
xioerror(Dpy); /* Server died, simulate IO error */
}
if (WIFEXITED(status) && WEXITSTATUS(status)) {
LoginPanel->Message("Failed to execute login command");
sleep(3);
} else {
string sessStop = cfg->getOption("sessionstop_cmd");
if (sessStop != "") {
replaceVariables(sessStop, USER_VAR, pw->pw_name);
system(sessStop.c_str());
}
}
#ifdef USE_CONSOLEKIT
try {
ck.close_session();
} catch(Ck::Exception &e) {
logStream << APPNAME << ": " << e << endl;
}
#endif
#ifdef USE_PAM
try {
pam.close_session();
} catch(PAM::Exception& e) {
logStream << APPNAME << ": " << e << endl;
}
#endif
/* Close all clients */
KillAllClients(False);
KillAllClients(True);
/* Send HUP signal to clientgroup */
killpg(pid, SIGHUP);
/* Send TERM signal to clientgroup, if error send KILL */
if (killpg(pid, SIGTERM))
killpg(pid, SIGKILL);
HideCursor();
#ifndef XNEST_DEBUG
/* Re-activate log file */
OpenLog();
RestartServer();
#endif
}
void App::Reboot()
{
#ifdef USE_PAM
try {
pam.end();
} catch(PAM::Exception& e) {
logStream << APPNAME << ": " << e << endl;
}
#endif
/* Write message */
LoginPanel->Message((char*)cfg->getOption("reboot_msg").c_str());
sleep(3);
/* Stop server and reboot */
StopServer();
RemoveLock();
system(cfg->getOption("reboot_cmd").c_str());
exit(OK_EXIT);
}
void App::Halt()
{
#ifdef USE_PAM
try {
pam.end();
} catch (PAM::Exception& e) {
logStream << APPNAME << ": " << e << endl;
}
#endif
/* Write message */
LoginPanel->Message((char*)cfg->getOption("shutdown_msg").c_str());
sleep(3);
/* Stop server and halt */
StopServer();
RemoveLock();
system(cfg->getOption("halt_cmd").c_str());
exit(OK_EXIT);
}
void App::Suspend()
{
sleep(1);
system(cfg->getOption("suspend_cmd").c_str());
}
void App::Console()
{
int posx = 40;
int posy = 40;
int fontx = 9;
int fonty = 15;
int width = (XWidthOfScreen(ScreenOfDisplay(Dpy, Scr)) - (posx * 2)) / fontx;
int height = (XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)) - (posy * 2)) / fonty;
/* Execute console */
const char* cmd = cfg->getOption("console_cmd").c_str();
char *tmp = new char[strlen(cmd) + 60];
sprintf(tmp, cmd, width, height, posx, posy, fontx, fonty);
system(tmp);
delete [] tmp;
}
void App::Exit()
{
#ifdef USE_PAM
try {
pam.end();
} catch(PAM::Exception& e) {
logStream << APPNAME << ": " << e << endl;
}
#endif
if (testing) {
const char* testmsg = "This is a test message :-)";
LoginPanel->Message(testmsg);
sleep(3);
delete LoginPanel;
XCloseDisplay(Dpy);
} else {
delete LoginPanel;
StopServer();
RemoveLock();
}
delete cfg;
exit(OK_EXIT);
}
int CatchErrors(Display *dpy, XErrorEvent *ev)
{
return 0;
}
void App::RestartServer()
{
#ifdef USE_PAM
try {
pam.end();
} catch(PAM::Exception& e) {
logStream << APPNAME << ": " << e << endl;
}
#endif
StopServer();
RemoveLock();
while (waitpid(-1, NULL, WNOHANG) > 0); /* Collects all dead childrens */
Run();
}
void App::KillAllClients(Bool top)
{
Window dummywindow;
Window *children;
unsigned int nchildren;
unsigned int i;
XWindowAttributes attr;
XSync(Dpy, 0);
XSetErrorHandler(CatchErrors);
nchildren = 0;
XQueryTree(Dpy, Root, &dummywindow, &dummywindow, &children, &nchildren);
if (!top) {
for (i=0; i<nchildren; i++) {
if (XGetWindowAttributes(Dpy, children[i], &attr) && (attr.map_state == IsViewable))
children[i] = XmuClientWindow(Dpy, children[i]);
else
children[i] = 0;
}
}
for (i=0; i<nchildren; i++) {
if (children[i])
XKillClient(Dpy, children[i]);
}
XFree((char *)children);
XSync(Dpy, 0);
XSetErrorHandler(NULL);
}
int App::ServerTimeout(int timeout, char* text)
{
int i = 0;
int pidfound = -1;
static char *lasttext;
while (1) {
pidfound = waitpid(ServerPID, NULL, WNOHANG);
if (pidfound == ServerPID)
break;
if (timeout) {
if (i == 0 && text != lasttext)
logStream << endl << APPNAME << ": waiting for " << text;
else
logStream << ".";
}
if (timeout)
sleep(1);
if (++i > timeout)
break;
}
if (i > 0)
logStream << endl;
lasttext = text;
return (ServerPID != pidfound);
}
int App::WaitForServer()
{
int ncycles = 120;
int cycles;
for (cycles = 0; cycles < ncycles; cycles++) {
if ((Dpy = XOpenDisplay(DisplayName))) {
XSetIOErrorHandler(xioerror);
return 1;
} else {
if (!ServerTimeout(1, (char *) "X server to begin accepting connections"))
break;
}
}
logStream << "Giving up." << endl;
return 0;
}
int App::StartServer()
{
ServerPID = fork();
int argc = 1, pos = 0, i;
static const int MAX_XSERVER_ARGS = 256;
static char* server[MAX_XSERVER_ARGS+2] = { NULL };
server[0] = (char *)cfg->getOption("default_xserver").c_str();
string argOption = cfg->getOption("xserver_arguments");
/* Add mandatory -xauth option */
argOption = argOption + " -auth " + cfg->getOption("authfile");
char* args = new char[argOption.length()+2]; /* NULL plus vt */
strcpy(args, argOption.c_str());
serverStarted = false;
bool hasVtSet = false;
while (args[pos] != '\0') {
if (args[pos] == ' ' || args[pos] == '\t') {
*(args+pos) = '\0';
server[argc++] = args+pos+1;
} else if (pos == 0) {
server[argc++] = args+pos;
}
++pos;
if (argc+1 >= MAX_XSERVER_ARGS) {
/* ignore _all_ arguments to make sure the server starts at */
/* all */
argc = 1;
break;
}
}
for (i = 0; i < argc; i++) {
if (server[i][0] == 'v' && server[i][1] == 't') {
bool ok = false;
Cfg::string2int(server[i]+2, &ok);
if (ok) {
hasVtSet = true;
}
}
}
if (!hasVtSet && daemonmode) {
server[argc++] = (char*)"vt07";
}
server[argc] = NULL;
switch (ServerPID) {
case 0:
signal(SIGTTIN, SIG_IGN);
signal(SIGTTOU, SIG_IGN);
signal(SIGUSR1, SIG_IGN);
setpgid(0,getpid());
execvp(server[0], server);
logStream << APPNAME << ": X server could not be started" << endl;
exit(ERR_EXIT);
break;
case -1:
break;
default:
errno = 0;
if (!ServerTimeout(0, (char *)"")) {
ServerPID = -1;
break;
}
/* Wait for server to start up */
if (WaitForServer() == 0) {
logStream << APPNAME << ": unable to connect to X server" << endl;
StopServer();
ServerPID = -1;
exit(ERR_EXIT);
}
break;
}
delete [] args;
serverStarted = true;
return ServerPID;
}
jmp_buf CloseEnv;
int IgnoreXIO(Display *d)
{
logStream << APPNAME << ": connection to X server lost." << endl;
longjmp(CloseEnv, 1);
}
void App::StopServer()
{
signal(SIGQUIT, SIG_IGN);
signal(SIGINT, SIG_IGN);
signal(SIGHUP, SIG_IGN);
signal(SIGPIPE, SIG_IGN);
signal(SIGTERM, SIG_DFL);
signal(SIGKILL, SIG_DFL);
/* Catch X error */
XSetIOErrorHandler(IgnoreXIO);
if (!setjmp(CloseEnv) && Dpy)
XCloseDisplay(Dpy);
/* Send HUP to process group */
errno = 0;
if ((killpg(getpid(), SIGHUP) != 0) && (errno != ESRCH))
logStream << APPNAME << ": can't send HUP to process group " << getpid() << endl;
/* Send TERM to server */
if (ServerPID < 0)
return;
errno = 0;
if (killpg(ServerPID, SIGTERM) < 0) {
if (errno == EPERM) {
logStream << APPNAME << ": can't kill X server" << endl;
exit(ERR_EXIT);
}
if (errno == ESRCH)
return;
}
/* Wait for server to shut down */
if (!ServerTimeout(10, (char *)"X server to shut down")) {
logStream << endl;
return;
}
logStream << endl << APPNAME <<
": X server slow to shut down, sending KILL signal." << endl;
/* Send KILL to server */
errno = 0;
if (killpg(ServerPID, SIGKILL) < 0) {
if (errno == ESRCH)
return;
}
/* Wait for server to die */
if (ServerTimeout(3, (char*)"server to die")) {
logStream << endl << APPNAME << ": can't kill server" << endl;
exit(ERR_EXIT);
}
logStream << endl;
}
void App::blankScreen()
{
GC gc = XCreateGC(Dpy, Root, 0, 0);
XSetForeground(Dpy, gc, BlackPixel(Dpy, Scr));
XFillRectangle(Dpy, Root, gc, 0, 0,
XWidthOfScreen(ScreenOfDisplay(Dpy, Scr)),
XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)));
XFlush(Dpy);
XFreeGC(Dpy, gc);
}
void App::setBackground(const string& themedir)
{
string filename;
filename = themedir + "/background.png";
image = new Image;
bool loaded = image->Read(filename.c_str());
if (!loaded) { /* try jpeg if png failed */
filename = themedir + "/background.jpg";
loaded = image->Read(filename.c_str());
}
if (loaded) {
string bgstyle = cfg->getOption("background_style");
if (bgstyle == "stretch") {
image->Resize(XWidthOfScreen(ScreenOfDisplay(Dpy, Scr)),
XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)));
} else if (bgstyle == "tile") {
image->Tile(XWidthOfScreen(ScreenOfDisplay(Dpy, Scr)),
XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)));
} else if (bgstyle == "center") {
string hexvalue = cfg->getOption("background_color");
hexvalue = hexvalue.substr(1,6);
image->Center(XWidthOfScreen(ScreenOfDisplay(Dpy, Scr)),
XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)),
hexvalue.c_str());
} else { /* plain color or error */
string hexvalue = cfg->getOption("background_color");
hexvalue = hexvalue.substr(1,6);
image->Center(XWidthOfScreen(ScreenOfDisplay(Dpy, Scr)),
XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)),
hexvalue.c_str());
}
Pixmap p = image->createPixmap(Dpy, Scr, Root);
XSetWindowBackgroundPixmap(Dpy, Root, p);
XChangeProperty(Dpy, Root, BackgroundPixmapId, XA_PIXMAP, 32,
PropModeReplace, (unsigned char *)&p, 1);
}
XClearWindow(Dpy, Root);
XFlush(Dpy);
delete image;
}
/* Check if there is a lockfile and a corresponding process */
void App::GetLock()
{
std::ifstream lockfile(cfg->getOption("lockfile").c_str());
if (!lockfile) {
/* no lockfile present, create one */
std::ofstream lockfile(cfg->getOption("lockfile").c_str(), ios_base::out);
if (!lockfile) {
logStream << APPNAME << ": Could not create lock file: " <<
cfg->getOption("lockfile").c_str() << std::endl;
exit(ERR_EXIT);
}
lockfile << getpid() << std::endl;
lockfile.close();
} else {
/* lockfile present, read pid from it */
int pid = 0;
lockfile >> pid;
lockfile.close();
if (pid > 0) {
/* see if process with this pid exists */
int ret = kill(pid, 0);
if (ret == 0 || (ret == -1 && errno == EPERM) ) {
logStream << APPNAME <<
": Another instance of the program is already running with PID "
<< pid << std::endl;
exit(0);
} else {
logStream << APPNAME << ": Stale lockfile found, removing it" << std::endl;
std::ofstream lockfile(cfg->getOption("lockfile").c_str(), ios_base::out);
if (!lockfile) {
logStream << APPNAME <<
": Could not create new lock file: " << cfg->getOption("lockfile")
<< std::endl;
exit(ERR_EXIT);
}
lockfile << getpid() << std::endl;
lockfile.close();
}
}
}
}
/* Remove lockfile and close logs */
void App::RemoveLock()
{
remove(cfg->getOption("lockfile").c_str());
}
/* Get server start check flag. */
bool App::isServerStarted()
{
return serverStarted;
}
/* Redirect stdout and stderr to log file */
void App::OpenLog()
{
if ( !logStream.openLog( cfg->getOption("logfile").c_str() ) ) {
logStream << APPNAME << ": Could not accesss log file: " << cfg->getOption("logfile") << endl;
RemoveLock();
exit(ERR_EXIT);
}
/* I should set the buffers to imediate write, but I just flush on every << operation. */
}
/* Relases stdout/err */
void App::CloseLog()
{
/* Simply closing the log */
logStream.closeLog();
}
string App::findValidRandomTheme(const string& set)
{
/* extract random theme from theme set; return empty string on error */
string name = set;
struct stat buf;
if (name[name.length()-1] == ',') {
name = name.substr(0, name.length() - 1);
}
Util::srandom(Util::makeseed());
vector<string> themes;
string themefile;
Cfg::split(themes, name, ',');
do {
int sel = Util::random() % themes.size();
name = Cfg::Trim(themes[sel]);
themefile = string(THEMESDIR) +"/" + name + THEMESFILE;
if (stat(themefile.c_str(), &buf) != 0) {
themes.erase(find(themes.begin(), themes.end(), name));
logStream << APPNAME << ": Invalid theme in config: "
<< name << endl;
name = "";
}
} while (name == "" && themes.size());
return name;
}
void App::replaceVariables(string& input,
const string& var,
const string& value)
{
string::size_type pos = 0;
int len = var.size();
while ((pos = input.find(var, pos)) != string::npos) {
input = input.substr(0, pos) + value + input.substr(pos+len);
}
}
/*
* We rely on the fact that all bits generated by Util::random()
* are usable, so we are taking full words from its output.
*/
void App::CreateServerAuth()
{
/* create mit cookie */
uint16_t word;
uint8_t hi, lo;
int i;
string authfile;
const char *digits = "0123456789abcdef";
Util::srandom(Util::makeseed());
for (i = 0; i < App::mcookiesize; i+=4) {
word = Util::random() & 0xffff;
lo = word & 0xff;
hi = word >> 8;
mcookie[i] = digits[lo & 0x0f];
mcookie[i+1] = digits[lo >> 4];
mcookie[i+2] = digits[hi & 0x0f];
mcookie[i+3] = digits[hi >> 4];
}
/* reinitialize auth file */
authfile = cfg->getOption("authfile");
remove(authfile.c_str());
putenv(StrConcat("XAUTHORITY=", authfile.c_str()));
Util::add_mcookie(mcookie, ":0", cfg->getOption("xauth_path"),
authfile);
}
char* App::StrConcat(const char* str1, const char* str2)
{
char* tmp = new char[strlen(str1) + strlen(str2) + 1];
strcpy(tmp, str1);
strcat(tmp, str2);
return tmp;
}
void App::UpdatePid()
{
std::ofstream lockfile(cfg->getOption("lockfile").c_str(), ios_base::out);
if (!lockfile) {
logStream << APPNAME << ": Could not update lock file: " <<
cfg->getOption("lockfile").c_str() << endl;
exit(ERR_EXIT);
}
lockfile << getpid() << endl;
lockfile.close();
}
| 29,141
|
C++
|
.cpp
| 1,117
| 23.249776
| 97
| 0.648733
|
iwamatsu/slim
| 124
| 35
| 16
|
GPL-2.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
750,980
|
util.cpp
|
iwamatsu_slim/util.cpp
|
/* SLiM - Simple Login Manager
Copyright (C) 2009 Eygene Ryabinkin <rea@codelabs.ru>
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.
*/
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include "util.h"
/*
* Adds the given cookie to the specified Xauthority file.
* Returns true on success, false on fault.
*/
bool Util::add_mcookie(const std::string &mcookie, const char *display,
const std::string &xauth_cmd, const std::string &authfile)
{
FILE *fp;
std::string cmd = xauth_cmd + " -f " + authfile + " -q";
fp = popen(cmd.c_str(), "w");
if (!fp)
return false;
fprintf(fp, "remove %s\n", display);
fprintf(fp, "add %s %s %s\n", display, ".", mcookie.c_str());
fprintf(fp, "exit\n");
pclose(fp);
return true;
}
/*
* Interface for random number generator. Just now it uses ordinary
* random/srandom routines and serves as a wrapper for them.
*/
void Util::srandom(unsigned long seed)
{
::srandom(seed);
}
long Util::random(void)
{
return ::random();
}
/*
* Makes seed for the srandom() using "random" values obtained from
* getpid(), time(NULL) and others.
*/
long Util::makeseed(void)
{
struct timespec ts;
long pid = getpid();
long tm = time(NULL);
if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) {
ts.tv_sec = ts.tv_nsec = 0;
}
return pid + tm + (ts.tv_sec ^ ts.tv_nsec);
}
| 1,577
|
C++
|
.cpp
| 57
| 25.649123
| 71
| 0.698276
|
iwamatsu/slim
| 124
| 35
| 16
|
GPL-2.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
750,981
|
switchuser.cpp
|
iwamatsu_slim/switchuser.cpp
|
/* SLiM - Simple Login Manager
Copyright (C) 1997, 1998 Per Liden
Copyright (C) 2004-06 Simone Rota <sip@varlock.com>
Copyright (C) 2004-06 Johannes Winkelmann <jw@tks6.net>
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.
*/
#include <cstdio>
#include "switchuser.h"
#include "util.h"
using namespace std;
SwitchUser::SwitchUser(struct passwd *pw, Cfg *c, const string& display,
char** _env)
: cfg(c),
Pw(pw),
displayName(display),
env(_env)
{
}
SwitchUser::~SwitchUser() {
/* Never called */
}
void SwitchUser::Login(const char* cmd, const char* mcookie) {
SetUserId();
SetClientAuth(mcookie);
Execute(cmd);
}
void SwitchUser::SetUserId() {
if( (Pw == 0) ||
(initgroups(Pw->pw_name, Pw->pw_gid) != 0) ||
(setgid(Pw->pw_gid) != 0) ||
(setuid(Pw->pw_uid) != 0) ) {
logStream << APPNAME << ": could not switch user id" << endl;
exit(ERR_EXIT);
}
}
void SwitchUser::Execute(const char* cmd) {
chdir(Pw->pw_dir);
execle(Pw->pw_shell, Pw->pw_shell, "-c", cmd, NULL, env);
logStream << APPNAME << ": could not execute login command" << endl;
}
void SwitchUser::SetClientAuth(const char* mcookie) {
string home = string(Pw->pw_dir);
string authfile = home + "/.Xauthority";
remove(authfile.c_str());
Util::add_mcookie(mcookie, ":0", cfg->getOption("xauth_path"),
authfile);
}
| 1,538
|
C++
|
.cpp
| 50
| 28.22
| 72
| 0.687627
|
iwamatsu/slim
| 124
| 35
| 16
|
GPL-2.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
750,982
|
main.cpp
|
iwamatsu_slim/main.cpp
|
/* SLiM - Simple Login Manager
Copyright (C) 1997, 1998 Per Liden
Copyright (C) 2004-06 Simone Rota <sip@varlock.com>
Copyright (C) 2004-06 Johannes Winkelmann <jw@tks6.net>
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.
*/
#include "app.h"
#include "const.h"
App* LoginApp = 0;
int main(int argc, char** argv)
{
LoginApp = new App(argc, argv);
LoginApp->Run();
return 0;
}
| 582
|
C++
|
.cpp
| 18
| 30.5
| 69
| 0.751342
|
iwamatsu/slim
| 124
| 35
| 16
|
GPL-2.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
750,983
|
numlock.cpp
|
iwamatsu_slim/numlock.cpp
|
/* SLiM - Simple Login Manager
Copyright (C) 2004-06 Simone Rota <sip@varlock.com>
Copyright (C) 2004-06 Johannes Winkelmann <jw@tks6.net>
Copyright (C) 2012 Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
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.
Code adapted from NumLockX, look at the end of this file for
the original Copyright information.
*/
#include "numlock.h"
#include <string.h>
NumLock::NumLock() {
}
int NumLock::xkb_init(Display* dpy) {
int xkb_opcode, xkb_event, xkb_error;
int xkb_lmaj = XkbMajorVersion;
int xkb_lmin = XkbMinorVersion;
return XkbLibraryVersion( &xkb_lmaj, &xkb_lmin )
&& XkbQueryExtension( dpy, &xkb_opcode, &xkb_event, &xkb_error,
&xkb_lmaj, &xkb_lmin );
}
unsigned int NumLock::xkb_mask_modifier( XkbDescPtr xkb, const char *name ) {
int i;
if( !xkb || !xkb->names )
return 0;
for( i = 0; i < XkbNumVirtualMods; i++ ) {
char* modStr = XGetAtomName( xkb->dpy, xkb->names->vmods[i] );
if( modStr != NULL && strcmp(name, modStr) == 0 ) {
unsigned int mask;
XkbVirtualModsToReal( xkb, 1 << i, &mask );
return mask;
}
}
return 0;
}
unsigned int NumLock::xkb_numlock_mask(Display* dpy) {
XkbDescPtr xkb;
xkb = XkbGetKeyboard( dpy, XkbAllComponentsMask, XkbUseCoreKbd );
if( xkb != NULL ) {
unsigned int mask = xkb_mask_modifier( xkb, "NumLock" );
XkbFreeKeyboard( xkb, 0, True );
return mask;
}
return 0;
}
void NumLock::control_numlock(Display *dpy, bool flag) {
unsigned int mask;
if( !xkb_init(dpy) )
return;
mask = xkb_numlock_mask(dpy);
if( mask == 0 )
return;
if( flag == true )
XkbLockModifiers ( dpy, XkbUseCoreKbd, mask, mask);
else
XkbLockModifiers ( dpy, XkbUseCoreKbd, mask, 0);
}
void NumLock::setOn(Display *dpy) {
control_numlock(dpy, true);
}
void NumLock::setOff(Display *dpy) {
control_numlock(dpy, false);
}
/*
Copyright (C) 2000-2001 Lubos Lunak <l.lunak@kde.org>
Copyright (C) 2001 Oswald Buddenhagen <ossi@kde.org>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
| 3,198
|
C++
|
.cpp
| 84
| 35.72619
| 77
| 0.746119
|
iwamatsu/slim
| 124
| 35
| 16
|
GPL-2.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
750,984
|
cfg.cpp
|
iwamatsu_slim/cfg.cpp
|
/* SLiM - Simple Login Manager
Copyright (C) 2004-06 Simone Rota <sip@varlock.com>
Copyright (C) 2004-06 Johannes Winkelmann <jw@tks6.net>
Copyright (C) 2012-13 Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
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.
*/
#include <fstream>
#include <string>
#include <iostream>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include "cfg.h"
using namespace std;
typedef pair<string,string> option;
Cfg::Cfg()
: currentSession(-1)
{
/* Configuration options */
options.insert(option("default_path","/bin:/usr/bin:/usr/local/bin"));
options.insert(option("default_xserver","/usr/bin/X"));
options.insert(option("xserver_arguments",""));
options.insert(option("numlock",""));
options.insert(option("daemon",""));
options.insert(option("xauth_path","/usr/bin/xauth"));
options.insert(option("login_cmd","exec /bin/bash -login ~/.xinitrc %session"));
options.insert(option("halt_cmd","/sbin/shutdown -h now"));
options.insert(option("reboot_cmd","/sbin/shutdown -r now"));
options.insert(option("suspend_cmd",""));
options.insert(option("sessionstart_cmd",""));
options.insert(option("sessionstop_cmd",""));
options.insert(option("console_cmd","/usr/bin/xterm -C -fg white -bg black +sb -g %dx%d+%d+%d -fn %dx%d -T ""Console login"" -e /bin/sh -c ""/bin/cat /etc/issue; exec /bin/login"""));
options.insert(option("screenshot_cmd","import -window root /slim.png"));
options.insert(option("welcome_msg","Welcome to %host"));
options.insert(option("session_msg","Session:"));
options.insert(option("default_user",""));
options.insert(option("focus_password","no"));
options.insert(option("auto_login","no"));
options.insert(option("current_theme","default"));
options.insert(option("lockfile","/var/run/slim.lock"));
options.insert(option("logfile","/var/log/slim.log"));
options.insert(option("authfile","/var/run/slim.auth"));
options.insert(option("shutdown_msg","The system is halting..."));
options.insert(option("reboot_msg","The system is rebooting..."));
options.insert(option("sessiondir",""));
options.insert(option("hidecursor","false"));
/* Theme stuff */
options.insert(option("input_panel_x","50%"));
options.insert(option("input_panel_y","40%"));
options.insert(option("input_name_x","200"));
options.insert(option("input_name_y","154"));
options.insert(option("input_pass_x","-1")); /* default is single inputbox */
options.insert(option("input_pass_y","-1"));
options.insert(option("input_font","Verdana:size=11"));
options.insert(option("input_color", "#000000"));
options.insert(option("input_cursor_height","20"));
options.insert(option("input_maxlength_name","20"));
options.insert(option("input_maxlength_passwd","20"));
options.insert(option("input_shadow_xoffset", "0"));
options.insert(option("input_shadow_yoffset", "0"));
options.insert(option("input_shadow_color","#FFFFFF"));
options.insert(option("welcome_font","Verdana:size=14"));
options.insert(option("welcome_color","#FFFFFF"));
options.insert(option("welcome_x","-1"));
options.insert(option("welcome_y","-1"));
options.insert(option("welcome_shadow_xoffset", "0"));
options.insert(option("welcome_shadow_yoffset", "0"));
options.insert(option("welcome_shadow_color","#FFFFFF"));
options.insert(option("intro_msg",""));
options.insert(option("intro_font","Verdana:size=14"));
options.insert(option("intro_color","#FFFFFF"));
options.insert(option("intro_x","-1"));
options.insert(option("intro_y","-1"));
options.insert(option("background_style","stretch"));
options.insert(option("background_color","#CCCCCC"));
options.insert(option("username_font","Verdana:size=12"));
options.insert(option("username_color","#FFFFFF"));
options.insert(option("username_x","-1"));
options.insert(option("username_y","-1"));
options.insert(option("username_msg","Please enter your username"));
options.insert(option("username_shadow_xoffset", "0"));
options.insert(option("username_shadow_yoffset", "0"));
options.insert(option("username_shadow_color","#FFFFFF"));
options.insert(option("password_x","-1"));
options.insert(option("password_y","-1"));
options.insert(option("password_msg","Please enter your password"));
options.insert(option("msg_color","#FFFFFF"));
options.insert(option("msg_font","Verdana:size=16:bold"));
options.insert(option("msg_x","40"));
options.insert(option("msg_y","40"));
options.insert(option("msg_shadow_xoffset", "0"));
options.insert(option("msg_shadow_yoffset", "0"));
options.insert(option("msg_shadow_color","#FFFFFF"));
options.insert(option("session_color","#FFFFFF"));
options.insert(option("session_font","Verdana:size=16:bold"));
options.insert(option("session_x","50%"));
options.insert(option("session_y","90%"));
options.insert(option("session_shadow_xoffset", "0"));
options.insert(option("session_shadow_yoffset", "0"));
options.insert(option("session_shadow_color","#FFFFFF"));
// slimlock-specific options
options.insert(option("dpms_standby_timeout", "60"));
options.insert(option("dpms_off_timeout", "600"));
options.insert(option("wrong_passwd_timeout", "2"));
options.insert(option("passwd_feedback_x", "50%"));
options.insert(option("passwd_feedback_y", "10%"));
options.insert(option("passwd_feedback_msg", "Authentication failed"));
options.insert(option("passwd_feedback_capslock", "Authentication failed (CapsLock is on)"));
options.insert(option("show_username", "1"));
options.insert(option("show_welcome_msg", "0"));
options.insert(option("tty_lock", "1"));
options.insert(option("bell", "1"));
error = "";
}
Cfg::~Cfg() {
options.clear();
}
/*
* Creates the Cfg object and parses
* known options from the given configfile / themefile
*/
bool Cfg::readConf(string configfile) {
int n = -1;
size_t pos = 0;
string line, next, op, fn(configfile);
map<string,string>::iterator it;
ifstream cfgfile(fn.c_str());
if (!cfgfile) {
error = "Cannot read configuration file: " + configfile;
return false;
}
while (getline(cfgfile, line)) {
if ((pos = line.find('\\')) != string::npos) {
if (line.length() == pos + 1) {
line.replace(pos, 1, " ");
next = next + line;
continue;
} else
line.replace(pos, line.length() - pos, " ");
}
if (!next.empty()) {
line = next + line;
next = "";
}
it = options.begin();
while (it != options.end()) {
op = it->first;
n = line.find(op);
if (n == 0)
options[op] = parseOption(line, op);
++it;
}
}
cfgfile.close();
fillSessionList();
return true;
}
/* Returns the option value, trimmed */
string Cfg::parseOption(string line, string option ) {
return Trim( line.substr(option.size(), line.size() - option.size()));
}
const string& Cfg::getError() const {
return error;
}
string& Cfg::getOption(string option) {
return options[option];
}
/* return a trimmed string */
string Cfg::Trim( const string& s ) {
if ( s.empty() ) {
return s;
}
int pos = 0;
string line = s;
int len = line.length();
while ( pos < len && isspace( line[pos] ) ) {
++pos;
}
line.erase( 0, pos );
pos = line.length()-1;
while ( pos > -1 && isspace( line[pos] ) ) {
--pos;
}
if ( pos != -1 ) {
line.erase( pos+1 );
}
return line;
}
/* Return the welcome message with replaced vars */
string Cfg::getWelcomeMessage(){
string s = getOption("welcome_msg");
int n = s.find("%host");
if (n >= 0) {
string tmp = s.substr(0, n);
char host[40];
gethostname(host,40);
tmp = tmp + host;
tmp = tmp + s.substr(n+5, s.size() - n);
s = tmp;
}
n = s.find("%domain");
if (n >= 0) {
string tmp = s.substr(0, n);;
char domain[40];
getdomainname(domain,40);
tmp = tmp + domain;
tmp = tmp + s.substr(n+7, s.size() - n);
s = tmp;
}
return s;
}
int Cfg::string2int(const char* string, bool* ok) {
char* err = 0;
int l = (int)strtol(string, &err, 10);
if (ok) {
*ok = (*err == 0);
}
return (*err == 0) ? l : 0;
}
int Cfg::getIntOption(std::string option) {
return string2int(options[option].c_str());
}
/* Get absolute position */
int Cfg::absolutepos(const string& position, int max, int width) {
int n = position.find("%");
if (n>0) { /* X Position expressed in percentage */
int result = (max*string2int(position.substr(0, n).c_str())/100) - (width / 2);
return result < 0 ? 0 : result ;
} else { /* Absolute X position */
return string2int(position.c_str());
}
}
/* split a comma separated string into a vector of strings */
void Cfg::split(vector<string>& v, const string& str, char c, bool useEmpty) {
v.clear();
string::const_iterator s = str.begin();
string tmp;
while (true) {
string::const_iterator begin = s;
while (*s != c && s != str.end()) { ++s; }
tmp = string(begin, s);
if (useEmpty || tmp.size() > 0)
v.push_back(tmp);
if (s == str.end()) {
break;
}
if (++s == str.end()) {
if (useEmpty)
v.push_back("");
break;
}
}
}
void Cfg::fillSessionList(){
string strSessionDir = getOption("sessiondir");
sessions.clear();
if( !strSessionDir.empty() ) {
DIR *pDir = opendir(strSessionDir.c_str());
if (pDir != NULL) {
struct dirent *pDirent = NULL;
while ((pDirent = readdir(pDir)) != NULL) {
string strFile(strSessionDir);
strFile += "/";
strFile += pDirent->d_name;
struct stat oFileStat;
if (stat(strFile.c_str(), &oFileStat) == 0) {
if (S_ISREG(oFileStat.st_mode) &&
access(strFile.c_str(), R_OK) == 0){
ifstream desktop_file(strFile.c_str());
if (desktop_file){
string line, session_name = "", session_exec = "";
while (getline( desktop_file, line )) {
if (line.substr(0, 5) == "Name=") {
session_name = line.substr(5);
if (!session_exec.empty())
break;
} else
if (line.substr(0, 5) == "Exec=") {
session_exec = line.substr(5);
if (!session_name.empty())
break;
}
}
desktop_file.close();
pair<string,string> session(session_name,session_exec);
sessions.push_back(session);
cout << session_exec << " - " << session_name << endl;
}
}
}
}
closedir(pDir);
}
}
if (sessions.empty()){
pair<string,string> session("","");
sessions.push_back(session);
}
}
pair<string,string> Cfg::nextSession() {
currentSession = (currentSession + 1) % sessions.size();
return sessions[currentSession];
}
| 10,665
|
C++
|
.cpp
| 308
| 31.701299
| 184
| 0.665859
|
iwamatsu/slim
| 124
| 35
| 16
|
GPL-2.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
750,985
|
slimlock.cpp
|
iwamatsu_slim/slimlock.cpp
|
/* slimlock
* Copyright (c) 2010-2012 Joel Burget <joelburget@gmail.com>
*
* 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.
*/
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <linux/vt.h>
#include <X11/keysym.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/extensions/dpms.h>
#include <security/pam_appl.h>
#include <pthread.h>
#include <err.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/file.h>
#include <errno.h>
#include <sys/file.h>
#include <fcntl.h>
#include "cfg.h"
#include "util.h"
#include "panel.h"
#undef APPNAME
#define APPNAME "slimlock"
#define SLIMLOCKCFG SYSCONFDIR"/slimlock.conf"
using namespace std;
void setBackground(const string& themedir);
void HideCursor();
bool AuthenticateUser();
static int ConvCallback(int num_msgs, const struct pam_message **msg,
struct pam_response **resp, void *appdata_ptr);
string findValidRandomTheme(const string& set);
void HandleSignal(int sig);
void *RaiseWindow(void *data);
// I really didn't wanna put these globals here, but it's the only way...
Display* dpy;
int scr;
Window win;
Cfg* cfg;
Panel* loginPanel;
string themeName = "";
pam_handle_t *pam_handle;
struct pam_conv conv = {ConvCallback, NULL};
CARD16 dpms_standby, dpms_suspend, dpms_off, dpms_level;
BOOL dpms_state, using_dpms;
int term;
static void
die(const char *errstr, ...) {
va_list ap;
va_start(ap, errstr);
vfprintf(stderr, errstr, ap);
va_end(ap);
exit(EXIT_FAILURE);
}
int main(int argc, char **argv) {
if((argc == 2) && !strcmp("-v", argv[1]))
die(APPNAME"-"VERSION", © 2010-2012 Joel Burget\n");
else if(argc != 1)
die("usage: "APPNAME" [-v]\n");
void (*prev_fn)(int);
// restore DPMS settings should slimlock be killed in the line of duty
prev_fn = signal(SIGTERM, HandleSignal);
if (prev_fn == SIG_IGN) signal(SIGTERM, SIG_IGN);
// create a lock file to solve mutliple instances problem
// /var/lock used to be the place to put this, now it's /run/lock
// ...i think
struct stat statbuf;
int lock_file;
// try /run/lock first, since i believe it's preferred
if (!stat("/run/lock", &statbuf))
lock_file = open("/run/lock/"APPNAME".lock", O_CREAT | O_RDWR, 0666);
else
lock_file = open("/var/lock/"APPNAME".lock", O_CREAT | O_RDWR, 0666);
int rc = flock(lock_file, LOCK_EX | LOCK_NB);
if(rc) {
if(EWOULDBLOCK == errno)
die(APPNAME" already running\n");
}
unsigned int cfg_passwd_timeout;
// Read user's current theme
cfg = new Cfg;
cfg->readConf(CFGFILE);
cfg->readConf(SLIMLOCKCFG);
string themebase = "";
string themefile = "";
string themedir = "";
themeName = "";
themebase = string(THEMESDIR) + "/";
themeName = cfg->getOption("current_theme");
string::size_type pos;
if ((pos = themeName.find(",")) != string::npos) {
themeName = findValidRandomTheme(themeName);
}
bool loaded = false;
while (!loaded) {
themedir = themebase + themeName;
themefile = themedir + THEMESFILE;
if (!cfg->readConf(themefile)) {
if (themeName == "default") {
cerr << APPNAME << ": Failed to open default theme file "
<< themefile << endl;
exit(ERR_EXIT);
} else {
cerr << APPNAME << ": Invalid theme in config: "
<< themeName << endl;
themeName = "default";
}
} else {
loaded = true;
}
}
const char *display = getenv("DISPLAY");
if (!display)
display = DISPLAY;
if(!(dpy = XOpenDisplay(display)))
die(APPNAME": cannot open display\n");
scr = DefaultScreen(dpy);
XSetWindowAttributes wa;
wa.override_redirect = 1;
wa.background_pixel = BlackPixel(dpy, scr);
// Create a full screen window
Window root = RootWindow(dpy, scr);
win = XCreateWindow(dpy,
root,
0,
0,
DisplayWidth(dpy, scr),
DisplayHeight(dpy, scr),
0,
DefaultDepth(dpy, scr),
CopyFromParent,
DefaultVisual(dpy, scr),
CWOverrideRedirect | CWBackPixel,
&wa);
XMapWindow(dpy, win);
XFlush(dpy);
for (int len = 1000; len; len--) {
if(XGrabKeyboard(dpy, root, True, GrabModeAsync, GrabModeAsync, CurrentTime)
== GrabSuccess)
break;
usleep(1000);
}
XSelectInput(dpy, win, ExposureMask | KeyPressMask);
// This hides the cursor if the user has that option enabled in their
// configuration
HideCursor();
loginPanel = new Panel(dpy, scr, win, cfg, themedir, Panel::Mode_Lock);
int ret = pam_start(APPNAME, loginPanel->GetName().c_str(), &conv, &pam_handle);
// If we can't start PAM, just exit because slimlock won't work right
if (ret != PAM_SUCCESS)
die("PAM: %s\n", pam_strerror(pam_handle, ret));
// disable tty switching
if(cfg->getOption("tty_lock") == "1") {
if ((term = open("/dev/console", O_RDWR)) == -1)
perror("error opening console");
if ((ioctl(term, VT_LOCKSWITCH)) == -1)
perror("error locking console");
}
// Set up DPMS
unsigned int cfg_dpms_standby, cfg_dpms_off;
cfg_dpms_standby = Cfg::string2int(cfg->getOption("dpms_standby_timeout").c_str());
cfg_dpms_off = Cfg::string2int(cfg->getOption("dpms_off_timeout").c_str());
using_dpms = DPMSCapable(dpy) && (cfg_dpms_standby > 0);
if (using_dpms) {
DPMSGetTimeouts(dpy, &dpms_standby, &dpms_suspend, &dpms_off);
DPMSSetTimeouts(dpy, cfg_dpms_standby,
cfg_dpms_standby, cfg_dpms_off);
DPMSInfo(dpy, &dpms_level, &dpms_state);
if (!dpms_state)
DPMSEnable(dpy);
}
// Get password timeout
cfg_passwd_timeout = Cfg::string2int(cfg->getOption("wrong_passwd_timeout").c_str());
// Let's just make sure it has a sane value
cfg_passwd_timeout = cfg_passwd_timeout > 60 ? 60 : cfg_passwd_timeout;
pthread_t raise_thread;
pthread_create(&raise_thread, NULL, RaiseWindow, NULL);
// Main loop
while (true)
{
loginPanel->ResetPasswd();
// AuthenticateUser returns true if authenticated
if (AuthenticateUser())
break;
loginPanel->WrongPassword(cfg_passwd_timeout);
}
// kill thread before destroying the window that it's supposed to be raising
pthread_cancel(raise_thread);
loginPanel->ClosePanel();
delete loginPanel;
// Get DPMS stuff back to normal
if (using_dpms) {
DPMSSetTimeouts(dpy, dpms_standby, dpms_suspend, dpms_off);
// turn off DPMS if it was off when we entered
if (!dpms_state)
DPMSDisable(dpy);
}
XCloseDisplay(dpy);
close(lock_file);
if(cfg->getOption("tty_lock") == "1") {
if ((ioctl(term, VT_UNLOCKSWITCH)) == -1) {
perror("error unlocking console");
}
}
close(term);
return 0;
}
void HideCursor()
{
if (cfg->getOption("hidecursor") == "true") {
XColor black;
char cursordata[1];
Pixmap cursorpixmap;
Cursor cursor;
cursordata[0] = 0;
cursorpixmap = XCreateBitmapFromData(dpy, win, cursordata, 1, 1);
black.red = 0;
black.green = 0;
black.blue = 0;
cursor = XCreatePixmapCursor(dpy, cursorpixmap, cursorpixmap,
&black, &black, 0, 0);
XFreePixmap(dpy, cursorpixmap);
XDefineCursor(dpy, win, cursor);
}
}
static int ConvCallback(int num_msgs, const struct pam_message **msg,
struct pam_response **resp, void *appdata_ptr)
{
loginPanel->EventHandler(Panel::Get_Passwd);
// PAM expects an array of responses, one for each message
if (num_msgs == 0 ||
(*resp = (pam_response*) calloc(num_msgs, sizeof(struct pam_message))) == NULL)
return PAM_BUF_ERR;
for (int i = 0; i < num_msgs; i++) {
if (msg[i]->msg_style != PAM_PROMPT_ECHO_OFF &&
msg[i]->msg_style != PAM_PROMPT_ECHO_ON)
continue;
// return code is currently not used but should be set to zero
resp[i]->resp_retcode = 0;
if ((resp[i]->resp = strdup(loginPanel->GetPasswd().c_str())) == NULL) {
free(*resp);
return PAM_BUF_ERR;
}
}
return PAM_SUCCESS;
}
bool AuthenticateUser()
{
return(pam_authenticate(pam_handle, 0) == PAM_SUCCESS);
}
string findValidRandomTheme(const string& set)
{
// extract random theme from theme set; return empty string on error
string name = set;
struct stat buf;
if (name[name.length() - 1] == ',') {
name.erase(name.length() - 1);
}
Util::srandom(Util::makeseed());
vector<string> themes;
string themefile;
Cfg::split(themes, name, ',');
do {
int sel = Util::random() % themes.size();
name = Cfg::Trim(themes[sel]);
themefile = string(THEMESDIR) +"/" + name + THEMESFILE;
if (stat(themefile.c_str(), &buf) != 0) {
themes.erase(find(themes.begin(), themes.end(), name));
cerr << APPNAME << ": Invalid theme in config: "
<< name << endl;
name = "";
}
} while (name == "" && themes.size());
return name;
}
void HandleSignal(int sig)
{
// Get DPMS stuff back to normal
if (using_dpms) {
DPMSSetTimeouts(dpy, dpms_standby, dpms_suspend, dpms_off);
// turn off DPMS if it was off when we entered
if (!dpms_state)
DPMSDisable(dpy);
}
if ((ioctl(term, VT_UNLOCKSWITCH)) == -1) {
perror("error unlocking console");
}
close(term);
loginPanel->ClosePanel();
delete loginPanel;
die(APPNAME": Caught signal; dying\n");
}
void* RaiseWindow(void *data) {
while(1) {
XRaiseWindow(dpy, win);
sleep(1);
}
return (void *)0;
}
| 9,226
|
C++
|
.cpp
| 308
| 27.405844
| 86
| 0.695461
|
iwamatsu/slim
| 124
| 35
| 16
|
GPL-2.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| true
| true
| false
|
750,986
|
image.cpp
|
iwamatsu_slim/image.cpp
|
/* SLiM - Simple Login Manager
Copyright (C) 2004-06 Simone Rota <sip@varlock.com>
Copyright (C) 2004-06 Johannes Winkelmann <jw@tks6.net>
Copyright (C) 2012 Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
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.
The following code has been adapted and extended from
xplanet 1.0.1, Copyright (C) 2002-04 Hari Nair <hari@alumni.caltech.edu>
*/
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
using namespace std;
#include "image.h"
extern "C" {
#include <jpeglib.h>
#include <png.h>
}
Image::Image() : width(0), height(0), area(0),
rgb_data(NULL), png_alpha(NULL), quality_(80) {}
Image::Image(const int w, const int h, const unsigned char *rgb, const unsigned char *alpha) :
width(w), height(h), area(w*h), quality_(80) {
width = w;
height = h;
area = w * h;
rgb_data = (unsigned char *) malloc(3 * area);
memcpy(rgb_data, rgb, 3 * area);
if (alpha == NULL) {
png_alpha = NULL;
} else {
png_alpha = (unsigned char *) malloc(area);
memcpy(png_alpha, alpha, area);
}
}
Image::~Image() {
free(rgb_data);
free(png_alpha);
}
bool
Image::Read(const char *filename) {
char buf[4];
unsigned char *ubuf = (unsigned char *) buf;
int success = 0;
FILE *file;
file = fopen(filename, "rb");
if (file == NULL)
return(false);
/* see what kind of file we have */
fread(buf, 1, 4, file);
fclose(file);
if ((ubuf[0] == 0x89) && !strncmp("PNG", buf+1, 3))
success = readPng(filename, &width, &height, &rgb_data, &png_alpha);
else if ((ubuf[0] == 0xff) && (ubuf[1] == 0xd8))
success = readJpeg(filename, &width, &height, &rgb_data);
else {
fprintf(stderr, "Unknown image format\n");
success = 0;
}
return(success == 1);
}
void
Image::Reduce(const int factor) {
if (factor < 1)
return;
int scale = 1;
for (int i = 0; i < factor; i++)
scale *= 2;
double scale2 = scale*scale;
int w = width / scale;
int h = height / scale;
int new_area = w * h;
unsigned char *new_rgb = (unsigned char *) malloc(3 * new_area);
memset(new_rgb, 0, 3 * new_area);
unsigned char *new_alpha = NULL;
if (png_alpha != NULL) {
new_alpha = (unsigned char *) malloc(new_area);
memset(new_alpha, 0, new_area);
}
int ipos = 0;
for (int j = 0; j < height; j++) {
int js = j / scale;
for (int i = 0; i < width; i++) {
int is = i/scale;
for (int k = 0; k < 3; k++)
new_rgb[3*(js * w + is) + k] += static_cast<unsigned char> ((rgb_data[3*ipos + k] + 0.5) / scale2);
if (png_alpha != NULL)
new_alpha[js * w + is] += static_cast<unsigned char> (png_alpha[ipos]/scale2);
ipos++;
}
}
free(rgb_data);
free(png_alpha);
rgb_data = new_rgb;
png_alpha = new_alpha;
width = w;
height = h;
area = w * h;
}
void
Image::Resize(const int w, const int h) {
if (width==w && height==h){
return;
}
int new_area = w * h;
unsigned char *new_rgb = (unsigned char *) malloc(3 * new_area);
unsigned char *new_alpha = NULL;
if (png_alpha != NULL)
new_alpha = (unsigned char *) malloc(new_area);
const double scale_x = ((double) w) / width;
const double scale_y = ((double) h) / height;
int ipos = 0;
for (int j = 0; j < h; j++) {
const double y = j / scale_y;
for (int i = 0; i < w; i++) {
const double x = i / scale_x;
if (new_alpha == NULL)
getPixel(x, y, new_rgb + 3*ipos);
else
getPixel(x, y, new_rgb + 3*ipos, new_alpha + ipos);
ipos++;
}
}
free(rgb_data);
free(png_alpha);
rgb_data = new_rgb;
png_alpha = new_alpha;
width = w;
height = h;
area = w * h;
}
/* Find the color of the desired point using bilinear interpolation. */
/* Assume the array indices refer to the denter of the pixel, so each */
/* pixel has corners at (i - 0.5, j - 0.5) and (i + 0.5, j + 0.5) */
void
Image::getPixel(double x, double y, unsigned char *pixel) {
getPixel(x, y, pixel, NULL);
}
void
Image::getPixel(double x, double y, unsigned char *pixel, unsigned char *alpha) {
if (x < -0.5)
x = -0.5;
if (x >= width - 0.5)
x = width - 0.5;
if (y < -0.5)
y = -0.5;
if (y >= height - 0.5)
y = height - 0.5;
int ix0 = (int) (floor(x));
int ix1 = ix0 + 1;
if (ix0 < 0)
ix0 = width - 1;
if (ix1 >= width)
ix1 = 0;
int iy0 = (int) (floor(y));
int iy1 = iy0 + 1;
if (iy0 < 0)
iy0 = 0;
if (iy1 >= height)
iy1 = height - 1;
const double t = x - floor(x);
const double u = 1 - (y - floor(y));
double weight[4];
weight[1] = t * u;
weight[0] = u - weight[1];
weight[2] = 1 - t - u + weight[1];
weight[3] = t - weight[1];
unsigned char *pixels[4];
pixels[0] = rgb_data + 3 * (iy0 * width + ix0);
pixels[1] = rgb_data + 3 * (iy0 * width + ix1);
pixels[2] = rgb_data + 3 * (iy1 * width + ix0);
pixels[3] = rgb_data + 3 * (iy1 * width + ix1);
memset(pixel, 0, 3);
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 3; j++)
pixel[j] += (unsigned char) (weight[i] * pixels[i][j]);
}
if (alpha != NULL) {
unsigned char pixels[4];
pixels[0] = png_alpha[iy0 * width + ix0];
pixels[1] = png_alpha[iy0 * width + ix1];
pixels[2] = png_alpha[iy0 * width + ix0];
pixels[3] = png_alpha[iy1 * width + ix1];
for (int i = 0; i < 4; i++)
*alpha = (unsigned char) (weight[i] * pixels[i]);
}
}
/* Merge the image with a background, taking care of the
* image Alpha transparency. (background alpha is ignored).
* The images is merged on position (x, y) on the
* background, the background must contain the image.
*/
void Image::Merge(Image* background, const int x, const int y) {
if (x + width > background->Width()|| y + height > background->Height())
return;
if (background->Width()*background->Height() != width*height)
background->Crop(x, y, width, height);
double tmp;
unsigned char *new_rgb = (unsigned char *) malloc(3 * width * height);
memset(new_rgb, 0, 3 * width * height);
const unsigned char *bg_rgb = background->getRGBData();
int ipos = 0;
if (png_alpha != NULL){
for (int j = 0; j < height; j++) {
for (int i = 0; i < width; i++) {
for (int k = 0; k < 3; k++) {
tmp = rgb_data[3*ipos + k]*png_alpha[ipos]/255.0
+ bg_rgb[3*ipos + k]*(1-png_alpha[ipos]/255.0);
new_rgb[3*ipos + k] = static_cast<unsigned char> (tmp);
}
ipos++;
}
}
} else {
for (int j = 0; j < height; j++) {
for (int i = 0; i < width; i++) {
for (int k = 0; k < 3; k++) {
tmp = rgb_data[3*ipos + k];
new_rgb[3*ipos + k] = static_cast<unsigned char> (tmp);
}
ipos++;
}
}
}
free(rgb_data);
free(png_alpha);
rgb_data = new_rgb;
png_alpha = NULL;
}
/* Merge the image with a background, taking care of the
* image Alpha transparency. (background alpha is ignored).
* The images is merged on position (x, y) on the
* background, the background must contain the image.
*/
#define IMG_POS_RGB(p, x) (3 * p + x)
void Image::Merge_non_crop(Image* background, const int x, const int y)
{
int bg_w = background->Width();
int bg_h = background->Height();
if (x + width > bg_w || y + height > bg_h)
return;
double tmp;
unsigned char *new_rgb = (unsigned char *)malloc(3 * bg_w * bg_h);
const unsigned char *bg_rgb = background->getRGBData();
int pnl_pos = 0;
int bg_pos = 0;
int pnl_w_end = x + width;
int pnl_h_end = y + height;
memcpy(new_rgb, bg_rgb, 3 * bg_w * bg_h);
for (int j = 0; j < bg_h; j++) {
for (int i = 0; i < bg_w; i++) {
if (j >= y && i >= x && j < pnl_h_end && i < pnl_w_end ) {
for (int k = 0; k < 3; k++) {
if (png_alpha != NULL)
tmp = rgb_data[IMG_POS_RGB(pnl_pos, k)]
* png_alpha[pnl_pos]/255.0
+ bg_rgb[IMG_POS_RGB(bg_pos, k)]
* (1 - png_alpha[pnl_pos]/255.0);
else
tmp = rgb_data[IMG_POS_RGB(pnl_pos, k)];
new_rgb[IMG_POS_RGB(bg_pos, k)] = static_cast<unsigned char>(tmp);
}
pnl_pos++;
}
bg_pos++;
}
}
width = bg_w;
height = bg_h;
free(rgb_data);
free(png_alpha);
rgb_data = new_rgb;
png_alpha = NULL;
}
/* Tile the image growing its size to the minimum entire
* multiple of w * h.
* The new dimensions should be > of the current ones.
* Note that this flattens image (alpha removed)
*/
void Image::Tile(const int w, const int h) {
if (w < width || h < height)
return;
int nx = w / width;
if (w % width > 0)
nx++;
int ny = h / height;
if (h % height > 0)
ny++;
int newwidth = nx*width;
int newheight=ny*height;
unsigned char *new_rgb = (unsigned char *) malloc(3 * newwidth * newheight);
memset(new_rgb, 0, 3 * width * height * nx * ny);
int ipos = 0;
int opos = 0;
for (int r = 0; r < ny; r++) {
for (int c = 0; c < nx; c++) {
for (int j = 0; j < height; j++) {
for (int i = 0; i < width; i++) {
opos = j*width + i;
ipos = r*width*height*nx + j*newwidth + c*width +i;
for (int k = 0; k < 3; k++) {
new_rgb[3*ipos + k] = static_cast<unsigned char> (rgb_data[3*opos + k]);
}
}
}
}
}
free(rgb_data);
free(png_alpha);
rgb_data = new_rgb;
png_alpha = NULL;
width = newwidth;
height = newheight;
area = width * height;
Crop(0,0,w,h);
}
/* Crop the image
*/
void Image::Crop(const int x, const int y, const int w, const int h) {
if (x+w > width || y+h > height) {
return;
}
int x2 = x + w;
int y2 = y + h;
unsigned char *new_rgb = (unsigned char *) malloc(3 * w * h);
memset(new_rgb, 0, 3 * w * h);
unsigned char *new_alpha = NULL;
if (png_alpha != NULL) {
new_alpha = (unsigned char *) malloc(w * h);
memset(new_alpha, 0, w * h);
}
int ipos = 0;
int opos = 0;
for (int j = 0; j < height; j++) {
for (int i = 0; i < width; i++) {
if (j>=y && i>=x && j<y2 && i<x2) {
for (int k = 0; k < 3; k++) {
new_rgb[3*ipos + k] = static_cast<unsigned char> (rgb_data[3*opos + k]);
}
if (png_alpha != NULL)
new_alpha[ipos] = static_cast<unsigned char> (png_alpha[opos]);
ipos++;
}
opos++;
}
}
free(rgb_data);
free(png_alpha);
rgb_data = new_rgb;
if (png_alpha != NULL)
png_alpha = new_alpha;
width = w;
height = h;
area = w * h;
}
/* Center the image in a rectangle of given width and height.
* Fills the remaining space (if any) with the hex color
*/
void Image::Center(const int w, const int h, const char *hex) {
unsigned long packed_rgb;
sscanf(hex, "%lx", &packed_rgb);
unsigned long r = packed_rgb>>16;
unsigned long g = packed_rgb>>8 & 0xff;
unsigned long b = packed_rgb & 0xff;
unsigned char *new_rgb = (unsigned char *) malloc(3 * w * h);
memset(new_rgb, 0, 3 * w * h);
int x = (w - width) / 2;
int y = (h - height) / 2;
if (x<0) {
Crop((width - w)/2,0,w,height);
x = 0;
}
if (y<0) {
Crop(0,(height - h)/2,width,h);
y = 0;
}
int x2 = x + width;
int y2 = y + height;
int ipos = 0;
int opos = 0;
double tmp;
area = w * h;
for (int i = 0; i < area; i++) {
new_rgb[3*i] = r;
new_rgb[3*i+1] = g;
new_rgb[3*i+2] = b;
}
if (png_alpha != NULL) {
for (int j = 0; j < h; j++) {
for (int i = 0; i < w; i++) {
if (j>=y && i>=x && j<y2 && i<x2) {
ipos = j*w + i;
for (int k = 0; k < 3; k++) {
tmp = rgb_data[3*opos + k]*png_alpha[opos]/255.0
+ new_rgb[k]*(1-png_alpha[opos]/255.0);
new_rgb[3*ipos + k] = static_cast<unsigned char> (tmp);
}
opos++;
}
}
}
} else {
for (int j = 0; j < h; j++) {
for (int i = 0; i < w; i++) {
if (j>=y && i>=x && j<y2 && i<x2) {
ipos = j*w + i;
for (int k = 0; k < 3; k++) {
tmp = rgb_data[3*opos + k];
new_rgb[3*ipos + k] = static_cast<unsigned char> (tmp);
}
opos++;
}
}
}
}
free(rgb_data);
free(png_alpha);
rgb_data = new_rgb;
png_alpha = NULL;
width = w;
height = h;
}
/* Fill the image with the given color and adjust its dimensions
* to passed values.
*/
void Image::Plain(const int w, const int h, const char *hex) {
unsigned long packed_rgb;
sscanf(hex, "%lx", &packed_rgb);
unsigned long r = packed_rgb>>16;
unsigned long g = packed_rgb>>8 & 0xff;
unsigned long b = packed_rgb & 0xff;
unsigned char *new_rgb = (unsigned char *) malloc(3 * w * h);
memset(new_rgb, 0, 3 * w * h);
area = w * h;
for (int i = 0; i < area; i++) {
new_rgb[3*i] = r;
new_rgb[3*i+1] = g;
new_rgb[3*i+2] = b;
}
free(rgb_data);
free(png_alpha);
rgb_data = new_rgb;
png_alpha = NULL;
width = w;
height = h;
}
void
Image::computeShift(unsigned long mask,
unsigned char &left_shift,
unsigned char &right_shift) {
left_shift = 0;
right_shift = 8;
if (mask != 0) {
while ((mask & 0x01) == 0) {
left_shift++;
mask >>= 1;
}
while ((mask & 0x01) == 1) {
right_shift--;
mask >>= 1;
}
}
}
Pixmap
Image::createPixmap(Display* dpy, int scr, Window win) {
int i, j; /* loop variables */
const int depth = DefaultDepth(dpy, scr);
Visual *visual = DefaultVisual(dpy, scr);
Colormap colormap = DefaultColormap(dpy, scr);
Pixmap tmp = XCreatePixmap(dpy, win, width, height,
depth);
char *pixmap_data = NULL;
switch (depth) {
case 32:
case 24:
pixmap_data = new char[4 * width * height];
break;
case 16:
case 15:
pixmap_data = new char[2 * width * height];
break;
case 8:
pixmap_data = new char[width * height];
break;
default:
break;
}
XImage *ximage = XCreateImage(dpy, visual, depth, ZPixmap, 0,
pixmap_data, width, height,
8, 0);
int entries;
XVisualInfo v_template;
v_template.visualid = XVisualIDFromVisual(visual);
XVisualInfo *visual_info = XGetVisualInfo(dpy, VisualIDMask,
&v_template, &entries);
unsigned long ipos = 0;
switch (visual_info->c_class) {
case PseudoColor: {
XColor xc;
xc.flags = DoRed | DoGreen | DoBlue;
int num_colors = 256;
XColor *colors = new XColor[num_colors];
for (i = 0; i < num_colors; i++)
colors[i].pixel = (unsigned long) i;
XQueryColors(dpy, colormap, colors, num_colors);
int *closest_color = new int[num_colors];
for (i = 0; i < num_colors; i++) {
xc.red = (i & 0xe0) << 8; /* highest 3 bits */
xc.green = (i & 0x1c) << 11; /* middle 3 bits */
xc.blue = (i & 0x03) << 14; /* lowest 2 bits */
/* find the closest color in the colormap */
double distance, distance_squared, min_distance = 0;
for (int ii = 0; ii < num_colors; ii++) {
distance = colors[ii].red - xc.red;
distance_squared = distance * distance;
distance = colors[ii].green - xc.green;
distance_squared += distance * distance;
distance = colors[ii].blue - xc.blue;
distance_squared += distance * distance;
if ((ii == 0) || (distance_squared <= min_distance)) {
min_distance = distance_squared;
closest_color[i] = ii;
}
}
}
for (j = 0; j < height; j++) {
for (i = 0; i < width; i++) {
xc.red = (unsigned short) (rgb_data[ipos++] & 0xe0);
xc.green = (unsigned short) (rgb_data[ipos++] & 0xe0);
xc.blue = (unsigned short) (rgb_data[ipos++] & 0xc0);
xc.pixel = xc.red | (xc.green >> 3) | (xc.blue >> 6);
XPutPixel(ximage, i, j,
colors[closest_color[xc.pixel]].pixel);
}
}
delete [] colors;
delete [] closest_color;
}
break;
case TrueColor: {
unsigned char red_left_shift;
unsigned char red_right_shift;
unsigned char green_left_shift;
unsigned char green_right_shift;
unsigned char blue_left_shift;
unsigned char blue_right_shift;
computeShift(visual_info->red_mask, red_left_shift,
red_right_shift);
computeShift(visual_info->green_mask, green_left_shift,
green_right_shift);
computeShift(visual_info->blue_mask, blue_left_shift,
blue_right_shift);
unsigned long pixel;
unsigned long red, green, blue;
for (j = 0; j < height; j++) {
for (i = 0; i < width; i++) {
red = (unsigned long)
rgb_data[ipos++] >> red_right_shift;
green = (unsigned long)
rgb_data[ipos++] >> green_right_shift;
blue = (unsigned long)
rgb_data[ipos++] >> blue_right_shift;
pixel = (((red << red_left_shift) & visual_info->red_mask)
| ((green << green_left_shift)
& visual_info->green_mask)
| ((blue << blue_left_shift)
& visual_info->blue_mask));
XPutPixel(ximage, i, j, pixel);
}
}
}
break;
default: {
logStream << "Login.app: could not load image" << endl;
return(tmp);
}
}
GC gc = XCreateGC(dpy, win, 0, NULL);
XPutImage(dpy, tmp, gc, ximage, 0, 0, 0, 0, width, height);
XFreeGC(dpy, gc);
XFree(visual_info);
delete [] pixmap_data;
/* Set ximage data to NULL since pixmap data was deallocated above */
ximage->data = NULL;
XDestroyImage(ximage);
return(tmp);
}
int
Image::readJpeg(const char *filename, int *width, int *height,
unsigned char **rgb)
{
int ret = 0;
struct jpeg_decompress_struct cinfo;
struct jpeg_error_mgr jerr;
unsigned char *ptr = NULL;
FILE *infile = fopen(filename, "rb");
if (infile == NULL) {
logStream << APPNAME << "Cannot fopen file: " << filename << endl;
return ret;
}
cinfo.err = jpeg_std_error(&jerr);
jpeg_create_decompress(&cinfo);
jpeg_stdio_src(&cinfo, infile);
jpeg_read_header(&cinfo, TRUE);
jpeg_start_decompress(&cinfo);
/* Prevent against integer overflow */
if(cinfo.output_width >= MAX_DIMENSION
|| cinfo.output_height >= MAX_DIMENSION)
{
logStream << APPNAME << "Unreasonable dimension found in file: "
<< filename << endl;
goto close_file;
}
*width = cinfo.output_width;
*height = cinfo.output_height;
rgb[0] = (unsigned char*)
malloc(3 * cinfo.output_width * cinfo.output_height);
if (rgb[0] == NULL) {
logStream << APPNAME << ": Can't allocate memory for JPEG file."
<< endl;
goto close_file;
}
if (cinfo.output_components == 3) {
ptr = rgb[0];
while (cinfo.output_scanline < cinfo.output_height) {
jpeg_read_scanlines(&cinfo, &ptr, 1);
ptr += 3 * cinfo.output_width;
}
} else if (cinfo.output_components == 1) {
ptr = (unsigned char*) malloc(cinfo.output_width);
if (ptr == NULL) {
logStream << APPNAME << ": Can't allocate memory for JPEG file."
<< endl;
goto rgb_free;
}
unsigned int ipos = 0;
while (cinfo.output_scanline < cinfo.output_height) {
jpeg_read_scanlines(&cinfo, &ptr, 1);
for (unsigned int i = 0; i < cinfo.output_width; i++) {
memset(rgb[0] + ipos, ptr[i], 3);
ipos += 3;
}
}
free(ptr);
}
jpeg_finish_decompress(&cinfo);
ret = 1;
goto close_file;
rgb_free:
free(rgb[0]);
close_file:
jpeg_destroy_decompress(&cinfo);
fclose(infile);
return(ret);
}
int
Image::readPng(const char *filename, int *width, int *height,
unsigned char **rgb, unsigned char **alpha)
{
int ret = 0;
png_structp png_ptr;
png_infop info_ptr;
png_bytepp row_pointers;
unsigned char *ptr = NULL;
png_uint_32 w, h;
int bit_depth, color_type, interlace_type;
int i;
FILE *infile = fopen(filename, "rb");
if (infile == NULL) {
logStream << APPNAME << "Can not fopen file: " << filename << endl;
return ret;
}
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
(png_voidp) NULL,
(png_error_ptr) NULL,
(png_error_ptr) NULL);
if (!png_ptr) {
goto file_close;
}
info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr) {
png_destroy_read_struct(&png_ptr, (png_infopp) NULL,
(png_infopp) NULL);
}
#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
if (setjmp(png_jmpbuf((png_ptr)))) {
#else
if (setjmp(png_ptr->jmpbuf)) {
#endif
goto png_destroy;
}
png_init_io(png_ptr, infile);
png_read_info(png_ptr, info_ptr);
png_get_IHDR(png_ptr, info_ptr, &w, &h, &bit_depth, &color_type,
&interlace_type, (int *) NULL, (int *) NULL);
/* Prevent against integer overflow */
if(w >= MAX_DIMENSION || h >= MAX_DIMENSION) {
logStream << APPNAME << "Unreasonable dimension found in file: "
<< filename << endl;
goto png_destroy;
}
*width = (int) w;
*height = (int) h;
if (color_type == PNG_COLOR_TYPE_RGB_ALPHA
|| color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
{
alpha[0] = (unsigned char *) malloc(*width * *height);
if (alpha[0] == NULL) {
logStream << APPNAME
<< ": Can't allocate memory for alpha channel in PNG file."
<< endl;
goto png_destroy;
}
}
/* Change a paletted/grayscale image to RGB */
if (color_type == PNG_COLOR_TYPE_PALETTE && bit_depth <= 8)
{
png_set_expand(png_ptr);
}
/* Change a grayscale image to RGB */
if (color_type == PNG_COLOR_TYPE_GRAY
|| color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
{
png_set_gray_to_rgb(png_ptr);
}
/* If the PNG file has 16 bits per channel, strip them down to 8 */
if (bit_depth == 16) {
png_set_strip_16(png_ptr);
}
/* use 1 byte per pixel */
png_set_packing(png_ptr);
row_pointers = (png_byte **) malloc(*height * sizeof(png_bytep));
if (row_pointers == NULL) {
logStream << APPNAME << ": Can't allocate memory for PNG file." << endl;
goto png_destroy;
}
for (i = 0; i < *height; i++) {
row_pointers[i] = (png_byte*) malloc(4 * *width);
if (row_pointers == NULL) {
logStream << APPNAME << ": Can't allocate memory for PNG file."
<< endl;
goto rows_free;
}
}
png_read_image(png_ptr, row_pointers);
rgb[0] = (unsigned char *) malloc(3 * (*width) * (*height));
if (rgb[0] == NULL) {
logStream << APPNAME << ": Can't allocate memory for PNG file." << endl;
goto rows_free;
}
if (alpha[0] == NULL) {
ptr = rgb[0];
for (i = 0; i < *height; i++) {
memcpy(ptr, row_pointers[i], 3 * (*width));
ptr += 3 * (*width);
}
} else {
ptr = rgb[0];
for (i = 0; i < *height; i++) {
unsigned int ipos = 0;
for (int j = 0; j < *width; j++) {
*ptr++ = row_pointers[i][ipos++];
*ptr++ = row_pointers[i][ipos++];
*ptr++ = row_pointers[i][ipos++];
alpha[0][i * (*width) + j] = row_pointers[i][ipos++];
}
}
}
ret = 1; /* data reading is OK */
rows_free:
for (i = 0; i < *height; i++) {
if (row_pointers[i] != NULL ) {
free(row_pointers[i]);
}
}
free(row_pointers);
png_destroy:
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp) NULL);
file_close:
fclose(infile);
return(ret);
}
| 22,268
|
C++
|
.cpp
| 786
| 25.12341
| 103
| 0.610592
|
iwamatsu/slim
| 124
| 35
| 16
|
GPL-2.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
750,987
|
Ck.cpp
|
iwamatsu_slim/Ck.cpp
|
/* SLiM - Simple Login Manager
* Copyright (C) 2011 David Hauweele
*
* 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.
*/
#include <cstdio>
#include <iostream>
#include <ck-connector.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <stdarg.h>
#include "Ck.h"
namespace Ck {
Exception::Exception(const std::string &func,
const std::string &errstr):
func(func),
errstr(errstr)
{}
dbus_bool_t
Session::ck_connector_open_graphic_session(
const std::string &display,
uid_t uid)
{
dbus_bool_t local = true;
const char *session_type = "x11";
const char *x11_display = display.c_str();
const char *x11_device = get_x11_device(display);
const char *remote_host = "";
const char *display_dev = "";
return ck_connector_open_session_with_parameters(ckc, &error,
"unix-user", &uid,
"session-type", &session_type,
"x11-display", &x11_display,
"x11-display-device", &x11_device,
"display-device", &display_dev,
"remote-host-name", &remote_host,
"is-local", &local,
NULL);
}
const char * Session::get_x11_device(const std::string &display)
{
static char device[32];
Display *xdisplay = XOpenDisplay(display.c_str());
if(!xdisplay)
throw Exception(__func__, "cannot open display");
Window root;
Atom xfree86_vt_atom;
Atom return_type_atom;
int return_format;
unsigned long return_count;
unsigned long bytes_left;
unsigned char *return_value;
long vt;
xfree86_vt_atom = XInternAtom(xdisplay, "XFree86_VT", true);
if(xfree86_vt_atom == None)
throw Exception(__func__, "cannot get XFree86_VT");
root = DefaultRootWindow(xdisplay);
if(XGetWindowProperty(xdisplay, root, xfree86_vt_atom,
0L, 1L, false, XA_INTEGER,
&return_type_atom, &return_format,
&return_count, &bytes_left,
&return_value) != Success)
throw Exception(__func__, "cannot get root window property");
if(return_type_atom != XA_INTEGER)
throw Exception(__func__, "bad atom type");
if(return_format != 32)
throw Exception(__func__, "invalid return format");
if(return_count != 1)
throw Exception(__func__, "invalid count");
if(bytes_left != 0)
throw Exception(__func__, "invalid bytes left");
vt = *((long *)return_value);
std::snprintf(device, 32, "/dev/tty%ld", vt);
if(return_value)
XFree(return_value);
return device;
}
void Session::open_session(const std::string &display, uid_t uid)
{
ckc = ck_connector_new();
if(!ckc)
throw Exception(__func__, "error setting up connection to ConsoleKit");
if (!ck_connector_open_graphic_session(display, uid)) {
if(dbus_error_is_set(&error))
throw Exception(__func__, error.message);
else
throw Exception(__func__, "cannot open ConsoleKit session: OOM,"
" DBus system bus not available or insufficient"
" privileges");
}
}
const char * Session::get_xdg_session_cookie()
{
return ck_connector_get_cookie(ckc);
}
void Session::close_session()
{
if(!ck_connector_close_session(ckc, &error)) {
if(dbus_error_is_set(&error))
throw Exception(__func__, error.message);
else
throw Exception(__func__, "cannot close ConsoleKit session: OOM,"
" DBus system bus not available or insufficient"
" privileges");
}
}
Session::Session()
{
dbus_error_init(&error);
}
Session::~Session()
{
dbus_error_free(&error);
}
}
std::ostream& operator<<( std::ostream& os, const Ck::Exception& e)
{
os << e.func << ": " << e.errstr;
return os;
}
| 3,703
|
C++
|
.cpp
| 123
| 26.715447
| 74
| 0.685352
|
iwamatsu/slim
| 124
| 35
| 16
|
GPL-2.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
750,988
|
PAM.cpp
|
iwamatsu_slim/PAM.cpp
|
/* SLiM - Simple Login Manager
* Copyright (C) 2007 Martin Parm
*
* 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.
*/
#include <string>
#include <iostream>
#include "PAM.h"
namespace PAM {
Exception::Exception(pam_handle_t* _pam_handle,
const std::string& _func_name,
int _errnum):
errnum(_errnum),
errstr(pam_strerror(_pam_handle, _errnum)),
func_name(_func_name)
{}
Exception::~Exception(void) {}
Auth_Exception::Auth_Exception(pam_handle_t* _pam_handle,
const std::string& _func_name,
int _errnum):
Exception(_pam_handle, _func_name, _errnum) {}
Cred_Exception::Cred_Exception(pam_handle_t* _pam_handle,
const std::string& _func_name,
int _errnum):
Exception(_pam_handle, _func_name, _errnum) {}
int Authenticator::_end (void)
{
int result=pam_end(pam_handle, last_result);
pam_handle=0;
return result;
}
Authenticator::Authenticator(conversation* conv, void* data):
pam_handle(0),
last_result(PAM_SUCCESS)
{
pam_conversation.conv=conv;
pam_conversation.appdata_ptr=data;
}
Authenticator::~Authenticator(void)
{
if (pam_handle)
_end();
}
void Authenticator::start(const std::string& service)
{
switch ((last_result=pam_start(service.c_str(), NULL, &pam_conversation, &pam_handle))) {
default:
throw Exception(pam_handle, "pam_start()", last_result);
case PAM_SUCCESS:
break;
}
return;
}
void Authenticator::end(void)
{
switch ((last_result=_end())) {
default:
throw Exception(pam_handle, "pam_end()", last_result);
case PAM_SUCCESS:
break;
}
return;
}
void Authenticator::set_item(const Authenticator::ItemType item, const void* value)
{
switch ((last_result=pam_set_item(pam_handle, item, value))) {
default:
_end();
throw Exception(pam_handle, "pam_set_item()", last_result);
case PAM_SUCCESS:
break;
}
return;
}
const void* Authenticator::get_item(const Authenticator::ItemType item)
{
const void* data;
switch ((last_result=pam_get_item(pam_handle, item, &data))) {
default:
case PAM_SYSTEM_ERR:
#ifdef __LIBPAM_VERSION
case PAM_BAD_ITEM:
#endif
_end();
throw Exception(pam_handle, "pam_get_item()", last_result);
case PAM_PERM_DENIED: /* The value of item was NULL */
case PAM_SUCCESS:
break;
}
return data;
}
#ifdef __LIBPAM_VERSION
void Authenticator::fail_delay(const unsigned int micro_sec)
{
switch ((last_result=pam_fail_delay(pam_handle, micro_sec))) {
default:
_end();
throw Exception(pam_handle, "fail_delay()", last_result);
case PAM_SUCCESS:
break;
}
return;
}
#endif
void Authenticator::authenticate(void)
{
switch ((last_result=pam_authenticate(pam_handle, 0))) {
default:
case PAM_ABORT:
case PAM_AUTHINFO_UNAVAIL:
_end();
throw Exception(pam_handle, "pam_authenticate()", last_result);
case PAM_USER_UNKNOWN:
case PAM_MAXTRIES:
case PAM_CRED_INSUFFICIENT:
case PAM_AUTH_ERR:
throw Auth_Exception(pam_handle, "pam_authentication()", last_result);
case PAM_SUCCESS:
break;
}
switch ((last_result=pam_acct_mgmt(pam_handle, PAM_SILENT))) {
/* The documentation and implementation of Linux PAM differs:
PAM_NEW_AUTHTOKEN_REQD is described in the documentation but
don't exists in the actual implementation. This issue needs
to be fixes at some point. */
default:
/* case PAM_NEW_AUTHTOKEN_REQD: */
case PAM_ACCT_EXPIRED:
case PAM_USER_UNKNOWN:
_end();
throw Exception(pam_handle, "pam_acct_mgmt()", last_result);
case PAM_AUTH_ERR:
case PAM_PERM_DENIED:
throw Auth_Exception(pam_handle, "pam_acct_mgmt()", last_result);
case PAM_SUCCESS:
break;
}
return;
}
void Authenticator::open_session(void)
{
switch ((last_result=pam_setcred(pam_handle, PAM_ESTABLISH_CRED))) {
default:
case PAM_CRED_ERR:
case PAM_CRED_UNAVAIL:
_end();
throw Exception(pam_handle, "pam_setcred()", last_result);
case PAM_CRED_EXPIRED:
case PAM_USER_UNKNOWN:
throw Cred_Exception(pam_handle, "pam_setcred()", last_result);
case PAM_SUCCESS:
break;
}
switch ((last_result=pam_open_session(pam_handle, 0))) {
/* The documentation and implementation of Linux PAM differs:
PAM_SESSION_ERROR is described in the documentation but
don't exists in the actual implementation. This issue needs
to be fixes at some point. */
default:
/* case PAM_SESSION_ERROR: */
pam_setcred(pam_handle, PAM_DELETE_CRED);
_end();
throw Exception(pam_handle, "pam_open_session()", last_result);
case PAM_SUCCESS:
break;
}
return;
}
void Authenticator::close_session(void)
{
switch ((last_result=pam_close_session(pam_handle, 0))) {
/* The documentation and implementation of Linux PAM differs:
PAM_SESSION_ERROR is described in the documentation but
don't exists in the actual implementation. This issue needs
to be fixes at some point. */
default:
/* case PAM_SESSION_ERROR: */
pam_setcred(pam_handle, PAM_DELETE_CRED);
_end();
throw Exception(pam_handle, "pam_close_session", last_result);
case PAM_SUCCESS:
break;
}
switch ((last_result=pam_setcred(pam_handle, PAM_DELETE_CRED))) {
default:
case PAM_CRED_ERR:
case PAM_CRED_UNAVAIL:
case PAM_CRED_EXPIRED:
case PAM_USER_UNKNOWN:
_end();
throw Exception(pam_handle, "pam_setcred()", last_result);
case PAM_SUCCESS:
break;
}
return;
}
void Authenticator::setenv(const std::string& key, const std::string& value)
{
std::string name_value = key+"="+value;
switch ((last_result = pam_putenv(pam_handle, name_value.c_str()))) {
default:
case PAM_PERM_DENIED:
case PAM_ABORT:
case PAM_BUF_ERR:
#ifdef __LIBPAM_VERSION
case PAM_BAD_ITEM:
#endif
_end();
throw Exception(pam_handle, "pam_putenv()", last_result);
case PAM_SUCCESS:
break;
}
return;
}
void Authenticator::delenv(const std::string& key)
{
switch ((last_result = pam_putenv(pam_handle, key.c_str()))) {
default:
case PAM_PERM_DENIED:
case PAM_ABORT:
case PAM_BUF_ERR:
#ifdef __LIBPAM_VERSION
case PAM_BAD_ITEM:
#endif
_end();
throw Exception(pam_handle, "pam_putenv()", last_result);
case PAM_SUCCESS:
break;
}
return;
}
const char* Authenticator::getenv(const std::string& key)
{
return pam_getenv(pam_handle, key.c_str());
}
char** Authenticator::getenvlist(void)
{
return pam_getenvlist(pam_handle);
}
}
std::ostream& operator<<( std::ostream& os, const PAM::Exception& e)
{
os << e.func_name << ": " << e.errstr;
return os;
}
| 6,844
|
C++
|
.cpp
| 248
| 23.991935
| 91
| 0.68996
|
iwamatsu/slim
| 124
| 35
| 16
|
GPL-2.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
750,989
|
panel.cpp
|
iwamatsu_slim/panel.cpp
|
/* SLiM - Simple Login Manager
Copyright (C) 1997, 1998 Per Liden
Copyright (C) 2004-06 Simone Rota <sip@varlock.com>
Copyright (C) 2004-06 Johannes Winkelmann <jw@tks6.net>
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.
*/
#include <sstream>
#include <poll.h>
#include <X11/extensions/Xrandr.h>
#include "panel.h"
using namespace std;
Panel::Panel(Display* dpy, int scr, Window root, Cfg* config,
const string& themedir, PanelType panel_mode) {
/* Set display */
Dpy = dpy;
Scr = scr;
Root = root;
cfg = config;
mode = panel_mode;
session_name = "";
session_exec = "";
if (mode == Mode_Lock) {
Win = root;
viewport = GetPrimaryViewport();
}
/* Init GC */
XGCValues gcv;
unsigned long gcm;
gcm = GCForeground|GCBackground|GCGraphicsExposures;
gcv.foreground = GetColor("black");
gcv.background = GetColor("white");
gcv.graphics_exposures = False;
if (mode == Mode_Lock)
TextGC = XCreateGC(Dpy, Win, gcm, &gcv);
else
TextGC = XCreateGC(Dpy, Root, gcm, &gcv);
if (mode == Mode_Lock) {
gcm = GCGraphicsExposures;
gcv.graphics_exposures = False;
WinGC = XCreateGC(Dpy, Win, gcm, &gcv);
if (WinGC < 0) {
cerr << APPNAME
<< ": failed to create pixmap\n.";
exit(ERR_EXIT);
}
}
font = XftFontOpenName(Dpy, Scr, cfg->getOption("input_font").c_str());
welcomefont = XftFontOpenName(Dpy, Scr, cfg->getOption("welcome_font").c_str());
introfont = XftFontOpenName(Dpy, Scr, cfg->getOption("intro_font").c_str());
enterfont = XftFontOpenName(Dpy, Scr, cfg->getOption("username_font").c_str());
msgfont = XftFontOpenName(Dpy, Scr, cfg->getOption("msg_font").c_str());
Visual* visual = DefaultVisual(Dpy, Scr);
Colormap colormap = DefaultColormap(Dpy, Scr);
/* NOTE: using XftColorAllocValue() would be a better solution. Lazy me. */
XftColorAllocName(Dpy, visual, colormap, cfg->getOption("input_color").c_str(), &inputcolor);
XftColorAllocName(Dpy, visual, colormap, cfg->getOption("input_shadow_color").c_str(), &inputshadowcolor);
XftColorAllocName(Dpy, visual, colormap, cfg->getOption("welcome_color").c_str(), &welcomecolor);
XftColorAllocName(Dpy, visual, colormap, cfg->getOption("welcome_shadow_color").c_str(), &welcomeshadowcolor);
XftColorAllocName(Dpy, visual, colormap, cfg->getOption("username_color").c_str(), &entercolor);
XftColorAllocName(Dpy, visual, colormap, cfg->getOption("username_shadow_color").c_str(), &entershadowcolor);
XftColorAllocName(Dpy, visual, colormap, cfg->getOption("msg_color").c_str(), &msgcolor);
XftColorAllocName(Dpy, visual, colormap, cfg->getOption("msg_shadow_color").c_str(), &msgshadowcolor);
XftColorAllocName(Dpy, visual, colormap, cfg->getOption("intro_color").c_str(), &introcolor);
XftColorAllocName(Dpy, visual, colormap,
cfg->getOption("session_color").c_str(), &sessioncolor);
XftColorAllocName(Dpy, visual, colormap,
cfg->getOption("session_shadow_color").c_str(), &sessionshadowcolor);
/* Load properties from config / theme */
input_name_x = cfg->getIntOption("input_name_x");
input_name_y = cfg->getIntOption("input_name_y");
input_pass_x = cfg->getIntOption("input_pass_x");
input_pass_y = cfg->getIntOption("input_pass_y");
inputShadowXOffset = cfg->getIntOption("input_shadow_xoffset");
inputShadowYOffset = cfg->getIntOption("input_shadow_yoffset");
if (input_pass_x < 0 || input_pass_y < 0){ /* single inputbox mode */
input_pass_x = input_name_x;
input_pass_y = input_name_y;
}
/* Load panel and background image */
string panelpng = "";
panelpng = panelpng + themedir +"/panel.png";
image = new Image;
bool loaded = image->Read(panelpng.c_str());
if (!loaded) { /* try jpeg if png failed */
panelpng = themedir + "/panel.jpg";
loaded = image->Read(panelpng.c_str());
if (!loaded) {
logStream << APPNAME
<< ": could not load panel image for theme '"
<< basename((char*)themedir.c_str()) << "'"
<< endl;
exit(ERR_EXIT);
}
}
Image* bg = new Image();
string bgstyle = cfg->getOption("background_style");
if (bgstyle != "color") {
panelpng = themedir +"/background.png";
loaded = bg->Read(panelpng.c_str());
if (!loaded) { /* try jpeg if png failed */
panelpng = themedir + "/background.jpg";
loaded = bg->Read(panelpng.c_str());
if (!loaded){
logStream << APPNAME
<< ": could not load background image for theme '"
<< basename((char*)themedir.c_str()) << "'"
<< endl;
exit(ERR_EXIT);
}
}
}
if (mode == Mode_Lock) {
if (bgstyle == "stretch")
bg->Resize(viewport.width, viewport.height);
//bg->Resize(XWidthOfScreen(ScreenOfDisplay(Dpy, Scr)),
// XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)));
else if (bgstyle == "tile")
bg->Tile(viewport.width, viewport.height);
else if (bgstyle == "center") {
string hexvalue = cfg->getOption("background_color");
hexvalue = hexvalue.substr(1,6);
bg->Center(viewport.width,
viewport.height,
hexvalue.c_str());
} else { // plain color or error
string hexvalue = cfg->getOption("background_color");
hexvalue = hexvalue.substr(1,6);
bg->Center(viewport.width,
viewport.height,
hexvalue.c_str());
}
} else {
if (bgstyle == "stretch") {
bg->Resize(XWidthOfScreen(ScreenOfDisplay(Dpy, Scr)),
XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)));
} else if (bgstyle == "tile") {
bg->Tile(XWidthOfScreen(ScreenOfDisplay(Dpy, Scr)),
XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)));
} else if (bgstyle == "center") {
string hexvalue = cfg->getOption("background_color");
hexvalue = hexvalue.substr(1,6);
bg->Center(XWidthOfScreen(ScreenOfDisplay(Dpy, Scr)),
XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)),
hexvalue.c_str());
} else { /* plain color or error */
string hexvalue = cfg->getOption("background_color");
hexvalue = hexvalue.substr(1,6);
bg->Center(XWidthOfScreen(ScreenOfDisplay(Dpy, Scr)),
XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)),
hexvalue.c_str());
}
}
string cfgX = cfg->getOption("input_panel_x");
string cfgY = cfg->getOption("input_panel_y");
if (mode == Mode_Lock) {
X = Cfg::absolutepos(cfgX, viewport.width, image->Width());
Y = Cfg::absolutepos(cfgY, viewport.height, image->Height());
input_name_x += X;
input_name_y += Y;
input_pass_x += X;
input_pass_y += Y;
} else {
X = Cfg::absolutepos(cfgX, XWidthOfScreen(ScreenOfDisplay(Dpy, Scr)), image->Width());
Y = Cfg::absolutepos(cfgY, XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)), image->Height());
}
if (mode == Mode_Lock) {
/* Merge image into background without crop */
image->Merge_non_crop(bg, X, Y);
PanelPixmap = image->createPixmap(Dpy, Scr, Win);
} else {
/* Merge image into background */
image->Merge(bg, X, Y);
PanelPixmap = image->createPixmap(Dpy, Scr, Root);
}
delete bg;
/* Read (and substitute vars in) the welcome message */
welcome_message = cfg->getWelcomeMessage();
intro_message = cfg->getOption("intro_msg");
if (mode == Mode_Lock) {
SetName(getenv("USER"));
field = Get_Passwd;
OnExpose();
}
}
Panel::~Panel() {
Visual* visual = DefaultVisual(Dpy, Scr);
Colormap colormap = DefaultColormap(Dpy, Scr);
XftColorFree(Dpy, visual, colormap, &inputcolor);
XftColorFree(Dpy, visual, colormap, &inputshadowcolor);
XftColorFree(Dpy, visual, colormap, &welcomecolor);
XftColorFree(Dpy, visual, colormap, &welcomeshadowcolor);
XftColorFree(Dpy, visual, colormap, &entercolor);
XftColorFree(Dpy, visual, colormap, &entershadowcolor);
XftColorFree(Dpy, visual, colormap, &msgcolor);
XftColorFree(Dpy, visual, colormap, &msgshadowcolor);
XftColorFree(Dpy, visual, colormap, &introcolor);
XftColorFree(Dpy, visual, colormap, &sessioncolor);
XftColorFree(Dpy, visual, colormap, &sessionshadowcolor);
XFreeGC(Dpy, TextGC);
XftFontClose(Dpy, font);
XftFontClose(Dpy, msgfont);
XftFontClose(Dpy, introfont);
XftFontClose(Dpy, welcomefont);
XftFontClose(Dpy, enterfont);
if (mode == Mode_Lock)
XFreeGC(Dpy, WinGC);
delete image;
}
void Panel::OpenPanel() {
/* Create window */
Win = XCreateSimpleWindow(Dpy, Root, X, Y,
image->Width(),
image->Height(),
0, GetColor("white"), GetColor("white"));
/* Events */
XSelectInput(Dpy, Win, ExposureMask | KeyPressMask);
/* Set background */
XSetWindowBackgroundPixmap(Dpy, Win, PanelPixmap);
/* Show window */
XMapWindow(Dpy, Win);
XMoveWindow(Dpy, Win, X, Y); /* override wm positioning (for tests) */
/* Grab keyboard */
XGrabKeyboard(Dpy, Win, False, GrabModeAsync, GrabModeAsync, CurrentTime);
XFlush(Dpy);
}
void Panel::ClosePanel() {
XUngrabKeyboard(Dpy, CurrentTime);
XUnmapWindow(Dpy, Win);
XDestroyWindow(Dpy, Win);
XFlush(Dpy);
}
void Panel::ClearPanel() {
session_name = "";
session_exec = "";
Reset();
XClearWindow(Dpy, Root);
XClearWindow(Dpy, Win);
Cursor(SHOW);
ShowText();
XFlush(Dpy);
}
void Panel::WrongPassword(int timeout) {
string message;
XGlyphInfo extents;
#if 0
if (CapsLockOn)
message = cfg->getOption("passwd_feedback_capslock");
else
#endif
message = cfg->getOption("passwd_feedback_msg");
XftDraw *draw = XftDrawCreate(Dpy, Win,
DefaultVisual(Dpy, Scr), DefaultColormap(Dpy, Scr));
XftTextExtents8(Dpy, msgfont, reinterpret_cast<const XftChar8*>(message.c_str()),
message.length(), &extents);
string cfgX = cfg->getOption("passwd_feedback_x");
string cfgY = cfg->getOption("passwd_feedback_y");
int shadowXOffset = cfg->getIntOption("msg_shadow_xoffset");
int shadowYOffset = cfg->getIntOption("msg_shadow_yoffset");
int msg_x = Cfg::absolutepos(cfgX, XWidthOfScreen(ScreenOfDisplay(Dpy, Scr)), extents.width);
int msg_y = Cfg::absolutepos(cfgY, XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)), extents.height);
OnExpose();
SlimDrawString8(draw, &msgcolor, msgfont, msg_x, msg_y, message,
&msgshadowcolor, shadowXOffset, shadowYOffset);
if (cfg->getOption("bell") == "1")
XBell(Dpy, 100);
XFlush(Dpy);
sleep(timeout);
ResetPasswd();
OnExpose();
// The message should stay on the screen even after the password field is
// cleared, methinks. I don't like this solution, but it works.
SlimDrawString8(draw, &msgcolor, msgfont, msg_x, msg_y, message,
&msgshadowcolor, shadowXOffset, shadowYOffset);
XSync(Dpy, True);
XftDrawDestroy(draw);
}
void Panel::Message(const string& text) {
string cfgX, cfgY;
XGlyphInfo extents;
XftDraw *draw;
if (mode == Mode_Lock)
draw = XftDrawCreate(Dpy, Win,
DefaultVisual(Dpy, Scr), DefaultColormap(Dpy, Scr));
else
draw = XftDrawCreate(Dpy, Root,
DefaultVisual(Dpy, Scr), DefaultColormap(Dpy, Scr));
XftTextExtents8(Dpy, msgfont,
reinterpret_cast<const XftChar8*>(text.c_str()),
text.length(), &extents);
cfgX = cfg->getOption("msg_x");
cfgY = cfg->getOption("msg_y");
int shadowXOffset = cfg->getIntOption("msg_shadow_xoffset");
int shadowYOffset = cfg->getIntOption("msg_shadow_yoffset");
int msg_x, msg_y;
if (mode == Mode_Lock) {
msg_x = Cfg::absolutepos(cfgX, viewport.width, extents.width);
msg_y = Cfg::absolutepos(cfgY, viewport.height, extents.height);
} else {
msg_x = Cfg::absolutepos(cfgX, XWidthOfScreen(ScreenOfDisplay(Dpy, Scr)), extents.width);
msg_y = Cfg::absolutepos(cfgY, XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)), extents.height);
}
SlimDrawString8 (draw, &msgcolor, msgfont, msg_x, msg_y,
text,
&msgshadowcolor,
shadowXOffset, shadowYOffset);
XFlush(Dpy);
XftDrawDestroy(draw);
}
void Panel::Error(const string& text) {
ClosePanel();
Message(text);
sleep(ERROR_DURATION);
OpenPanel();
ClearPanel();
}
unsigned long Panel::GetColor(const char* colorname) {
XColor color;
XWindowAttributes attributes;
if (mode == Mode_Lock)
XGetWindowAttributes(Dpy, Win, &attributes);
else
XGetWindowAttributes(Dpy, Root, &attributes);
color.pixel = 0;
if(!XParseColor(Dpy, attributes.colormap, colorname, &color))
logStream << APPNAME << ": can't parse color " << colorname << endl;
else if(!XAllocColor(Dpy, attributes.colormap, &color))
logStream << APPNAME << ": can't allocate color " << colorname << endl;
return color.pixel;
}
void Panel::Cursor(int visible) {
const char* text = NULL;
int xx = 0, yy = 0, y2 = 0, cheight = 0;
const char* txth = "Wj"; /* used to get cursor height */
if (mode == Mode_Lock) {
text = HiddenPasswdBuffer.c_str();
xx = input_pass_x;
yy = input_pass_y;
} else {
switch(field) {
case Get_Passwd:
text = HiddenPasswdBuffer.c_str();
xx = input_pass_x;
yy = input_pass_y;
break;
case Get_Name:
text = NameBuffer.c_str();
xx = input_name_x;
yy = input_name_y;
break;
}
}
XGlyphInfo extents;
XftTextExtents8(Dpy, font, (XftChar8*)txth, strlen(txth), &extents);
cheight = extents.height;
y2 = yy - extents.y + extents.height;
XftTextExtents8(Dpy, font, (XftChar8*)text, strlen(text), &extents);
xx += extents.width;
if(visible == SHOW) {
if (mode == Mode_Lock) {
xx += viewport.x;
yy += viewport.y;
y2 += viewport.y;
}
XSetForeground(Dpy, TextGC,
GetColor(cfg->getOption("input_color").c_str()));
XDrawLine(Dpy, Win, TextGC,
xx+1, yy-cheight,
xx+1, y2);
} else {
if (mode == Mode_Lock)
ApplyBackground(Rectangle(xx+1, yy-cheight,
1, y2-(yy-cheight)+1));
else
XClearArea(Dpy, Win, xx+1, yy-cheight,
1, y2-(yy-cheight)+1, false);
}
}
void Panel::EventHandler(const Panel::FieldType& curfield) {
XEvent event;
field = curfield;
bool loop = true;
if (mode == Mode_DM)
OnExpose();
struct pollfd x11_pfd = {0};
x11_pfd.fd = ConnectionNumber(Dpy);
x11_pfd.events = POLLIN;
while (loop) {
if (XPending(Dpy) || poll(&x11_pfd, 1, -1) > 0) {
while(XPending(Dpy)) {
XNextEvent(Dpy, &event);
switch(event.type) {
case Expose:
OnExpose();
break;
case KeyPress:
loop=OnKeyPress(event);
break;
}
}
}
}
return;
}
void Panel::OnExpose(void) {
XftDraw *draw = XftDrawCreate(Dpy, Win,
DefaultVisual(Dpy, Scr), DefaultColormap(Dpy, Scr));
if (mode == Mode_Lock)
ApplyBackground();
else
XClearWindow(Dpy, Win);
if (input_pass_x != input_name_x || input_pass_y != input_name_y){
SlimDrawString8 (draw, &inputcolor, font, input_name_x, input_name_y,
NameBuffer,
&inputshadowcolor,
inputShadowXOffset, inputShadowYOffset);
SlimDrawString8 (draw, &inputcolor, font, input_pass_x, input_pass_y,
HiddenPasswdBuffer,
&inputshadowcolor,
inputShadowXOffset, inputShadowYOffset);
} else { /*single input mode */
switch(field) {
case Get_Passwd:
SlimDrawString8 (draw, &inputcolor, font,
input_pass_x, input_pass_y,
HiddenPasswdBuffer,
&inputshadowcolor,
inputShadowXOffset, inputShadowYOffset);
break;
case Get_Name:
SlimDrawString8 (draw, &inputcolor, font,
input_name_x, input_name_y,
NameBuffer,
&inputshadowcolor,
inputShadowXOffset, inputShadowYOffset);
break;
}
}
XftDrawDestroy (draw);
Cursor(SHOW);
ShowText();
}
void Panel::EraseLastChar(string &formerString) {
switch(field) {
case GET_NAME:
if (! NameBuffer.empty()) {
formerString=NameBuffer;
NameBuffer.erase(--NameBuffer.end());
}
break;
case GET_PASSWD:
if (!PasswdBuffer.empty()) {
formerString=HiddenPasswdBuffer;
PasswdBuffer.erase(--PasswdBuffer.end());
HiddenPasswdBuffer.erase(--HiddenPasswdBuffer.end());
}
break;
}
}
bool Panel::OnKeyPress(XEvent& event) {
char ascii;
KeySym keysym;
XComposeStatus compstatus;
int xx = 0;
int yy = 0;
string text;
string formerString = "";
XLookupString(&event.xkey, &ascii, 1, &keysym, &compstatus);
switch(keysym){
case XK_F1:
SwitchSession();
return true;
case XK_F11:
/* Take a screenshot */
system(cfg->getOption("screenshot_cmd").c_str());
return true;
case XK_Return:
case XK_KP_Enter:
if (field==Get_Name){
/* Don't allow an empty username */
if (NameBuffer.empty()) return true;
if (NameBuffer==CONSOLE_STR){
action = Console;
} else if (NameBuffer==HALT_STR){
action = Halt;
} else if (NameBuffer==REBOOT_STR){
action = Reboot;
} else if (NameBuffer==SUSPEND_STR){
action = Suspend;
} else if (NameBuffer==EXIT_STR){
action = Exit;
} else{
if (mode == Mode_DM)
action = Login;
else
action = Lock;
}
};
return false;
default:
break;
};
Cursor(HIDE);
switch(keysym){
case XK_Delete:
case XK_BackSpace:
EraseLastChar(formerString);
break;
case XK_w:
case XK_u:
if (reinterpret_cast<XKeyEvent&>(event).state & ControlMask) {
switch(field) {
case Get_Passwd:
formerString = HiddenPasswdBuffer;
HiddenPasswdBuffer.clear();
PasswdBuffer.clear();
break;
case Get_Name:
formerString = NameBuffer;
NameBuffer.clear();
break;
}
break;
}
case XK_h:
if (reinterpret_cast<XKeyEvent&>(event).state & ControlMask) {
EraseLastChar(formerString);
break;
}
/* Deliberate fall-through */
default:
if (isprint(ascii) && (keysym < XK_Shift_L || keysym > XK_Hyper_R)){
switch(field) {
case GET_NAME:
formerString=NameBuffer;
if (NameBuffer.length() < INPUT_MAXLENGTH_NAME-1){
NameBuffer.append(&ascii,1);
};
break;
case GET_PASSWD:
formerString=HiddenPasswdBuffer;
if (PasswdBuffer.length() < INPUT_MAXLENGTH_PASSWD-1){
PasswdBuffer.append(&ascii,1);
HiddenPasswdBuffer.append("*");
};
break;
};
}
else {
return true; //nodraw if notchange
};
break;
};
XGlyphInfo extents;
XftDraw *draw = XftDrawCreate(Dpy, Win,
DefaultVisual(Dpy, Scr), DefaultColormap(Dpy, Scr));
switch(field) {
case Get_Name:
text = NameBuffer;
xx = input_name_x;
yy = input_name_y;
break;
case Get_Passwd:
text = HiddenPasswdBuffer;
xx = input_pass_x;
yy = input_pass_y;
break;
}
if (!formerString.empty()){
const char* txth = "Wj"; /* get proper maximum height ? */
XftTextExtents8(Dpy, font,
reinterpret_cast<const XftChar8*>(txth), strlen(txth), &extents);
int maxHeight = extents.height;
XftTextExtents8(Dpy, font,
reinterpret_cast<const XftChar8*>(formerString.c_str()),
formerString.length(), &extents);
int maxLength = extents.width;
if (mode == Mode_Lock)
ApplyBackground(Rectangle(input_pass_x - 3,
input_pass_y - maxHeight - 3,
maxLength + 6, maxHeight + 6));
else
XClearArea(Dpy, Win, xx - 3, yy-maxHeight - 3,
maxLength + 6, maxHeight + 6, false);
}
if (!text.empty()) {
SlimDrawString8 (draw, &inputcolor, font, xx, yy,
text,
&inputshadowcolor,
inputShadowXOffset, inputShadowYOffset);
}
XftDrawDestroy (draw);
Cursor(SHOW);
return true;
}
/* Draw welcome and "enter username" message */
void Panel::ShowText(){
string cfgX, cfgY;
XGlyphInfo extents;
bool singleInputMode =
input_name_x == input_pass_x &&
input_name_y == input_pass_y;
XftDraw *draw = XftDrawCreate(Dpy, Win,
DefaultVisual(Dpy, Scr), DefaultColormap(Dpy, Scr));
/* welcome message */
XftTextExtents8(Dpy, welcomefont, (XftChar8*)welcome_message.c_str(),
strlen(welcome_message.c_str()), &extents);
cfgX = cfg->getOption("welcome_x");
cfgY = cfg->getOption("welcome_y");
int shadowXOffset = cfg->getIntOption("welcome_shadow_xoffset");
int shadowYOffset = cfg->getIntOption("welcome_shadow_yoffset");
welcome_x = Cfg::absolutepos(cfgX, image->Width(), extents.width);
welcome_y = Cfg::absolutepos(cfgY, image->Height(), extents.height);
if (welcome_x >= 0 && welcome_y >= 0) {
SlimDrawString8 (draw, &welcomecolor, welcomefont,
welcome_x, welcome_y,
welcome_message,
&welcomeshadowcolor, shadowXOffset, shadowYOffset);
}
/* Enter username-password message */
string msg;
if ((!singleInputMode|| field == Get_Passwd) && mode == Mode_DM) {
msg = cfg->getOption("password_msg");
XftTextExtents8(Dpy, enterfont, (XftChar8*)msg.c_str(),
strlen(msg.c_str()), &extents);
cfgX = cfg->getOption("password_x");
cfgY = cfg->getOption("password_y");
int shadowXOffset = cfg->getIntOption("username_shadow_xoffset");
int shadowYOffset = cfg->getIntOption("username_shadow_yoffset");
password_x = Cfg::absolutepos(cfgX, image->Width(), extents.width);
password_y = Cfg::absolutepos(cfgY, image->Height(), extents.height);
if (password_x >= 0 && password_y >= 0){
SlimDrawString8 (draw, &entercolor, enterfont, password_x, password_y,
msg, &entershadowcolor, shadowXOffset, shadowYOffset);
}
}
if (!singleInputMode|| field == Get_Name) {
msg = cfg->getOption("username_msg");
XftTextExtents8(Dpy, enterfont, (XftChar8*)msg.c_str(),
strlen(msg.c_str()), &extents);
cfgX = cfg->getOption("username_x");
cfgY = cfg->getOption("username_y");
int shadowXOffset = cfg->getIntOption("username_shadow_xoffset");
int shadowYOffset = cfg->getIntOption("username_shadow_yoffset");
username_x = Cfg::absolutepos(cfgX, image->Width(), extents.width);
username_y = Cfg::absolutepos(cfgY, image->Height(), extents.height);
if (username_x >= 0 && username_y >= 0){
SlimDrawString8 (draw, &entercolor, enterfont, username_x, username_y,
msg, &entershadowcolor, shadowXOffset, shadowYOffset);
}
}
XftDrawDestroy(draw);
if (mode == Mode_Lock) {
// If only the password box is visible, draw the user name somewhere too
string user_msg = "User: " + GetName();
int show_username = cfg->getIntOption("show_username");
if (singleInputMode && show_username) {
Message(user_msg);
}
}
}
string Panel::getSession() {
return session_exec;
}
/* choose next available session type */
void Panel::SwitchSession() {
pair<string,string> ses = cfg->nextSession();
session_name = ses.first;
session_exec = ses.second;
if (session_name.size() > 0) {
ShowSession();
}
}
/* Display session type on the screen */
void Panel::ShowSession() {
string msg_x, msg_y;
XClearWindow(Dpy, Root);
string currsession = cfg->getOption("session_msg") + " " + session_name;
XGlyphInfo extents;
sessionfont = XftFontOpenName(Dpy, Scr, cfg->getOption("session_font").c_str());
XftDraw *draw = XftDrawCreate(Dpy, Root,
DefaultVisual(Dpy, Scr), DefaultColormap(Dpy, Scr));
XftTextExtents8(Dpy, sessionfont, reinterpret_cast<const XftChar8*>(currsession.c_str()),
currsession.length(), &extents);
msg_x = cfg->getOption("session_x");
msg_y = cfg->getOption("session_y");
int x = Cfg::absolutepos(msg_x, XWidthOfScreen(ScreenOfDisplay(Dpy, Scr)), extents.width);
int y = Cfg::absolutepos(msg_y, XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)), extents.height);
int shadowXOffset = cfg->getIntOption("session_shadow_xoffset");
int shadowYOffset = cfg->getIntOption("session_shadow_yoffset");
SlimDrawString8(draw, &sessioncolor, sessionfont, x, y,
currsession,
&sessionshadowcolor,
shadowXOffset, shadowYOffset);
XFlush(Dpy);
XftDrawDestroy(draw);
}
void Panel::SlimDrawString8(XftDraw *d, XftColor *color, XftFont *font,
int x, int y, const string& str,
XftColor* shadowColor,
int xOffset, int yOffset)
{
int calc_x = 0;
int calc_y = 0;
if (mode == Mode_Lock) {
calc_x = viewport.x;
calc_y = viewport.y;
}
if (xOffset && yOffset) {
XftDrawStringUtf8(d, shadowColor, font,
x + xOffset + calc_x,
y + yOffset + calc_y,
reinterpret_cast<const FcChar8*>(str.c_str()),
str.length());
}
XftDrawStringUtf8(d, color, font,
x + calc_x,
y + calc_y,
reinterpret_cast<const FcChar8*>(str.c_str()),
str.length());
}
Panel::ActionType Panel::getAction(void) const{
return action;
}
void Panel::Reset(void){
ResetName();
ResetPasswd();
}
void Panel::ResetName(void){
NameBuffer.clear();
}
void Panel::ResetPasswd(void){
PasswdBuffer.clear();
HiddenPasswdBuffer.clear();
}
void Panel::SetName(const string& name){
NameBuffer=name;
if (mode == Mode_DM)
action = Login;
else
action = Lock;
}
const string& Panel::GetName(void) const{
return NameBuffer;
}
const string& Panel::GetPasswd(void) const{
return PasswdBuffer;
}
Rectangle Panel::GetPrimaryViewport() {
Rectangle fallback;
Rectangle result;
RROutput primary;
XRROutputInfo *primary_info;
XRRScreenResources *resources;
XRRCrtcInfo *crtc_info;
int crtc;
fallback.x = 0;
fallback.y = 0;
fallback.width = DisplayWidth(Dpy, Scr);
fallback.height = DisplayHeight(Dpy, Scr);
primary = XRRGetOutputPrimary(Dpy, Win);
if (!primary) {
return fallback;
}
resources = XRRGetScreenResources(Dpy, Win);
if (!resources)
return fallback;
primary_info = XRRGetOutputInfo(Dpy, resources, primary);
if (!primary_info) {
XRRFreeScreenResources(resources);
return fallback;
}
// Fixes bug with multiple monitors. Just pick first monitor if
// XRRGetOutputInfo gives returns bad into for crtc.
if (primary_info->crtc < 1) {
if (primary_info->ncrtc > 0) {
crtc = primary_info->crtcs[0];
} else {
cerr << "Cannot get crtc from xrandr.\n";
exit(EXIT_FAILURE);
}
} else {
crtc = primary_info->crtc;
}
crtc_info = XRRGetCrtcInfo(Dpy, resources, crtc);
if (!crtc_info) {
XRRFreeOutputInfo(primary_info);
XRRFreeScreenResources(resources);
return fallback;
}
result.x = crtc_info->x;
result.y = crtc_info->y;
result.width = crtc_info->width;
result.height = crtc_info->height;
XRRFreeCrtcInfo(crtc_info);
XRRFreeOutputInfo(primary_info);
XRRFreeScreenResources(resources);
return result;
}
void Panel::ApplyBackground(Rectangle rect) {
int ret = 0;
if (rect.is_empty()) {
rect.x = 0;
rect.y = 0;
rect.width = viewport.width;
rect.height = viewport.height;
}
ret = XCopyArea(Dpy, PanelPixmap, Win, WinGC,
rect.x, rect.y, rect.width, rect.height,
viewport.x + rect.x, viewport.y + rect.y);
if (!ret)
cerr << APPNAME << ": failed to put pixmap on the screen\n.";
}
| 26,305
|
C++
|
.cpp
| 815
| 28.77546
| 111
| 0.691425
|
iwamatsu/slim
| 124
| 35
| 16
|
GPL-2.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
750,990
|
app.h
|
iwamatsu_slim/app.h
|
/* SLiM - Simple Login Manager
* Copyright (C) 1997, 1998 Per Liden
* Copyright (C) 2004-06 Simone Rota <sip@varlock.com>
* Copyright (C) 2004-06 Johannes Winkelmann <jw@tks6.net>
*
* 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.
*/
#ifndef _APP_H_
#define _APP_H_
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <signal.h>
#include <unistd.h>
#include <sys/wait.h>
#include <errno.h>
#include <setjmp.h>
#include <stdlib.h>
#include <iostream>
#include "panel.h"
#include "cfg.h"
#include "image.h"
#ifdef USE_PAM
#include "PAM.h"
#endif
#ifdef USE_CONSOLEKIT
#include "Ck.h"
#endif
class App {
public:
App(int argc, char **argv);
~App();
void Run();
int GetServerPID();
void RestartServer();
void StopServer();
/* Lock functions */
void GetLock();
void RemoveLock();
bool isServerStarted();
private:
void Login();
void Reboot();
void Halt();
void Suspend();
void Console();
void Exit();
void KillAllClients(Bool top);
void ReadConfig();
void OpenLog();
void CloseLog();
void HideCursor();
void CreateServerAuth();
char *StrConcat(const char *str1, const char *str2);
void UpdatePid();
bool AuthenticateUser(bool focuspass);
static std::string findValidRandomTheme(const std::string &set);
static void replaceVariables(std::string &input,
const std::string &var,
const std::string &value);
/* Server functions */
int StartServer();
int ServerTimeout(int timeout, char *string);
int WaitForServer();
/* Private data */
Window Root;
Display *Dpy;
int Scr;
Panel *LoginPanel;
int ServerPID;
const char *DisplayName;
bool serverStarted;
#ifdef USE_PAM
PAM::Authenticator pam;
#endif
#ifdef USE_CONSOLEKIT
Ck::Session ck;
#endif
/* Options */
char *DispName;
Cfg *cfg;
Pixmap BackgroundPixmap;
void blankScreen();
Image *image;
Atom BackgroundPixmapId;
void setBackground(const std::string &themedir);
bool firstlogin;
bool daemonmode;
bool force_nodaemon;
/* For testing themes */
char *testtheme;
bool testing;
std::string themeName;
std::string mcookie;
const int mcookiesize;
};
#endif /* _APP_H_ */
| 2,318
|
C++
|
.h
| 99
| 21.353535
| 72
| 0.735789
|
iwamatsu/slim
| 124
| 35
| 16
|
GPL-2.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,991
|
cfg.h
|
iwamatsu_slim/cfg.h
|
/* SLiM - Simple Login Manager
Copyright (C) 2004-06 Simone Rota <sip@varlock.com>
Copyright (C) 2004-06 Johannes Winkelmann <jw@tks6.net>
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.
*/
#ifndef _CFG_H_
#define _CFG_H_
#include <string>
#include <map>
#include <vector>
#define INPUT_MAXLENGTH_NAME 30
#define INPUT_MAXLENGTH_PASSWD 50
#define CFGFILE SYSCONFDIR"/slim.conf"
#define THEMESDIR PKGDATADIR"/themes"
#define THEMESFILE "/slim.theme"
class Cfg {
public:
Cfg();
~Cfg();
bool readConf(std::string configfile);
std::string parseOption(std::string line, std::string option);
const std::string& getError() const;
std::string& getOption(std::string option);
int getIntOption(std::string option);
std::string getWelcomeMessage();
static int absolutepos(const std::string &position, int max, int width);
static int string2int(const char *string, bool *ok = 0);
static void split(std::vector<std::string> &v, const std::string &str,
char c, bool useEmpty=true);
static std::string Trim(const std::string &s);
std::pair<std::string,std::string> nextSession();
private:
void fillSessionList();
private:
std::map<std::string,std::string> options;
std::vector<std::pair<std::string,std::string> > sessions;
int currentSession;
std::string error;
};
#endif /* _CFG_H_ */
| 1,528
|
C++
|
.h
| 43
| 33.069767
| 73
| 0.742527
|
iwamatsu/slim
| 124
| 35
| 16
|
GPL-2.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,992
|
util.h
|
iwamatsu_slim/util.h
|
/* SLiM - Simple Login Manager
Copyright (C) 2009 Eygene Ryabinkin <rea@codelabs.ru>
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.
*/
#ifndef _UTIL_H__
#define _UTIL_H__
#include <string>
namespace Util {
bool add_mcookie(const std::string &mcookie, const char *display,
const std::string &xauth_cmd, const std::string &authfile);
void srandom(unsigned long seed);
long random(void);
long makeseed(void);
}
#endif /* _UTIL_H__ */
| 651
|
C++
|
.h
| 18
| 33.666667
| 71
| 0.743222
|
iwamatsu/slim
| 124
| 35
| 16
|
GPL-2.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,993
|
numlock.h
|
iwamatsu_slim/numlock.h
|
/* SLiM - Simple Login Manager
Copyright (C) 2004-06 Simone Rota <sip@varlock.com>
Copyright (C) 2004-06 Johannes Winkelmann <jw@tks6.net>
Copyright (C) 2012 Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
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.
*/
#ifndef _NUMLOCK_H_
#define _NUMLOCK_H_
#include <X11/Xlib.h>
#include <X11/XKBlib.h>
#include <X11/keysym.h>
class NumLock {
public:
NumLock();
static void setOn(Display *dpy);
static void setOff(Display *dpy);
private:
static int xkb_init(Display *dpy);
static unsigned int xkb_mask_modifier(XkbDescPtr xkb, const char *name);
static unsigned int xkb_numlock_mask(Display *dpy);
static void control_numlock(Display *dpy, bool flag);
};
#endif /* _NUMLOCK_H_ */
| 927
|
C++
|
.h
| 26
| 33.846154
| 73
| 0.765101
|
iwamatsu/slim
| 124
| 35
| 16
|
GPL-2.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,994
|
PAM.h
|
iwamatsu_slim/PAM.h
|
/* SLiM - Simple Login Manager
Copyright (C) 2007 Martin Parm
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.
*/
#ifndef _PAM_H_
#define _PAM_H_
#include <string>
#include <security/pam_appl.h>
#ifdef __LIBPAM_VERSION
#include <security/pam_misc.h>
#endif
namespace PAM {
class Exception {
public:
int errnum;
std::string errstr;
std::string func_name;
Exception(pam_handle_t* _pam_handle,
const std::string& _func_name,
int _errnum);
virtual ~Exception(void);
};
class Auth_Exception: public Exception {
public:
Auth_Exception(pam_handle_t* _pam_handle,
const std::string& _func_name,
int _errnum);
};
class Cred_Exception: public Exception {
public:
Cred_Exception(pam_handle_t* _pam_handle,
const std::string& _func_name,
int _errnum);
};
class Authenticator {
private:
struct pam_conv pam_conversation;
pam_handle_t* pam_handle;
int last_result;
int _end(void);
public:
typedef int (conversation)(int num_msg,
const struct pam_message **msg,
struct pam_response **resp,
void *appdata_ptr);
enum ItemType {
Service = PAM_SERVICE,
User = PAM_USER,
User_Prompt = PAM_USER_PROMPT,
TTY = PAM_TTY,
Requestor = PAM_RUSER,
Host = PAM_RHOST,
Conv = PAM_CONV,
#ifdef __LIBPAM_VERSION
/* Fail_Delay = PAM_FAIL_DELAY */
#endif
};
public:
Authenticator(conversation* conv, void* data=0);
~Authenticator(void);
void start(const std::string& service);
void end(void);
void set_item(const ItemType item, const void* value);
const void* get_item(const ItemType item);
#ifdef __LIBPAM_VERSION
void fail_delay(const unsigned int micro_sec);
#endif
void authenticate(void);
void open_session(void);
void close_session(void);
void setenv(const std::string& key, const std::string& value);
void delenv(const std::string& key);
const char* getenv(const std::string& key);
char** getenvlist(void);
private:
/* Explicitly disable copy constructor and copy assignment */
Authenticator(const PAM::Authenticator&);
Authenticator& operator=(const PAM::Authenticator&);
};
}
std::ostream& operator<<( std::ostream& os, const PAM::Exception& e);
#endif /* _PAM_H_ */
| 2,442
|
C++
|
.h
| 85
| 25.341176
| 71
| 0.705254
|
iwamatsu/slim
| 124
| 35
| 16
|
GPL-2.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,995
|
image.h
|
iwamatsu_slim/image.h
|
/* SLiM - Simple Login Manager
Copyright (C) 2004-06 Simone Rota <sip@varlock.com>
Copyright (C) 2004-06 Johannes Winkelmann <jw@tks6.net>
Copyright (C) 2012 Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
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.
The following code has been adapted and extended from
xplanet 1.0.1, Copyright (C) 2002-04 Hari Nair <hari@alumni.caltech.edu>
*/
#ifndef _IMAGE_H_
#define _IMAGE_H_
#include <X11/Xlib.h>
#include <X11/Xmu/WinUtil.h>
#include "log.h"
class Image {
public:
Image();
Image(const int w, const int h, const unsigned char *rgb,
const unsigned char *alpha);
~Image();
const unsigned char *getPNGAlpha() const {
return(png_alpha);
};
const unsigned char *getRGBData() const {
return(rgb_data);
};
void getPixel(double px, double py, unsigned char *pixel);
void getPixel(double px, double py, unsigned char *pixel,
unsigned char *alpha);
int Width() const {
return(width);
};
int Height() const {
return(height);
};
void Quality(const int q) {
quality_ = q;
};
bool Read(const char *filename);
void Reduce(const int factor);
void Resize(const int w, const int h);
void Merge(Image *background, const int x, const int y);
void Merge_non_crop(Image* background, const int x, const int y);
void Crop(const int x, const int y, const int w, const int h);
void Tile(const int w, const int h);
void Center(const int w, const int h, const char *hex);
void Plain(const int w, const int h, const char *hex);
void computeShift(unsigned long mask, unsigned char &left_shift,
unsigned char &right_shift);
Pixmap createPixmap(Display *dpy, int scr, Window win);
private:
int width, height, area;
unsigned char *rgb_data;
unsigned char *png_alpha;
int quality_;
int readJpeg(const char *filename, int *width, int *height,
unsigned char **rgb);
int readPng(const char *filename, int *width, int *height,
unsigned char **rgb, unsigned char **alpha);
};
#endif /* _IMAGE_H_ */
| 2,183
|
C++
|
.h
| 63
| 32.174603
| 74
| 0.731336
|
iwamatsu/slim
| 124
| 35
| 16
|
GPL-2.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,996
|
const.h
|
iwamatsu_slim/const.h
|
/* SLiM - Simple Login Manager
Copyright (C) 1997, 1998 Per Liden
Copyright (C) 2004-06 Simone Rota <sip@varlock.com>
Copyright (C) 2004-06 Johannes Winkelmann <jw@tks6.net>
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.
*/
#ifndef _CONST_H_
#define _CONST_H_
#define APPNAME "slim"
#define DISPLAY ":0.0"
#define CONSOLE_STR "console"
#define HALT_STR "halt"
#define REBOOT_STR "reboot"
#define EXIT_STR "exit"
#define SUSPEND_STR "suspend"
#define HIDE 0
#define SHOW 1
#define GET_NAME 0
#define GET_PASSWD 1
#define OK_EXIT 0
#define ERR_EXIT 1
/* duration for showing error messages,
* as "login command failed", in seconds
*/
#define ERROR_DURATION 5
/* variables replaced in login_cmd */
#define SESSION_VAR "%session"
#define THEME_VAR "%theme"
/* variables replaced in pre-session_cmd and post-session_cmd */
#define USER_VAR "%user"
/* max height/width for images */
#define MAX_DIMENSION 10000
#endif /* _CONST_H_ */
| 1,175
|
C++
|
.h
| 36
| 30.638889
| 71
| 0.736469
|
iwamatsu/slim
| 124
| 35
| 16
|
GPL-2.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,997
|
switchuser.h
|
iwamatsu_slim/switchuser.h
|
/* SLiM - Simple Login Manager
Copyright (C) 1997, 1998 Per Liden
Copyright (C) 2004-06 Simone Rota <sip@varlock.com>
Copyright (C) 2004-06 Johannes Winkelmann <jw@tks6.net>
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.
*/
#ifndef _SWITCHUSER_H_
#define _SWITCHUSER_H_
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <pwd.h>
#include <grp.h>
#include <paths.h>
#include <cstdio>
#include <iostream>
#include "log.h"
#include "cfg.h"
class SwitchUser {
public:
SwitchUser(struct passwd *pw, Cfg *c, const std::string& display,
char** _env);
~SwitchUser();
void Login(const char* cmd, const char* mcookie);
private:
SwitchUser();
void SetEnvironment();
void SetUserId();
void Execute(const char* cmd);
void SetClientAuth(const char* mcookie);
Cfg* cfg;
struct passwd *Pw;
std::string displayName;
char** env;
};
#endif /* _SWITCHUSER_H_ */
| 1,101
|
C++
|
.h
| 39
| 26
| 71
| 0.735043
|
iwamatsu/slim
| 124
| 35
| 16
|
GPL-2.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,998
|
Ck.h
|
iwamatsu_slim/Ck.h
|
/* SLiM - Simple Login Manager
* Copyright (C) 2007 Martin Parm
*
* 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.
*/
#ifndef _CK_H_
#define _CK_H_
#include <string>
#include <ck-connector.h>
#include <dbus/dbus.h>
namespace Ck {
class Exception {
public:
std::string func;
std::string errstr;
Exception(const std::string &func, const std::string &errstr);
};
class Session {
private:
CkConnector *ckc;
DBusError error;
const char *get_x11_device(const std::string &display);
dbus_bool_t ck_connector_open_graphic_session(const std::string &display,
uid_t uid);
public:
const char *get_xdg_session_cookie();
void open_session(const std::string &display, uid_t uid);
void close_session();
Session();
~Session();
};
}
std::ostream &operator<<(std::ostream &os, const Ck::Exception &e);
#endif /* _CK_H_ */
| 1,050
|
C++
|
.h
| 37
| 26.081081
| 75
| 0.724104
|
iwamatsu/slim
| 124
| 35
| 16
|
GPL-2.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
750,999
|
panel.h
|
iwamatsu_slim/panel.h
|
/* SLiM - Simple Login Manager
Copyright (C) 1997, 1998 Per Liden
Copyright (C) 2004-06 Simone Rota <sip@varlock.com>
Copyright (C) 2004-06 Johannes Winkelmann <jw@tks6.net>
Copyright (C) 2013 Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
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.
*/
#ifndef _PANEL_H_
#define _PANEL_H_
#include <X11/Xlib.h>
#include <X11/keysym.h>
#include <X11/Xft/Xft.h>
#include <X11/cursorfont.h>
#include <X11/Xmu/WinUtil.h>
#include <sys/wait.h>
#include <stdlib.h>
#include <signal.h>
#include <iostream>
#include <string>
#ifdef NEEDS_BASENAME
#include <libgen.h>
#endif
#include "switchuser.h"
#include "log.h"
#include "image.h"
struct Rectangle {
int x;
int y;
unsigned int width;
unsigned int height;
Rectangle() : x(0), y(0), width(0), height(0) {};
Rectangle(int x, int y, unsigned int width,
unsigned int height) :
x(x), y(y), width(width), height(height) {};
bool is_empty() const {
return width == 0 || height == 0;
}
};
class Panel {
public:
enum ActionType {
Login,
Lock,
Console,
Reboot,
Halt,
Exit,
Suspend
};
enum FieldType {
Get_Name,
Get_Passwd
};
enum PanelType {
Mode_DM,
Mode_Lock
};
Panel(Display *dpy, int scr, Window root, Cfg *config,
const std::string& themed, PanelType panel_mode);
~Panel();
void OpenPanel();
void ClosePanel();
void ClearPanel();
void WrongPassword(int timeout);
void Message(const std::string &text);
void Error(const std::string &text);
void EventHandler(const FieldType &curfield);
std::string getSession();
ActionType getAction(void) const;
void Reset(void);
void ResetName(void);
void ResetPasswd(void);
void SetName(const std::string &name);
const std::string& GetName(void) const;
const std::string& GetPasswd(void) const;
void SwitchSession();
private:
Panel();
void Cursor(int visible);
unsigned long GetColor(const char *colorname);
void OnExpose(void);
void EraseLastChar(string &formerString);
bool OnKeyPress(XEvent& event);
void ShowText();
void ShowSession();
void SlimDrawString8(XftDraw *d, XftColor *color, XftFont *font,
int x, int y, const std::string &str,
XftColor *shadowColor,
int xOffset, int yOffset);
Rectangle GetPrimaryViewport();
void ApplyBackground(Rectangle = Rectangle());
/* Private data */
PanelType mode; /* work mode */
Cfg *cfg;
Window Win;
Window Root;
Display *Dpy;
int Scr;
int X, Y;
GC TextGC;
GC WinGC;
XftFont *font;
XftColor inputshadowcolor;
XftColor inputcolor;
XftColor msgcolor;
XftColor msgshadowcolor;
XftFont *msgfont;
XftColor introcolor;
XftFont *introfont;
XftFont *welcomefont;
XftColor welcomecolor;
XftFont *sessionfont;
XftColor sessioncolor;
XftColor sessionshadowcolor;
XftColor welcomeshadowcolor;
XftFont *enterfont;
XftColor entercolor;
XftColor entershadowcolor;
ActionType action;
FieldType field;
//Pixmap background;
/* Username/Password */
std::string NameBuffer;
std::string PasswdBuffer;
std::string HiddenPasswdBuffer;
/* screen stuff */
Rectangle viewport;
/* Configuration */
int input_name_x;
int input_name_y;
int input_pass_x;
int input_pass_y;
int inputShadowXOffset;
int inputShadowYOffset;
int input_cursor_height;
int welcome_x;
int welcome_y;
int welcome_shadow_xoffset;
int welcome_shadow_yoffset;
int session_shadow_xoffset;
int session_shadow_yoffset;
int intro_x;
int intro_y;
int username_x;
int username_y;
int username_shadow_xoffset;
int username_shadow_yoffset;
int password_x;
int password_y;
std::string welcome_message;
std::string intro_message;
/* Pixmap data */
Pixmap PanelPixmap;
Image *image;
/* For thesting themes */
bool testing;
std::string themedir;
/* Session handling */
std::string session_name;
std::string session_exec;
};
#endif /* _PANEL_H_ */
| 4,041
|
C++
|
.h
| 165
| 22.163636
| 71
| 0.746106
|
iwamatsu/slim
| 124
| 35
| 16
|
GPL-2.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
751,000
|
log.h
|
iwamatsu_slim/log.h
|
#ifndef _LOG_H_
#define _LOG_H_
#ifdef USE_CONSOLEKIT
#include "Ck.h"
#endif
#ifdef USE_PAM
#include "PAM.h"
#endif
#include "const.h"
#include <fstream>
using namespace std;
static class LogUnit {
ofstream logFile;
public:
bool openLog(const char * filename);
void closeLog();
~LogUnit() { closeLog(); }
template<typename Type>
LogUnit & operator<<(const Type & text) {
logFile << text; logFile.flush();
return *this;
}
LogUnit & operator<<(ostream & (*fp)(ostream&)) {
logFile << fp; logFile.flush();
return *this;
}
LogUnit & operator<<(ios_base & (*fp)(ios_base&)) {
logFile << fp; logFile.flush();
return *this;
}
} logStream;
#endif /* _LOG_H_ */
| 685
|
C++
|
.h
| 32
| 19.40625
| 52
| 0.683721
|
iwamatsu/slim
| 124
| 35
| 16
|
GPL-2.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
751,001
|
wrappy.cpp
|
lava_wrappy/wrappy.cpp
|
// Python header must be included first since they insist on
// unconditionally defining some system macros
// (http://bugs.python.org/issue1045893, still broken in python3.4)
#include <Python.h>
#include <wrappy/wrappy.h>
#include <iostream>
#include <mutex>
#include <cstdio>
namespace wrappy {
PythonObject None, True, False;
} // end namespace wrappy
namespace {
using namespace wrappy;
PyObject *s_EmptyTuple;
PyObject *s_EmptyDict;
__attribute__((constructor))
void wrappyInitialize()
{
// Initialize python interpreter.
// The module search path is initialized as following:
// Python looks at PATH to find an executable called "python"
// The name that is searched can be changed by calling Py_SetProgramName()
// before Py_Initialize(). The folder where this executable resides is
// python-home, which can be overwritten at runtime by setting $PYTHONHOME.
// The default module search path is then
//
// <python-home>/../lib/<python-version>/
//
// All entries from $PYTHONPATH are pre-pended to the module search path
Py_Initialize();
// Setting a dummy value since many libraries require sys.argv[0] to exist
char* dummy_args[] = {const_cast<char*>("wrappy"), nullptr};
PySys_SetArgvEx(1, dummy_args, 0);
wrappy::None = PythonObject(PythonObject::borrowed{}, Py_None);
wrappy::True = PythonObject(PythonObject::borrowed{}, Py_True);
wrappy::False = PythonObject(PythonObject::borrowed{}, Py_False);
s_EmptyTuple = Py_BuildValue("()");
s_EmptyDict = Py_BuildValue("{}");
}
__attribute__((destructor))
void wrappyFinalize()
{
Py_Finalize();
}
PythonObject loadBuiltin(const std::string& name)
{
auto builtins = PyEval_GetBuiltins(); // returns a borrowed reference
PythonObject function(PythonObject::borrowed {},
PyDict_GetItemString(builtins, name.c_str()));
return function;
}
// Load the longest prefix of name that is a valid module name.
// Returns null object if none is.
PythonObject loadModule(const std::string& name, size_t& dot)
{
dot = name.size();
PythonObject module;
while (!module && dot != std::string::npos) {
dot = name.rfind('.', dot-1);
std::string prefix = name.substr(0, dot);
module = PythonObject(PythonObject::owning {},
PyImport_ImportModule(prefix.c_str()));
}
return module;
}
// name must start with a dot
PythonObject loadObject(PythonObject module, const std::string& name)
{
// Evaluate the chain of dot-operators that leads from the module to
// the function.
PythonObject object = module;
size_t suffixDot = 0;
while(suffixDot != std::string::npos) {
size_t next_dot = name.find('.', suffixDot+1);
auto attr = name.substr(suffixDot+1, next_dot - (suffixDot+1));
object = PythonObject(PythonObject::owning {}, PyObject_GetAttrString(object.get(), attr.c_str()));
suffixDot = next_dot;
}
return object;
}
} // end unnamed namespace
namespace wrappy {
PythonObject::PythonObject()
: obj_(nullptr)
{ }
PythonObject::PythonObject(owning, PyObject* value)
: obj_(value)
{ }
PythonObject::PythonObject(borrowed, PyObject* value)
: obj_(value)
{
Py_XINCREF(obj_);
}
PythonObject::~PythonObject()
{
Py_XDECREF(obj_);
}
PythonObject::PythonObject(const PythonObject& other)
: obj_(other.obj_)
{
Py_XINCREF(obj_);
}
PyObject* PythonObject::release()
{
auto res = obj_;
obj_ = nullptr;
return res;
}
PythonObject& PythonObject::operator=(const PythonObject& other)
{
PythonObject tmp(other);
std::swap(obj_, tmp.obj_);
return *this;
}
PythonObject::PythonObject(PythonObject&& other)
: obj_(nullptr)
{
std::swap(obj_, other.obj_);
}
PythonObject& PythonObject::operator=(PythonObject&& other)
{
std::swap(obj_, other.obj_);
return *this;
}
PyObject* PythonObject::get() const
{
return obj_;
}
PythonObject PythonObject::attr(const std::string& name) const
{
return PythonObject(owning{}, PyObject_GetAttrString(obj_, name.c_str()));
}
long long PythonObject::num() const
{
return PyLong_AsLongLong(obj_);
}
double PythonObject::floating() const
{
return PyFloat_AsDouble(obj_);
}
const char* PythonObject::str() const
{
return PyString_AsString(obj_);
}
PythonObject::operator bool() const
{
return obj_ != nullptr;
}
PythonObject PythonObject::operator()() const
{
return PythonObject(owning{}, PyObject_Call(obj_, s_EmptyTuple, s_EmptyDict));
}
PythonObject construct(long long ll)
{
return PythonObject(PythonObject::owning {}, PyLong_FromLongLong(ll));
}
PythonObject construct(int i)
{
return PythonObject(PythonObject::owning {}, PyInt_FromLong(i));
}
PythonObject construct(double d)
{
return PythonObject(PythonObject::owning {}, PyFloat_FromDouble(d));
}
PythonObject construct(const std::string& str)
{
return PythonObject(PythonObject::owning {}, PyString_FromString(str.c_str()));
}
PythonObject construct(const std::vector<PythonObject>& v)
{
PythonObject list(PythonObject::owning {}, PyList_New(v.size()));
for (size_t i = 0; i < v.size(); ++i) {
PyObject* item = v.at(i).get();
Py_XINCREF(item); // PyList_SetItem steals a reference
PyList_SetItem(list.get(), i, item);
}
return list;
}
PythonObject construct(PythonObject object)
{
return object;
}
void addModuleSearchPath(const std::string& path)
{
std::string pathString("path");
auto syspath = PySys_GetObject(&pathString[0]); // Borrowed reference
PythonObject pypath(PythonObject::owning {},
PyString_FromString(path.c_str()));
if (!pypath) {
throw WrappyError("Wrappy: Can't allocate memory for string.");
}
auto pos = PyList_Insert(syspath, 0, pypath.get());
if (pos < 0) {
throw WrappyError("Wrappy: Couldn't add " + path + " to sys.path");
}
}
// Doesn't perform checks on the return value (input is still checked)
PythonObject callFunctionWithArgs(
PythonObject function,
const std::vector<PythonObject>& args,
const std::vector<std::pair<std::string, PythonObject>>& kwargs)
{
if (!PyCallable_Check(function.get())) {
throw WrappyError("Wrappy: Supplied object isn't callable.");
}
// Build tuple
size_t sz = args.size();
PythonObject tuple(PythonObject::owning {}, PyTuple_New(sz));
if (!tuple) {
PyErr_Print();
throw WrappyError("Wrappy: Couldn't create python tuple.");
}
for (size_t i = 0; i < sz; ++i) {
PyObject* arg = args.at(i).get();
Py_XINCREF(arg); // PyTuple_SetItem steals a reference
PyTuple_SetItem(tuple.get(), i, arg);
}
// Build kwargs dict
PythonObject dict(PythonObject::owning {}, PyDict_New());
if (!dict) {
PyErr_Print();
throw WrappyError("Wrappy: Couldn't create python dictionary.");
}
for (const auto& kv : kwargs) {
PyDict_SetItemString(dict.get(), kv.first.c_str(), kv.second.get());
}
PythonObject res(PythonObject::owning{},
PyObject_Call(function.get(), tuple.get(), dict.get()));
if (PyErr_Occurred()) {
PyErr_Print();
PyErr_Clear(); // TODO add string to exception, make custom exception class
throw WrappyError("Wrappy: Exception during call to python function");
}
if (!res) {
throw WrappyError("Wrappy: Error calling function");
}
return res;
}
PythonObject load(
const std::string& name)
{
size_t cutoff;
PythonObject module = loadModule(name, cutoff);
PythonObject object;
if (module) {
object = loadObject(module, name.substr(cutoff));
} else {
// No proper prefix was a valid module, but maybe it's a built-in
object = loadBuiltin(name);
}
if (!object) {
std::string error_message;
if(cutoff != std::string::npos) {
error_message = "Wrappy: Lookup of function " +
name.substr(cutoff) + " in module " +
name.substr(0,cutoff) + " failed.";
} else {
error_message = "Wrappy: Lookup of function " + name + "failed.";
}
throw WrappyError(error_message);
}
return object;
}
PythonObject callWithArgs(
const std::string& name,
const std::vector<PythonObject>& args,
const std::vector<std::pair<std::string, PythonObject>>& kwargs)
{
PythonObject function = load(name);
return callFunctionWithArgs(function, args, kwargs);
}
// Call a python function with arguments args and keyword arguments kwargs
PythonObject callWithArgs(
PythonObject from,
const std::string& functionName,
const std::vector<PythonObject>& args,
const std::vector<std::pair<std::string, PythonObject>>& kwargs)
{
std::string name;
if (functionName[0] == '.') {
name = functionName;
} else {
name = "." + functionName;
}
PythonObject function = loadObject(from, name);
if (!function) {
throw WrappyError("Wrappy: "
"Lookup of function " + functionName + " failed.");
}
return callFunctionWithArgs(function, args, kwargs);
}
//
// PythonIterator implementation
//
PythonIterator::PythonIterator(bool stopped, PythonObject iter):
stopped_(stopped),
iter_(iter)
{}
PythonIterator begin(PythonObject obj)
{
PythonObject pyIter(PythonObject::owning{}, PyObject_GetIter(obj.get()));
PythonIterator iter(false, pyIter);
// Move iterator to first position in list to
// initialize obj_
return ++iter;
}
PythonIterator end(PythonObject)
{
return PythonIterator(true, PythonObject());
}
PythonIterator& PythonIterator::operator++()
{
auto next = iter_.attr("next"); // Change this to __next__ if switching to python 3
// Can't use the normal "call" because we want to actually
// handle the exception
obj_ = PythonObject(PythonObject::owning{},
PyObject_Call(next.get(), s_EmptyTuple, s_EmptyDict));
if (PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_StopIteration) ) {
stopped_ = true;
PyErr_Clear();
} else if (PyErr_Occurred() || !obj_) {
PyErr_Print();
PyErr_Clear();
throw WrappyError("Unexcected exception during iteration");
}
return *this;
}
PythonObject PythonIterator::operator*()
{
return obj_;
}
bool PythonIterator::operator!=(const PythonIterator& other) {
return stopped_ != other.stopped_;
}
//
// wrapFunction implementation
//
namespace {
std::vector<PythonObject> to_vector(PyObject* pyargs)
{
if (!PyTuple_Check(pyargs)) {
throw WrappyError("Trampoling args was no tuple");
}
auto nargs = PyTuple_Size(pyargs);
std::vector<PythonObject> args;
args.reserve(nargs);
for (ssize_t i=0; i<nargs; ++i) {
args.emplace_back(PythonObject::borrowed{}, PyTuple_GetItem(pyargs, i));
}
return args;
}
std::map<const char*, PythonObject> to_map(PyObject* pykwargs)
{
if (!PyDict_Check(pykwargs)) {
throw WrappyError("Trampoling kwargs was no dict");
}
std::map<const char*, PythonObject> kwargs;
PyObject *key, *value;
Py_ssize_t pos = 0;
while (PyDict_Next(pykwargs, &pos, &key, &value)) {
const char* str = PyString_AsString(key);
PythonObject obj(PythonObject::borrowed{}, value);
kwargs.emplace(str, obj);
}
return kwargs;
}
PyObject* trampolineWithData(PyObject* data, PyObject* pyargs, PyObject* pykwargs) {
if (!PyCObject_Check(data)) {
throw WrappyError("Trampoline data corrupted");
}
LambdaWithData fun = reinterpret_cast<LambdaWithData>(PyCObject_AsVoidPtr(data));
void* userdata = PyCObject_GetDesc(data);
auto args = to_vector(pyargs);
auto kwargs = to_map(pykwargs);
return fun(args, kwargs, userdata).release();
}
PyObject* trampolineNoData(PyObject* data, PyObject* pyargs, PyObject* pykwargs)
{
if (!PyCObject_Check(data)) {
throw WrappyError("Trampoline data corrupted");
}
Lambda fun = reinterpret_cast<Lambda>(PyCObject_AsVoidPtr(data));
auto args = to_vector(pyargs);
auto kwargs = to_map(pykwargs);
return fun(args, kwargs).release();
}
// The reinterpret_cast<>'s here are technically undefined behaviour, but it's
// the only way that python's C API provides :(
PyMethodDef trampolineNoDataMethod {"trampoline1", reinterpret_cast<PyCFunction>(trampolineNoData), METH_KEYWORDS, nullptr};
PyMethodDef trampolineWithDataMethod {"trampoline2", reinterpret_cast<PyCFunction>(trampolineWithData), METH_KEYWORDS, nullptr};
} // end namespace
PythonObject construct(Lambda lambda)
{
PyObject* pydata = PyCObject_FromVoidPtr(reinterpret_cast<void*>(lambda), nullptr);
return PythonObject(PythonObject::owning{}, PyCFunction_New(&trampolineNoDataMethod, pydata));
}
PythonObject construct(LambdaWithData lambda, void* userdata)
{
PyObject* pydata;
if (!userdata) {
pydata = PyCObject_FromVoidPtr(reinterpret_cast<void*>(lambda), nullptr);
} else { // python returns an error if FromVoidPtrAndDesc is called with desc being null
pydata = PyCObject_FromVoidPtrAndDesc(reinterpret_cast<void*>(lambda), userdata, nullptr);
}
return PythonObject(PythonObject::owning{}, PyCFunction_New(&trampolineWithDataMethod, pydata));
}
typedef PythonObject (*Lambda)(const std::vector<PythonObject>& args, const std::map<const char*, PythonObject>& kwargs);
typedef PythonObject (*LambdaWithData)(const std::vector<PythonObject>& args, const std::map<const char*, PythonObject>& kwargs, void* userdata);
} // end namespace wrappy
| 13,696
|
C++
|
.cpp
| 409
| 29.195599
| 145
| 0.689315
|
lava/wrappy
| 121
| 14
| 3
|
GPL-2.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
751,002
|
plot.cpp
|
lava_wrappy/examples/plot.cpp
|
#include <wrappy/wrappy.h>
#include <algorithm>
int main() {
std::vector<double> x {1.0, 2.0, 3.0, 4.0}, y {1.5, 1.0, 1.3, 2.0};
std::vector<wrappy::PythonObject> pyx, pyy;
std::transform(x.begin(), x.end(), std::back_inserter(pyx),
[](double d) { return wrappy::construct(d); });
std::transform(y.begin(), y.end(), std::back_inserter(pyy),
[](double d) { return wrappy::construct(d); });
wrappy::call("matplotlib.pyplot.plot", pyx, pyy);
wrappy::call("matplotlib.pyplot.show");
}
| 514
|
C++
|
.cpp
| 12
| 39.083333
| 68
| 0.627255
|
lava/wrappy
| 121
| 14
| 3
|
GPL-2.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
751,003
|
email.cpp
|
lava_wrappy/examples/email.cpp
|
#include <wrappy/wrappy.h>
int main() {
auto s = wrappy::call("smtplib.SMTP", "localhost");
s.call("sendmail", "python@localhost", "wrappy@bmevers.de",
"Subject: Third time's the charm\n"
"Dear Mr. or Ms.,\n"
"please send my best regards.");
}
| 283
|
C++
|
.cpp
| 8
| 29.5
| 65
| 0.60219
|
lava/wrappy
| 121
| 14
| 3
|
GPL-2.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
751,004
|
turtle.cpp
|
lava_wrappy/examples/turtle.cpp
|
#include <wrappy/wrappy.h>
void drawTree(double len, double angle, int lvl) {
if(!lvl) return;
wrappy::call("turtle.left", angle);
wrappy::call("turtle.forward", len);
drawTree(0.5*len, 60, lvl-1);
drawTree(0.7*len, 0, lvl-1);
drawTree(0.5*len, -60, lvl-1);
wrappy::call("turtle.backward", len);
wrappy::call("turtle.right", angle);
}
int main() {
drawTree(100, 90, 6);
}
| 388
|
C++
|
.cpp
| 14
| 25.785714
| 50
| 0.673854
|
lava/wrappy
| 121
| 14
| 3
|
GPL-2.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
751,005
|
sugar.cpp
|
lava_wrappy/tests/sugar.cpp
|
#define BOOST_TEST_MODULE sugar
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MAIN
#include <boost/test/unit_test.hpp>
#include <wrappy/wrappy.h>
BOOST_AUTO_TEST_CASE(stdlib)
{
auto datetime = wrappy::call("datetime.datetime", 2003, 8, 4, 12, 30, 45);
auto formatted = wrappy::call(datetime, "isoformat");
BOOST_CHECK_EQUAL(formatted.str(), "2003-08-04T12:30:45");
}
BOOST_AUTO_TEST_CASE(kwargs)
{
auto delta = wrappy::call("datetime.timedelta", std::make_pair("hours", 1));
auto seconds = delta.attr("seconds").num();
BOOST_CHECK_EQUAL(seconds, 3600);
}
| 586
|
C++
|
.cpp
| 17
| 31.705882
| 80
| 0.712256
|
lava/wrappy
| 121
| 14
| 3
|
GPL-2.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
751,006
|
stdlib.cpp
|
lava_wrappy/tests/stdlib.cpp
|
#define BOOST_TEST_MODULE stdlib
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MAIN
#include <wrappy/wrappy.h>
#include <vector>
#include <boost/test/unit_test.hpp>
BOOST_AUTO_TEST_CASE(random_number)
{
std::vector<wrappy::PythonObject> args;
args.push_back(wrappy::construct(0));
wrappy::callWithArgs("random.seed", args);
auto v1 = wrappy::callWithArgs("random.random");
wrappy::callWithArgs("random.seed", args);
auto v2 = wrappy::callWithArgs("random.random");
BOOST_CHECK_EQUAL(v1.num(), v2.num());
}
BOOST_AUTO_TEST_CASE(builtins)
{
std::vector<wrappy::PythonObject> args(1);
args[0] = wrappy::construct(255);
auto intval = wrappy::callWithArgs("hex", args);
args[0] = wrappy::construct(255ll);
auto longval = wrappy::callWithArgs("hex", args);
BOOST_CHECK_EQUAL(intval.str(), "0xff");
BOOST_CHECK_EQUAL(longval.str(), "0xffL");
}
BOOST_AUTO_TEST_CASE(error)
{
BOOST_CHECK_THROW(wrappy::callWithArgs("asdf"),
wrappy::WrappyError);
}
BOOST_AUTO_TEST_CASE(destruction)
{
{
auto v1 = wrappy::callWithArgs("random.random");
}
{
auto v2 = wrappy::callWithArgs("random.random");
}
// test successful if python didn't crash
}
| 1,246
|
C++
|
.cpp
| 41
| 26.463415
| 56
| 0.688814
|
lava/wrappy
| 121
| 14
| 3
|
GPL-2.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
751,007
|
wrappy.h
|
lava_wrappy/include/wrappy/wrappy.h
|
#pragma once
#include <map>
#include <vector>
#include <string>
#include <stdexcept>
struct _object;
typedef _object PyObject;
/**
* Note that this library is *NOT* thread-safe.
*
* This is basically unfixable since the reference count of a python object
* is stored in a non-atomic ssize_t and modified without any locking,
* making any increases and decreases inherently racy.
*
* If you want to use this in a multi-threaded environment, please make sure
* to protect all concurrent calls that are not read-only by mutexes.
*/
namespace wrappy {
class WrappyError : public std::runtime_error {
public:
WrappyError(const std::string& str)
: std::runtime_error(str)
{ }
};
// A Raii-wrapper around PyObject* that transparently handles
// the necessary reference-counting
class PythonObject {
public:
// Accessors
// Python doesn't care about const-ness, so having a separate acccessor
// for a const PyObject* would be useless. We have to trust the caller
// not to do non-const things with it.
long long num() const;
double floating() const;
const char* str() const;
PyObject* get() const;
PythonObject attr(const std::string& x) const; // returns self.x
// Give up ownership of the underlying object
PyObject* release();
// Constructors
struct owning {};
struct borrowed {};
PythonObject(); // Note that this does not default to "None"
PythonObject(owning, PyObject*);
PythonObject(borrowed, PyObject*);
// Syntactic sugar
operator bool() const;
PythonObject operator()() const; // forwards to self.__call__()
template<typename... Args>
PythonObject call(const std::string& f, Args... args);
// Rule-of-five plumbing
~PythonObject();
PythonObject(const PythonObject&);
PythonObject& operator=(const PythonObject&);
PythonObject(PythonObject&&);
PythonObject& operator=(PythonObject&&);
private:
PyObject* obj_;
};
// Note that this is an input iterator, iterators cannot
// be stored, rewound, or compared to anything but "end"
struct PythonIterator {
PythonIterator& operator++(); // pre-increment
PythonObject operator*(); // dereference
// *only* for comparison to "end", python iterators have
// no concept of position or comparability
bool operator!=(const PythonIterator&);
private:
PythonIterator(bool, PythonObject);
friend PythonIterator begin(PythonObject);
friend PythonIterator end(PythonObject);
bool stopped_;
PythonObject iter_;
PythonObject obj_;
};
PythonIterator begin(PythonObject);
PythonIterator end(PythonObject);
// Providing access to pythons global objects
extern PythonObject None;
extern PythonObject True;
extern PythonObject False;
void addModuleSearchPath(const std::string& path);
// There is one quirk of call() for the case of member methods:
//
// call("module.A.foo")
//
// calls the unbound method "foo", so it is necessary to provide an instance
// of A as the first argument, while
//
// auto a = call("module.A"); call(a, "foo");
//
// calls the method "foo" that is already bound to a, so providing an explicit
// self argument in that case is an error.
template<typename... Args>
PythonObject call(const std::string& f, Args... args);
template<typename... Args>
PythonObject call(PythonObject from, const std::string& f, Args... args);
// The template-magic in call() constructs a series of appropriate calls
// to these functions, but of course they can also be used directly:
PythonObject construct(long long);
PythonObject construct(int);
PythonObject construct(double);
PythonObject construct(const std::string&);
PythonObject construct(PythonObject); // identity
PythonObject construct(const std::vector<PythonObject>&); // python list
// TODO there is no good way to actually call these constructed functions
typedef PythonObject (*Lambda)(const std::vector<PythonObject>& args, const std::map<const char*, PythonObject>& kwargs);
typedef PythonObject (*LambdaWithData)(const std::vector<PythonObject>& args, const std::map<const char*, PythonObject>& kwargs, void* userdata);
PythonObject construct(Lambda);
PythonObject construct(LambdaWithData, void*);
PythonObject callWithArgs(
const std::string& function,
const std::vector<PythonObject>& args
= std::vector<PythonObject>(),
const std::vector<std::pair<std::string, PythonObject>>& kwargs
= std::vector<std::pair<std::string, PythonObject>>());
PythonObject callWithArgs(
PythonObject from,
const std::string& function,
const std::vector<PythonObject>& args
= std::vector<PythonObject>(),
const std::vector<std::pair<std::string, PythonObject>>& kwargs
= std::vector<std::pair<std::string, PythonObject>>());
// Just get an object, without calling a function
PythonObject load(const std::string& name);
// Will call x.__enter__() in constructor and x.__exit__() in destructor
class ContextManager {
public:
ContextManager(PythonObject x);
~ContextManager();
};
} // end namespace wrappy
#include <wrappy/detail/call.hpp>
| 5,120
|
C++
|
.h
| 133
| 35.37594
| 145
| 0.735716
|
lava/wrappy
| 121
| 14
| 3
|
GPL-2.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
751,008
|
call.hpp
|
lava_wrappy/include/wrappy/detail/call.hpp
|
#pragma once
// Implementation of call()
namespace wrappy {
namespace detail {
typedef std::vector<PythonObject> PositionalArgs;
typedef std::vector<std::pair<std::string, PythonObject>> KeywordArgs;
template<typename... Args>
void appendArgs(PositionalArgs& pargs, KeywordArgs& kwargs, Args... args);
// Base case
template<>
inline void appendArgs(PositionalArgs&, KeywordArgs&)
{}
// Positional argument
template<typename Head, typename... Tail>
void appendArgs(
PositionalArgs& pargs,
KeywordArgs& kwargs,
Head head,
Tail... tail)
{
pargs.push_back(construct(head));
appendArgs(pargs, kwargs, tail...);
}
// Keyword argument from string
template<typename Head, typename... Tail>
void appendArgs(
PositionalArgs& pargs,
KeywordArgs& kwargs,
std::pair<std::string, Head> head,
Tail... tail)
{
kwargs.emplace_back(head.first, construct(head.second));
appendArgs(pargs, kwargs, tail...);
}
// Keyword argument from const char*
template<typename Head, typename... Tail>
void appendArgs(
PositionalArgs& pargs,
KeywordArgs& kwargs,
std::pair<const char*, Head> head,
Tail... tail)
{
kwargs.emplace_back(std::string(head.first), construct(head.second));
appendArgs(pargs, kwargs, tail...);
}
} // end namespace detail
template<typename... Args>
PythonObject call(const std::string& f, Args... args)
{
auto pargs = std::vector<PythonObject>();
auto kwargs = std::vector<std::pair<std::string, PythonObject>>();
detail::appendArgs(pargs, kwargs, args...);
return callWithArgs(f, pargs, kwargs);
}
template<typename... Args>
PythonObject call(PythonObject from, const std::string& f, Args... args)
{
auto pargs = std::vector<PythonObject>();
auto kwargs = std::vector<std::pair<std::string, PythonObject>>();
detail::appendArgs(pargs, kwargs, args...);
return callWithArgs(from, f, pargs, kwargs);
}
template<typename... Args>
PythonObject PythonObject::call(const std::string& f, Args... args)
{
return wrappy::call(*this, f, args...);
}
} // end namespace wrappy
| 2,083
|
C++
|
.h
| 68
| 27.794118
| 74
| 0.718781
|
lava/wrappy
| 121
| 14
| 3
|
GPL-2.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
751,009
|
main.cpp
|
dimkanovikov_WidgetAnimationFramework/demo/main.cpp
|
/*
* Copyright (C) 2015 Dimka Novikov, to@dimkanovikov.pro
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* Full license: https://github.com/dimkanovikov/WidgetAnimationFramework/blob/master/LICENSE
*/
#include <QApplication>
#include <QDebug>
#include <QFrame>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QResizeEvent>
#include <QScrollBar>
#include <QStackedWidget>
#include <QTabBar>
#include <QTextEdit>
#include <QTimer>
#include <QToolButton>
#include <QVBoxLayout>
#include <Animation/Animation.h>
#include <StackedWidgetAnimation/StackedWidgetAnimation.h>
class NotifyMessage : public QFrame
{
public:
explicit NotifyMessage(const QString& _message, QWidget* _parent = 0) : QFrame(_parent) {
setProperty("notifyMessage", true);
QLabel* message = new QLabel(_message, this);
message->setProperty("notifyMessage", true);
message->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
message->setWordWrap(true);
QToolButton* close = new QToolButton(this);
close->setIcon(QIcon(":/close.png"));
QHBoxLayout* layout = new QHBoxLayout(this);
layout->addWidget(message);
layout->addWidget(close);
QObject::connect(close, &QToolButton::clicked, this, &NotifyMessage::hideMessage);
setMaximumHeight(0);
m_lastHeight = 0;
QTimer* timer = new QTimer(this);
QObject::connect(timer, &QTimer::timeout, [=] {
if (m_lastHeight != maximumHeight()) {
int delta = maximumHeight() - m_lastHeight;
m_lastHeight = maximumHeight();
parentWidget()->resize(parentWidget()->width(), parentWidget()->height() + delta);
parentWidget()->move(parentWidget()->pos().x(), parentWidget()->pos().y() - delta);
}
});
timer->start(10);
}
void showMessage() {
WAF::Animation::slideIn(this, WAF::FromBottomToTop, false);
QTimer::singleShot(5000, this, &NotifyMessage::hideMessage);
}
void hideMessage() {
WAF::Animation::slideOut(this, WAF::FromBottomToTop, false);
}
private:
int m_lastHeight;
};
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget w;
//
// Настроим главную панель
//
QFrame* mainToolbar = new QFrame(&w);
mainToolbar->setProperty("toolbar", true);
mainToolbar->setFrameShape(QFrame::StyledPanel);
QToolButton* mainToolbarMenuButton = new QToolButton(mainToolbar);
mainToolbarMenuButton->setIcon(QIcon(":/menu.png"));
QLabel* mainToolbarTitle = new QLabel("<b>Widgets Animation Framework demo</b>", mainToolbar);
QHBoxLayout* mainToolbarLayout = new QHBoxLayout(mainToolbar);
mainToolbarLayout->setContentsMargins(QMargins());
mainToolbarLayout->setSpacing(10);
mainToolbarLayout->addWidget(mainToolbarMenuButton);
mainToolbarLayout->addWidget(mainToolbarTitle);
//
// Настроим вкладки
//
QTabBar* tabs = new QTabBar(&w);
tabs->addTab("TEXT");
tabs->addTab("CREDITS");
//
// Настроим главный виджет
//
QStackedWidget* pages = new QStackedWidget(&w);
//
// ... настроим страницу с текстом
//
QTextEdit* textEdit = new QTextEdit(&w);
textEdit->document()->setDocumentMargin(20);
textEdit->setHtml(
"<h1>WAF</h1>"
"<h2>Widgets Animation Framework</h2>"
"<p>Let you implement rich user interface interactions "
"for applications based on Qt Widgets.</p>"
"<h3>Side Sliding Animation</h3>"
"<p>Slide widget from side of application and make background little darker for accent attension to slided widget. To do it just call</p>"
"<p><pre>WAF::Animation::sideSlide</pre></p>"
"<p>with your cool widget for slide and set application side from which their must slide.</p>"
"<h3>Sliding Animation</h3>"
"<p>Expand or collapse widgets in it's layout. Just call</p>"
"<p><pre>WAF::Animation::slide</pre></p>"
"<p>and set sliding direction."
"<p></p>"
);
pages->addWidget(textEdit);
//
// ... настроим страницу о программе
//
QPushButton* creditsInfo = new QPushButton(&w);
creditsInfo->setText("DimkaNovikov labs.");
pages->addWidget(creditsInfo);
//
// Настроим компоновку
//
QVBoxLayout* mainLayout = new QVBoxLayout(&w);
mainLayout->setContentsMargins(QMargins());
mainLayout->setSpacing(0);
mainLayout->addWidget(mainToolbar);
mainLayout->addWidget(tabs);
mainLayout->addWidget(pages);
//
// Настроим меню
//
QFrame* menu = new QFrame(&w);
menu->setProperty("menu", true);
menu->setFixedWidth(300);
//
// ... панель меню
//
QFrame* menuToolbar = new QFrame(menu);
menuToolbar->setFrameShape(QFrame::StyledPanel);
QToolButton* menuToolbarBackButton = new QToolButton(menuToolbar);
menuToolbarBackButton->setIcon(QIcon(":/arrow-left.png"));
QLabel* menuToolbarTitle = new QLabel("<b>Menu</b>", menuToolbar);
QHBoxLayout* menuToolbarLayout = new QHBoxLayout(menuToolbar);
menuToolbarLayout->setContentsMargins(QMargins());
menuToolbarLayout->setSpacing(10);
menuToolbarLayout->addWidget(menuToolbarBackButton);
menuToolbarLayout->addWidget(menuToolbarTitle);
//
QPushButton* menuButtonLogin = new QPushButton("Login", menu);
menuButtonLogin->setProperty("menu", true);
QPushButton* menuButtonNotify = new QPushButton("Notify", menu);
menuButtonNotify->setProperty("menu", true);
QPushButton* menuButtonExit = new QPushButton("Exit", menu);
menuButtonExit->setProperty("menu", true);
QVBoxLayout* menuLayout = new QVBoxLayout(menu);
menuLayout->setContentsMargins(QMargins());
menuLayout->setSpacing(0);
menuLayout->addWidget(menuToolbar);
menuLayout->addWidget(menuButtonLogin);
menuLayout->addWidget(menuButtonNotify);
menuLayout->addWidget(menuButtonExit);
menuLayout->addStretch();
menu->hide();
//
// Панель авторизации
//
QFrame* auth = new QFrame(&w);
auth->setProperty("menu", false);
auth->setFrameShape(QFrame::StyledPanel);
QLineEdit* authUserName = new QLineEdit(auth);
authUserName->setPlaceholderText("User Name");
QLineEdit* authPassword = new QLineEdit(auth);
authPassword->setPlaceholderText("Password");
authPassword->setEchoMode(QLineEdit::Password);
QPushButton* authLoginButton = new QPushButton("Login", auth);
QPushButton* authCancelButton = new QPushButton("Cancel", auth);
QVBoxLayout* authLayout = new QVBoxLayout(auth);
authLayout->addWidget(authUserName);
authLayout->addWidget(authPassword);
QHBoxLayout* authButtonsLayout = new QHBoxLayout;
authButtonsLayout->addWidget(authLoginButton);
authButtonsLayout->addWidget(authCancelButton);
authLayout->addLayout(authButtonsLayout);
auth->hide();
//
// Панель уведомлений
//
QFrame* notify = new QFrame(&w);
notify->setProperty("notifyArea", true);
notify->setFrameShape(QFrame::NoFrame);
NotifyMessage* connectionMessage = new NotifyMessage("Connections estabilished", notify);
NotifyMessage* subscriptionMessage = new NotifyMessage("Subscribe to <b>pro</b> account and get more available features.<br/><br/><a href=\"http://dimkanovikov.pro\">Read more</a>", notify);
QVBoxLayout* notifyLayout = new QVBoxLayout(notify);
notifyLayout->setContentsMargins(QMargins());
notifyLayout->setSpacing(1);
notifyLayout->addWidget(connectionMessage);
notifyLayout->addWidget(subscriptionMessage);
notify->hide();
//
// Настроим соединения
//
QObject::connect(mainToolbarMenuButton, &QToolButton::clicked, [=] {
WAF::Animation::sideSlideIn(menu, WAF::LeftSide);
});
QObject::connect(menuToolbarBackButton, &QToolButton::clicked, [=] {
WAF::Animation::sideSlideOut(menu, WAF::LeftSide);
});
QObject::connect(menuButtonLogin, &QPushButton::clicked, [=] {
WAF::Animation::sideSlideIn(auth, WAF::TopSide);
authUserName->setFocus();
});
QObject::connect(authLoginButton, &QPushButton::clicked, [=] {
WAF::Animation::sideSlideOut(auth, WAF::TopSide);
QString userName = authUserName->text();
if (userName.isEmpty()) {
userName = "Noname";
}
menuButtonLogin->setText("Logged as " + userName);
menuButtonLogin->setEnabled(false);
});
QObject::connect(authCancelButton, &QPushButton::clicked, [=] {
WAF::Animation::sideSlideOut(auth, WAF::TopSide);
});
QObject::connect(menuButtonNotify, &QPushButton::clicked, [=] {
WAF::Animation::sideSlideOut(menu, WAF::LeftSide);
WAF::Animation::sideSlideIn(notify, WAF::BottomSide, false);
QTimer::singleShot(420, Qt::PreciseTimer, [=] {
connectionMessage->showMessage();
QTimer::singleShot(300, subscriptionMessage, &NotifyMessage::showMessage);
});
});
QObject::connect(menuButtonExit, &QPushButton::clicked, &QApplication::quit);
//
// Соединяем вкладки со страницами
//
QObject::connect(tabs, &QTabBar::currentChanged, [=] (int _showWidgetIndex) {
WAF::StackedWidgetAnimation::fadeIn(pages, pages->widget(_showWidgetIndex));
});
//
// Скрываем или показываем тулбар и вкладки, в зависимости от направления прокрутки текстового редактора
//
QObject::connect(textEdit->verticalScrollBar(), &QScrollBar::valueChanged, [=] (int _currentScrollPosition) {
static int lastScrollPosition = 0;
static int lastScrollMaximum = textEdit->verticalScrollBar()->maximum();
if (lastScrollMaximum == textEdit->verticalScrollBar()->maximum()) {
//
// Прокрутка вниз
//
if (lastScrollPosition < _currentScrollPosition) {
if (mainToolbar->height() > 0) {
WAF::Animation::slideOut(mainToolbar, WAF::FromTopToBottom);
WAF::Animation::slideOut(tabs, WAF::FromTopToBottom);
}
}
//
// Прокрутка вверх
//
else {
if (mainToolbar->height() == 0) {
WAF::Animation::slideIn(mainToolbar, WAF::FromTopToBottom);
WAF::Animation::slideIn(tabs, WAF::FromTopToBottom);
}
}
}
lastScrollPosition = _currentScrollPosition;
lastScrollMaximum = textEdit->verticalScrollBar()->maximum();
});
QObject::connect(creditsInfo, &QPushButton::clicked, [=] {
static int i = 2;
WAF::Animation::circleFill(creditsInfo, creditsInfo->rect().topRight(), QColor("#66C966"), (i++ % 2 == 0));
});
//
// Настроим и покажем приложение
//
w.setStyleSheet(
"QAbstractButton { outline: none; }"
"QToolButton { border: none; min-width: 40px; min-height: 40px; icon-size: 24px; }"
"QTextEdit { border: none; }"
"QPushButton[menu=true] { text-align: left; background-color: white; border: none; border-bottom: 1px solid palette(dark); padding: 8px; }"
"QFrame[toolbar=true] { background-color: #66C966; }"
"QFrame[menu=false] { background-color: palette(window); }"
"QFrame[menu=true] { background-color: white; border: none; border-right: 1px solid palette(dark); }"
"QFrame[notifyArea=true] { background-color: white; }"
"QFrame[notifyMessage=true] { background-color: #232323; color: white; }"
"QLabel[notifyMessage=true] { background-color: #232323; color: white; }"
);
w.resize(400, 400);
w.show();
return a.exec();
}
| 11,446
|
C++
|
.cpp
| 295
| 35.057627
| 191
| 0.744445
|
dimkanovikov/WidgetAnimationFramework
| 119
| 47
| 0
|
LGPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
751,010
|
StackedWidgetAnimation.cpp
|
dimkanovikov_WidgetAnimationFramework/src/StackedWidgetAnimation/StackedWidgetAnimation.cpp
|
/*
* Copyright (C) 2015 Dimka Novikov, to@dimkanovikov.pro
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* Full license: https://github.com/dimkanovikov/WidgetAnimationFramework/blob/master/LICENSE
*/
#include "../AbstractAnimator.h"
#include "StackedWidgetAnimation.h"
#include "StackedWidgetAnimationPrivate.h"
#include "StackedWidgetSlide/StackedWidgetSlideAnimator.h"
#include "StackedWidgetSlideOver/StackedWidgetSlideOverAnimator.h"
#include "StackedWidgetFadeIn/StackedWidgetFadeInAnimator.h"
using WAF::StackedWidgetAnimation;
using WAF::StackedWidgetAnimationPrivate;
using WAF::AbstractAnimator;
using WAF::StackedWidgetSlideAnimator;
using WAF::StackedWidgetSlideOverAnimator;
using WAF::StackedWidgetFadeInAnimator;
void StackedWidgetAnimation::slide(QStackedWidget* _container, QWidget* _widget, WAF::AnimationDirection _direction)
{
const StackedWidgetAnimationPrivate::AnimatorType animatorType = StackedWidgetAnimationPrivate::Slide;
AbstractAnimator* animator = 0;
if (pimpl()->hasAnimator(_widget, animatorType)) {
animator = pimpl()->animator(_widget, animatorType);
if (StackedWidgetSlideAnimator* slideAnimator = qobject_cast<StackedWidgetSlideAnimator*>(animator)) {
slideAnimator->setAnimationDirection(_direction);
}
} else {
StackedWidgetSlideAnimator* slideAnimator = new StackedWidgetSlideAnimator(_container, _widget);
slideAnimator->setAnimationDirection(_direction);
animator = slideAnimator;
pimpl()->saveAnimator(_widget, animator, animatorType);
}
animator->animateForward();
}
void StackedWidgetAnimation::slideOverIn(QStackedWidget* _container, QWidget* _widget, WAF::AnimationDirection _direction)
{
const bool IN = true;
slideOver(_container, _widget, _direction, IN);
}
void StackedWidgetAnimation::slideOverOut(QStackedWidget* _container, QWidget* _widget, WAF::AnimationDirection _direction)
{
const bool OUT = false;
slideOver(_container, _widget, _direction, OUT);
}
void StackedWidgetAnimation::slideOver(QStackedWidget* _container, QWidget* _widget, WAF::AnimationDirection _direction, bool _in)
{
const StackedWidgetAnimationPrivate::AnimatorType animatorType = StackedWidgetAnimationPrivate::SlideOver;
AbstractAnimator* animator = 0;
if (pimpl()->hasAnimator(_widget, animatorType)) {
animator = pimpl()->animator(_widget, animatorType);
if (StackedWidgetSlideOverAnimator* slideOverAnimator = qobject_cast<StackedWidgetSlideOverAnimator*>(animator)) {
if (_in) {
slideOverAnimator->updateCoveredWidget();
}
slideOverAnimator->setAnimationDirection(_direction);
}
} else {
StackedWidgetSlideOverAnimator* slideOverAnimator = new StackedWidgetSlideOverAnimator(_container, _widget);
slideOverAnimator->setAnimationDirection(_direction);
animator = slideOverAnimator;
pimpl()->saveAnimator(_widget, animator, animatorType);
}
if (_in) {
animator->animateForward();
} else {
animator->animateBackward();
}
}
int StackedWidgetAnimation::fadeIn(QStackedWidget* _container, QWidget* _widget)
{
const StackedWidgetAnimationPrivate::AnimatorType animatorType = StackedWidgetAnimationPrivate::FadeIn;
AbstractAnimator* animator = 0;
if (pimpl()->hasAnimator(_widget, animatorType)) {
animator = pimpl()->animator(_widget, animatorType);
} else {
StackedWidgetFadeInAnimator* fadeInAnimator = new StackedWidgetFadeInAnimator(_container, _widget);
animator = fadeInAnimator;
pimpl()->saveAnimator(_widget, animator, animatorType);
}
animator->animateForward();
return animator->animationDuration();
}
StackedWidgetAnimationPrivate* StackedWidgetAnimation::m_pimpl = 0;
StackedWidgetAnimationPrivate* StackedWidgetAnimation::pimpl()
{
if (m_pimpl == 0) {
m_pimpl = new StackedWidgetAnimationPrivate;
}
return m_pimpl;
}
| 4,601
|
C++
|
.cpp
| 100
| 40.03
| 131
| 0.73952
|
dimkanovikov/WidgetAnimationFramework
| 119
| 47
| 0
|
LGPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
751,011
|
StackedWidgetSlideAnimator.cpp
|
dimkanovikov_WidgetAnimationFramework/src/StackedWidgetAnimation/StackedWidgetSlide/StackedWidgetSlideAnimator.cpp
|
/*
* Copyright (C) 2015 Dimka Novikov, to@dimkanovikov.pro
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* Full license: https://github.com/dimkanovikov/WidgetAnimationFramework/blob/master/LICENSE
*/
#include "StackedWidgetSlideAnimator.h"
#include "StackedWidgetSlideDecorator.h"
#include <QEvent>
#include <QPropertyAnimation>
#include <QStackedWidget>
using WAF::StackedWidgetSlideAnimator;
using WAF::StackedWidgetSlideDecorator;
StackedWidgetSlideAnimator::StackedWidgetSlideAnimator(QStackedWidget* _container, QWidget* _widgetForSlide) :
AbstractAnimator(_container),
m_direction(WAF::FromLeftToRight),
m_containerDecorator(new StackedWidgetSlideDecorator(_container, _container->currentWidget())),
m_widgetDecorator(new StackedWidgetSlideDecorator(_container, _widgetForSlide)),
m_containerAnimation(new QPropertyAnimation(m_containerDecorator, "pos")),
m_widgetAnimation(new QPropertyAnimation(m_widgetDecorator, "pos"))
{
Q_ASSERT(_container);
Q_ASSERT(_widgetForSlide);
_container->installEventFilter(this);
m_containerAnimation->setDuration(400);
m_widgetAnimation->setDuration(400);
m_containerDecorator->hide();
m_widgetDecorator->hide();
connect(m_widgetAnimation, &QPropertyAnimation::finished, [=] {
setAnimatedStopped();
_container->setCurrentWidget(_widgetForSlide);
m_containerDecorator->hide();
m_widgetDecorator->hide();
});
}
void StackedWidgetSlideAnimator::setAnimationDirection(WAF::AnimationDirection _direction)
{
if (m_direction != _direction) {
m_direction = _direction;
}
}
int StackedWidgetSlideAnimator::animationDuration() const
{
return m_containerAnimation->duration();
}
void StackedWidgetSlideAnimator::animateForward()
{
slide();
}
void StackedWidgetSlideAnimator::slide()
{
//
// Прерываем выполнение, если клиент хочет повторить его
//
if (isAnimated() && isAnimatedForward()) return;
setAnimatedForward();
//
// Обновляем изображения виджетов в декораторах
//
m_containerDecorator->grabContainer();
m_widgetDecorator->grabWidget();
//
// Определим стартовые и финальные позиции для декораций
//
QPoint containerStartPos;
QPoint containerFinalPos;
QPoint widgetStartPos;
QPoint widgetFinalPos;
switch (m_direction) {
default:
case WAF::FromLeftToRight: {
containerFinalPos.setX(widgetForSlide()->width());
widgetStartPos.setX(-1 * widgetForSlide()->width());
break;
}
case WAF::FromRightToLeft: {
containerFinalPos.setX(-1 * widgetForSlide()->width());
widgetStartPos.setX(widgetForSlide()->width());
break;
}
case WAF::FromTopToBottom: {
containerFinalPos.setY(widgetForSlide()->height());
widgetStartPos.setY(-1 * widgetForSlide()->height());
break;
}
case WAF::FromBottomToTop: {
containerFinalPos.setY(-1 * widgetForSlide()->height());
widgetStartPos.setY(widgetForSlide()->height());
break;
}
}
//
// Позиционируем декораторы
//
m_containerDecorator->move(containerStartPos);
m_containerDecorator->show();
m_containerDecorator->raise();
m_widgetDecorator->move(widgetStartPos);
m_widgetDecorator->show();
m_widgetDecorator->raise();
//
// Выкатываем виджет
//
if (m_widgetAnimation->state() == QPropertyAnimation::Running) {
//
// ... если ещё не закончилась предыдущая анимация реверсируем её
//
m_containerAnimation->pause();
m_containerAnimation->setDirection(QPropertyAnimation::Backward);
m_containerAnimation->resume();
m_widgetAnimation->pause();
m_widgetAnimation->setDirection(QPropertyAnimation::Backward);
m_widgetAnimation->resume();
} else {
//
// ... если предыдущая анимация закончилась, запускаем новую анимацию
//
m_containerAnimation->setEasingCurve(QEasingCurve::InOutExpo);
m_containerAnimation->setDirection(QPropertyAnimation::Forward);
m_containerAnimation->setStartValue(containerStartPos);
m_containerAnimation->setEndValue(containerFinalPos);
m_widgetAnimation->setEasingCurve(QEasingCurve::InOutExpo);
m_widgetAnimation->setDirection(QPropertyAnimation::Forward);
m_widgetAnimation->setStartValue(widgetStartPos);
m_widgetAnimation->setEndValue(widgetFinalPos);
m_containerAnimation->start();
m_widgetAnimation->start();
}
}
bool StackedWidgetSlideAnimator::eventFilter(QObject* _object, QEvent* _event)
{
if (_object == widgetForSlide()
&& _event->type() == QEvent::Resize
&& m_containerDecorator->isVisible()
&& m_widgetDecorator->isVisible()) {
m_containerDecorator->grabWidget();
m_widgetDecorator->grabWidget();
}
return QObject::eventFilter(_object, _event);
}
QWidget* StackedWidgetSlideAnimator::widgetForSlide() const
{
return qobject_cast<QWidget*>(parent());
}
| 5,564
|
C++
|
.cpp
| 153
| 30.986928
| 111
| 0.755459
|
dimkanovikov/WidgetAnimationFramework
| 119
| 47
| 0
|
LGPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
751,012
|
StackedWidgetSlideOverAnimator.cpp
|
dimkanovikov_WidgetAnimationFramework/src/StackedWidgetAnimation/StackedWidgetSlideOver/StackedWidgetSlideOverAnimator.cpp
|
/*
* Copyright (C) 2015 Dimka Novikov, to@dimkanovikov.pro
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* Full license: https://github.com/dimkanovikov/WidgetAnimationFramework/blob/master/LICENSE
*/
#include "StackedWidgetSlideOverAnimator.h"
#include "StackedWidgetSlideOverDecorator.h"
#include <QEvent>
#include <QPropertyAnimation>
#include <QStackedWidget>
using WAF::StackedWidgetSlideOverAnimator;
using WAF::StackedWidgetSlideOverDecorator;
StackedWidgetSlideOverAnimator::StackedWidgetSlideOverAnimator(QStackedWidget* _container, QWidget* _widgetForSlide) :
AbstractAnimator(_container),
m_direction(WAF::FromLeftToRight),
m_coveredWidget(_container->currentWidget()),
m_decorator(new StackedWidgetSlideOverDecorator(_container, _widgetForSlide)),
m_animation(new QPropertyAnimation(m_decorator, "pos"))
{
Q_ASSERT(_container);
Q_ASSERT(_widgetForSlide);
_container->installEventFilter(this);
m_animation->setDuration(400);
m_decorator->hide();
connect(m_animation, &QPropertyAnimation::finished, [=] {
setAnimatedStopped();
if (isAnimatedForward()) {
_container->setCurrentWidget(_widgetForSlide);
}
m_decorator->hide();
});
}
void StackedWidgetSlideOverAnimator::updateCoveredWidget()
{
m_coveredWidget = stackedWidget()->currentWidget();
}
void StackedWidgetSlideOverAnimator::setAnimationDirection(WAF::AnimationDirection _direction)
{
if (m_direction != _direction) {
m_direction = _direction;
}
}
int StackedWidgetSlideOverAnimator::animationDuration() const
{
return m_animation->duration();
}
void StackedWidgetSlideOverAnimator::animateForward()
{
slideOverIn();
}
void StackedWidgetSlideOverAnimator::slideOverIn()
{
//
// Прерываем выполнение, если клиент хочет повторить его
//
if (isAnimated() && isAnimatedForward()) return;
setAnimatedForward();
//
// Обновляем изображение виджета в декораторе
//
m_decorator->grabWidget();
//
// Определим стартовую и финальную позиции для декорации
//
QPoint startPos;
QPoint finalPos;
switch (m_direction) {
default:
case WAF::FromLeftToRight: {
startPos.setX(-1 * stackedWidget()->width());
break;
}
case WAF::FromRightToLeft: {
startPos.setX(stackedWidget()->width());
break;
}
case WAF::FromTopToBottom: {
startPos.setY(-1 * stackedWidget()->height());
break;
}
case WAF::FromBottomToTop: {
startPos.setY(stackedWidget()->height());
break;
}
}
//
// Позиционируем декоратор
//
m_decorator->show();
m_decorator->raise();
//
// Выкатываем виджет
//
if (m_animation->state() == QPropertyAnimation::Running) {
//
// ... если ещё не закончилась предыдущая анимация реверсируем её
//
m_animation->pause();
m_animation->setDirection(QPropertyAnimation::Backward);
m_animation->resume();
} else {
//
// ... если предыдущая анимация закончилась, запускаем новую анимацию
//
m_animation->setEasingCurve(QEasingCurve::InOutExpo);
m_animation->setDirection(QPropertyAnimation::Forward);
m_animation->setStartValue(startPos);
m_animation->setEndValue(finalPos);
m_animation->start();
}
}
void StackedWidgetSlideOverAnimator::animateBackward()
{
slideOverOut();
}
void StackedWidgetSlideOverAnimator::slideOverOut()
{
//
// Прерываем выполнение, если клиент хочет повторить его
//
if (isAnimated() && isAnimatedBackward()) return;
setAnimatedBackward();
//
// Обновляем изображение виджета в декораторе
//
m_decorator->grabWidget();
//
// Определим стартовую и финальную позиции для декорации
//
QPoint startPos;
QPoint finalPos;
switch (m_direction) {
default:
case WAF::FromLeftToRight: {
finalPos.setX(-1 * stackedWidget()->width());
break;
}
case WAF::FromRightToLeft: {
finalPos.setX(stackedWidget()->width());
break;
}
case WAF::FromTopToBottom: {
finalPos.setY(-1 * stackedWidget()->height());
break;
}
case WAF::FromBottomToTop: {
finalPos.setY(stackedWidget()->height());
break;
}
}
//
// Делаем виджет, над которым мы выкатывали текущий, активным
//
if (QStackedWidget* container = qobject_cast<QStackedWidget*>(stackedWidget())) {
container->setCurrentWidget(m_coveredWidget);
}
//
// Позиционируем декоратор
//
m_decorator->show();
m_decorator->raise();
//
// Закатываем виджет
//
if (m_animation->state() == QPropertyAnimation::Running) {
//
// ... если ещё не закончилась предыдущая анимация реверсируем её
//
m_animation->pause();
m_animation->setDirection(QPropertyAnimation::Backward);
m_animation->resume();
} else {
//
// ... если предыдущая анимация закончилась, запускаем новую анимацию
//
m_animation->setEasingCurve(QEasingCurve::InOutExpo);
m_animation->setDirection(QPropertyAnimation::Forward);
m_animation->setStartValue(startPos);
m_animation->setEndValue(finalPos);
m_animation->start();
}
}
bool StackedWidgetSlideOverAnimator::eventFilter(QObject* _object, QEvent* _event)
{
if (_object == stackedWidget()
&& _event->type() == QEvent::Resize
&& m_decorator->isVisible()) {
m_decorator->grabWidget();
}
return QObject::eventFilter(_object, _event);
}
QStackedWidget* StackedWidgetSlideOverAnimator::stackedWidget() const
{
return qobject_cast<QStackedWidget*>(parent());
}
| 6,538
|
C++
|
.cpp
| 205
| 25.360976
| 119
| 0.725972
|
dimkanovikov/WidgetAnimationFramework
| 119
| 47
| 0
|
LGPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
751,013
|
StackedWidgetFadeInDecorator.cpp
|
dimkanovikov_WidgetAnimationFramework/src/StackedWidgetAnimation/StackedWidgetFadeIn/StackedWidgetFadeInDecorator.cpp
|
/*
* Copyright (C) 2015 Dimka Novikov, to@dimkanovikov.pro
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* Full license: https://github.com/dimkanovikov/WidgetAnimationFramework/blob/master/LICENSE
*/
#include "StackedWidgetFadeInDecorator.h"
#include <QPainter>
#include <QStackedWidget>
using WAF::StackedWidgetFadeInDecorator;
StackedWidgetFadeInDecorator::StackedWidgetFadeInDecorator(QWidget* _parent, QWidget* _fadeWidget) :
QWidget(_parent),
m_opacity(1),
m_fadeWidget(_fadeWidget)
{
grabFadeWidget();
}
qreal StackedWidgetFadeInDecorator::opacity() const
{
return m_opacity;
}
void StackedWidgetFadeInDecorator::setOpacity(qreal _opacity)
{
if (m_opacity != _opacity) {
m_opacity = _opacity;
update();
}
}
void StackedWidgetFadeInDecorator::grabContainer()
{
if (QStackedWidget* container = qobject_cast<QStackedWidget*>(parentWidget())) {
m_containerPixmap = grabWidget(container->currentWidget());
}
}
void StackedWidgetFadeInDecorator::grabFadeWidget()
{
m_fadeWidgetPixmap = grabWidget(m_fadeWidget);
}
void StackedWidgetFadeInDecorator::paintEvent(QPaintEvent* _event)
{
QPainter painter(this);
painter.drawPixmap(0, 0, m_containerPixmap);
painter.setOpacity(m_opacity);
painter.drawPixmap(0, 0, m_fadeWidgetPixmap);
QWidget::paintEvent(_event);
}
QPixmap StackedWidgetFadeInDecorator::grabWidget(QWidget* _widgetForGrab)
{
const QSize size = parentWidget()->size();
_widgetForGrab->resize(size);
resize(size);
QPixmap widgetPixmap(size);
_widgetForGrab->render(&widgetPixmap, QPoint(), QRegion(QRect(QPoint(), size)));
return widgetPixmap;
}
| 2,137
|
C++
|
.cpp
| 64
| 30.3125
| 101
| 0.766748
|
dimkanovikov/WidgetAnimationFramework
| 119
| 47
| 0
|
LGPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
751,014
|
StackedWidgetFadeInAnimator.cpp
|
dimkanovikov_WidgetAnimationFramework/src/StackedWidgetAnimation/StackedWidgetFadeIn/StackedWidgetFadeInAnimator.cpp
|
/*
* Copyright (C) 2015 Dimka Novikov, to@dimkanovikov.pro
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* Full license: https://github.com/dimkanovikov/WidgetAnimationFramework/blob/master/LICENSE
*/
#include "StackedWidgetFadeInAnimator.h"
#include "StackedWidgetFadeInDecorator.h"
#include <QEvent>
#include <QPropertyAnimation>
#include <QStackedWidget>
using WAF::StackedWidgetFadeInAnimator;
using WAF::StackedWidgetFadeInDecorator;
StackedWidgetFadeInAnimator::StackedWidgetFadeInAnimator(QStackedWidget* _container, QWidget* _fadeWidget) :
AbstractAnimator(_container),
m_decorator(new StackedWidgetFadeInDecorator(_container, _fadeWidget)),
m_animation(new QPropertyAnimation(m_decorator, "opacity"))
{
Q_ASSERT(_container);
Q_ASSERT(_fadeWidget);
_container->installEventFilter(this);
m_animation->setDuration(200);
m_decorator->hide();
connect(m_animation, &QPropertyAnimation::finished, [=] {
setAnimatedStopped();
if (m_animation->direction() == QPropertyAnimation::Forward) {
_container->setCurrentWidget(_fadeWidget);
}
m_decorator->hide();
});
}
int StackedWidgetFadeInAnimator::animationDuration() const
{
return m_animation->duration();
}
void StackedWidgetFadeInAnimator::animateForward()
{
fadeIn();
}
void StackedWidgetFadeInAnimator::fadeIn()
{
//
// Прерываем выполнение, если клиент хочет повторить его
//
if (isAnimated() && isAnimatedForward()) return;
setAnimatedForward();
//
// Обновляем изображения виджетов в декораторах
//
m_decorator->grabContainer();
m_decorator->grabFadeWidget();
//
// Определим стартовые и финальные позиции для декораций
//
qreal startOpacity = 0.;
qreal finalOpacity = 1.;
//
// Позиционируем декораторы
//
m_decorator->setOpacity(startOpacity);
m_decorator->move(0, 0);
m_decorator->show();
m_decorator->raise();
//
// Анимируем виджет
//
if (m_animation->state() == QPropertyAnimation::Running) {
//
// ... если ещё не закончилась предыдущая анимация реверсируем её
//
m_animation->pause();
m_animation->setDirection(QPropertyAnimation::Backward);
m_animation->resume();
} else {
//
// ... если предыдущая анимация закончилась, запускаем новую анимацию
//
m_animation->setEasingCurve(QEasingCurve::InQuad);
m_animation->setDirection(QPropertyAnimation::Forward);
m_animation->setStartValue(startOpacity);
m_animation->setEndValue(finalOpacity);
m_animation->start();
}
}
bool StackedWidgetFadeInAnimator::eventFilter(QObject* _object, QEvent* _event)
{
if (_object == fadeWidget()
&& _event->type() == QEvent::Resize
&& m_decorator->isVisible()) {
m_decorator->grabContainer();
m_decorator->grabFadeWidget();
}
return QObject::eventFilter(_object, _event);
}
QWidget* StackedWidgetFadeInAnimator::fadeWidget() const
{
return qobject_cast<QWidget*>(parent());
}
| 3,698
|
C++
|
.cpp
| 107
| 28.598131
| 109
| 0.741443
|
dimkanovikov/WidgetAnimationFramework
| 119
| 47
| 0
|
LGPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| false
| false
|
751,016
|
StackedWidgetAnimation.h
|
dimkanovikov_WidgetAnimationFramework/src/StackedWidgetAnimation/StackedWidgetAnimation.h
|
/*
* Copyright (C) 2015 Dimka Novikov, to@dimkanovikov.pro
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* Full license: https://github.com/dimkanovikov/WidgetAnimationFramework/blob/master/LICENSE
*/
#ifndef STACKEDWIDGETANIMATION_H
#define STACKEDWIDGETANIMATION_H
#include "../WAF.h"
class QColor;
class QRect;
class QStackedWidget;
class QWidget;
/**
* Widgets Animation Framework
*/
namespace WAF
{
/**
* @brief Данные фасада
*/
class StackedWidgetAnimationPrivate;
/**
* @brief Фасад доступа к анимациям
*/
class StackedWidgetAnimation
{
public:
/**
* @brief Выкатить заданный виджет, смещая текущий активный
*/
static void slide(QStackedWidget* _container, QWidget* _widget, AnimationDirection _direction);
/****/
/**
* @brief Выкатить заданный виджет поверх текущего
*/
static void slideOverIn(QStackedWidget* _container, QWidget* _widget, AnimationDirection _direction);
/**
* @brief Закатить заданный виджет поверх текущего
*/
static void slideOverOut(QStackedWidget* _container, QWidget* _widget, AnimationDirection _direction);
/**
* @brief Выкатить или закатить заданный виджет поверх текущего
*/
static void slideOver(QStackedWidget* _container, QWidget* _widget, AnimationDirection _direction, bool _in);
/****/
/**
* @brief Текущий виджет растворяется, а заданный виджет появляется
*/
static int fadeIn(QStackedWidget* _container, QWidget* _widget);
private:
/**
* @brief Данные
*/
/** @{ */
static StackedWidgetAnimationPrivate* m_pimpl;
static StackedWidgetAnimationPrivate* pimpl();
/** @} */
};
}
#endif // STACKEDWIDGETANIMATION_H
| 2,662
|
C++
|
.h
| 70
| 27.571429
| 118
| 0.658737
|
dimkanovikov/WidgetAnimationFramework
| 119
| 47
| 0
|
LGPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
751,017
|
StackedWidgetSlideAnimator.h
|
dimkanovikov_WidgetAnimationFramework/src/StackedWidgetAnimation/StackedWidgetSlide/StackedWidgetSlideAnimator.h
|
/*
* Copyright (C) 2015 Dimka Novikov, to@dimkanovikov.pro
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* Full license: https://github.com/dimkanovikov/WidgetAnimationFramework/blob/master/LICENSE
*/
#ifndef STACKEDWIDGETSLIDEANIMATOR_H
#define STACKEDWIDGETSLIDEANIMATOR_H
#include "../../WAF.h"
#include "../../AbstractAnimator.h"
class QPropertyAnimation;
class QStackedWidget;
/**
* Widgets Animation Framework
*/
namespace WAF
{
class StackedWidgetSlideDecorator;
/**
* @brief Аниматор выдвижения виджета из стека со смещением текущего виджета
*/
class StackedWidgetSlideAnimator : public AbstractAnimator
{
Q_OBJECT
public:
explicit StackedWidgetSlideAnimator(QStackedWidget* _container, QWidget* _widgetForSlide);
/**
* @brief Установить направление выдвижения
*/
void setAnimationDirection(AnimationDirection _direction);
/**
* @brief Длительность анимации
*/
int animationDuration() const;
/**
* @brief Выдвинуть виджет
*/
/** @{ */
void animateForward();
void slide();
/** @} */
/**
* @brief Обратной анимации для данного случая нет
*/
void animateBackward() {}
protected:
/**
* @brief Переопределяется, чтобы корректировать позицию перекрывающего виджета
*/
bool eventFilter(QObject* _object, QEvent* _event);
private:
/**
* @brief Получить виджет, который нужно анимировать
*/
QWidget* widgetForSlide() const;
private:
/**
* @brief Направление, по которому выкатывать виджет
*/
AnimationDirection m_direction;
/**
* @brief Помошники
*/
/** @{ */
StackedWidgetSlideDecorator* m_containerDecorator;
StackedWidgetSlideDecorator* m_widgetDecorator;
/** @} */
/**
* @brief Объекты для анимирования выезжания
*/
/** @{ */
QPropertyAnimation* m_containerAnimation;
QPropertyAnimation* m_widgetAnimation;
/** @} */
};
}
#endif // STACKEDWIDGETSLIDEANIMATOR_H
| 3,126
|
C++
|
.h
| 86
| 24.72093
| 99
| 0.628561
|
dimkanovikov/WidgetAnimationFramework
| 119
| 47
| 0
|
LGPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
751,018
|
StackedWidgetSlideOverAnimator.h
|
dimkanovikov_WidgetAnimationFramework/src/StackedWidgetAnimation/StackedWidgetSlideOver/StackedWidgetSlideOverAnimator.h
|
/*
* Copyright (C) 2015 Dimka Novikov, to@dimkanovikov.pro
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* Full license: https://github.com/dimkanovikov/WidgetAnimationFramework/blob/master/LICENSE
*/
#ifndef STACKEDWIDGETSLIDEOVERANIMATOR_H
#define STACKEDWIDGETSLIDEOVERANIMATOR_H
#include "../../WAF.h"
#include "../../AbstractAnimator.h"
class QPropertyAnimation;
class QStackedWidget;
/**
* Widgets Animation Framework
*/
namespace WAF
{
class StackedWidgetSlideOverDecorator;
/**
* @brief Аниматор выдвижения виджета из стека с наезжанием на текущий виджет
*/
class StackedWidgetSlideOverAnimator : public AbstractAnimator
{
Q_OBJECT
public:
explicit StackedWidgetSlideOverAnimator(QStackedWidget* _container, QWidget* _widgetForSlide);
/**
* @brief Обновить виджет поверх которого будем выезжать
*/
void updateCoveredWidget();
/**
* @brief Установить направление выдвижения
*/
void setAnimationDirection(AnimationDirection _direction);
/**
* @brief Длительность анимации
*/
int animationDuration() const;
/**
* @brief Выдвинуть виджет
*/
/** @{ */
void animateForward();
void slideOverIn();
/** @} */
/**
* @brief Задвинуть виджет
*/
/** @{ */
void animateBackward();
void slideOverOut();
/** @} */
protected:
/**
* @brief Переопределяется, чтобы корректировать позицию перекрывающего виджета
*/
bool eventFilter(QObject* _object, QEvent* _event);
private:
/**
* @brief Получить виджет, который нужно анимировать
*/
QStackedWidget* stackedWidget() const;
private:
/**
* @brief Направление, по которому выкатывать виджет
*/
AnimationDirection m_direction;
/**
* @brief Виджет, поверх которого выкатываем текущий
*/
QWidget* m_coveredWidget;
/**
* @brief Помошники
*/
StackedWidgetSlideOverDecorator* m_decorator;
/**
* @brief Объекты для анимирования выезжания
*/
QPropertyAnimation* m_animation;
};
}
#endif // STACKEDWIDGETSLIDEOVERANIMATOR_H
| 3,324
|
C++
|
.h
| 91
| 24.263736
| 103
| 0.625223
|
dimkanovikov/WidgetAnimationFramework
| 119
| 47
| 0
|
LGPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
751,019
|
StackedWidgetFadeInAnimator.h
|
dimkanovikov_WidgetAnimationFramework/src/StackedWidgetAnimation/StackedWidgetFadeIn/StackedWidgetFadeInAnimator.h
|
/*
* Copyright (C) 2015 Dimka Novikov, to@dimkanovikov.pro
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* Full license: https://github.com/dimkanovikov/WidgetAnimationFramework/blob/master/LICENSE
*/
#ifndef STACKEDWIDGETFADEINANIMATOR_H
#define STACKEDWIDGETFADEINANIMATOR_H
#include "../../WAF.h"
#include "../../AbstractAnimator.h"
class QPropertyAnimation;
class QStackedWidget;
/**
* Widgets Animation Framework
*/
namespace WAF
{
class StackedWidgetFadeInDecorator;
/**
* @brief Аниматор появления виджета из стека с пропаданием текущего виджета
*/
class StackedWidgetFadeInAnimator : public AbstractAnimator
{
Q_OBJECT
public:
explicit StackedWidgetFadeInAnimator(QStackedWidget* _container, QWidget* _fadeWidget);
/**
* @brief Длительность анимации
*/
int animationDuration() const;
/**
* @brief Отобразить виджет
*/
/** @{ */
void animateForward();
void fadeIn();
/** @} */
/**
* @brief Обратной анимации для данного случая нет
*/
void animateBackward() {}
protected:
/**
* @brief Переопределяется, чтобы корректировать позицию перекрывающего виджета
*/
bool eventFilter(QObject* _object, QEvent* _event);
private:
/**
* @brief Получить виджет, который нужно анимировать
*/
QWidget* fadeWidget() const;
private:
/**
* @brief Помошник
*/
StackedWidgetFadeInDecorator* m_decorator;
/**
* @brief Объект для анимирования появления
*/
QPropertyAnimation* m_animation;
};
}
#endif // STACKEDWIDGETFADEINANIMATOR_H
| 2,577
|
C++
|
.h
| 72
| 24.916667
| 96
| 0.645059
|
dimkanovikov/WidgetAnimationFramework
| 119
| 47
| 0
|
LGPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
751,026
|
XmlRpcSource.cpp
|
w1hkj_fldigi/src/xmlrpcpp/XmlRpcSource.cpp
|
// ----------------------------------------------------------------------------
//
// flxmlrpc Copyright (c) 2015 by W1HKJ, Dave Freese <iam_w1hkj@w1hkj.com>
//
// XmlRpc++ Copyright (c) 2002-2008 by Chris Morley
//
// This file is part of fldigi
//
// flxmlrpc is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include <config.h>
#include "XmlRpcSource.h"
#include "XmlRpcUtil.h"
#if defined(_WINDOWS)
#undef _WINSOCKAPI_
# include <stdio.h>
# include <winsock2.h>
#else
extern "C" {
# include <unistd.h>
# include <stdio.h>
}
#endif
#if USE_OPENSSL_XMLRPC
# include <openssl/crypto.h>
# include <openssl/x509.h>
# include <openssl/pem.h>
# include <openssl/ssl.h>
# include <openssl/err.h>
#endif
namespace XmlRpc {
struct SslProxy
{
#if USE_OPENSSL_XMLRPC
SSL_CTX* _ssl_ctx;
SSL_METHOD* _ssl_meth;
SSL* _ssl_ssl;
#endif
};
XmlRpcSource::XmlRpcSource(XmlRpcSocket::Socket fd /*= -1*/, bool deleteOnClose /*= false*/)
: _fd(fd)
, _deleteOnClose(deleteOnClose)
, _keepOpen(false)
, _sslEnabled(false)
, _ssl(0)
{
}
XmlRpcSource::~XmlRpcSource()
{
delete _ssl;
}
void
XmlRpcSource::setSslEnabled(bool b /*=true*/)
{
#if USE_OPENSSL_XMLRPC
_sslEnabled = b;
#endif
}
bool
XmlRpcSource::doConnect()
{
#if USE_OPENSSL_XMLRPC
// Perform SSL if needed
if (_sslEnabled)
{
_ssl = new SslProxy;
SSLeay_add_ssl_algorithms();
_ssl->_ssl_meth = const_cast<SSL_METHOD*>(SSLv23_client_method());
SSL_load_error_strings();
_ssl->_ssl_ctx = SSL_CTX_new(_ssl->_ssl_meth);
_ssl->_ssl_ssl = SSL_new(_ssl->_ssl_ctx);
SSL_set_fd(_ssl->_ssl_ssl, _fd);
return SSL_connect(_ssl->_ssl_ssl) == 1;
}
#endif
return true;
}
// Read available text from the specified socket. Returns false on error.
bool
XmlRpcSource::nbRead(std::string& s, bool *eof)
{
const int READ_SIZE = 4096; // Number of bytes to attempt to read at a time
char readBuf[READ_SIZE];
bool wouldBlock = false;
*eof = false;
while ( ! wouldBlock && ! *eof)
{
int n;
#if USE_OPENSSL_XMLRPC
// Perform SSL if needed
if (_ssl && _ssl->_ssl_ssl)
{
n = SSL_read(_ssl->_ssl_ssl, readBuf, READ_SIZE-1);
}
else
#endif
#if defined(_WINDOWS)
n = recv(_fd, readBuf, READ_SIZE-1, 0);
#else
n = read(_fd, readBuf, READ_SIZE-1);
#endif
XmlRpcUtil::log(5, "XmlRpcSocket::nbRead: read/recv returned %d.", n);
if (n > 0) {
readBuf[n] = 0;
s.append(readBuf, n);
} else if (n == 0) {
*eof = true;
} else if (XmlRpcSocket::nonFatalError()) {
wouldBlock = true;
} else {
return false; // Error
}
}
return true;
}
// Write text to the socket. Returns false on error.
bool
XmlRpcSource::nbWrite(std::string const& s, int *bytesSoFar)
{
int nToWrite = int(s.length()) - *bytesSoFar;
const char *sp = s.c_str() + *bytesSoFar;
bool wouldBlock = false;
while ( nToWrite > 0 && ! wouldBlock )
{
int n;
#if USE_OPENSSL_XMLRPC
// Perform SSL if needed
if (_ssl && _ssl->_ssl_ssl)
{
n = SSL_write(_ssl->_ssl_ssl, sp, nToWrite);
}
else
#endif
#if defined(_WINDOWS)
n = send(_fd, sp, nToWrite, 0);
#else
n = write(_fd, sp, nToWrite);
#endif
XmlRpcUtil::log(5, "XmlRpcSocket::nbWrite: send/write returned %d.", n);
if (n > 0)
{
sp += n;
*bytesSoFar += n;
nToWrite -= n;
}
else if (XmlRpcSocket::nonFatalError())
{
wouldBlock = true;
}
else
{
return false; // Error
}
}
return true;
}
void
XmlRpcSource::close()
{
#if USE_OPENSSL_XMLRPC
if (_ssl && _ssl->_ssl_ssl)
{
SSL_shutdown(_ssl->_ssl_ssl);
// Should close be called here ? ...
SSL_free(_ssl->_ssl_ssl);
SSL_CTX_free(_ssl->_ssl_ctx);
delete _ssl;
_ssl = 0;
}
#endif
if ( (int)_fd != -1)
{
XmlRpcUtil::log(2,"XmlRpcSource::close: closing socket %d.", _fd);
XmlRpcSocket::close(_fd);
_fd = -1;
}
if (_deleteOnClose)
{
XmlRpcUtil::log(2,"XmlRpcSource::close: deleting this");
_deleteOnClose = false;
delete this;
}
}
} // namespace XmlRpc
| 4,783
|
C++
|
.cpp
| 190
| 20.684211
| 95
| 0.584703
|
w1hkj/fldigi
| 109
| 27
| 38
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| true
| false
| false
| true
| true
| false
|
751,031
|
main.cxx
|
w1hkj_fldigi/src/main.cxx
|
// ----------------------------------------------------------------------------
// Digital Modem Program for the Fast Light Toolkit
//
// Copyright 2006-2010, Dave Freese, W1HKJ
// Copyright 2007-2010, Stelios Bounanos, M0GLD
//
// This file is part of fldigi.
//
// Fldigi 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 3 of the License, or
// (at your option) any later version.
//
// Fldigi 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 fldigi. If not, see <http://www.gnu.org/licenses/>.
//
// Please report all bugs and problems to fldigi-devel@lists.sourceforge.net.
// ----------------------------------------------------------------------------
#include <config.h>
//++++++++++++++++++
#include <FL/Fl_Scroll.H>
extern Fl_Scroll *wefax_pic_rx_scroll;
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdlib>
#include <getopt.h>
#include <sys/types.h>
#if !defined(__WOE32__) && !defined(__APPLE__)
# include <sys/ipc.h>
# include <sys/msg.h>
#endif
#ifdef __MINGW32__
# include "compat.h"
#endif
#include <sys/stat.h>
#if HAVE_SYS_UTSNAME_H
# include <sys/utsname.h>
#endif
#include <unistd.h>
#include <exception>
#include <signal.h>
#include <locale.h>
#include <FL/Fl.H>
#include <FL/Enumerations.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Shared_Image.H>
#include <FL/x.H>
#ifdef __MINGW32__
# define dirent fl_dirent_no_thanks
#endif
#include <FL/filename.H>
#ifdef __WOE32__
# if FLDIGI_FLTK_API_MAJOR == 1 && FLDIGI_FLTK_API_MINOR < 3
# undef dirent
# include <dirent.h>
# endif
#else
# include <dirent.h>
#endif
#include "gettext.h"
#include "main.h"
#include "waterfall.h"
#include "trx.h"
#include "soundconf.h"
#include "fl_digi.h"
#include "rigio.h"
#include "globals.h"
#include "confdialog.h"
#include "rxmon.h"
#include "configuration.h"
#include "macros.h"
#include "status.h"
#include "fileselect.h"
#include "timeops.h"
#include "debug.h"
#include "pskrep.h"
#include "notify.h"
#include "logbook.h"
#include "dxcc.h"
#include "newinstall.h"
#include "Viewer.h"
#include "kmlserver.h"
#include "data_io.h"
#include "maclogger.h"
#include "psm/psm.h"
#include "fd_logger.h"
#include "n3fjp_logger.h"
#include "dx_cluster.h"
#include "dx_dialog.h"
#include "record_loader.h"
#if USE_HAMLIB
#include "rigclass.h"
#endif
#include "rigsupport.h"
#include "log.h"
#include "qrunner.h"
#include "stacktrace.h"
#include "xmlrpc.h"
#include "icons.h"
#include "nullmodem.h"
#include "spectrum_viewer.h"
#include "contest.h"
#include "counties.h"
#include "cmedia.h"
#if BENCHMARK_MODE
#include "benchmark.h"
#endif
using namespace std;
string appname;
string scDevice[2];
string BaseDir = "";
string HomeDir = "";
string RigsDir = "";
string ScriptsDir = "";
string PalettesDir = "";
string LogsDir = "";
string PicsDir = "";
string AvatarDir = "";
string HelpDir = "";
string MacrosDir = "";
string WrapDir = "";
string TalkDir = "";
string TempDir = "";
string DebugDir = "";
string LoTWDir = "";
string KmlDir = "";
string PskMailDir = "";
string AnalysisDir = "";
string FMTDir = "";
string NBEMS_dir = "";
string NBEMS_dir_default = "";
string DATA_dir = "";
string ARQ_dir = "";
string ARQ_files_dir = "";
string ARQ_recv_dir = "";
string ARQ_send = "";
string WRAP_dir = "";
string WRAP_recv_dir = "";
string WRAP_send_dir = "";
string WRAP_auto_dir = "";
string ICS_dir = "";
string ICS_msg_dir = "";
string ICS_tmp_dir = "";
string FLMSG_dir = "";
string FLMSG_dir_default = "";
string FLMSG_WRAP_dir = "";
string FLMSG_WRAP_recv_dir = "";
string FLMSG_WRAP_send_dir = "";
string FLMSG_WRAP_auto_dir = "";
string FLMSG_ICS_dir = "";
string FLMSG_ICS_msg_dir = "";
string FLMSG_ICS_tmp_dir = "";
string PskMailFile;
string ArqFilename;
string xmlfname;
PTT *push2talk = (PTT *)0;
#if USE_HAMLIB
Rig *xcvr = (Rig *)0;
#endif
bool tlfio = false;
cLogfile *logfile = 0;
cLogfile *Maillogfile = (cLogfile *)0;
FILE *server;
FILE *client;
bool mailserver = false, mailclient = false, arqmode = false;
static bool show_cpucheck = false;
static bool iconified = false;
string option_help, version_text, build_text;
qrunner *cbq[NUM_QRUNNER_THREADS];
void arqchecks(void);
void generate_option_help(void);
int parse_args(int argc, char **argv, int& idx);
void generate_version_text(void);
void debug_exec(char** argv);
void set_platform_ui(void);
double speed_test(int converter, unsigned repeat);
static void setup_signal_handlers(void);
static void checkdirectories(void);
static void arg_error(const char* name, const char* arg, bool missing);
static void fatal_error(string);
/*
from: https://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
BOOL WINAPI CreateProcess(
_In_opt_ LPCTSTR lpApplicationName,
_Inout_opt_ LPTSTR lpCommandLine,
_In_opt_ LPSECURITY_ATTRIBUTES lpProcessAttributes,
_In_opt_ LPSECURITY_ATTRIBUTES lpThreadAttributes,
_In_ BOOL bInheritHandles,
_In_ DWORD dwCreationFlags,
_In_opt_ LPVOID lpEnvironment,
_In_opt_ LPCTSTR lpCurrentDirectory,
_In_ LPSTARTUPINFO lpStartupInfo,
_Out_ LPPROCESS_INFORMATION lpProcessInformation
);
Parameters
lpApplicationName [in, optional]
The name of the module to be executed. This module can be a Windows-based
application. It can be some other type of module (for example, MS-DOS or OS/2)
if the appropriate subsystem is available on the local computer.
The string can specify the full path and file name of the module to execute
or it can specify a partial name. In the case of a partial name, the function
uses the current drive and current directory to complete the specification.
The function will not use the search path. This parameter must include the
file name extension; no default extension is assumed.
The lpApplicationName parameter can be NULL. In that case, the module name must
be the first white space–delimited token in the lpCommandLine string. If you are
using a long file name that contains a space, use quoted strings to indicate where
the file name ends and the arguments begin; otherwise, the file name is ambiguous.
For example, consider the string "c:\program files\sub dir\program name".
This string can be interpreted in a number of ways. The system tries to interpret
the possibilities in the following order:
c:\program.exe files\sub dir\program name
c:\program files\sub.exe dir\program name
c:\program files\sub dir\program.exe name
c:\program files\sub dir\program name.exe
If the executable module is a 16-bit application, lpApplicationName should be NULL,
and the string pointed to by lpCommandLine should specify the executable module as
well as its arguments.
To run a batch file, you must start the command interpreter; set lpApplicationName
to cmd.exe and set lpCommandLine to the following arguments: /c plus the name of the
batch file.
lpCommandLine [in, out, optional]
The command line to be executed. The maximum length of this string is 32,768
characters, including the Unicode terminating null character. If lpApplicationName
is NULL, the module name portion of lpCommandLine is limited to MAX_PATH characters.
The Unicode version of this function, CreateProcessW, can modify the contents of this
string. Therefore, this parameter cannot be a pointer to read-only memory (such as a
const variable or a literal string). If this parameter is a constant string, the
function may cause an access violation.
The lpCommandLine parameter can be NULL. In that case, the function uses the string
pointed to by lpApplicationName as the command line.
If both lpApplicationName and lpCommandLine are non-NULL, the null-terminated string
pointed to by lpApplicationName specifies the module to execute, and the n
ull-terminated string pointed to by lpCommandLine specifies the command line. The
new process can use GetCommandLine to retrieve the entire command line. Console
processes written in C can use the argc and argv arguments to parse the command line.
Because argv[0] is the module name, C programmers generally repeat the module name
as the first token in the command line.
If lpApplicationName is NULL, the first white space–delimited token of the command
line specifies the module name. If you are using a long file name that contains a
space, use quoted strings to indicate where the file name ends and the arguments
begin (see the explanation for the lpApplicationName parameter). If the file name
does not contain an extension, .exe is appended. Therefore, if the file name
extension is .com, this parameter must include the .com extension. If the file
name ends in a period (.) with no extension, or if the file name contains a path,
.exe is not appended. If the file name does not contain a directory path, the
system searches for the executable file in the following sequence:
The directory from which the application loaded.
The current directory for the parent process.
The 32-bit Windows system directory. Use the GetSystemDirectory function to get
the path of this directory.
The 16-bit Windows system directory. There is no function that obtains the path
of this directory, but it is searched. The name of this directory is System.
The Windows directory. Use the GetWindowsDirectory function to get the path of
this directory.
The directories that are listed in the PATH environment variable. Note that this
function does not search the per-application path specified by the App Paths registry
key. To include this per-application path in the search sequence, use the ShellExecute
function.
The system adds a terminating null character to the command-line string to separate
the file name from the arguments. This divides the original string into two strings
for internal processing.
lpProcessAttributes [in, optional]
A pointer to a SECURITY_ATTRIBUTES structure that determines whether the returned
handle to the new process object can be inherited by child processes. If
lpProcessAttributes is NULL, the handle cannot be inherited.
The lpSecurityDescriptor member of the structure specifies a security descriptor for
the new process. If lpProcessAttributes is NULL or lpSecurityDescriptor is NULL, the
process gets a default security descriptor. The ACLs in the default security descriptor
for a process come from the primary token of the creator.
Windows XP: The ACLs in the default security descriptor for a process come from the
primary or impersonation token of the creator. This behavior changed with Windows XP
with SP2 and Windows Server 2003.
lpThreadAttributes [in, optional]
A pointer to a SECURITY_ATTRIBUTES structure that determines whether the returned
handle to the new thread object can be inherited by child processes. If
lpThreadAttributes is NULL, the handle cannot be inherited.
The lpSecurityDescriptor member of the structure specifies a security descriptor for
the main thread. If lpThreadAttributes is NULL or lpSecurityDescriptor is NULL, the
thread gets a default security descriptor. The ACLs in the default security descriptor
for a thread come from the process token.
Windows XP: The ACLs in the default security descriptor for a thread come from the
primary or impersonation token of the creator. This behavior changed with Windows XP
with SP2 and Windows Server 2003.
bInheritHandles [in]
If this parameter TRUE, each inheritable handle in the calling process is inherited by
the new process. If the parameter is FALSE, the handles are not inherited. Note that
inherited handles have the same value and access rights as the original handles.
dwCreationFlags [in]
The flags that control the priority class and the creation of the process. For a list
of values, see Process Creation Flags.
This parameter also controls the new process's priority class, which is used to
determine the scheduling priorities of the process's threads. For a list of values,
see GetPriorityClass. If none of the priority class flags is specified, the priority
class defaults to NORMAL_PRIORITY_CLASS unless the priority class of the creating
process is IDLE_PRIORITY_CLASS or BELOW_NORMAL_PRIORITY_CLASS. In this case, the
child process receives the default priority class of the calling process.
lpEnvironment [in, optional]
A pointer to the environment block for the new process. If this parameter is NULL,
the new process uses the environment of the calling process.
An environment block consists of a null-terminated block of null-terminated strings.
Each string is in the following form:
name=value\0
Because the equal sign is used as a separator, it must not be used in the name of
an environment variable.
An environment block can contain either Unicode or ANSI characters. If the
environment block pointed to by lpEnvironment contains Unicode characters, be
sure that dwCreationFlags includes CREATE_UNICODE_ENVIRONMENT. If this parameter
is NULL and the environment block of the parent process contains Unicode characters,
you must also ensure that dwCreationFlags includes CREATE_UNICODE_ENVIRONMENT.
The ANSI version of this function, CreateProcessA fails if the total size of the
environment block for the process exceeds 32,767 characters.
Note that an ANSI environment block is terminated by two zero bytes: one for the
last string, one more to terminate the block. A Unicode environment block is
terminated by four zero bytes: two for the last string, two more to terminate
the block.
lpCurrentDirectory [in, optional]
The full path to the current directory for the process. The string can also
specify a UNC path.
If this parameter is NULL, the new process will have the same current drive and
directory as the calling process. (This feature is provided primarily for shells
that need to start an application and specify its initial drive and working
directory.)
lpStartupInfo [in]
A pointer to a STARTUPINFO or STARTUPINFOEX structure.
To set extended attributes, use a STARTUPINFOEX structure and specify
EXTENDED_STARTUPINFO_PRESENT in the dwCreationFlags parameter.
Handles in STARTUPINFO or STARTUPINFOEX must be closed with CloseHandle when
they are no longer needed.
Important The caller is responsible for ensuring that the standard handle
fields in STARTUPINFO contain valid handle values. These fields are copied
unchanged to the child process without validation, even when the dwFlags
member specifies STARTF_USESTDHANDLES. Incorrect values can cause the child
process to misbehave or crash. Use the Application Verifier runtime verification
tool to detect invalid handles.
lpProcessInformation [out]
A pointer to a PROCESS_INFORMATION structure that receives identification
information about the new process.
Handles in PROCESS_INFORMATION must be closed with CloseHandle when they are
no longer needed.
Return value
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information,
call GetLastError.
Note that the function returns before the process has finished initialization. If a
required DLL cannot be located or fails to initialize, the process is terminated. To
get the termination status of a process, call GetExitCodeProcess.
Remarks
The process is assigned a process identifier. The identifier is valid until the
process terminates. It can be used to identify the process, or specified in the
OpenProcess function to open a handle to the process. The initial thread in the
process is also assigned a thread identifier. It can be specified in the OpenThread
function to open a handle to the thread. The identifier is valid until the thread
terminates and can be used to uniquely identify the thread within the system. These
identifiers are returned in the PROCESS_INFORMATION structure.
The name of the executable in the command line that the operating system provides
to a process is not necessarily identical to that in the command line that the
calling process gives to the CreateProcess function. The operating system may
prepend a fully qualified path to an executable name that is provided without
a fully qualified path.
The calling thread can use the WaitForInputIdle function to wait until the new
process has finished its initialization and is waiting for user input with no
input pending. This can be useful for synchronization between parent and child
processes, because CreateProcess returns without waiting for the new process to
finish its initialization. For example, the creating process would use
WaitForInputIdle before trying to find a window associated with the new process.
The preferred way to shut down a process is by using the ExitProcess function,
because this function sends notification of approaching termination to all DLLs
attached to the process. Other means of shutting down a process do not notify
the attached DLLs. Note that when a thread calls ExitProcess, other threads of
the process are terminated without an opportunity to execute any additional code
(including the thread termination code of attached DLLs). For more information,
see Terminating a Process.
A parent process can directly alter the environment variables of a child process
during process creation. This is the only situation when a process can directly
change the environment settings of another process. For more information, see
Changing Environment Variables.
If an application provides an environment block, the current directory information
of the system drives is not automatically propagated to the new process. For
example, there is an environment variable named =C: whose value is the current
directory on drive C. An application must manually pass the current directory
information to the new process. To do so, the application must explicitly create
these environment variable strings, sort them alphabetically (because the system
uses a sorted environment), and put them into the environment block. Typically,
they will go at the front of the environment block, due to the environment block
sort order.
One way to obtain the current directory information for a drive X is to make the
following call: GetFullPathName("X:", ...). That avoids an application having to
scan the environment block. If the full path returned is X:\, there is no need to
pass that value on as environment data, since the root directory is the default
current directory for drive X of a new process.
When a process is created with CREATE_NEW_PROCESS_GROUP specified, an implicit
call to SetConsoleCtrlHandler(NULL,TRUE) is made on behalf of the new process;
this means that the new process has CTRL+C disabled. This lets shells handle
CTRL+C themselves, and selectively pass that signal on to sub-processes.
CTRL+BREAK is not disabled, and may be used to interrupt the process/process group.
Security Remarks
The first parameter, lpApplicationName, can be NULL, in which case the executable
name must be in the white space–delimited string pointed to by lpCommandLine. If
the executable or path name has a space in it, there is a risk that a different
executable could be run because of the way the function parses spaces. The following
example is dangerous because the function will attempt to run "Program.exe", if it
exists, instead of "MyApp.exe".
LPTSTR szCmdline = _tcsdup(TEXT("C:\\Program Files\\MyApp -L -S"));
CreateProcess(NULL, szCmdline, ... );
If a malicious user were to create an application called "Program.exe" on a system,
any program that incorrectly calls CreateProcess using the Program Files directory
will run this application instead of the intended application.
To avoid this problem, do not pass NULL for lpApplicationName. If you do pass NULL
for lpApplicationName, use quotation marks around the executable path in lpCommandLine.
*/
void start_process(string executable)
{
while(executable[executable.length()-1] == ' ')
executable.erase(executable.length()-1);
if (!executable.empty()) {
#ifdef __MINGW32__
static string cmdstr;
cmdstr.assign(executable);
STARTUPINFO si;
PROCESS_INFORMATION pi;
memset(&si, 0, sizeof(si));
si.cb = sizeof(si);
memset(&pi, 0, sizeof(pi));
LOG_INFO("Starting external process: %s", cmdstr.c_str());
if (!CreateProcess( NULL, const_cast<char*>(cmdstr.c_str()),
NULL, NULL,
FALSE, CREATE_NO_WINDOW,
NULL, NULL,
&si, &pi))
LOG_ERROR("CreateProcess failed with error code %ld", GetLastError());
for (int i = 0; i < 5; i++) {
MilliSleep(50);
Fl::awake();
}
// MilliSleep(100);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
LOG_INFO("Process handles closed");
#else
#ifdef __APPLE__
string params = "";
size_t p = executable.find(".app/Contents/MacOS");
if (p == string::npos) {
p = executable.find(".app");
if (p != string::npos) {
params = executable.substr(p+4);
executable.erase(p+4);
if (executable[0] == '"') executable.erase(0,1);
while ( (executable[executable.length()-1] == '"') ||
(executable[executable.length()-1] == ' ') )
executable.erase(executable.length()-1, 1);
if (params[0] == '"') params.erase(0,1);
while (params[0] == ' ') params.erase(0,1);
DIR *dp = NULL;
executable.append("/Contents/MacOS/");
dp = opendir(executable.c_str());
if (!dp) {
fl_alert2("FOLDER NOT FOUND\n\n%s", executable.c_str());
return;
}
struct dirent *sd = NULL;
sd = readdir(dp);
string sds = sd->d_name;
while (sds == "." || sds == "..") { sd = readdir(dp); sds = sd->d_name; }
closedir(dp);
executable.insert(0,"\"");
executable.append(sds).append("\"");
if (!params.empty()) executable.append(" ").append(params);
}
}
#endif // __APPLE__
LOG_INFO("Start external process: %s", executable.c_str());
switch (fork()) {
case -1:
LOG_PERROR("fork");
// fall through
default:
break;
case 0:
execl("/bin/sh", "sh", "-c", executable.c_str(), (char *)NULL);
perror("execl");
exit(EXIT_FAILURE);
}
#endif
}
}
void toggle_io_port_selection(int io_mode)
{
switch(io_mode) {
case ARQ_IO:
enable_arq();
progdefaults.changed = false;
break;
case KISS_IO:
enable_kiss();
if(progdefaults.tcp_udp_auto_connect) {
btn_connect_kiss_io->value(1);
btn_connect_kiss_io->do_callback();
}
if(progdefaults.kpsql_enabled && progdefaults.show_psm_btn) {
btnPSQL->value(progdefaults.kpsql_enabled);
btnPSQL->do_callback();
}
progdefaults.changed = false;
break;
default:
LOG_INFO("Unknown data io mode");
}
}
static void auto_start()
{
bool run_flamp = false;
// Make sure we are in ARQ_IO mode if executing FLAMP
if (!progdefaults.auto_flamp_pathname.empty() &&
progdefaults.flamp_auto_enable) {
toggle_io_port_selection(ARQ_IO);
run_flamp = true;
}
// A general wait to ensure FLDIGI initialization of
// io ports. 1/4 to 3/4 second delay.
int nloops = 0;
while(nloops++ < 15) {// 3) {
MilliSleep(50);
Fl::awake();
// MilliSleep(250);
if(arq_state() && data_io_enabled == ARQ_IO)
break; // Exit early if verified.
}
if (!progdefaults.auto_flrig_pathname.empty() &&
progdefaults.flrig_auto_enable)
start_process(progdefaults.auto_flrig_pathname);
if (run_flamp)
start_process(progdefaults.auto_flamp_pathname);
if (!progdefaults.auto_fllog_pathname.empty() &&
progdefaults.fllog_auto_enable)
start_process(progdefaults.auto_fllog_pathname);
if (!progdefaults.auto_flnet_pathname.empty() &&
progdefaults.flnet_auto_enable)
start_process(progdefaults.auto_flnet_pathname);
if (!progdefaults.auto_prog1_pathname.empty() &&
progdefaults.prog1_auto_enable)
start_process(progdefaults.auto_prog1_pathname);
if (!progdefaults.auto_prog2_pathname.empty() &&
progdefaults.prog2_auto_enable)
start_process(progdefaults.auto_prog2_pathname);
if (!progdefaults.auto_prog3_pathname.empty() &&
progdefaults.prog3_auto_enable)
start_process(progdefaults.auto_prog3_pathname);
}
// reset those default values that have been overriden by a command line parameter
void check_overrides()
{
if (xmlrpc_address_override_flag)
progdefaults.xmlrpc_address = override_xmlrpc_address;
if (xmlrpc_port_override_flag)
progdefaults.xmlrpc_port = override_xmlrpc_port;
if (arq_address_override_flag)
progdefaults.arq_address = override_arq_address;
if (arq_port_override_flag)
progdefaults.arq_port = override_arq_port;
}
// these functions are all started after Fl::run() is executing
void delayed_startup(void *)
{
macros.loadDefault();
connect_to_log_server();
#ifdef __WIN32__
if (progdefaults.auto_talk) open_talker();
#else
grpTalker->hide();
#endif
XML_RPC_Server::start(progdefaults.xmlrpc_address.c_str(), progdefaults.xmlrpc_port.c_str());
FLRIG_start_flrig_thread();
data_io_enabled = DISABLED_IO;
n3fjp_init();
arq_init();
FD_init();
DXcluster_init();
start_psm_thread();
if (progdefaults.connect_to_maclogger) maclogger_init();
data_io_enabled = progStatus.data_io_enabled;
toggle_io_port_selection(data_io_enabled);
disable_config_p2p_io_widgets();
notify_start();
if (progdefaults.pskrep_autostart) {
if (!pskrep_start()) {
LOG_ERROR("Could not start PSK reporter: %s", pskrep_error());
box_connected_to_pskrep->color(FL_WHITE);
} else
box_connected_to_pskrep->color(FL_GREEN);
}
auto_start();
if (progStatus.WK_online) {
if (progStatus.WKFSK_mode) {
btn_WKFSK_connect->value(1);
WKFSK_connect(1);
} else {
btn_WKCW_connect->value(1);
WKCW_connect(1);
}
}
if (progStatus.Nav_online) {
if (open_NavFSK()) btn_Nav_connect->value(1);
}
if (progStatus.Nav_config_online) {
if (open_NavConfig()) btn_Nav_config->value(1);
}
if (progStatus.nanoCW_online) {
if (open_nanoCW()) btn_nanoCW_connect->value(1);
}
if (progStatus.nanoFSK_online) {
if (open_nanoIO()) btn_nanoIO_connect->value(1);
}
if (progStatus.useCW_KEYLINE) {
if (!open_CW_KEYLINE())
progStatus.useCW_KEYLINE = false;
}
if (progdefaults.check_for_updates)
cb_mnuCheckUpdate((Fl_Widget *)0, NULL);
#if USE_PORTAUDIO
try {
audio_alert = 0;
audio_alert = new Caudio_alert;
} catch (...) {
audio_alert = 0;
LOG_ERROR("%s", "Failed to create audio alert object");
}
if (audio_alert)
LOG_INFO("%s", "Created audio alert object");
reset_audio_alerts();
#endif
}
std::string pname = "";
int main (int argc, char *argv[])
{
pname = argv[0];
size_t pn = pname.rfind("/");
if (pn != std::string::npos) pname.erase(0, pn + 1);
pn = pname.rfind("\\");
if (pn != std::string::npos) pname.erase(0, pn + 1);
XmlRpc::set_pname(pname);
// for KISS_IO status information
program_start_time = time(0);
active_modem = new NULLMODEM;
string appdir = appname = argv[0];
string test_file_name;
BaseDir.clear();
HomeDir.clear();
NBEMS_dir.clear();
FLMSG_dir.clear();
#ifdef __WOE32__
size_t p = appdir.rfind("fldigi.exe");
appdir.erase(p);
p = appdir.find("FL_APPS\\");
if (p != string::npos) {
BaseDir.assign(appdir.substr(0, p + 8));
progdefaults.flmsg_pathname.assign(BaseDir).append("flmsg.exe");
} else {
BaseDir.clear();
HomeDir.clear();
NBEMS_dir.clear();
FLMSG_dir.clear();
}
#else
char apptemp[FL_PATH_MAX + 1];
fl_filename_absolute(apptemp, sizeof(apptemp), argv[0]);
appdir.assign(apptemp);
size_t p = appdir.rfind("fldigi");
if (p != string::npos)
appdir.erase(p);
p = appdir.find("FL_APPS/");
if (p != string::npos) {
BaseDir.assign(appdir.substr(0, p + 8));
progdefaults.flmsg_pathname.assign(BaseDir).append("flmsg");
string test_dir;
test_dir.assign(BaseDir).append("fldigi.files/");
DIR *isdir = opendir(test_dir.c_str());
if (isdir) {
HomeDir = test_dir;
closedir(isdir);
} else {
test_dir.assign(BaseDir).append(".fldigi/");
isdir = opendir(test_dir.c_str());
if (isdir) {
HomeDir = test_dir;
} else {
HomeDir.clear();
}
}
if (!HomeDir.empty()) {
test_dir.assign(BaseDir).append("NBEMS.files/");
isdir = opendir(test_dir.c_str());
if (isdir) {
NBEMS_dir = test_dir;
FLMSG_dir = test_dir;
closedir(isdir);
} else {
test_dir.assign(BaseDir).append(".nbems/");
isdir = opendir(test_dir.c_str());
if (isdir) {
NBEMS_dir = test_dir;
FLMSG_dir = test_dir;
} else {
NBEMS_dir.clear();
FLMSG_dir.clear();
}
}
}
} else {
BaseDir.clear();
HomeDir.clear();
NBEMS_dir.clear();
FLMSG_dir.clear();
}
#endif
debug_exec(argv);
CREATE_THREAD_ID(); // only call this once
SET_THREAD_ID(FLMAIN_TID);
for (int i = 0; i < NUM_QRUNNER_THREADS; i++) {
cbq[i] = new qrunner;
switch(i) {
case TRX_TID:
cbq[i]->attach(i, "TRX_TID");
break;
case TOD_TID:
cbq[i]->attach(i, "TOD_TID");
break;
case QRZ_TID:
cbq[i]->attach(i, "QRZ_TID");
break;
case RIGCTL_TID:
cbq[i]->attach(i, "RIGCTL_TID");
break;
case NORIGCTL_TID:
cbq[i]->attach(i, "NORIGCTL_TID");
break;
case EQSL_TID:
cbq[i]->attach(i, "EQSL_TID");
break;
case ADIF_RW_TID:
cbq[i]->attach(i, "ADIF_RW_TID");
break;
case ADIF_MERGE_TID:
cbq[i]->attach(i, "ADIF_MERGE_TID");
break;
case XMLRPC_TID:
cbq[i]->attach(i, "XMLRPC_TID");
break;
case ARQ_TID:
cbq[i]->attach(i, "ARQ_TID");
break;
case ARQSOCKET_TID:
cbq[i]->attach(i, "ARQSOCKET_TID");
break;
case KISS_TID:
cbq[i]->attach(i, "KISS_TID");
break;
case KISSSOCKET_TID:
cbq[i]->attach(i, "KISSSOCKET_TID");
break;
case MACLOGGER_TID:
cbq[i]->attach(i, "MACLOGGER_TID");
break;
case PSM_TID:
cbq[i]->attach(i, "PSM_TID");
break;
case AUDIO_ALERT_TID:
cbq[i]->attach(i, "AUDIO_ALERT_TID");
break;
case FD_TID:
cbq[i]->attach(i, "FD_TID");
break;
case N3FJP_TID:
cbq[i]->attach(i, "N3FJP_TID");
break;
case DXCC_TID:
cbq[i]->attach(i, "DXCC_TID");
break;
case WKEY_TID:
cbq[i]->attach(i, "WKEY_TID");
break;
case FLMAIN_TID:
cbq[i]->attach(i, "FLMAIN_TID");
break;
default:
break;
}
}
set_unexpected(handle_unexpected);
set_terminate(diediedie);
setup_signal_handlers();
setlocale(LC_ALL, "");
#ifndef ENABLE_NLS
setlocale(LC_TIME, "");
#endif
set_platform_ui();
generate_version_text();
{
char dirbuf[FL_PATH_MAX + 1];
#ifdef __WOE32__
if (BaseDir.empty()) {
fl_filename_expand(dirbuf, sizeof(dirbuf) -1, "$USERPROFILE/");
BaseDir = dirbuf;
}
#else
if (BaseDir.empty()) {
fl_filename_expand(dirbuf, sizeof(dirbuf) -1, "$HOME/");
BaseDir = dirbuf;
}
#endif
}
generate_option_help();
// FL_NORMAL_SIZE = 14;
int arg_idx;
if (Fl::args(argc, argv, arg_idx, parse_args) != argc)
arg_error(argv[0], NULL, false);
if (argv_window_title.empty())
argv_window_title.assign(PACKAGE_TARNAME);
#ifdef __WOE32__
if (HomeDir.empty()) HomeDir.assign(BaseDir).append("fldigi.files/");
if (PskMailDir.empty()) PskMailDir = BaseDir;
if (DATA_dir.empty()) DATA_dir.assign(BaseDir).append("DATA.files/");
if (NBEMS_dir.empty()) NBEMS_dir.assign(BaseDir).append("NBEMS.files/");
if (FLMSG_dir.empty()) FLMSG_dir = NBEMS_dir;
#else
if (HomeDir.empty()) HomeDir.assign(BaseDir).append(".fldigi/");
if (PskMailDir.empty()) PskMailDir = BaseDir;
if (DATA_dir.empty()) DATA_dir.assign(BaseDir).append("DATA.files/");
if (NBEMS_dir.empty()) NBEMS_dir.assign(BaseDir).append(".nbems/");
if (FLMSG_dir.empty()) FLMSG_dir = NBEMS_dir;
#endif
if (!FLMSG_dir_default.empty()) {
char dirbuf[FL_PATH_MAX + 1];
if (FLMSG_dir_default[FLMSG_dir_default.length()-1] != '/')
FLMSG_dir_default += '/';
fl_filename_expand(dirbuf, sizeof(dirbuf) - 1, FLMSG_dir_default.c_str());
FLMSG_dir = dirbuf;
}
if (!NBEMS_dir_default.empty()) {
char dirbuf[FL_PATH_MAX + 1];
if (NBEMS_dir_default[NBEMS_dir_default.length()-1] != '/')
NBEMS_dir_default += '/';
fl_filename_expand(dirbuf, sizeof(dirbuf) - 1, NBEMS_dir_default.c_str());
NBEMS_dir = dirbuf;
}
checkdirectories();
check_nbems_dirs();
check_data_dir();
try {
debug::start(string(DebugDir).append("status_log.txt").c_str());
time_t t = time(NULL);
LOG(debug::QUIET_LEVEL, debug::LOG_OTHER, _("%s log started on %s"), PACKAGE_STRING, ctime(&t));
LOG_THREAD_ID();
}
catch (const char* error) {
cerr << error << '\n';
debug::stop();
}
TOD_init(); // initialize time of day thread
LOG_INFO("appname: %s", appname.c_str());
LOG_INFO("%s", "Directories");
LOG_INFO("HomeDir: %s", HomeDir.c_str());
LOG_INFO("DATA_dir: %s", DATA_dir.c_str());
LOG_INFO("DebugDir: %s", DebugDir.c_str());
LOG_INFO("HelpDir: %s", HelpDir.c_str());
LOG_INFO("KmlDir: %s", KmlDir.c_str());
LOG_INFO("LogsDir: %s", LogsDir.c_str());
LOG_INFO("LoTWDir: %s", LoTWDir.c_str());
LOG_INFO("MacrosDir: %s", MacrosDir.c_str());
LOG_INFO("AnalysisDir: %s", AnalysisDir.c_str());
LOG_INFO("FMTDir: %s", FMTDir.c_str());
LOG_INFO("PalettesDir: %s", PalettesDir.c_str());
LOG_INFO("PicsDir: %s", PicsDir.c_str());
LOG_INFO("PskMailDir: %s", PskMailDir.c_str());
LOG_INFO("RigsDir: %s", RigsDir.c_str());
LOG_INFO("ScriptsDir: %s", ScriptsDir.c_str());
LOG_INFO("TalkDir: %s", TalkDir.c_str());
LOG_INFO("TempDir: %s", TempDir.c_str());
LOG_INFO("WrapDir: %s", WrapDir.c_str());
LOG_INFO("%s", "NBEMS directories");
LOG_INFO("NBEMS_dir: %s", NBEMS_dir.c_str());
LOG_INFO("ARQ_dir: %s", ARQ_dir.c_str());
LOG_INFO("ARQ_files_dir: %s", ARQ_files_dir.c_str());
LOG_INFO("ARQ_recv_dir: %s", ARQ_recv_dir.c_str());
LOG_INFO("ARQ_send: %s", ARQ_send.c_str());
LOG_INFO("WRAP_dir: %s", WRAP_dir.c_str());
LOG_INFO("WRAP_recv_dir: %s", WRAP_recv_dir.c_str());
LOG_INFO("WRAP_send_dir: %s", WRAP_send_dir.c_str());
LOG_INFO("WRAP_auto_dir: %s", WRAP_auto_dir.c_str());
LOG_INFO("ICS_dir: %s", ICS_dir.c_str());
LOG_INFO("ICS_msg_dir: %s", ICS_msg_dir.c_str());
LOG_INFO("ICS_tmp_dir: %s", ICS_tmp_dir.c_str());
LOG_INFO("%s", "FLMSG directories");
LOG_INFO("FLMSG_dir: %s", FLMSG_dir.c_str());
LOG_INFO("FLMSG_dir_default: %s", FLMSG_dir_default.c_str());
LOG_INFO("FLMSG_WRAP_dir: %s", FLMSG_WRAP_dir.c_str());
LOG_INFO("FLMSG_WRAP_recv_dir: %s", FLMSG_WRAP_recv_dir.c_str());
LOG_INFO("FLMSG_WRAP_send_dir: %s", FLMSG_WRAP_send_dir.c_str());
LOG_INFO("FLMSG_WRAP_auto_dir: %s", FLMSG_WRAP_auto_dir.c_str());
LOG_INFO("FLMSG_ICS_dir: %s", FLMSG_ICS_dir.c_str());
LOG_INFO("FLMSG_ICS_msg_dir: %s", FLMSG_ICS_msg_dir.c_str());
LOG_INFO("FLMSG_ICS_tmp_dir: %s", FLMSG_ICS_tmp_dir.c_str());
bool have_config = progdefaults.readDefaultsXML();
check_overrides();
xmlfname = HomeDir;
xmlfname.append(DEFAULT_RIGXML_FILENAME);
checkTLF();
Fl::lock(); // start the gui thread!!
Fl::visual(FL_RGB); // insure 24 bit color operation
fl_register_images();
Fl::set_fonts(0);
Fl::scheme(progdefaults.ui_scheme.c_str());
progdefaults.initFonts();
if (progdefaults.cty_dat_pathname.empty())
progdefaults.cty_dat_pathname = HomeDir;
dxcc_open(string(progdefaults.cty_dat_pathname).append("cty.dat").c_str());
qsl_open(string(progdefaults.cty_dat_pathname).append("lotw1.txt").c_str(), QSL_LOTW);
if (!qsl_open(string(progdefaults.cty_dat_pathname).append("eqsl.txt").c_str(), QSL_EQSL))
qsl_open(string(progdefaults.cty_dat_pathname).append("AGMemberList.txt").c_str(), QSL_EQSL);
progStatus.loadLastState();
create_fl_digi_main(argc, argv);
if (!have_config || show_cpucheck) {
double speed = speed_test(SRC_SINC_FASTEST, 8);
if (speed > 150.0) { // fast
progdefaults.slowcpu = false;
progdefaults.sample_converter = SRC_SINC_BEST_QUALITY;
}
else if (speed > 60.0) { // ok
progdefaults.slowcpu = false;
progdefaults.sample_converter = SRC_SINC_MEDIUM_QUALITY;
}
else if (speed > 15.0) { // slow
progdefaults.slowcpu = true;
progdefaults.sample_converter = SRC_SINC_FASTEST;
}
else { // recycle me
progdefaults.slowcpu = true;
progdefaults.sample_converter = SRC_LINEAR;
}
LOG_INFO("CPU speed factor=%f: setting slowcpu=%s, sample_converter=\"%s\"", speed,
progdefaults.slowcpu ? "true" : "false",
src_get_name(progdefaults.sample_converter));
}
if (progdefaults.XmlRigFilename.empty())
progdefaults.XmlRigFilename = xmlfname;
#if BENCHMARK_MODE
return setup_benchmark();
#endif
FSEL::create();
#if FLDIGI_FLTK_API_MAJOR == 1 && FLDIGI_FLTK_API_MINOR < 3
listbox_charset_status->hide();
#else
listbox_charset_status->show();
#endif
populate_charset_listbox();
set_default_charset();
setTabColors();
progdefaults.testCommPorts();
init_hids();
#if USE_HAMLIB
xcvr = new Rig();
#endif
push2talk = new PTT();
progdefaults.setDefaults();
atexit(sound_close);
sound_init();
progdefaults.initInterface();
trx_start();
#if USE_PORTAUDIO
try {
audio_alert = 0;
audio_alert = new Caudio_alert;
} catch (...) {
audio_alert = 0;
LOG_ERROR("%s", "Failed to create audio alert object");
}
if (audio_alert)
LOG_INFO("%s", "Created audio alert object");
#endif
if (!have_config) {
show_wizard(argc, argv);
Fl_Window* w;
while ((w = Fl::first_window()) && w->visible())
Fl::wait();
}
dlgViewer = createViewer();
dxcluster_viewer = dxc_window();
dxcluster_viewer->hide();
if (!dlgLogbook)
create_logbook_dialogs();
LOGBOOK_colors_font();
rxaudio_dialog = make_rxaudio_dialog();
rxaudio_dialog->hide();
if( progdefaults.kml_save_dir.empty() ) {
progdefaults.kml_save_dir = KmlDir ;
}
kml_init(true);
if (progdefaults.kml_purge_on_startup) {
KmlServer::GetInstance()->Reset();
}
// OS X will prevent the main window from being resized if we change its
// size *after* it has been shown. With some X11 window managers, OTOH,
// the main window will not be restored at its exact saved position if
// we move it *after* it has been shown.
#ifndef __APPLE__
progStatus.initLastState();
fl_digi_main->show(argc, argv);
#else
# if FLDIGI_FLTK_API_MAJOR == 1 && FLDIGI_FLTK_API_MINOR < 4
fl_digi_main->show(argc, argv);
progStatus.initLastState();
# else
progStatus.initLastState();
fl_digi_main->show(argc, argv);
# endif
#endif
if (iconified)
for (Fl_Window* w = Fl::first_window(); w; w = Fl::next_window(w))
w->iconize();
update_main_title();
mode_browser = new Mode_Browser;
clearQSO();
Fl::add_timeout(.25, delayed_startup);
Fl::set_color(FL_SELECTION_COLOR, 0, 0, 128);
return Fl::run();
}
void exit_process() {
LOG_INFO("Close Spectrum dialog");
close_spectrum_viewer();
LOG_INFO("Stop KML server");
if (progdefaults.kml_enabled)
KmlServer::Exit();
LOG_INFO("Stop PSM processing");
stop_psm_thread();
LOG_INFO("Stop ARQ processing");
arq_close();
LOG_INFO("Close FD dialog");
FD_close();
LOG_INFO("Stop DX cluster i/o");
DXcluster_close();
LOG_INFO("Stop KISS processing");
kiss_close(false);
LOG_INFO("Stop MacLogger i/o");
maclogger_close();
LOG_INFO("Send shutdown signal to flrig");
if (progdefaults.flrig_auto_shutdown)
xmlrpc_shutdown_flrig();
LOG_INFO("Stop xmlrpc processing");
XML_RPC_Server::stop();
LOG_INFO("Stop PSK reporter processing");
if (progdefaults.usepskrep)
pskrep_stop();
LOG_INFO("Detach/delete qrunner threads");
for (int i = 0; i < NUM_QRUNNER_THREADS; i++) {
LOG_INFO("thread %d", i);
cbq[i]->detach();
delete cbq[i];
}
LOG_INFO("FSEL::destroy()");
FSEL::destroy();
}
void generate_option_help(void) {
ostringstream help;
string disp_base_dir = BaseDir;
#ifdef __WOE32__
size_t p = 0;
while ((p = disp_base_dir.find("/")) != string::npos)
disp_base_dir[p] = '\\';
#endif
help << "Usage:\n"
<< " " << PACKAGE_NAME << " [option...]\n\n";
help << PACKAGE_NAME << " options:\n\n"
#if !defined(__WOE32__)
<< " --home-dir DIRECTORY\n"
<< " Set the home directory to full pathname of DIRECTORY\n"
<< " fldigi will put the file stores\n"
<< " .fldigi.files, and .nbems.files\n"
<< " in this directory\n"
<< " The default is: " << disp_base_dir << "\n\n"
<< " --config-dir DIRECTORY\n"
<< " Look for configuration files in DIRECTORY\n"
<< " The default is: " << disp_base_dir << ".fldigi/\n\n"
#else
<< " --home-dir FOLDER\n"
<< " Set the home folder to full pathname of FOLDER\n"
<< " fldigi will put the file stores\n"
<< " fldigi.files, and nbems.files\n"
<< " in this folder\n"
<< " The default is: " << disp_base_dir << "\n\n"
<< " --config-dir FOLDER\n"
<< " Look for configuration files in FOLDER\n"
<< " The default is: " << disp_base_dir << "fldigi.files\\\n\n"
#endif
#if !defined(__WOE32__) && !defined(__APPLE__)
<< " --rx-ipc-key KEY\n"
<< " Set the receive message queue key\n"
<< " May be given in hex if prefixed with \"0x\"\n"
<< " The default is: " << progdefaults.rx_msgid
<< " or 0x" << hex << progdefaults.rx_msgid << dec << "\n\n"
<< " --tx-ipc-key KEY\n"
<< " Set the transmit message queue key\n"
<< " May be given in hex if prefixed with \"0x\"\n"
<< " The default is: " << progdefaults.tx_msgid
<< " or 0x" << hex << progdefaults.tx_msgid << dec << "\n\n"
#endif
<< " --enable-io-port <" << ARQ_IO << "|" << KISS_IO << "> ARQ=" << ARQ_IO << " KISS=" << KISS_IO << "\n"
<< " Select the active IO Port\n"
<< " The default is: " << progdefaults.data_io_enabled << "\n\n"
<< " --kiss-server-address HOSTNAME\n"
<< " Set the KISS TCP/UDP server address\n"
<< " The default is: " << progdefaults.kiss_address << "\n\n"
<< " --kiss-server-port-io I/O PORT\n"
<< " Set the KISS TCP/UDP server I/O port\n"
<< " The default is: " << progdefaults.kiss_io_port << "\n\n"
<< " --kiss-server-port-o Output PORT\n"
<< " Set the KISS UDP server output port\n"
<< " The default is: " << progdefaults.kiss_out_port << "\n\n"
<< " --kiss-server-dual-port Dual Port Use (0=disable / 1=enable)\n"
<< " Set the KISS UDP server dual port flag\n"
<< " The default is: " << progdefaults.kiss_dual_port_enabled << "\n\n"
<< " --arq-server-address HOSTNAME\n"
<< " Set the ARQ TCP server address\n"
<< " The default is: " << progdefaults.arq_address << "\n\n"
<< " --arq-server-port PORT\n"
<< " Set the ARQ TCP server port\n"
<< " The default is: " << progdefaults.arq_port << "\n\n"
<< " --flmsg-dir DIRECTORY\n"
<< " Look for flmsg files in DIRECTORY\n"
<< " The default is " << FLMSG_dir_default << "\n\n"
<< " --auto-dir DIRECTORY\n"
<< " Look for auto-send files in DIRECTORY\n"
<< " The default is " << HomeDir << "/autosend" << "\n\n"
<< " --xmlrpc-server-address HOSTNAME\n"
<< " Set the XML-RPC server address\n"
<< " The default is: " << progdefaults.xmlrpc_address << "\n\n"
<< " --xmlrpc-server-port PORT\n"
<< " Set the XML-RPC server port\n"
<< " The default is: " << progdefaults.xmlrpc_port << "\n\n"
<< " --xmlrpc-allow REGEX\n"
<< " Allow only the methods whose names match REGEX\n\n"
<< " --xmlrpc-deny REGEX\n"
<< " Allow only the methods whose names don't match REGEX\n\n"
<< " --xmlrpc-list\n"
<< " List all available methods\n\n"
#if BENCHMARK_MODE
<< " --benchmark-modem ID\n"
<< " Specify the modem\n"
<< " Default: " << mode_info[benchmark.modem].sname << "\n\n"
<< " --benchmark-frequency FREQ\n"
<< " Specify the modem frequency\n"
<< " Default: " << benchmark.freq << "\n\n"
<< " --benchmark-afc BOOLEAN\n"
<< " Set modem AFC\n"
<< " Default: " << benchmark.afc
<< " (" << boolalpha << benchmark.afc << noboolalpha << ")\n\n"
<< " --benchmark-squelch BOOLEAN\n"
<< " Set modem squelch\n"
<< " Default: " << benchmark.sql
<< " (" << boolalpha << benchmark.sql << noboolalpha << ")\n\n"
<< " --benchmark-squelch-level LEVEL\n"
<< " Set modem squelch level\n"
<< " Default: " << benchmark.sqlevel << " (%)\n\n"
<< " --benchmark-input INPUT\n"
<< " Specify the input\n"
<< " Must be a positive integer indicating the number of samples\n"
" of silence to generate as the input"
", or a filename containing\n"
" non-digit characters"
"\n\n"
<< " --benchmark-output FILE\n"
<< " Specify the output data file\n"
<< " Default: decoder output is discarded\n\n"
<< " --benchmark-src-ratio RATIO\n"
<< " Specify the sample rate conversion ratio\n"
<< " Default: 1.0 (input is not resampled)\n\n"
<< " --benchmark-src-type TYPE\n"
<< " Specify the sample rate conversion type\n"
<< " Default: " << benchmark.src_type << " (" << src_get_name(benchmark.src_type) << ")\n\n"
#endif
<< " --cpu-speed-test\n"
<< " Perform the CPU speed test, show results in the event log\n"
<< " and possibly change options.\n\n"
<< " --wfall-only\n"
<< " Hide all controls but the waterfall\n\n"
<< " --debug-level LEVEL\n"
<< " Set the event log verbosity\n\n"
<< " --version\n"
<< " Print version information\n\n"
<< " --build-info\n"
<< " Print build information\n\n"
<< " --help\n"
<< " Print this option help\n\n";
// Fl::help looks ugly so we'll write our own
help << "Standard FLTK options:\n\n"
<< " -bg COLOR, -background COLOR\n"
<< " Set the background color\n"
<< " -bg2 COLOR, -background2 COLOR\n"
<< " Set the secondary (text) background color\n\n"
<< " -di DISPLAY, -display DISPLAY\n"
<< " Set the X display to use DISPLAY,\n"
<< " format is ``host:n.n''\n\n"
<< " -dn, -dnd or -nodn, -nodnd\n"
<< " Enable or disable drag and drop copy and paste in text fields\n\n"
<< " -fg COLOR, -foreground COLOR\n"
<< " Set the foreground color\n\n"
<< " -g GEOMETRY, -geometry GEOMETRY\n"
<< " Set the initial window size and position\n"
<< " GEOMETRY format is ``WxH+X+Y''\n"
<< " ** " << PACKAGE_NAME << " may override this setting **\n\n"
<< " -i, -iconic\n"
<< " Start " << PACKAGE_NAME << " in iconified state\n\n"
<< " -k, -kbd or -nok, -nokbd\n"
<< " Enable or disable visible keyboard focus in non-text widgets\n\n"
<< " -na CLASSNAME, -name CLASSNAME\n"
<< " Set the window class to CLASSNAME\n\n"
<< " -ti WINDOWTITLE, -title WINDOWTITLE\n"
<< " Set the window title\n\n";
help << "Additional UI options:\n\n"
<< " --font FONT[:SIZE]\n"
<< " Set the widget font and (optionally) size\n"
<< " The default is: " << Fl::get_font(FL_HELVETICA)
<< ':' << FL_NORMAL_SIZE << "\n\n"
;
option_help = help.str();
}
void exit_cb(void*) { fl_digi_main->do_callback(); }
int parse_args(int argc, char **argv, int& idx)
{
// Only handle long options
if (!(strlen(argv[idx]) >= 2 && strncmp(argv[idx], "--", 2) == 0)) {
// Store the window title. We may need this early in the initialisation
// process, before FLTK uses it to set the main window title.
if (argv_window_title.empty() && argc > idx &&
(!strcmp(argv[idx], "-ti") || !strcmp(argv[idx], "-title")))
argv_window_title = argv[idx + 1];
else if (!strcmp(argv[idx], "-i") || !strcmp(argv[idx], "-iconic"))
iconified = true;
return 0;
}
enum { OPT_ZERO,
#ifndef __WOE32__
OPT_RX_IPC_KEY, OPT_TX_IPC_KEY,
#endif
OPT_HOME_DIR,
OPT_CONFIG_DIR,
OPT_ARQ_ADDRESS, OPT_ARQ_PORT,
OPT_SHOW_CPU_CHECK,
OPT_FLMSG_DIR,
OPT_NBEMS_DIR,
OPT_AUTOSEND_DIR,
OPT_CONFIG_XMLRPC_ADDRESS, OPT_CONFIG_XMLRPC_PORT,
OPT_CONFIG_XMLRPC_ALLOW, OPT_CONFIG_XMLRPC_DENY, OPT_CONFIG_XMLRPC_LIST,
OPT_CONFIG_KISS_ADDRESS, OPT_CONFIG_KISS_PORT_IO, OPT_CONFIG_KISS_PORT_O,
OPT_CONFIG_KISS_DUAL_PORT, OPT_ENABLE_IO_PORT,
#if BENCHMARK_MODE
OPT_BENCHMARK_MODEM, OPT_BENCHMARK_AFC, OPT_BENCHMARK_SQL, OPT_BENCHMARK_SQLEVEL,
OPT_BENCHMARK_FREQ, OPT_BENCHMARK_INPUT, OPT_BENCHMARK_OUTPUT,
OPT_BENCHMARK_SRC_RATIO, OPT_BENCHMARK_SRC_TYPE,
#endif
OPT_FONT, OPT_WFALL_HEIGHT,
OPT_WINDOW_WIDTH, OPT_WINDOW_HEIGHT, OPT_WFALL_ONLY,
OPT_RX_ONLY,
#if USE_PORTAUDIO
OPT_FRAMES_PER_BUFFER,
#endif
OPT_DEBUG_LEVEL,
OPT_EXIT_AFTER,
OPT_DEPRECATED, OPT_HELP, OPT_VERSION, OPT_BUILD_INFO };
static const char shortopts[] = ":";
static const struct option longopts[] = {
#ifndef __WOE32__
{ "rx-ipc-key", 1, 0, OPT_RX_IPC_KEY },
{ "tx-ipc-key", 1, 0, OPT_TX_IPC_KEY },
#endif
{ "home-dir", 1, 0, OPT_HOME_DIR },
{ "config-dir", 1, 0, OPT_CONFIG_DIR },
{ "arq-server-address", 1, 0, OPT_ARQ_ADDRESS },
{ "arq-server-port", 1, 0, OPT_ARQ_PORT },
{ "flmsg-dir", 1, 0, OPT_FLMSG_DIR },
{ "nbems-dir", 1, 0, OPT_NBEMS_DIR },
{ "auto-dir", 1, 0, OPT_AUTOSEND_DIR },
{ "cpu-speed-test", 0, 0, OPT_SHOW_CPU_CHECK },
{ "enable-io-port", 1, 0, OPT_ENABLE_IO_PORT },
{ "kiss-server-address", 1, 0, OPT_CONFIG_KISS_ADDRESS },
{ "kiss-server-port-io", 1, 0, OPT_CONFIG_KISS_PORT_IO },
{ "kiss-server-port-o", 1, 0, OPT_CONFIG_KISS_PORT_O },
{ "kiss-server-dual-port", 1, 0, OPT_CONFIG_KISS_DUAL_PORT },
{ "xmlrpc-server-address", 1, 0, OPT_CONFIG_XMLRPC_ADDRESS },
{ "xmlrpc-server-port", 1, 0, OPT_CONFIG_XMLRPC_PORT },
{ "xmlrpc-allow", 1, 0, OPT_CONFIG_XMLRPC_ALLOW },
{ "xmlrpc-deny", 1, 0, OPT_CONFIG_XMLRPC_DENY },
{ "xmlrpc-list", 0, 0, OPT_CONFIG_XMLRPC_LIST },
#if BENCHMARK_MODE
{ "benchmark-modem", 1, 0, OPT_BENCHMARK_MODEM },
{ "benchmark-frequency", 1, 0, OPT_BENCHMARK_FREQ },
{ "benchmark-afc", 1, 0, OPT_BENCHMARK_AFC },
{ "benchmark-squelch", 1, 0, OPT_BENCHMARK_SQL },
{ "benchmark-squelch-level", 1, 0, OPT_BENCHMARK_SQLEVEL },
{ "benchmark-input", 1, 0, OPT_BENCHMARK_INPUT },
{ "benchmark-output", 1, 0, OPT_BENCHMARK_OUTPUT },
{ "benchmark-src-ratio", 1, 0, OPT_BENCHMARK_SRC_RATIO },
{ "benchmark-src-type", 1, 0, OPT_BENCHMARK_SRC_TYPE },
#endif
{ "font", 1, 0, OPT_FONT },
{ "wfall-height", 1, 0, OPT_WFALL_HEIGHT },
{ "window-width", 1, 0, OPT_WINDOW_WIDTH },
{ "window-height", 1, 0, OPT_WINDOW_HEIGHT },
{ "wfall-only", 0, 0, OPT_WFALL_ONLY },
{ "wo", 0, 0, OPT_WFALL_ONLY },
{ "rx-only", 0, 0, OPT_RX_ONLY },
{ "ro", 0, 0, OPT_RX_ONLY },
#if USE_PORTAUDIO
{ "frames-per-buffer",1, 0, OPT_FRAMES_PER_BUFFER },
#endif
{ "exit-after", 1, 0, OPT_EXIT_AFTER },
{ "debug-level", 1, 0, OPT_DEBUG_LEVEL },
{ "help", 0, 0, OPT_HELP },
{ "version", 0, 0, OPT_VERSION },
{ "build-info", 0, 0, OPT_BUILD_INFO },
{ 0 }
};
int longindex;
optind = idx;
opterr = 0;
int c = getopt_long(argc, argv, shortopts, longopts, &longindex);
switch (c) {
case -1:
return 0;
case 0:
// handle options with non-0 flag here
return 0;
#if !defined(__WOE32__) && !defined(__APPLE__)
case OPT_RX_IPC_KEY: case OPT_TX_IPC_KEY:
{
errno = 0;
int key = strtol(optarg, NULL, (strncasecmp(optarg, "0x", 2) ? 10 : 16));
if (errno || key <= 0)
cerr << "Hmm, " << key << " doesn't look like a valid IPC key\n";
if (c == OPT_RX_IPC_KEY)
progdefaults.rx_msgid = key;
else
progdefaults.tx_msgid = key;
}
break;
#endif
case OPT_HOME_DIR: {
char buf[FL_PATH_MAX + 1];
fl_filename_absolute(buf, sizeof(buf) - 1, optarg);
BaseDir = buf;
}
if (*BaseDir.rbegin() != '/')
BaseDir += '/';
break;
case OPT_CONFIG_DIR: {
char buf[FL_PATH_MAX + 1];
fl_filename_absolute(buf, sizeof(buf) - 1, optarg);
HomeDir = buf;
}
if (*HomeDir.rbegin() != '/')
HomeDir += '/';
break;
case OPT_ARQ_ADDRESS:
override_arq_address = optarg;
arq_address_override_flag = true;
break;
case OPT_ARQ_PORT:
override_arq_port = optarg;
arq_port_override_flag = true;
break;
case OPT_FLMSG_DIR:
FLMSG_dir_default = optarg;
break;
case OPT_NBEMS_DIR:
NBEMS_dir_default = optarg;
break;
case OPT_AUTOSEND_DIR:
FLMSG_WRAP_auto_dir = optarg;
break;
case OPT_ENABLE_IO_PORT:
if(optarg) {
switch(atoi(optarg)) {
case ARQ_IO:
progdefaults.data_io_enabled = ARQ_IO;
override_data_io_enabled = ARQ_IO;
arq_address_override_flag = true;
break;
case KISS_IO:
progdefaults.data_io_enabled = KISS_IO;
override_data_io_enabled = KISS_IO;
kiss_address_override_flag = true;
break;
}
}
break;
case OPT_CONFIG_KISS_ADDRESS:
progdefaults.kiss_address = optarg;
override_kiss_address = optarg;
kiss_address_override_flag = true;
break;
case OPT_CONFIG_KISS_PORT_IO:
progdefaults.kiss_io_port = optarg;
override_kiss_io_port = optarg;
kiss_address_override_flag = true;
break;
case OPT_CONFIG_KISS_PORT_O:
progdefaults.kiss_out_port = optarg;
override_kiss_out_port = optarg;
kiss_address_override_flag = true;
break;
case OPT_CONFIG_KISS_DUAL_PORT:
if((optarg) && atoi(optarg)) {
progdefaults.kiss_dual_port_enabled = true;
override_kiss_dual_port_enabled = true;
kiss_address_override_flag = true;
} else {
progdefaults.kiss_dual_port_enabled = false;
override_kiss_dual_port_enabled = false;
kiss_address_override_flag = true;
}
break;
case OPT_CONFIG_XMLRPC_ADDRESS:
override_xmlrpc_address = optarg;
xmlrpc_address_override_flag = true;
break;
case OPT_CONFIG_XMLRPC_PORT:
override_xmlrpc_port = optarg;
xmlrpc_port_override_flag = true;
break;
case OPT_CONFIG_XMLRPC_ALLOW:
progdefaults.xmlrpc_allow = optarg;
break;
case OPT_CONFIG_XMLRPC_DENY:
if (!progdefaults.xmlrpc_allow.empty())
cerr << "W: --" << longopts[longindex].name
<< " cannot be used together with --"
<< longopts[OPT_CONFIG_XMLRPC_ALLOW-1].name
<< " and will be ignored\n";
else
progdefaults.xmlrpc_deny = optarg;
break;
case OPT_CONFIG_XMLRPC_LIST:
XML_RPC_Server::list_methods(cout);
exit(EXIT_SUCCESS);
#if BENCHMARK_MODE
case OPT_BENCHMARK_MODEM:
benchmark.modem = strtol(optarg, NULL, 10);
if (!(benchmark.modem >= 0 && benchmark.modem < NUM_MODES)) {
fatal_error(_("Bad modem id"));
}
break;
case OPT_BENCHMARK_FREQ:
benchmark.freq = strtol(optarg, NULL, 10);
if (benchmark.freq < 0) {
fatal_error(_("Bad frequency"));
}
break;
case OPT_BENCHMARK_AFC:
benchmark.afc = strtol(optarg, NULL, 10);
break;
case OPT_BENCHMARK_SQL:
benchmark.sql = strtol(optarg, NULL, 10);
break;
case OPT_BENCHMARK_SQLEVEL:
benchmark.sqlevel = strtod(optarg, NULL);
break;
case OPT_BENCHMARK_INPUT:
benchmark.input = optarg;
break;
case OPT_BENCHMARK_OUTPUT:
benchmark.output = optarg;
break;
case OPT_BENCHMARK_SRC_RATIO:
benchmark.src_ratio = strtod(optarg, NULL);
break;
case OPT_BENCHMARK_SRC_TYPE:
benchmark.src_type = strtol(optarg, NULL, 10);
break;
#endif
case OPT_FONT:
{
char *p;
if ((p = strchr(optarg, ':'))) {
*p = '\0';
FL_NORMAL_SIZE = strtol(p + 1, 0, 10);
}
}
Fl::set_font(FL_HELVETICA, optarg);
break;
// case OPT_WFALL_HEIGHT:
// progdefaults.wfheight = strtol(optarg, NULL, 10);
// break;
// case OPT_WINDOW_WIDTH:
// WNOM = strtol(optarg, NULL, 10);
// break;
// case OPT_WINDOW_HEIGHT:
// HNOM = strtol(optarg, NULL, 10);
// break;
#if USE_PORTAUDIO
case OPT_FRAMES_PER_BUFFER:
progdefaults.PortFramesPerBuffer = strtol(optarg, 0, 10);
break;
#endif // USE_PORTAUDIO
case OPT_EXIT_AFTER:
Fl::add_timeout(strtod(optarg, 0), exit_cb);
break;
case OPT_WFALL_ONLY:
bWF_only = true;
break;
case OPT_RX_ONLY:
rx_only = true;
break;
case OPT_SHOW_CPU_CHECK:
show_cpucheck = true;
break;
case OPT_DEBUG_LEVEL:
{
int v = strtol(optarg, 0, 10);
debug::level = (debug::level_e)CLAMP(v, 0, debug::LOG_NLEVELS-1);
}
break;
case OPT_DEPRECATED:
cerr << "W: the --" << longopts[longindex].name
<< " option has been deprecated and will be removed in a future version\n";
break;
case OPT_HELP:
cout << option_help;
exit(EXIT_SUCCESS);
case OPT_VERSION:
cout << version_text;
exit(EXIT_SUCCESS);
case OPT_BUILD_INFO:
cout << build_text;
exit(EXIT_SUCCESS);
case '?': case ':': default:
arg_error(argv[0], argv[idx], (c == ':'));
}
// Increment idx by the number of args we used and return that number.
// We must check whether the option argument is in the same argv element
// as the option name itself, i.e., --opt=arg.
c = longopts[longindex].has_arg ? 2 : 1;
if (c == 2) {
string arg = argv[idx];
string::size_type p;
if ((p = arg.rfind(optarg)) != string::npos && arg[p-1] == '=')
c = 1;
}
idx += c;
return c;
}
void generate_version_text(void)
{
version_text.assign(PACKAGE_STRING "\nCopyright (C) 2007-2010 " PACKAGE_AUTHORS ".\n");
version_text.append(_("License GPLv3+: GNU GPL version 3 or later "
"<http://www.gnu.org/licenses/gpl-3.0.html>\n"
"This is free software: you are free to change and redistribute it.\n"
"There is NO WARRANTY, to the extent permitted by law.\n"));
ostringstream s;
s << "Build information:\n";
s << " built : " << BUILD_DATE << " by " << BUILD_USER
<< '@' << BUILD_HOST << " on " << BUILD_BUILD_PLATFORM
<< " for " << BUILD_TARGET_PLATFORM << "\n\n"
<< " configure flags: " << BUILD_CONFIGURE_ARGS << "\n\n"
<< " compiler : " << BUILD_COMPILER << "\n\n"
<< " compiler flags : " << FLDIGI_BUILD_CXXFLAGS << "\n\n"
<< " linker flags : " << FLDIGI_BUILD_LDFLAGS << "\n\n"
<< " libraries : " "FLTK " FLTK_BUILD_VERSION "\n"
<< " " "libsamplerate " << SAMPLERATE_BUILD_VERSION "\n";
s << " " "libsndfile " << SNDFILE_BUILD_VERSION "\n";
#if USE_PORTAUDIO
s << " " "PortAudio " << PORTAUDIO_BUILD_VERSION "\n";
#endif
#if USE_PULSEAUDIO
s << " " "PulseAudio " << PULSEAUDIO_BUILD_VERSION "\n";
#endif
#if USE_HAMLIB
s << " " "Hamlib " << HAMLIB_BUILD_VERSION "\n";
#endif
s << "\nRuntime information:\n";
struct utsname u;
if (uname(&u) != -1) {
s << " system : " << u.sysname << ' ' << u.nodename
<< ' ' << u.release << ' ' << u.version << ' ' << u.machine << "\n\n";
}
s << " libraries : " << src_get_version() << '\n';
char sndfile_version[32];
sf_command(NULL, SFC_GET_LIB_VERSION, sndfile_version, sizeof(sndfile_version));
s << " " << sndfile_version << '\n';
#if USE_PORTAUDIO
s << " " << Pa_GetVersionText() << ' ' << Pa_GetVersion() << '\n';
#endif
#if USE_PULSEAUDIO
s << " " << "Pulseaudio " << pa_get_library_version() << '\n';
#endif
#if USE_HAMLIB
s << " " << hamlib_version << '\n';
#endif
build_text = s.str();
}
// When debugging is enabled, reexec with malloc debugging hooks enabled, unless
// the env var FLDIGI_NO_EXEC is set, or our parent process is gdb.
void debug_exec(char** argv)
{
#if !defined(NDEBUG) && defined(__GLIBC__)
if (getenv("FLDIGI_NO_EXEC"))
return;
char ppath[32], lname[32];
ssize_t n;
snprintf(ppath, sizeof(ppath), "/proc/%u/exe", getppid());
if ((n = readlink(ppath, lname, sizeof(lname))) > 0) {
lname[n] = '\0';
if (strstr(lname, "gdb")) {
cerr << "Not using malloc debugging hooks\n";
return;
}
}
setenv("FLDIGI_NO_EXEC", "1", 0);
setenv("MALLOC_CHECK_", "3", 0);
setenv("MALLOC_PERTURB_", "42", 0);
if (execvp(*argv, argv) == -1)
perror("execvp");
#endif
}
void set_platform_ui(void)
{
#if defined(__APPLE__)
FL_NORMAL_SIZE = 12;
progdefaults.WaterfallFontsize = 12;
progdefaults.RxFontsize = 12;
progdefaults.TxFontsize = 12;
#elif defined(__WOE32__)
Fl::set_font(FL_HELVETICA, "Tahoma");
FL_NORMAL_SIZE = 11;
progdefaults.WaterfallFontnbr = FL_HELVETICA;
progdefaults.WaterfallFontsize = 12;
progdefaults.RxFontsize = 12;
progdefaults.TxFontsize = 12;
#else
FL_NORMAL_SIZE = 12;
#endif
}
// Convert 1 second of 1-channel silence from IN_RATE Hz to OUT_RATE Hz,
// Repeat test "repeat" times. Return (repeat / elapsed_time),
// the faster-than-realtime factor averaged over "repeat" runs.
// Some figures for SRC_SINC_FASTEST:
// Pentium 4 2.8GHz: 70
// Pentium 3 550MHz: 13
// UltraSparc II 270MHz: 3.5
// Atom N280 1.66GHz: 17.7
#define IN_RATE 48000
#define OUT_RATE 8000
double speed_test(int converter, unsigned repeat)
{
float input_frames[IN_RATE];
float output_frames[OUT_RATE];
SRC_DATA src;
src.src_ratio = (double)OUT_RATE / IN_RATE;
src.input_frames = IN_RATE;
src.output_frames = OUT_RATE;
src.data_in = &input_frames[0];
src.data_out = &output_frames[0];
memset(input_frames, 0, sizeof(input_frames));
// warm up
src_simple(&src, converter, 1);
struct timespec t0, t1;
#ifdef _POSIX_MONOTONIC_CLOCK
clock_gettime(CLOCK_MONOTONIC, &t0);
#else
clock_gettime(CLOCK_REALTIME, &t0);
#endif
for (unsigned i = 0; i < repeat; i++)
src_simple(&src, converter, 1);
#ifdef _POSIX_MONOTONIC_CLOCK
clock_gettime(CLOCK_MONOTONIC, &t1);
#else
clock_gettime(CLOCK_REALTIME, &t1);
#endif
t0 = t1 - t0;
return repeat / (t0.tv_sec + t0.tv_nsec/1e9);
}
static void setup_signal_handlers(void)
{
#ifndef __WOE32__
struct sigaction action;
memset(&action, 0, sizeof(struct sigaction));
// no child stopped notifications, no zombies
action.sa_handler = SIG_DFL;
action.sa_flags = SA_NOCLDSTOP;
#ifdef SA_NOCLDWAIT
action.sa_flags |= SA_NOCLDWAIT;
#endif
sigaction(SIGCHLD, &action, NULL);
action.sa_flags = 0;
action.sa_handler = handle_signal;
sigaction(SIGSEGV, &action, NULL);
sigaction(SIGILL, &action, NULL);
sigaction(SIGABRT, &action, NULL);
sigaction(SIGUSR2, &action, NULL);
action.sa_handler = SIG_IGN;
sigaction(SIGPIPE, &action, NULL);
sigemptyset(&action.sa_mask);
sigaddset(&action.sa_mask, SIGUSR2);
pthread_sigmask(SIG_BLOCK, &action.sa_mask, NULL);
#else
signal(SIGSEGV, handle_signal);
signal(SIGILL, handle_signal);
signal(SIGABRT, handle_signal);
#endif
}
// Show an error dialog and print to cerr if available.
// On win32 Fl::fatal displays its own error window.
static void fatal_error(string sz_error)
{
string s = "Fatal error!\n";
s.append(sz_error).append("\n").append(strerror(errno));
// Win32 will display a MessageBox error message
#if !defined(__WOE32__)
fl_message_font(FL_HELVETICA, FL_NORMAL_SIZE);
fl_alert2("%s", s.c_str());
#endif
Fl::fatal(s.c_str());
}
static void checkdirectories(void)
{
struct DIRS {
string& dir;
const char* suffix;
void (*new_dir_func)(void);
};
DIRS fldigi_dirs[] = {
{ HomeDir, 0, 0 },
{ RigsDir, "rigs", 0 },
{ ScriptsDir, "scripts", 0 },
{ PalettesDir, "palettes", create_new_palettes },
{ LogsDir, "logs", 0 },
{ PicsDir, "images", 0 },
{ AvatarDir, "avatars", 0},
{ HelpDir, "help", 0 },
{ MacrosDir, "macros", create_new_macros },
{ AnalysisDir, "analysis", 0 },
{ FMTDir, "fmt", 0 },
{ WrapDir, "wrap", 0 },
{ TalkDir, "talk", 0 },
{ TempDir, "temp", 0 },
{ LoTWDir, "LOTW", 0 },
{ KmlDir, "kml", 0 },
{ DATA_dir, "data", 0 },
{ DebugDir, "debug", 0 }
};
int r;
for (size_t i = 0; i < sizeof(fldigi_dirs)/sizeof(*fldigi_dirs); i++) {
if (fldigi_dirs[i].suffix)
fldigi_dirs[i].dir.assign(HomeDir).append(fldigi_dirs[i].suffix).append(PATH_SEP);
r = mkdir(fldigi_dirs[i].dir.c_str(), 0777);
if (r == -1 && errno != EEXIST) {
string s = _("Could not make directory ");
s.append(fldigi_dirs[i].dir);
fatal_error(s);
}
else if (r == 0 && fldigi_dirs[i].new_dir_func)
fldigi_dirs[i].new_dir_func();
}
}
bool nbems_dirs_checked = false;
void check_nbems_dirs(void)
{
if (nbems_dirs_checked) return;
struct DIRS {
string& dir;
const char* suffix;
void (*new_dir_func)(void);
};
DIRS NBEMS_dirs[] = {
{ NBEMS_dir, 0, 0 },
{ ARQ_dir, "ARQ", 0 },
{ ARQ_files_dir, "ARQ/files", 0 },
{ ARQ_recv_dir, "ARQ/recv", 0 },
{ ARQ_send, "ARQ/send", 0 },
{ WRAP_dir, "WRAP", 0 },
{ WRAP_recv_dir, "WRAP/recv", 0 },
{ WRAP_send_dir, "WRAP/send", 0 },
{ WRAP_auto_dir, "WRAP/auto", 0 },
{ ICS_dir, "ICS", 0 },
{ ICS_msg_dir, "ICS/messages", 0 },
{ ICS_tmp_dir, "ICS/templates", 0 },
};
int r;
for (size_t i = 0; i < sizeof(NBEMS_dirs)/sizeof(*NBEMS_dirs); i++) {
if (NBEMS_dirs[i].suffix)
NBEMS_dirs[i].dir.assign(NBEMS_dir).append(NBEMS_dirs[i].suffix).append(PATH_SEP);
if ((r = mkdir(NBEMS_dirs[i].dir.c_str(), 0777)) == -1 && errno != EEXIST) {
string s = _("Could not make directory ");
s.append(NBEMS_dirs[i].dir).append(", ").append(strerror(errno));
fatal_error(s);
}
else if (r == 0 && NBEMS_dirs[i].new_dir_func)
NBEMS_dirs[i].new_dir_func();
}
DIRS FLMSG_dirs[] = {
{ FLMSG_dir, 0, 0 },
{ FLMSG_WRAP_dir, "WRAP", 0 },
{ FLMSG_WRAP_recv_dir, "WRAP/recv", 0 },
{ FLMSG_WRAP_send_dir, "WRAP/send", 0 },
{ FLMSG_WRAP_auto_dir, "WRAP/auto", 0 },
{ FLMSG_ICS_dir, "ICS", 0 },
{ FLMSG_ICS_msg_dir, "ICS/messages", 0 },
{ FLMSG_ICS_tmp_dir, "ICS/templates", 0 },
};
for (size_t i = 0; i < sizeof(FLMSG_dirs)/sizeof(*FLMSG_dirs); i++) {
if (FLMSG_dirs[i].dir.empty() && FLMSG_dirs[i].suffix)
FLMSG_dirs[i].dir.assign(FLMSG_dir).append(FLMSG_dirs[i].suffix).append("/");
if ((r = mkdir(FLMSG_dirs[i].dir.c_str(), 0777)) == -1 && errno != EEXIST) {
string s = _("Could not make directory ");
s.append(FLMSG_dirs[i].dir);
fatal_error(s);
}
else if (r == 0 && FLMSG_dirs[i].new_dir_func)
FLMSG_dirs[i].new_dir_func();
}
nbems_dirs_checked = true;
}
void check_data_dir(void)
{
if (mkdir(DATA_dir.c_str(), 0777) == -1 && errno != EEXIST) {
string s = _("Could not make directory ");
s.append(DATA_dir);
fatal_error(s);
}
}
// Print an error message and exit.
static void arg_error(const char* name, const char* arg, bool missing)
{
ostringstream msg;
msg << name << ": ";
if (arg && *arg) {
if (missing)
msg << "option '" << arg << "' requires an argument\n";
else
msg << "unrecognized option '" << arg << "'\n";
}
else
msg << "error while parsing command line\n";
msg << "See command line help for more information.";
fatal_error(msg.str());
}
/// Sets or resets the KML parameters, and loads existing files.
void kml_init(bool load_files)
{
if (progdefaults.kml_enabled == false) return; // disabled kml service
KmlServer::GetInstance()->InitParams(
progdefaults.kml_command,
progdefaults.kml_save_dir,
(double)progdefaults.kml_merge_distance,
progdefaults.kml_retention_time,
progdefaults.kml_refresh_interval,
progdefaults.kml_balloon_style);
if (load_files)
KmlServer::GetInstance()->ReloadKmlFiles();
/// TODO: Should do this only when the locator has changed.
try {
/// One special KML object for the user.
CoordinateT::Pair myCoo( progdefaults.myLocator );
/// TODO: Fix this: It does not seem to create a polyline when changing the locator.
KmlServer::CustomDataT custData ;
custData.Push( "QTH", progdefaults.myQth );
custData.Push( "Locator", progdefaults.myLocator );
custData.Push( "Antenna", progdefaults.myAntenna );
custData.Push( "Name", progdefaults.myName );
KmlServer::GetInstance()->Broadcast(
"User",
KmlServer::UniqueEvent,
myCoo,
0.0, // Altitude.
progdefaults.myCall,
progdefaults.myLocator,
progdefaults.myQth,
custData );
}
catch( const std::exception & exc ) {
;// LOG_WARN("Cannot publish user position:%s", exc.what() );
}
}
/// Tests if a directory exists.
int directory_is_created( const char * strdir )
{
DIR *dir = opendir(strdir);
if (dir) {
closedir(dir);
return true;
}
return false;
}
| 68,547
|
C++
|
.cxx
| 1,898
| 33.170706
| 109
| 0.681311
|
w1hkj/fldigi
| 109
| 27
| 38
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
751,032
|
status.cxx
|
w1hkj_fldigi/src/status/status.cxx
|
// ---------------------------------------------------------------------
// status.cxx
//
// Copyright (C) 2007-2010
// Dave Freese, W1HKJ
// Copyright (C) 2008-2010
// Stelios Bounanos, M0GLD
//
// This file is part of fldigi.
//
// Fldigi 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 3 of the License, or
// (at your option) any later version.
//
// Fldigi 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 fldigi. If not, see <http://www.gnu.org/licenses/>.
// ---------------------------------------------------------------------
//
// Save all floating point values as integers
//
// int_fval = fval * NNN where NNN is a factor of 10
//
// restore using fval = int_fval / NNN
//
// A work around for a bug in class preferences. Read/Write of floating
// point values fails on read if locale is not EN_...
//
//----------------------------------------------------------------------
#include <config.h>
#include <iostream>
#include <fstream>
#include <string>
#include <FL/Fl_Preferences.H>
#include "gettext.h"
#include "main.h"
#include "globals.h"
#include "status.h"
#include "configuration.h"
#include "confdialog.h"
#include "fl_digi.h"
#include "debug.h"
#include "waterfall.h"
#include "modem.h"
#include "psk.h"
#include "cw.h"
#include "mfsk.h"
#include "rtty.h"
#include "olivia.h"
#include "dominoex.h"
#include "feld.h"
#include "throb.h"
#include "wwv.h"
#include "analysis.h"
#include "rigsupport.h"
#include "Viewer.h"
#include "lgbook.h"
#include "logsupport.h"
#include "qso_db.h"
#include "dx_dialog.h"
#include "contest.h"
#include "misc.h"
#include "data_io.h"
#include "psm/psm.h"
#include "spectrum_viewer.h"
#define STATUS_FILENAME "status"
status progStatus = {
MODE_PSK31, // trx_mode lastmode;
mode_info[MODE_PSK31].sname, // lastmode_name
50, // int mainX;
50, // int mainY;
WMIN, // int mainW;
HMIN, // int mainH;
false, // bool WF_UI;
false, // bool NO_RIGLOG;
false, // bool Rig_Log_UI;
false, // bool Rig_Contest_UI;
false, // bool DOCKEDSCOPE;
false, // bool tbar_is_docked;
// 50, // int RxTextHeight;
WMIN/2, // int tiled_group_x;
true, // bool show_channels;
50, // int rigX;
50, // int rigY;
560, // int rigW
80, // int rigH
1000, // int carrier;
14070000, // int noCATfreq;
"USB", // string noCATmode;
"3000", // string noCATwidth;
1, // int mag;
0, // int offset;
NORMAL, // WFdisp::WFspeed
-20, // reflevel
-2000, // int_reflevel
70, // ampspan
7000, // int_ampspan
50, // uint VIEWERxpos
50, // uint VIEWERypos
200, // uint VIEWERwidth
400, // uint VIEDWERheight
3.0, // double VIEWER_psksquelch
300, // int int_VIEWER_psksquelch
-6.0, // double VIEWER_rttysquelch
-600, // int int_VIEWER_rttysquelch
3.0, // double VIEWER_cwsquelch
300, // int int_VIEWER_cwsquelch
false, // bool VIEWERvisible
50, // unsigned int fsqMONITORxpos;
50, // unsigned int fsqMONITORypos;
600, // unsigned int fsqMONITORwidth;
400, // unsigned int fsqMONITORheight;
100, // int tile_x
200, // int tile_w;
90, // int tile_y;
150, // int tile_h;
0.5, // double tile_y_ratio;
0.5, // double fsq_ratio;
0.5, // double ifkp_ratio;
500, // int int_tile_y_ratio;
500, // int int_fsq_ratio;
500, // int int_ifkp_ratio;
false, // bool LOGenabled
5.0, // double sldrSquelchValue
500, // int int_sldrSquelchValue
5.0, // double sldrPwrSquelchValue
500, // int int_sldrPwrSquelchValue
true, // bool afconoff
true, // bool sqlonoff
false, // bool reverse
-3.0, // double txlevel
50, // int scopeX;
50, // int scopeY;
false, // bool scopeVisible;
172, // int scopeW;
172, // int scopeH;
10, // int svX;
10, // int svY;
550, // int svW;
400, // int svH;
false, // bool x_graticule;
false, // bool y_graticule;
true, // bool xy_graticule;
-1, // int repeatMacro;
0, // float repeatIdleTime;
0, // int timer
0, // int timerMacro
false, // bool skip_sked_macro
"macros.mdf", // string LastMacroFile;
0, // int n_rsids
false, // bool spot_recv
false, // bool spot_log
false, // bool contest
false, // bool quick_entry
true, // bool rx_scroll_hints;
true, // bool rx_word_wrap
true, // bool tx_word_wrap
false, // bool cluster_connected; // not saved
50, // int logbook_x;
50, // int logbook_y;
590, // int logbook_w;
490, // int logbook_h;
false, // bool logbook_reverse;
85, // int logbook_browser_col_0;
47, // int logbook_browser_col_1;
100, // int logbook_browser_col_2;
110, // int logbook_browser_col_3;
120, // int logbook_browser_col_4;
103, // int logbook_browser_col_5;
50, // int dxdialog_x;
50, // int dxdialog_y;
625, // int dxdialog_w;
395, // int dxdialog_h;
progdefaults.contestiatones,
progdefaults.contestiabw,
progdefaults.contestiasmargin,
progdefaults.contestiasinteg,
progdefaults.contestia8bit,
progdefaults.oliviatones,
progdefaults.oliviabw,
progdefaults.oliviasmargin,
progdefaults.oliviasinteg,
progdefaults.olivia8bit,
progdefaults.rtty_shift,
progdefaults.rtty_custom_shift,
progdefaults.rtty_baud,
progdefaults.rtty_bits,
progdefaults.rtty_parity,
progdefaults.rtty_stop,
progdefaults.rtty_reverse,
progdefaults.rtty_crcrlf,
progdefaults.rtty_autocrlf,
progdefaults.rtty_autocount,
progdefaults.rtty_afcspeed,
false, // bool rtty_filter_changed
progdefaults.PreferXhairScope,
true, // bool shaped_rtty
progdefaults.UOSrx,
progdefaults.UOStx,
DEFAULT_XMLPRC_IP_ADDRESS,
DEFAULT_XMLRPC_IP_PORT,
DEFAULT_ARQ_IP_ADDRESS,
DEFAULT_ARQ_IP_PORT,
DEFAULT_KISS_IP_ADDRESS,
DEFAULT_KISS_IP_IO_PORT,
DEFAULT_KISS_IP_OUT_PORT,
progdefaults.kiss_dual_port_enabled,
progdefaults.data_io_enabled,
progdefaults.ax25_decode_enabled,
progdefaults.enableBusyChannel,
progdefaults.busyChannelSeconds,
progdefaults.kpsql_attenuation,
progdefaults.csma_enabled,
progdefaults.kiss_tcp_io,
progdefaults.kiss_tcp_listen,
progdefaults.kpsql_enabled,
progdefaults.csma_persistance,
progdefaults.csma_slot_time,
progdefaults.csma_transmit_delay,
progdefaults.psm_flush_buffer_timeout,
progdefaults.psm_minimum_bandwidth,
progdefaults.psm_minimum_bandwidth_margin,
progdefaults.psm_use_histogram,
progdefaults.psm_histogram_offset_threshold,
progdefaults.psm_hit_time_window,
progdefaults.tx_buffer_timeout,
progdefaults.kiss_io_modem_change_inhibit,
true,
0.0,
0,
progdefaults.psk8DCDShortFlag,
"CQ", // string browser_search;
false, // meters
false, // fsq_rx_abort
false, // ifkp_rx_abort
//----------------------------------------------------------------------
// winkeyer status values
//----------------------------------------------------------------------
"NONE", // string WK_serial_port_name;
1200, // int WK_comm_baudrate;
2, // int WK_stopbits;
2, // int WK_comm_retries;
5, // int WK_comm_wait;
50, // int WK_comm_timeout;
false, // bool WK_comm_echo;
// wkeyer defaults
0xC4, // unsigned char WK_mode_register;
18, // unsigned char WK_speed_wpm;
6, // unsigned char WK_sidetone;
50, // unsigned char WK_weight;
0, // unsigned char WK_lead_in_time;
0, // unsigned char WK_tail_time;
10, // unsigned char WK_min_wpm;
25, // unsigned char WK_max_wpm;
0, // unsigned char WK_first_extension;
0, // unsigned char WK_key_compensation;
0, // unsigned char WK_farnsworth_wpm;
50, // unsigned char WK_paddle_setpoint;
50, // unsigned char WK_dit_dah_ratio;
7, // unsigned char WK_pin_configuration;
255, // unsigned char WK_dont_care;
false, // bool WK_cut_zeronine;
18, // unsigned char WK_cmd_wpm;
false, // bool WK_use_pot
false, // bool WK_online;
2, // int WK_version;
0, // int WKFSK_mode;
0, // int WKFSK_baud;
0, // int WKFSK_stopbits;
0, // int WKFSK_ptt;
0, // int WKFSK_polarity;
0, // int WKFSK_sidetone;
0, // int WKFSK_auto_crlf;
0, // int WKFSK_diddle;
0, // int WKFSK_diddle_char;
0, // int WKFSK_usos;
1, // int WKFSK_monitor;
false, // bool Nav_online;
false, // bool Nav_config_online;
false, // bool nanoCW_online;
false, // bool nanoFSK_online;
false, // bool useCW_KEYLINE;
//----------------------------------------------------------------------
// FMT saved controls
1500.0, // double FMT_ref_freq;
1500000, // int int_FMT_ref_freq;
1500.0, // double FMT_unk_fre;
1500000, // int int_FMT_unk_fre;
1, // int FMT_trk_speed;
1, // int FMT_trk_scale;
2, // int FMT_rec_interval
//----------------------------------------------------------------------
046, // debug_mask
// 046
// 0000000000010110
// ||||||||||||||_ARQ control
// |||||||||||||__Audio
// ||||||||||||___Modem
// |||||||||||____Rig Control
// ||||||||||_____Xmlrpc
// |||||||||______Spotter
// ||||||||_______Data Sources
// |||||||________Synop
// ||||||_________KML
// |||||__________KISS control
// ||||___________Mac Logger
// |||____________Field Day Logger
// ||_____________N3FJP Logger
// |______________Other
3, // debug_level : INFO(3)
//----------------------------------------------------------------------
1, // int vumeter_shown
//----------------------------------------------------------------------
false // bool bLastStateRead;
};
void status::saveLastState()
{
int mX = fl_digi_main->x();
int mY = fl_digi_main->y();
if (mX >= 0 && mX >= 0) {
mainX = mX;
mainY = mY;
}
mainW = fl_digi_main->w();
mainH = fl_digi_main->h();
carrier = wf->Carrier();
mag = wf->Mag();
offset = wf->Offset();
speed = wf->Speed();
reflevel = progdefaults.wfRefLevel;
ampspan = progdefaults.wfAmpSpan;
logbook_x = dlgLogbook->x();
logbook_y = dlgLogbook->y();
logbook_w = dlgLogbook->w();
logbook_h = dlgLogbook->h();
logbook_reverse = cQsoDb::reverse;
logbook_col_0 = wBrowser->columnWidth(0);
logbook_col_1 = wBrowser->columnWidth(1);
logbook_col_2 = wBrowser->columnWidth(2);
logbook_col_3 = wBrowser->columnWidth(3);
logbook_col_4 = wBrowser->columnWidth(4);
logbook_col_5 = wBrowser->columnWidth(5);
dxdialog_x = dxcluster_viewer->x();
dxdialog_y = dxcluster_viewer->y();
dxdialog_w = dxcluster_viewer->w();
dxdialog_h = dxcluster_viewer->h();
if (!bWF_only) {
// RxTextHeight = (ReceiveText->h() * 100) / text_panel->h();//VTgroup->h();
quick_entry = ReceiveText->get_quick_entry();
rx_scroll_hints = ReceiveText->get_scroll_hints();
rx_word_wrap = ReceiveText->get_word_wrap();
tx_word_wrap = TransmitText->get_word_wrap();
tile_w = text_panel->w();
tile_y = progdefaults.rxtx_swap ? TransmitText->h() : ReceiveText->h();
tile_h = text_panel->h();
tile_y_ratio = 1.0 * tile_y / text_group->h();
if (text_panel->w() != ReceiveText->w())
tile_x = mvgroup->w();
fsq_ratio = 1.0 * fsq_rx_text->h() / fsq_group->h();
ifkp_ratio = 1.0 * ifkp_rx_text->h() / ifkp_group->h();
int_tile_y_ratio = round(tile_y_ratio * 1000);
int_fsq_ratio = round(fsq_ratio * 1000);
int_ifkp_ratio = round (ifkp_ratio * 1000);
}
VIEWERvisible = dlgViewer->visible();
if (VIEWERvisible) {
VIEWERxpos = dlgViewer->x();
VIEWERypos = dlgViewer->y();
VIEWERwidth = dlgViewer->w();
VIEWERheight = dlgViewer->h();
}
scopeVisible = scopeview->visible();
scopeX = scopeview->x();
scopeY = scopeview->y();
scopeW = scopeview->w();
scopeH = scopeview->h();
if (spectrum_viewer) {
svX = spectrum_viewer->x();
svY = spectrum_viewer->y();
svW = spectrum_viewer->w();
svH = spectrum_viewer->h();
}
contestiatones = progdefaults.contestiatones;
contestiabw = progdefaults.contestiabw;
contestiamargin = progdefaults.contestiasmargin;
contestiainteg = progdefaults.contestiasinteg;
contestia8bit = progdefaults.contestia8bit;
oliviatones = progdefaults.oliviatones;
oliviabw = progdefaults.oliviabw;
oliviamargin = progdefaults.oliviasmargin;
oliviainteg = progdefaults.oliviasinteg;
olivia8bit = progdefaults.olivia8bit;
rtty_shift = progdefaults.rtty_shift;
rtty_custom_shift = progdefaults.rtty_custom_shift;
rtty_baud = progdefaults.rtty_baud;
rtty_bits = progdefaults.rtty_bits;
rtty_parity = progdefaults.rtty_parity;
rtty_stop = progdefaults.rtty_stop;
rtty_reverse = progdefaults.rtty_reverse;
rtty_crcrlf = progdefaults.rtty_crcrlf;
rtty_autocrlf = progdefaults.rtty_autocrlf;
rtty_autocount = progdefaults.rtty_autocount;
rtty_afcspeed = progdefaults.rtty_afcspeed;
PreferXhairScope = progdefaults.PreferXhairScope;
UOSrx = progdefaults.UOSrx;
UOStx = progdefaults.UOStx;
xmlrpc_address = progdefaults.xmlrpc_address;
xmlrpc_port = progdefaults.xmlrpc_port;
arq_address = progdefaults.arq_address;
arq_port = progdefaults.arq_port;
kiss_address = progdefaults.kiss_address;
kiss_io_port = progdefaults.kiss_io_port;
kiss_out_port = progdefaults.kiss_out_port;
kiss_dual_port_enabled = progdefaults.kiss_dual_port_enabled;
data_io_enabled = progdefaults.data_io_enabled;
ax25_decode_enabled = progdefaults.ax25_decode_enabled;
enableBusyChannel = progdefaults.enableBusyChannel;
busyChannelSeconds = progdefaults.busyChannelSeconds;
kpsql_attenuation = progdefaults.kpsql_attenuation;
csma_enabled = progdefaults.csma_enabled;
kiss_tcp_io = progdefaults.kiss_tcp_io;
kiss_tcp_listen = progdefaults.kiss_tcp_listen;
kpsql_enabled = progdefaults.kpsql_enabled;
csma_persistance = progdefaults.csma_persistance;
csma_slot_time = progdefaults.csma_slot_time;
csma_transmit_delay = progdefaults.csma_transmit_delay;
psm_flush_buffer_timeout = progdefaults.psm_flush_buffer_timeout;
psm_minimum_bandwidth = progdefaults.psm_minimum_bandwidth;
psm_minimum_bandwidth_margin = progdefaults.psm_minimum_bandwidth_margin;
psm_use_histogram = progdefaults.psm_use_histogram;
psm_histogram_offset_threshold = progdefaults.psm_histogram_offset_threshold;
psm_hit_time_window = progdefaults.psm_hit_time_window;
tx_buffer_timeout = progdefaults.tx_buffer_timeout;
kiss_io_modem_change_inhibit = progdefaults.kiss_io_modem_change_inhibit;
squelch_value = 0;
int_squelch_value = 0;
Fl_Preferences spref(HomeDir.c_str(), "w1hkj.com", PACKAGE_TARNAME);
spref.set("version", PACKAGE_VERSION);
spref.set("dual_channels", "YES");
spref.set("mode_name", mode_info[lastmode].sname);
spref.set("squelch_enabled", sqlonoff);
spref.set("int_squelch_level", (int)round(sldrSquelchValue * 100));
spref.set("int_pwr_squelch_level", (int)round(sldrPwrSquelchValue * 100));
spref.set("afc_enabled", afconoff);
spref.set("reverse", reverse);
spref.set("psk8DCDShortFlag", psk8DCDShortFlag);
spref.set("log_enabled", LOGenabled);
spref.set("wf_carrier", carrier);
spref.set("wf_mag", mag);
spref.set("wf_offset", offset);
spref.set("wf_speed", speed);
spref.set("int_wf_reflevel", (int)round(reflevel * 100));
spref.set("int_wf_ampspan", (int)round(ampspan * 100));
spref.set("noCATfreq", noCATfreq);
spref.set("noCATmode", noCATmode.c_str());
spref.set("noCATwidth", noCATwidth.c_str());
spref.set("main_x", mainX);
spref.set("main_y", mainY);
spref.set("main_w", mainW);
if (!bWF_only) {
spref.set("main_h", mainH);
// spref.set("rx_text_height", RxTextHeight);
spref.set("tiled_group_x", tiled_group_x);
spref.set("show_channels", show_channels);
}
spref.set("wf_ui", WF_UI);
spref.set("riglog_ui", Rig_Log_UI);
spref.set("rigcontest_ui", Rig_Contest_UI);
spref.set("noriglog", NO_RIGLOG);
spref.set("docked_scope", DOCKEDSCOPE);
spref.set("tbar_is_docked", tbar_is_docked);
spref.set("rigctl_x", rigX);
spref.set("rigctl_y", rigY);
spref.set("rigctl_w", rigW);
spref.set("rigctl_h", rigH);
spref.set("viewer_visible", VIEWERvisible);
spref.set("viewer_x", static_cast<int>(VIEWERxpos));
spref.set("viewer_y", static_cast<int>(VIEWERypos));
spref.set("viewer_w", static_cast<int>(VIEWERwidth));
spref.set("viewer_h", static_cast<int>(VIEWERheight));
spref.set("int_viewer_psksq", (int)round(VIEWER_psksquelch * 100));
spref.set("int_viewer_rttysq", (int)round(VIEWER_rttysquelch * 100));
spref.set("int_viewer_cwsq", (int)round(VIEWER_cwsquelch * 100));
spref.set("fsq_monitor_x", static_cast<int>(fsqMONITORxpos));
spref.set("fsq_monitor_y", static_cast<int>(fsqMONITORypos));
spref.set("fsq_monitor_w", static_cast<int>(fsqMONITORwidth));
spref.set("fsq_monitor_h", static_cast<int>(fsqMONITORheight));
spref.set("tile_x", tile_x);
spref.set("tile_y", tile_y);
spref.set("tile_w", tile_w);
spref.set("tile_h", tile_h);
spref.set("int_tile_y_ratio", int_tile_y_ratio);
spref.set("int_fsq_ratio", int_fsq_ratio);
spref.set("int_ifkp_ratio", int_ifkp_ratio);
spref.set("scope_visible", scopeVisible);
spref.set("scope_x", scopeX);
spref.set("scope_y", scopeY);
spref.set("scope_w", scopeW);
spref.set("scope_h", scopeH);
spref.set("svX", svX);
spref.set("svY", svY);
spref.set("svW", svW);
spref.set("svH", svH);
spref.set("x_graticule", x_graticule);
spref.set("y_graticule", y_graticule);
spref.set("xy_graticule", xy_graticule);
spref.set("last_macro_file", LastMacroFile.c_str());
spref.set("spot_recv", spot_recv);
spref.set("spot_log", spot_log);
spref.set("contest", contest);
spref.set("quick_entry", quick_entry);
spref.set("rx_scroll_hints", rx_scroll_hints);
spref.set("rx_word_wrap", rx_word_wrap);
spref.set("tx_word_wrap", tx_word_wrap);
spref.set("logbook_x", logbook_x);
spref.set("logbook_y", logbook_y);
spref.set("logbook_w", logbook_w);
spref.set("logbook_h", logbook_h);
spref.set("logbook_reverse", logbook_reverse);
spref.set("logbook_col_0", logbook_col_0);
spref.set("logbook_col_1", logbook_col_1);
spref.set("logbook_col_2", logbook_col_2);
spref.set("logbook_col_3", logbook_col_3);
spref.set("logbook_col_4", logbook_col_4);
spref.set("logbook_col_5", logbook_col_5);
spref.set("dxdialog_x", dxdialog_x);
spref.set("dxdialog_y", dxdialog_y);
spref.set("dxdialog_w", dxdialog_w);
spref.set("dxdialog_h", dxdialog_h);
spref.set("contestiatones", contestiatones);
spref.set("contestiabw", contestiabw);
spref.set("contestiamargin", contestiamargin);
spref.set("contestiainteg", contestiainteg);
spref.set("contestia8bit", contestia8bit);
spref.set("oliviaiatones", oliviatones);
spref.set("oliviaiabw", oliviabw);
spref.set("oliviaiamargin", oliviamargin);
spref.set("oliviaiainteg", oliviainteg);
spref.set("oliviaia8bit", olivia8bit);
spref.set("rtty_shift", rtty_shift);
spref.set("rtty_custom_shift", rtty_custom_shift);
spref.set("rtty_baud", rtty_baud);
spref.set("rtty_bits", rtty_bits);
spref.set("rtty_parity", rtty_parity);
spref.set("rtty_stop", rtty_stop);
spref.set("rtty_reverse", rtty_reverse);
spref.set("rtty_crcrlf", rtty_crcrlf);
spref.set("rtty_autocrlf", rtty_autocrlf);
spref.set("rtty_autocount", rtty_autocount);
spref.set("rtty_afcspeed", rtty_afcspeed);
spref.set("preferxhairscope", PreferXhairScope);
spref.set("shaped_rtty", shaped_rtty);
spref.set("uosrx", UOSrx);
spref.set("uostx", UOStx);
if(!xmlrpc_address_override_flag) {
spref.set("xmlrpc_address", xmlrpc_address.c_str());
spref.set("xmlrpc_port", xmlrpc_port.c_str());
}
if(!arq_address_override_flag) {
spref.set("arq_address", arq_address.c_str());
spref.set("arq_port", arq_port.c_str());
}
if(!kiss_address_override_flag) {
spref.set("kiss_address", kiss_address.c_str());
spref.set("kiss_io_port", kiss_io_port.c_str());
spref.set("kiss_out_port", kiss_out_port.c_str());
spref.set("kiss_dual_port_enabled", kiss_dual_port_enabled);
}
if(!override_data_io_enabled)
spref.set("data_io_enabled", data_io_enabled);
spref.set("ax25_decode_enabled", ax25_decode_enabled);
spref.set("enableBusyChannel", enableBusyChannel);
spref.set("busyChannelSeconds", busyChannelSeconds);
spref.set("kpsql_attenuation", kpsql_attenuation);
spref.set("csma_enabled", csma_enabled);
spref.set("kiss_tcp_io", kiss_tcp_io);
spref.set("kiss_tcp_listen", kiss_tcp_listen);
spref.set("kpsql_enabled", kpsql_enabled);
spref.set("csma_persistance", csma_persistance);
spref.set("csma_slot_time", csma_slot_time);
spref.set("csma_transmit_delay", csma_transmit_delay);
spref.set("psm_flush_buffer_timeout", psm_flush_buffer_timeout);
spref.set("psm_minimum_bandwidth", psm_minimum_bandwidth);
spref.set("psm_minimum_bandwidth_margin", psm_minimum_bandwidth_margin);
spref.set("psm_use_histogram", psm_use_histogram);
spref.set("psm_histogram_offset_threshold", psm_histogram_offset_threshold);
spref.set("psm_hit_time_window", psm_hit_time_window);
spref.set("tx_buffer_timeout", tx_buffer_timeout);
spref.set("kiss_io_modem_change_inhibit", kiss_io_modem_change_inhibit);
spref.set("browser_search", browser_search.c_str());
spref.set("meters", meters);
//----------------------------------------------------------------------
// WinKeyer prefs set
spref.set("WK_serial_port_name", WK_serial_port_name.c_str());
spref.set("WK_mode_register", WK_mode_register);
spref.set("WK_speed_wpm", WK_speed_wpm);
spref.set("WK_cut_zeronine", WK_cut_zeronine);
spref.set("WK_cmd_wpm", WK_cmd_wpm);
spref.set("WK_sidetone", WK_sidetone);
spref.set("WK_weight", WK_weight);
spref.set("WK_lead_in_time", WK_lead_in_time);
spref.set("WK_tail_time", WK_tail_time);
spref.set("WK_min_wpm", WK_min_wpm);
spref.set("WK_rng_wpm", WK_rng_wpm);
spref.set("WK_1st_ext", WK_first_extension);
spref.set("WK_key_comp", WK_key_compensation);
spref.set("WK_farnsworth", WK_farnsworth_wpm);
spref.set("WK_paddle_set", WK_paddle_setpoint);
spref.set("WK_dit_dah_ratio", WK_dit_dah_ratio);
spref.set("WK_pin_config", WK_pin_configuration);
spref.set("WK_use_pot", WK_use_pot);
spref.set("WK_online", WK_online);
spref.set("WK_version", WK_version);
spref.set("WKFSK_mode", WKFSK_mode);
spref.set("WKFSK_baud", WKFSK_baud);
spref.set("WKFSK_stopbits", WKFSK_stopbits);
spref.set("WKFSK_ptt", WKFSK_ptt);
spref.set("WKFSK_polarity", WKFSK_polarity);
spref.set("WKFSK_sidetone", WKFSK_sidetone);
spref.set("WKFSK_auto_crlf", WKFSK_auto_crlf);
spref.set("WKFSK_diddle", WKFSK_diddle);
spref.set("WKFSK_diddle_char", WKFSK_diddle_char);
spref.set("WKFSK_usos", WKFSK_usos);
spref.set("WKFSK_monitor", WKFSK_monitor);
spref.set("Nav_online", Nav_online);
spref.set("Nav_config_online", Nav_config_online);
spref.set("nanoCW_online", nanoCW_online);
spref.set("nanoFSK_online", nanoFSK_online);
spref.set("useCW_KEYLINE", useCW_KEYLINE);
//----------------------------------------------------------------------
// FMT saved controls
spref.set("int_FMT_ref_freq", (int)round(FMT_ref_freq * 1000));
spref.set("int_FMT_unk_freq", (int)round(FMT_unk_freq * 1000));
spref.set("FMT_rec_interval", FMT_rec_interval);
spref.set("FMT_trk_scale", FMT_trk_scale);
spref.set("FMT_minutes", FMT_minutes);
//----------------------------------------------------------------------
debug_mask = debug::mask;
spref.set("debug_mask", debug_mask);
debug_level = debug::level;
spref.set("debug_level", debug_level);
//----------------------------------------------------------------------
spref.set("vumeter_shown", vumeter_shown);
save_mode_state();
}
void status::loadLastState()
{
Fl_Preferences spref(HomeDir.c_str(), "w1hkj.com", PACKAGE_TARNAME);
int i;
char strbuff[1000];
char version[64]; version[sizeof(version)-1] = '\0';
// Skip loading the rest of the status variables if we didn't read a
// version name/value pair; or this is not a file that supports dual
// channel browsers.
bLastStateRead = spref.get("version", version, "", sizeof(version)-1);
if (!bLastStateRead)
return;
bLastStateRead = spref.get("dual_channels", version, "", sizeof(version) - 1);
if (!bLastStateRead)
return;
memset(strbuff, 0, sizeof(strbuff));
spref.get("mode_name", strbuff, mode_info[MODE_PSK31].sname, sizeof(strbuff) - 1);
mode_name = strbuff;
lastmode = MODE_PSK31;
for (i = 0; i < NUM_MODES;i++) {
if (mode_name == mode_info[i].sname) {
lastmode = (trx_mode) i;
break;
}
}
spref.get("squelch_enabled", i, sqlonoff); sqlonoff = i;
spref.get("int_squelch_level", i, int_sldrSquelchValue); int_sldrSquelchValue = i;
sldrSquelchValue = int_sldrSquelchValue / 100.0;
spref.get("int_pwr_squelch_level", i, int_sldrPwrSquelchValue); int_sldrPwrSquelchValue = i;
sldrPwrSquelchValue = int_sldrPwrSquelchValue / 100.0;
spref.get("afc_enabled", i, afconoff); afconoff = i;
spref.get("reverse", i, reverse); reverse = i;
// spref.get("rx_text_height", RxTextHeight, RxTextHeight);
spref.get("tiled_group_x", tiled_group_x, tiled_group_x);
spref.get("show_channels", i, show_channels); show_channels = i;
spref.get("log_enabled", i, LOGenabled); LOGenabled = i;
spref.get("wf_carrier", carrier, carrier);
spref.get("wf_mag", mag, mag);
spref.get("wf_offset", offset, offset);
spref.get("wf_speed", speed, speed);
spref.get("int_wf_reflevel", int_reflevel, int_reflevel);
reflevel = int_reflevel / 100.0;
progdefaults.wfRefLevel = reflevel;
spref.get("int_wf_ampspan", int_ampspan, int_ampspan);
ampspan = int_ampspan / 100.0;
progdefaults.wfAmpSpan = ampspan;
spref.get("noCATfreq", noCATfreq, noCATfreq);
memset(strbuff, 0, sizeof(strbuff));
spref.get("noCATmode", strbuff, "USB", sizeof(strbuff) - 1);
noCATmode = strbuff;
memset(strbuff, 0, sizeof(strbuff));
spref.get("noCATwidth", strbuff, "3000", sizeof(strbuff) - 1);
noCATwidth = strbuff;
spref.get("main_x", mainX, mainX);
if (mainX > Fl::w())
mainX = 0;
spref.get("main_y", mainY, mainY);
if (mainY > Fl::h())
mainY = 0;
spref.get("main_w", mainW, mainW);
if (mainW < WMIN) mainW = WMIN;
if (mainW > Fl::w()) mainW = Fl::w();
spref.get("main_h", mainH, mainH);
// if (mainH < HMIN) mainH = HMIN;
if (mainH > Fl::w()) mainH = Fl::h();
spref.get("wf_ui", i, WF_UI); WF_UI = i;
spref.get("riglog_ui", i, Rig_Log_UI); Rig_Log_UI = i;
spref.get("rigcontest_ui", i, Rig_Contest_UI); Rig_Contest_UI = i;
spref.get("noriglog", i, NO_RIGLOG); NO_RIGLOG = i;
spref.get("docked_scope", i, DOCKEDSCOPE); DOCKEDSCOPE = i;
spref.get("tbar_is_docked", i, tbar_is_docked); tbar_is_docked = i;
spref.get("rigctl_x", rigX, rigX);
spref.get("rigctl_y", rigY, rigY);
spref.get("rigctl_w", rigW, rigW);
spref.get("rigctl_h", rigH, rigH);
spref.get("viewer_visible", i, VIEWERvisible); VIEWERvisible = i;
spref.get("viewer_x", i, VIEWERxpos); VIEWERxpos = i;
spref.get("viewer_y", i, VIEWERypos); VIEWERypos = i;
spref.get("viewer_w", i, VIEWERwidth); VIEWERwidth = i;
spref.get("viewer_h", i, VIEWERheight); VIEWERheight = i;
spref.get("int_viewer_psksq", int_VIEWER_psksquelch, int_VIEWER_psksquelch);
VIEWER_psksquelch = int_VIEWER_psksquelch / 100.0;
spref.get("int_viewer_rttysq", int_VIEWER_rttysquelch, int_VIEWER_rttysquelch);
VIEWER_rttysquelch = int_VIEWER_rttysquelch / 100.0;
spref.get("int_viewer_cwsq", int_VIEWER_cwsquelch, int_VIEWER_cwsquelch);
VIEWER_cwsquelch = int_VIEWER_cwsquelch / 100.0;
spref.get("fsq_monitor_x", i, fsqMONITORxpos); fsqMONITORxpos = i;
spref.get("fsq_monitor_y", i, fsqMONITORypos); fsqMONITORypos = i;
spref.get("fsq_monitor_w", i, fsqMONITORwidth); fsqMONITORwidth = i;
spref.get("fsq_monitor_h", i, fsqMONITORheight); fsqMONITORheight = i;
spref.get("tile_x", tile_x, tile_x);
spref.get("tile_y", tile_y, tile_y);
spref.get("tile_w", tile_w, tile_w);
spref.get("tile_h", tile_h, tile_h);
spref.get("int_tile_y_ratio", int_tile_y_ratio, int_tile_y_ratio);
spref.get("int_fsq_ratio", int_fsq_ratio, int_fsq_ratio);
spref.get("int_ifkp_ratio", int_ifkp_ratio, int_ifkp_ratio);
tile_y_ratio = int_tile_y_ratio / 1000.0;
fsq_ratio = int_fsq_ratio / 1000.0;
ifkp_ratio = int_ifkp_ratio / 1000.0;
spref.get("scope_visible", i, scopeVisible); scopeVisible = i;
spref.get("scope_x", scopeX, scopeX);
spref.get("scope_y", scopeY, scopeY);
spref.get("scope_w", scopeW, scopeW);
spref.get("scope_h", scopeH, scopeH);
spref.get("svX", svX, svX);
spref.get("svY", svY, svY);
spref.get("svW", svW, svW);
spref.get("svH", svH, svH);
spref.get("x_graticule", i, x_graticule); x_graticule = i;
spref.get("y_graticule", i, y_graticule); y_graticule = i;
spref.get("xy_graticule",i, xy_graticule); xy_graticule = i;
memset(strbuff, 0, sizeof(strbuff));
spref.get("last_macro_file", strbuff, "macros.mdf", sizeof(strbuff) - 1);
LastMacroFile = strbuff;
spref.get("spot_recv", i, spot_recv); spot_recv = i;
spref.get("spot_log", i, spot_log); spot_log = i;
spref.get("contest", i, contest); contest = i;
spref.get("quick_entry", i, quick_entry); quick_entry = i;
spref.get("rx_scroll_hints", i, rx_scroll_hints); rx_scroll_hints = i;
spref.get("rx_word_wrap", i, rx_word_wrap); rx_word_wrap = i;
spref.get("tx_word_wrap", i, tx_word_wrap); tx_word_wrap = i;
spref.get("logbook_x", logbook_x, logbook_x);
spref.get("logbook_y", logbook_y, logbook_y);
spref.get("logbook_w", logbook_w, logbook_w);
spref.get("logbook_h", logbook_h, logbook_h);
spref.get("logbook_reverse", i, logbook_reverse); logbook_reverse = i;
spref.get("logbook_col_0", logbook_col_0, logbook_col_0);
spref.get("logbook_col_1", logbook_col_1, logbook_col_1);
spref.get("logbook_col_2", logbook_col_2, logbook_col_2);
spref.get("logbook_col_3", logbook_col_3, logbook_col_3);
spref.get("logbook_col_4", logbook_col_4, logbook_col_4);
spref.get("logbook_col_5", logbook_col_5, logbook_col_5);
spref.get("dxdialog_x", dxdialog_x, dxdialog_x);
spref.get("dxdialog_y", dxdialog_y, dxdialog_y);
spref.get("dxdialog_w", dxdialog_w, dxdialog_w);
spref.get("dxdialog_h", dxdialog_h, dxdialog_h);
spref.get("contestiatones", contestiatones, contestiatones);
spref.get("contestiabw", contestiabw, contestiabw);
spref.get("contestiamargin", contestiamargin, contestiamargin);
spref.get("contestiainteg", contestiainteg, contestiainteg);
spref.get("contestia8bit", i, contestia8bit); contestia8bit = i;
spref.get("oliviaiatones", oliviatones, oliviatones);
spref.get("oliviaiabw", oliviabw, oliviabw);
spref.get("oliviaiamargin", oliviamargin, oliviamargin);
spref.get("oliviaiainteg", oliviainteg, oliviainteg);
spref.get("oliviaia8bit", i, olivia8bit); olivia8bit = i;
spref.get("rtty_shift", rtty_shift, rtty_shift);
spref.get("rtty_custom_shift", rtty_custom_shift, rtty_custom_shift);
spref.get("rtty_baud", rtty_baud, rtty_baud);
spref.get("rtty_bits", rtty_bits, rtty_bits);
spref.get("rtty_parity", rtty_parity, rtty_parity);
spref.get("rtty_stop", rtty_stop, rtty_stop);
spref.get("rtty_reverse", i, rtty_reverse); rtty_reverse = i;
spref.get("rtty_crcrlf", i, rtty_crcrlf); rtty_crcrlf = i;
spref.get("rtty_autocrlf", i, rtty_autocrlf); rtty_autocrlf = i;
spref.get("rtty_autocount", rtty_autocount, rtty_autocount);
spref.get("rtty_afcspeed", rtty_afcspeed, rtty_afcspeed);
spref.get("preferxhairscope", i, PreferXhairScope); PreferXhairScope = i;
spref.get("shaped_rtty", i, shaped_rtty); shaped_rtty = i;
spref.get("uosrx", i, UOSrx); UOSrx = i;
spref.get("uostx", i, UOStx); UOStx = i;
if(!xmlrpc_address_override_flag) {
memset(strbuff, 0, sizeof(strbuff));
spref.get("xmlrpc_address", strbuff, xmlrpc_address.c_str(), sizeof(strbuff) - 1);
xmlrpc_address = strbuff;
}
if (!xmlrpc_port_override_flag) {
memset(strbuff, 0, sizeof(strbuff));
spref.get("xmlrpc_port", strbuff, xmlrpc_port.c_str(), sizeof(strbuff) - 1);
xmlrpc_port = strbuff;
}
if(!arq_address_override_flag) {
memset(strbuff, 0, sizeof(strbuff));
spref.get("arq_address", strbuff, arq_address.c_str(), sizeof(strbuff) - 1);
arq_address = strbuff;
}
if(!arq_port_override_flag) {
memset(strbuff, 0, sizeof(strbuff));
spref.get("arq_port", strbuff, arq_port.c_str(), sizeof(strbuff) - 1);
arq_port = strbuff;
}
if(!kiss_address_override_flag) {
memset(strbuff, 0, sizeof(strbuff));
spref.get("kiss_address", strbuff, kiss_address.c_str(), sizeof(strbuff) - 1);
kiss_address = strbuff;
memset(strbuff, 0, sizeof(strbuff));
spref.get("kiss_io_port", strbuff, kiss_io_port.c_str(), sizeof(strbuff) - 1);
kiss_io_port = strbuff;
memset(strbuff, 0, sizeof(strbuff));
spref.get("kiss_out_port", strbuff, kiss_out_port.c_str(), sizeof(strbuff) - 1);
kiss_out_port = strbuff;
spref.get("kiss_dual_port_enabled", i, kiss_dual_port_enabled); kiss_dual_port_enabled = i;
}
if(!override_data_io_enabled) {
spref.get("data_io_enabled", i, data_io_enabled); data_io_enabled = i;
}
spref.get("ax25_decode_enabled", i, ax25_decode_enabled); ax25_decode_enabled = i;
spref.get("enableBusyChannel", i, enableBusyChannel); enableBusyChannel = i;
spref.get("busyChannelSeconds", i, busyChannelSeconds); busyChannelSeconds = i;
spref.get("kpsql_attenuation", i, kpsql_attenuation); kpsql_attenuation = i;
spref.get("csma_enabled", i, csma_enabled); csma_enabled = i;
spref.get("kiss_tcp_io", i, kiss_tcp_io); kiss_tcp_io = i;
spref.get("kiss_tcp_listen", i, kiss_tcp_listen); kiss_tcp_listen = i;
spref.get("kpsql_enabled", i, kpsql_enabled); kpsql_enabled = i;
spref.get("csma_persistance", i, csma_persistance); csma_persistance = i;
spref.get("csma_slot_time", i, csma_slot_time); csma_slot_time = i;
spref.get("csma_transmit_delay", i, csma_transmit_delay); csma_transmit_delay = i;
spref.get("psm_flush_buffer_timeout", i, psm_flush_buffer_timeout); psm_flush_buffer_timeout = i;
spref.get("psm_minimum_bandwidth", i, psm_minimum_bandwidth); psm_minimum_bandwidth = i;
spref.get("psm_minimum_bandwidth_margin", i, psm_minimum_bandwidth_margin); psm_minimum_bandwidth_margin = i;
spref.get("psm_use_histogram", i, psm_use_histogram); psm_use_histogram = i;
spref.get("psm_histogram_offset_threshold", i, psm_histogram_offset_threshold); psm_histogram_offset_threshold = i;
spref.get("psm_hit_time_window", i, psm_hit_time_window); psm_hit_time_window = i;
spref.get("tx_buffer_timeout", i, tx_buffer_timeout); tx_buffer_timeout = i;
spref.get("kiss_io_modem_change_inhibit", i, kiss_io_modem_change_inhibit); kiss_io_modem_change_inhibit = i;
spref.get("psk8DCDShortFlag", i, psk8DCDShortFlag); psk8DCDShortFlag = i;
memset(strbuff, 0, sizeof(strbuff));
spref.get("browser_search", strbuff, browser_search.c_str(), sizeof(strbuff) - 1);
browser_search = strbuff;
seek_re.recompile(browser_search.c_str());
spref.get("meters", i, meters); meters = i;
//----------------------------------------------------------------------
// WinKeyer prefs get
//----------------------------------------------------------------------
spref.get("WK_serial_port_name", strbuff, "NONE", 199);
WK_serial_port_name = strbuff;
if (WK_serial_port_name.find("tty") == 0)
WK_serial_port_name.insert(0, "/dev/");
spref.get("WK_mode_register", i, WK_mode_register); WK_mode_register = i;
spref.get("WK_speed_wpm", i, WK_speed_wpm); WK_speed_wpm = i;
spref.get("WK_cmd_wpm", i, WK_cmd_wpm); WK_cmd_wpm = i;
spref.get("WK_cut_zeronine", i, WK_cut_zeronine); WK_cut_zeronine = i;
spref.get("WK_sidetone", i, WK_sidetone); WK_sidetone = i;
spref.get("WK_weight", i, WK_weight); WK_weight = i;
spref.get("WK_lead_in_time", i, WK_lead_in_time); WK_lead_in_time = i;
spref.get("WK_tail_time", i, WK_tail_time); WK_tail_time = i;
spref.get("WK_min_wpm", i, WK_min_wpm); WK_min_wpm = i;
spref.get("WK_rng_wpm", i, WK_rng_wpm); WK_rng_wpm = i;
spref.get("WK_1st_ext", i, WK_first_extension); WK_first_extension = i;
spref.get("WK_key_comp", i, WK_key_compensation); WK_key_compensation = i;
spref.get("WK_farnsworth", i, WK_farnsworth_wpm); WK_farnsworth_wpm = i;
spref.get("WK_paddle_set", i, WK_paddle_setpoint); WK_paddle_setpoint = i;
spref.get("WK_dit_dah_ratio", i, WK_dit_dah_ratio); WK_dit_dah_ratio = i;
spref.get("WK_pin_config", i, WK_pin_configuration); WK_pin_configuration = i;
spref.get("WK_use_pot", i, WK_use_pot); WK_use_pot = i;
spref.get("WK_online", i, WK_online); WK_online = i;
spref.get("WK_version", WK_version, WK_version);
spref.get("WKFSK_mode", WKFSK_mode, WKFSK_mode);
spref.get("WKFSK_baud", WKFSK_baud, WKFSK_baud);
spref.get("WKFSK_stopbits", WKFSK_stopbits, WKFSK_stopbits);
spref.get("WKFSK_ptt", WKFSK_ptt, WKFSK_ptt);
spref.get("WKFSK_polarity", WKFSK_polarity, WKFSK_polarity);
spref.get("WKFSK_sidetone", WKFSK_sidetone, WKFSK_sidetone);
spref.get("WKFSK_auto_crlf", WKFSK_auto_crlf, WKFSK_auto_crlf);
spref.get("WKFSK_diddle", WKFSK_diddle, WKFSK_diddle);
spref.get("WKFSK_diddle_char", WKFSK_diddle_char, WKFSK_diddle_char);
spref.get("WKFSK_diddle_char", WKFSK_diddle_char, WKFSK_diddle_char);
spref.get("WKFSK_monitor", WKFSK_monitor, WKFSK_monitor);
spref.get("Nav_online", i, Nav_online); Nav_online = i;
spref.get("Nav_config_online", i, Nav_config_online); Nav_config_online = i;
spref.get("nanoCW_online", i, nanoCW_online); nanoCW_online = i;
spref.get("nanoFSK_online", i, nanoFSK_online); nanoFSK_online = i;
spref.get("useCW_KEYLINE", i, useCW_KEYLINE); useCW_KEYLINE = i;
//----------------------------------------------------------------------
// FMT saved controls
spref.get("int_FMT_ref_freq", int_FMT_ref_freq, int_FMT_ref_freq);
FMT_ref_freq = int_FMT_ref_freq / 1000.0;
spref.get("int_FMT_unk_freq", int_FMT_unk_freq, int_FMT_unk_freq);
FMT_unk_freq = int_FMT_unk_freq / 1000.0;
spref.get("FMT_rec_interval", FMT_rec_interval, FMT_rec_interval);
spref.get("FMT_trk_scale", FMT_trk_scale, FMT_trk_scale);
spref.get("FMT_minutes", FMT_minutes, FMT_minutes);
//----------------------------------------------------------------------
spref.get("debug_level", debug_level, debug_level);
spref.get("debug_mask", debug_mask, debug_mask);
//----------------------------------------------------------------------
spref.get("vumeter_shown", vumeter_shown, vumeter_shown);
//----------------------------------------------------------------------
load_mode_state();
set_debug_mask(debug_mask);
}
void status::initLastState()
{
if (!bLastStateRead)
loadLastState();
// RTTY
if (lastmode == MODE_RTTY ) {
progdefaults.rtty_shift = rtty_shift;
selShift->index(progdefaults.rtty_shift);
if (rtty_shift == selShift->lsize() - 1) {
selCustomShift->deactivate();
}
else { // Custom shift
selCustomShift->activate();
}
selBaud->index((progdefaults.rtty_baud = rtty_baud));
selBits->index((progdefaults.rtty_bits = rtty_bits));
selParity->index((progdefaults.rtty_parity = rtty_parity));
selStopBits->index((progdefaults.rtty_stop = rtty_stop));
btnCRCRLF->value(progdefaults.rtty_crcrlf = rtty_crcrlf);
btnAUTOCRLF->value(progdefaults.rtty_autocrlf = rtty_autocrlf);
cntrAUTOCRLF->value(progdefaults.rtty_autocount = rtty_autocount);
chkUOSrx->value(progdefaults.UOSrx = UOSrx);
chkUOStx->value(progdefaults.UOStx = UOStx);
i_listbox_rtty_afc_speed->index(progdefaults.rtty_afcspeed = rtty_afcspeed);
btnPreferXhairScope->value(progdefaults.PreferXhairScope = PreferXhairScope);
if (mvsquelch) {
mvsquelch->range(-12.0, 6.0);
mvsquelch->value(VIEWER_rttysquelch);
}
if (sldrViewerSquelch) {
sldrViewerSquelch->range(-12.0, 6.0);
sldrViewerSquelch->value(VIEWER_rttysquelch);
}
}
if (lastmode >= MODE_PSK_FIRST && lastmode <= MODE_PSK_LAST) {
if (mvsquelch) {
mvsquelch->range(-3.0, 6.0);
mvsquelch->value(VIEWER_psksquelch);
}
if (sldrViewerSquelch) {
sldrViewerSquelch->range(-3.0, 6.0);
sldrViewerSquelch->value(VIEWER_psksquelch);
}
}
// OLIVIA
if (lastmode == MODE_OLIVIA) {
i_listbox_olivia_tones->index(progdefaults.oliviatones = oliviatones);
i_listbox_olivia_bandwidth->index(progdefaults.oliviabw = oliviabw);
cntOlivia_smargin->value(progdefaults.oliviasmargin = oliviamargin);
cntOlivia_sinteg->value(progdefaults.oliviasinteg = oliviainteg);
btnOlivia_8bit->value(progdefaults.olivia8bit = olivia8bit);
}
// CONTESTIA
if (lastmode == MODE_CONTESTIA) {
i_listbox_contestia_tones->index(progdefaults.contestiatones = contestiatones);
i_listbox_contestia_bandwidth->index(progdefaults.contestiabw = contestiabw);
cntContestia_smargin->value(progdefaults.contestiasmargin = contestiamargin);
cntContestia_sinteg->value(progdefaults.contestiasinteg = contestiainteg);
btnContestia_8bit->value(progdefaults.contestia8bit = contestia8bit);
}
init_modem_sync(lastmode);
wf->opmode();
wf->Mag(mag);
wf->Offset(offset);
wf->Speed(speed);
wf->setRefLevel();
wf->setAmpSpan();
btnAFC->value(afconoff);
if(override_data_io_enabled != DISABLED_IO) {
data_io_enabled = override_data_io_enabled;
progdefaults.data_io_enabled = data_io_enabled;
data_io_enabled = data_io_enabled;
}
if(data_io_enabled == KISS_IO) {
data_io_enabled = KISS_IO;
progdefaults.data_io_enabled = KISS_IO;
} else {
data_io_enabled = ARQ_IO;
progdefaults.data_io_enabled = ARQ_IO;
data_io_enabled = ARQ_IO;
kpsql_enabled = false;
}
btnSQL->value(sqlonoff);
btnPSQL->value(kpsql_enabled);
if(kpsql_enabled)
sldrSquelch->value(sldrPwrSquelchValue);
else
sldrSquelch->value(sldrSquelchValue);
if (arq_address_override_flag)
arq_address = progdefaults.arq_address = override_arq_address;
if (arq_port_override_flag)
arq_port = progdefaults.arq_port = override_arq_port;
if(kiss_address_override_flag) {
if(!override_kiss_address.empty())
kiss_address = progdefaults.kiss_address = override_kiss_address;
if(!override_kiss_io_port.empty())
kiss_io_port = progdefaults.kiss_io_port = override_kiss_io_port;
if(!override_kiss_out_port.empty())
kiss_out_port = progdefaults.kiss_out_port = override_kiss_out_port;
if(override_kiss_dual_port_enabled > -1)
kiss_dual_port_enabled = progdefaults.kiss_dual_port_enabled = override_kiss_dual_port_enabled;
}
if (xmlrpc_address_override_flag)
xmlrpc_address = progdefaults.xmlrpc_address = override_xmlrpc_address;
if (xmlrpc_port_override_flag)
xmlrpc_port = progdefaults.xmlrpc_port = override_xmlrpc_port;
txtArq_ip_address->value(arq_address.c_str());
txtArq_ip_port_no->value(arq_port.c_str());
txtXmlrpc_ip_address->value(xmlrpc_address.c_str());
txtXmlrpc_ip_port_no->value(xmlrpc_port.c_str());
txtKiss_ip_address->value(kiss_address.c_str());
txtKiss_ip_io_port_no->value(kiss_io_port.c_str());
txtKiss_ip_out_port_no->value(kiss_out_port.c_str());
btnEnable_dual_port->value(kiss_dual_port_enabled);
progdefaults.kiss_dual_port_enabled = kiss_dual_port_enabled;
btnEnable_csma->value(csma_enabled);
progdefaults.csma_enabled = csma_enabled;
btnEnable_ax25_decode->value(ax25_decode_enabled);
progdefaults.ax25_decode_enabled = ax25_decode_enabled;
cntKPSQLAttenuation->value(kpsql_attenuation);
progdefaults.kpsql_attenuation = kpsql_attenuation;
kiss_io_set_button_state(0);
if (bWF_only)
fl_digi_main->resize(mainX, mainY, mainW, Hmenu + Hwfall + Hstatus);
else {
fl_digi_main->resize(mainX, mainY, mainW, mainH);
set_macroLabels();
UI_select();
}
if (VIEWERvisible)
openViewer();
if (scopeview) {
scopeview->resize(scopeX, scopeY, scopeW, scopeH);
digiscope->resize(0,0,scopeW,scopeH);
if (scopeVisible)
scopeview->show();
}
cQsoDb::reverse = logbook_reverse;
if (cQsoDb::reverse) {
qsodb.SortByDate(progdefaults.sort_date_time_off);
loadBrowser();
}
dlgLogbook->resize(logbook_x, logbook_y, logbook_w, logbook_h);
wBrowser->columnWidth(0, logbook_col_0);
wBrowser->columnWidth(1, logbook_col_1);
wBrowser->columnWidth(2, logbook_col_2);
wBrowser->columnWidth(3, logbook_col_3);
wBrowser->columnWidth(4, logbook_col_4);
wBrowser->columnWidth(5, logbook_col_5);
dxcluster_viewer->resize(dxdialog_x, dxdialog_y, dxdialog_w, dxdialog_h);
ReceiveText->set_all_entry(quick_entry);
ReceiveText->set_scroll_hints(rx_scroll_hints);
ReceiveText->set_word_wrap(rx_word_wrap, true);
TransmitText->set_word_wrap(tx_word_wrap, true);
disable_config_p2p_io_widgets();
update_csma_io_config(CSMA_ALL);
// config_WK
choice_WK_keyer_mode->add("Iambic B");
choice_WK_keyer_mode->add("Iambic A");
choice_WK_keyer_mode->add("Ultimatic");
choice_WK_keyer_mode->add("Bug Mode");
choice_WK_keyer_mode->index((WK_mode_register & 0x30) >> 4);
choice_WK_output_pins->add("Key 1");
choice_WK_output_pins->add("Key 2");
choice_WK_output_pins->add("Key 1 & 2");
choice_WK_output_pins->index(((WK_pin_configuration & 0x06) >> 2) - 1);
choice_WK_sidetone->add("4000");
choice_WK_sidetone->add("2000");
choice_WK_sidetone->add("1333");
choice_WK_sidetone->add("1000");
choice_WK_sidetone->add("800");
choice_WK_sidetone->add("666");
choice_WK_sidetone->add("571");
choice_WK_sidetone->add("500");
choice_WK_sidetone->add("444");
choice_WK_sidetone->add("400");
choice_WK_sidetone->index((WK_sidetone & 0x0F) - 1);
choice_WK_hang->add("Wait 1.0");
choice_WK_hang->add("Wait 1.33");
choice_WK_hang->add("Wait 1.66");
choice_WK_hang->add("Wait 2.0");
choice_WK_hang->index((WK_pin_configuration & 0x30) >> 4);
cntr_WK_tail->minimum(0);
cntr_WK_tail->maximum(250);
cntr_WK_tail->step(10);
cntr_WK_tail->value(WK_tail_time);
cntr_WK_leadin->minimum(0);
cntr_WK_leadin->maximum(250);
cntr_WK_leadin->step(10);
cntr_WK_leadin->value(WK_lead_in_time);
cntr_WK_weight->minimum(10);
cntr_WK_weight->maximum(90);
cntr_WK_weight->step(1);
cntr_WK_weight->value(WK_weight);
cntr_WK_sample->minimum(10);
cntr_WK_sample->maximum(90);
cntr_WK_sample->step(1);
cntr_WK_sample->value(WK_paddle_setpoint);
cntr_WK_first_ext->minimum(0);
cntr_WK_first_ext->maximum(250);
cntr_WK_first_ext->step(1);
cntr_WK_first_ext->value(WK_first_extension);
cntr_WK_comp->minimum(0);
cntr_WK_comp->maximum(250);
cntr_WK_comp->step(1);
cntr_WK_comp->value(WK_key_compensation);
cntr_WK_ratio->minimum(2.0);
cntr_WK_ratio->maximum(4.0);
cntr_WK_ratio->step(0.1);
cntr_WK_ratio->value(WK_dit_dah_ratio * 3 / 50.0);
cntr_WK_cmd_wpm->minimum(10);
cntr_WK_cmd_wpm->maximum(30);
cntr_WK_cmd_wpm->step(1);
cntr_WK_cmd_wpm->value(WK_cmd_wpm);
cntr_WK_farnsworth->minimum(10);
cntr_WK_farnsworth->maximum(99);
cntr_WK_farnsworth->step(1);
cntr_WK_farnsworth->value(WK_farnsworth_wpm);
cntr_WK_rng_wpm->minimum(10);
cntr_WK_rng_wpm->maximum(40);
cntr_WK_rng_wpm->step(1);
cntr_WK_rng_wpm->value(WK_rng_wpm);
cntr_WK_min_wpm->minimum(5);
cntr_WK_min_wpm->maximum(89);
cntr_WK_min_wpm->step(1);
cntr_WK_min_wpm->value(WK_min_wpm);
btn_WK_sidetone_on->value(WK_sidetone);
btn_WK_cut_zeronine->value(WK_cut_zeronine);
btn_WK_ptt_on->value((WK_pin_configuration & 0x01) == 0x01);
btn_WK_tone_on->value((WK_pin_configuration & 0x02) == 0x02);
btn_WK_ct_space->value((WK_mode_register & 0x01) == 0x01);
btn_WK_auto_space->value((WK_mode_register & 0x02) == 0x02);
btn_WK_serial_echo->value((WK_mode_register & 0x04) == 0x04);
btn_WK_swap->value((WK_mode_register & 0x08) == 0x08);
btn_WK_paddle_echo->value((WK_mode_register & 0x40) == 0x40);
btn_WK_paddledog->value((WK_mode_register & 0x80) == 0x80);
select_WK_CommPort->value(WK_serial_port_name.c_str());
}
| 48,324
|
C++
|
.cxx
| 1,170
| 38.901709
| 119
| 0.674322
|
w1hkj/fldigi
| 109
| 27
| 38
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
751,033
|
squelch_status.cxx
|
w1hkj_fldigi/src/status/squelch_status.cxx
|
// ---------------------------------------------------------------------
// squelch_status.cxx
//
// Copyright (C) 2021
// Dave Freese, W1HKJ
//
// This file is part of fldigi.
//
// Fldigi 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 3 of the License, or
// (at your option) any later version.
//
// Fldigi 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 fldigi. If not, see <http://www.gnu.org/licenses/>.
// ---------------------------------------------------------------------
//
// Save all floating point values as integers
//
// int_fval = fval * NNN where NNN is a factor of 10
//
// restore using fval = int_fval / NNN
//
// A work around for a bug in class preferences. Read/Write of floating
// point values fails on read if locale is not EN_...
//
//----------------------------------------------------------------------
#include <config.h>
#include <iostream>
#include <fstream>
#include <string>
#include <FL/Fl_Preferences.H>
#include "squelch_status.h"
#include "configuration.h"
#include "status.h"
#include "main.h"
// { mode, squelch_level, squelch_state, tx_atten, afc_state, reverse }
struct struct_mode_state mode_state[NUM_MODES] = {
{ MODE_NULL, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_CW, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_CONTESTIA, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_CONTESTIA_4_125, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_CONTESTIA_4_250, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_CONTESTIA_4_500, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_CONTESTIA_4_1000, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_CONTESTIA_4_2000, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_CONTESTIA_8_125, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_CONTESTIA_8_250, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_CONTESTIA_8_500, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_CONTESTIA_8_1000, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_CONTESTIA_8_2000, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_CONTESTIA_16_250, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_CONTESTIA_16_500, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_CONTESTIA_16_1000, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_CONTESTIA_16_2000, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_CONTESTIA_32_1000, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_CONTESTIA_32_2000, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_CONTESTIA_64_500, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_CONTESTIA_64_1000, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_CONTESTIA_64_2000, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_DOMINOEXMICRO, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_DOMINOEX4, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_DOMINOEX5, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_DOMINOEX8, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_DOMINOEX11, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_DOMINOEX16, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_DOMINOEX22, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_DOMINOEX44, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_DOMINOEX88, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_FELDHELL, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_SLOWHELL, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_HELLX5, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_HELLX9, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_FSKH245, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_FSKH105, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_HELL80, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_MFSK8, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_MFSK16, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_MFSK32, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_MFSK4, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_MFSK11, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_MFSK22, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_MFSK31, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_MFSK64, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_MFSK128, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_MFSK64L, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_MFSK128L, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_WEFAX_576, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_WEFAX_288, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_NAVTEX, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_SITORB, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_MT63_500S, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_MT63_500L, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_MT63_1000S, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_MT63_1000L, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_MT63_2000S, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_MT63_2000L, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_PSK31, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_PSK63, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_PSK63F, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_PSK125, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_PSK250, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_PSK500, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_PSK1000, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_12X_PSK125, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_6X_PSK250, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_2X_PSK500, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_4X_PSK500, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_2X_PSK800, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_2X_PSK1000, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_QPSK31, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_QPSK63, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_QPSK125, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_QPSK250, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_QPSK500, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_8PSK125, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_8PSK125FL, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_8PSK125F, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_8PSK250, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_8PSK250FL, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_8PSK250F, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_8PSK500, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_8PSK500F, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_8PSK1000, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_8PSK1000F, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_8PSK1200F, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_OFDM_500F, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_OFDM_750F, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_OFDM_2000F, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_OFDM_2000, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_OFDM_3500, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_OLIVIA, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_OLIVIA_4_125, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_OLIVIA_4_250, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_OLIVIA_4_500, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_OLIVIA_4_1000, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_OLIVIA_4_2000, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_OLIVIA_8_125, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_OLIVIA_8_250, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_OLIVIA_8_500, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_OLIVIA_8_1000, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_OLIVIA_8_2000, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_OLIVIA_16_500, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_OLIVIA_16_1000, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_OLIVIA_16_2000, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_OLIVIA_32_1000, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_OLIVIA_32_2000, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_OLIVIA_64_500, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_OLIVIA_64_1000, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_OLIVIA_64_2000, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_RTTY, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_THORMICRO, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_THOR4, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_THOR5, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_THOR8, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_THOR11, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_THOR16, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_THOR22, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_THOR25x4, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_THOR50x1, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_THOR50x2, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_THOR100, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_THROB1, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_THROB2, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_THROB4, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_THROBX1, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_THROBX2, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_THROBX4, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_PSK125R, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_PSK250R, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_PSK500R, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_PSK1000R, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_4X_PSK63R, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_5X_PSK63R, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_10X_PSK63R, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_20X_PSK63R, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_32X_PSK63R, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_4X_PSK125R, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_5X_PSK125R, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_10X_PSK125R, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_12X_PSK125R, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_16X_PSK125R, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_2X_PSK250R, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_3X_PSK250R, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_5X_PSK250R, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_6X_PSK250R, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_7X_PSK250R, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_2X_PSK500R, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_3X_PSK500R, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_4X_PSK500R, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_2X_PSK800R, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_2X_PSK1000R, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_FSQ, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_IFKP, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_SSB, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_WWV, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_ANALYSIS, 10, STATE_ON, -30, STATE_ON, STATE_ON },
{ MODE_FMT, 10, STATE_ON, -30, STATE_ON, STATE_ON }
};
void set_mode_squelch( trx_mode mode, double sqlch)
{
mode_state[mode].squelch_level = sqlch;
}
double get_mode_squelch( trx_mode mode )
{
return mode_state[mode].squelch_level;
}
void set_mode_squelch_onoff( trx_mode mode, int sql)
{
mode_state[mode].squelch_state = sql;
}
int get_mode_squelch_onoff( trx_mode mode )
{
return mode_state[mode].squelch_state;
}
void set_mode_txlevel( trx_mode mode, double sqlch)
{
mode_state[mode].tx_atten = sqlch * 10;
}
double get_mode_txlevel( trx_mode mode )
{
return mode_state[mode].tx_atten / 10.0;
}
void set_mode_afc( trx_mode mode, int on)
{
mode_state[mode].afc_state = on;
}
int get_mode_afc( trx_mode mode )
{
return mode_state[mode].afc_state;
}
void set_mode_reverse( trx_mode mode, int on)
{
mode_state[mode].reverse = on;
}
int get_mode_reverse( trx_mode mode )
{
return mode_state[mode].reverse;
}
static int firstuse = 1;
void load_mode_state()
{
int val = 10;
int state = STATE_ON;
Fl_Preferences spref(HomeDir.c_str(), "w1hkj.com", "mode_state");
spref.get("firstuse", firstuse, firstuse);
if (firstuse) {
for (size_t n = MODE_NULL; n <= NUM_RXTX_MODES; n++) {
mode_state[n].squelch_level = progStatus.sldrSquelchValue;
mode_state[n].squelch_state = progStatus.sqlonoff;
mode_state[n].tx_atten = 10 * progStatus.txlevel;
mode_state[n].afc_state = progStatus.afconoff;
mode_state[n].reverse = progStatus.reverse;
}
return;
}
for (size_t n = MODE_NULL; n <= NUM_RXTX_MODES; n++) {
spref.get(
std::string( mode_info[n].name).append(".squelch_level").c_str(),
val,
mode_state[n].squelch_level);
mode_state[n].squelch_level = val;
spref.get(
std::string( mode_info[n].name).append(".squelch_state").c_str(),
state,
mode_state[n].squelch_state);
mode_state[n].squelch_state = state;
spref.get(
std::string( mode_info[n].name).append(".tx_atten").c_str(),
val,
mode_state[n].tx_atten);
mode_state[n].tx_atten = val;
spref.get(
std::string( mode_info[n].name).append(".afc_state").c_str(),
state,
mode_state[n].afc_state);
mode_state[n].afc_state = state;
spref.get(
std::string( mode_info[n].name).append(".reverse").c_str(),
state,
mode_state[n].reverse);
mode_state[n].reverse = state;
}
}
void save_mode_state()
{
Fl_Preferences spref(HomeDir.c_str(), "w1hkj.com", "mode_state");
spref.set("firstuse", 0);
for (size_t n = MODE_NULL; n <= NUM_RXTX_MODES; n++) {
spref.set(
std::string( mode_info[n].name).append(".squelch_level").c_str(),
mode_state[n].squelch_level);
spref.set( std::string(
mode_info[n].name).append(".squelch_state").c_str(),
mode_state[n].squelch_state);
spref.set(
std::string( mode_info[n].name).append(".tx_atten").c_str(),
mode_state[n].tx_atten);
spref.set( std::string(
mode_info[n].name).append(".afc_state").c_str(),
mode_state[n].afc_state);
spref.set( std::string(
mode_info[n].name).append(".reverse").c_str(),
mode_state[n].reverse);
}
}
| 14,097
|
C++
|
.cxx
| 311
| 43.607717
| 72
| 0.650912
|
w1hkj/fldigi
| 109
| 27
| 38
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
751,034
|
norig.cxx
|
w1hkj_fldigi/src/rigcontrol/norig.cxx
|
// ----------------------------------------------------------------------------
// norig.cxx
//
// Copyright (C) 2016
// Dave Freese, W1HKJ
//
// This file is part of fldigi.
//
// Fldigi 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 3 of the License, or
// (at your option) any later version.
//
// Fldigi 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 fldigi. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include <config.h>
#include <ctime>
#include <sys/time.h>
#include <iostream>
#include <list>
#include <vector>
#include <string>
#ifdef RIGCATTEST
#include "rigCAT.h"
#else
#include "fl_digi.h"
#include "misc.h"
#include "configuration.h"
#endif
#include "rigsupport.h"
#include "rigxml.h"
#include "trx.h"
#include "serial.h"
#include "rigio.h"
#include "debug.h"
#include "threads.h"
#include "qrunner.h"
#include "confdialog.h"
#include "status.h"
//----------------------------------------------------------------------
// functions used when no xcvr control is in use
//----------------------------------------------------------------------
long long noCAT_getfreq() {
return progStatus.noCATfreq;
}
void noCAT_setfreq(long long f)
{
progStatus.noCATfreq = f;
wf->rfcarrier(f);
}
std::string noCAT_getmode()
{
return progStatus.noCATmode;
}
void noCAT_setmode(const std::string &md)
{
progStatus.noCATmode = md;
if (ModeIsLSB(md))
wf->USB(false);
else
wf->USB(true);
}
std::string noCAT_getwidth()
{
return progStatus.noCATwidth;
}
void noCAT_setwidth(const std::string &w)
{
progStatus.noCATwidth = w;
show_bw(w);
}
void noCAT_setPTT(bool val)
{
rigio.SetPTT(val); // always execute the h/w ptt if enabled
}
void noCAT_init()
{
qso_setFreq(progStatus.noCATfreq);
wf->rfcarrier(progStatus.noCATfreq);
init_NoRig_RigDialog();
qso_opMODE->value(progStatus.noCATmode.c_str());
chkUSEHAMLIB->value(0);
chkUSEHAMLIB->redraw();
btnInitHAMLIB->labelcolor(FL_BLACK);
btnInitHAMLIB->redraw_label();
chkUSERIGCAT->value(0);
chkUSERIGCAT->redraw();
btnInitRIGCAT->labelcolor(FL_BLACK);
btnInitRIGCAT->redraw_label();
return;
}
| 2,560
|
C++
|
.cxx
| 97
| 24.876289
| 79
| 0.660123
|
w1hkj/fldigi
| 109
| 27
| 38
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
751,035
|
rigsupport.cxx
|
w1hkj_fldigi/src/rigcontrol/rigsupport.cxx
|
// ----------------------------------------------------------------------------
// rigsupport.cxx - support functions file
//
// Copyright (C) 2007-2009
// Dave Freese, W1HKJ
// Copyright (C) 2008-2009
// Stelios Bounanos, M0GLD
//
// This file is part of fldigi.
//
// Fldigi 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 3 of the License, or
// (at your option) any later version.
//
// Fldigi 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 fldigi. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include <config.h>
#include <fstream>
#include <sstream>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
#include <iterator>
#include <cstring>
#include "rigsupport.h"
#include "rigxml.h"
#include "rigio.h"
#include "threads.h"
#include "main.h"
#include "fl_digi.h"
#include "trx.h"
#include "configuration.h"
#include "globals.h"
#include "debug.h"
#include "gettext.h"
extern void n3fjp_set_freq(long);
extern bool n3fjp_connected;
LOG_FILE_SOURCE(debug::LOG_RIGCONTROL);
std::string windowTitle;
std::vector<qrg_mode_t> freqlist;
const unsigned char nfields = 5;//4;
int fwidths[nfields];
enum { max_rfcarrier, max_rmode, max_mode, max_carrier };
#if !USE_HAMLIB
typedef enum {
RIG_MODE_NONE = 0, /*!< '' -- None */
RIG_MODE_AM = (1<<0), /*!< \c AM -- Amplitude Modulation */
RIG_MODE_CW = (1<<1), /*!< \c CW -- CW "normal" sideband */
RIG_MODE_USB = (1<<2), /*!< \c USB -- Upper Side Band */
RIG_MODE_LSB = (1<<3), /*!< \c LSB -- Lower Side Band */
RIG_MODE_RTTY = (1<<4), /*!< \c RTTY -- Radio Teletype */
RIG_MODE_FM = (1<<5), /*!< \c FM -- "narrow" band FM */
RIG_MODE_WFM = (1<<6), /*!< \c WFM -- broadcast wide FM */
RIG_MODE_CWR = (1<<7), /*!< \c CWR -- CW "reverse" sideband */
RIG_MODE_RTTYR = (1<<8), /*!< \c RTTYR -- RTTY "reverse" sideband */
RIG_MODE_AMS = (1<<9), /*!< \c AMS -- Amplitude Modulation Synchronous */
RIG_MODE_PKTLSB = (1<<10),/*!< \c PKTLSB -- Packet/Digital LSB mode (dedicated port) */
RIG_MODE_PKTUSB = (1<<11),/*!< \c PKTUSB -- Packet/Digital USB mode (dedicated port) */
RIG_MODE_PKTFM = (1<<12),/*!< \c PKTFM -- Packet/Digital FM mode (dedicated port) */
RIG_MODE_ECSSUSB = (1<<13),/*!< \c ECSSUSB -- Exalted Carrier Single Sideband USB */
RIG_MODE_ECSSLSB = (1<<14),/*!< \c ECSSLSB -- Exalted Carrier Single Sideband LSB */
RIG_MODE_FAX = (1<<15),/*!< \c FAX -- Facsimile Mode */
RIG_MODE_SAM = (1<<16),/*!< \c SAM -- Synchronous AM double sideband */
RIG_MODE_SAL = (1<<17),/*!< \c SAL -- Synchronous AM lower sideband */
RIG_MODE_SAH = (1<<18),/*!< \c SAH -- Synchronous AM upper (higher) sideband */
RIG_MODE_DSB = (1<<19), /*!< \c DSB -- Double sideband suppressed carrier */
} rmode_t;
#endif
struct rmode_name_t {
rmode_t mode;
const char *name;
} modes[] = {
{ RIG_MODE_NONE, "NONE" },
{ RIG_MODE_AM, "AM" },
{ RIG_MODE_CW, "CW" },
{ RIG_MODE_USB, "USB" },
{ RIG_MODE_LSB, "LSB" },
{ RIG_MODE_RTTY, "RTTY" },
{ RIG_MODE_FM, "FM" },
{ RIG_MODE_WFM, "WFM" },
{ RIG_MODE_CWR, "CWR" },
{ RIG_MODE_RTTYR, "RTTYR" },
{ RIG_MODE_AMS, "AMS" },
{ RIG_MODE_PKTLSB, "PKTLSB" },
{ RIG_MODE_PKTUSB, "PKTUSB" },
{ RIG_MODE_PKTFM, "PKTFM" }
//, // C99 trailing commas in enumerations not yet in the C++ standard
// { RIG_MODE_ECSSUSB, "ECSSUSB" },
// { RIG_MODE_ECSSLSB, "ECSSLSB" },
// { RIG_MODE_FAX, "FAX" }
// the above are covered by our requirement that hamlib be >= 1.2.4
#if (defined(RIG_MODE_SAM) && defined(RIG_MODE_SAL) && defined(RIG_MODE_SAH))
, // C99 trailing commas in enumerations not yet in the C++ standard
{ RIG_MODE_SAM, "SAM" },
{ RIG_MODE_SAL, "SAL" },
{ RIG_MODE_SAH, "SAH" }
#endif
};
std::map<std::string, rmode_t> mode_nums;
std::map<rmode_t, std::string> mode_names;
void qso_selMode(rmode_t m)
{
qso_opMODE->value(mode_names[m].c_str());
}
std::string modeString(rmode_t m)
{
return mode_names[m].c_str();
}
void initOptionMenus()
{
qso_opMODE->clear();
std::list<MODE>::iterator MD;
std::list<MODE> *pMD = 0;
if (lmodes.empty() == false)
pMD = &lmodes;
else if (lmodeCMD.empty() == false)
pMD = &lmodeCMD;
//printf("initOptionMenus()\n");
if (pMD) {
MD = pMD->begin();
while (MD != pMD->end()) {
//printf("adding mode: %s\n", (*MD).SYMBOL.c_str());
qso_opMODE->add( (*MD).SYMBOL.c_str());
MD++;
}
qso_opMODE->activate();
qso_opMODE->index(0);
}
else {
qso_opMODE->deactivate();
}
qso_opBW->clear();
std::list<BW>::iterator bw;
std::list<BW> *pBW = 0;
if (lbws.empty() == false)
pBW = &lbws;
else if (lbwCMD.empty() == false)
pBW = &lbwCMD;
if (pBW) {
bw = pBW->begin();
while (bw != pBW->end()) {
//printf("adding BW: %s\n", (*bw).SYMBOL.c_str());
qso_opBW->add( (*bw).SYMBOL.c_str());
bw++;
}
qso_opBW->activate();
qso_opBW->index(0);
}
else {
qso_opBW->deactivate();
}
}
void clearList()
{
freqlist.clear();
qso_opBrowser->clear();
}
void updateSelect()
{
if (freqlist.empty())
return;
for (size_t i = 0; i < freqlist.size(); i++) {
qso_opBrowser->add(freqlist[i].str().c_str());
}
}
size_t updateList(long rf, int freq, std::string rmd, trx_mode md, std::string usage = "")
{
qrg_mode_t m;
m.rmode = rmd;
m.mode = md;
m.rfcarrier = rf;
m.carrier = freq;
m.usage = usage;
freqlist.push_back(m);
sort(freqlist.begin(), freqlist.end());
std::vector<qrg_mode_t>::const_iterator pos = find(freqlist.begin(), freqlist.end(), m);
if (pos != freqlist.end())
return pos - freqlist.begin();
else
return 0;
}
size_t addtoList(long val)
{
qrg_mode_t m;
m.rfcarrier = val;
if (strlen(qso_opMODE->value()))
m.rmode = qso_opMODE->value();
if (active_modem) {
m.carrier = active_modem->get_freq();
m.mode = active_modem->get_mode();
}
return updateList(val, m.carrier, m.rmode, m.mode);
}
bool readFreqList()
{
std::ifstream freqfile((HomeDir + "frequencies2.txt").c_str());
if (!freqfile) {
LOG_ERROR("Could not open %s", (HomeDir + "frequencies2.txt").c_str());
return false;
}
std::string line;
qrg_mode_t m;
while (!getline(freqfile, line).eof()) {
LOG_INFO("%s", line.c_str());
if (line[0] == '#')
continue;
std::istringstream is(line);
is >> m;
freqlist.push_back(m);
}
sort(freqlist.begin(), freqlist.end());
updateSelect();
freqfile.close();
return freqlist.size();
}
void saveFreqList()
{
if (freqlist.empty()) return;
std::ofstream freqfile((HomeDir + "frequencies2.txt").c_str());
if (!freqfile) {
LOG_ERROR("Could not open %s", (HomeDir + "frequencies2.txt").c_str());
return;
}
freqfile << "# rfcarrier rig_mode carrier mode usage\n";
copy( freqlist.begin(),
freqlist.end(),
std::ostream_iterator<qrg_mode_t>(freqfile, "\n") );
freqfile.close();
}
void build_frequencies2_list()
{
if (!freqlist.empty()) saveFreqList();
clearList();
// calculate the column widths
memset(fwidths, 0, sizeof(fwidths));
// these need to be a little wider than fl_width thinks
fwidths[max_rmode] = fwidths[max_mode] =
fwidths[max_carrier] = fwidths[max_rfcarrier]= 15;
fwidths[max_rfcarrier] += (int)ceil(fl_width("999999.999"));
fwidths[max_rmode] += (int)ceil(fl_width("XXXXXX"));
fwidths[max_carrier] += (int)ceil(fl_width("8888"));
// find mode with longest shortname
size_t s, smax = 0, mmax = 0;
for (size_t i = 0; i < NUM_MODES; i++) {
s = strlen(mode_info[i].sname);
if (smax < s) {
smax = s;
mmax = i;
}
}
fwidths[max_mode] += (int)ceil(fl_width(mode_info[mmax].sname));
if (readFreqList() == true)
return;
updateList (1807000L, 1000, "USB", MODE_PSK31 );
updateList (3505000L, 800, "USB", MODE_CW);
updateList (3580000L, 1000, "USB", MODE_PSK31 );
updateList (1000500L, 800, "USB", MODE_CW);
updateList (10135000L, 1000, "USB", MODE_PSK31 );
updateList (7005000L, 800, "USB", MODE_CW);
updateList (7030000L, 1000, "USB", MODE_PSK31 );
updateList (7070000L, 1000, "USB", MODE_PSK31 );
updateList (14005000L, 800, "USB", MODE_CW);
updateList (14070000L, 1000, "USB", MODE_PSK31 );
updateList (18100000L, 1000, "USB", MODE_PSK31 );
updateList (21005000L, 800, "USB", MODE_CW);
updateList (21070000L, 1000, "USB", MODE_PSK31 );
updateList (24920000L, 1000, "USB", MODE_PSK31 );
updateList (28005000L, 800, "USB", MODE_CW);
updateList (28120000, 1000, "USB", MODE_PSK31 );
updateSelect();
}
int cb_qso_opMODE()
{
if (connected_to_flrig) {
set_flrig_mode(qso_opMODE->value());
return 0;
}
#if USE_HAMLIB
if (progdefaults.chkUSEHAMLIBis)
hamlib_setmode(mode_nums[qso_opMODE->value()]);
else
#endif
if (progdefaults.chkUSERIGCATis)
rigCAT_setmode(qso_opMODE->value());
else
noCAT_setmode(qso_opMODE->value());
return 0;
}
int cb_qso_opBW()
{
if (connected_to_flrig)
set_flrig_bw(qso_opBW->index(), -1);
else if (progdefaults.chkUSERIGCATis)
rigCAT_setwidth(qso_opBW->value());
else
noCAT_setwidth(qso_opBW->value());
return 0;
}
int cb_qso_btnBW1()
{
qso_btnBW1->hide();
qso_opBW1->hide();
qso_btnBW2->show();
qso_opBW2->show();
return 0;
}
int cb_qso_btnBW2()
{
qso_btnBW2->hide();
qso_opBW2->hide();
qso_btnBW1->show();
qso_opBW1->show();
return 0;
}
int cb_qso_opBW1()
{
//printf("opBW1 %d:%s\n", qso_opBW1->index(), qso_opBW1->value());
set_flrig_bw(qso_opBW2->index(), qso_opBW1->index());
return 0;
}
int cb_qso_opBW2()
{
//printf("opBW2 %d:%s\n", qso_opBW2->index(), qso_opBW2->value());
set_flrig_bw(qso_opBW2->index(), qso_opBW1->index());
return 0;
}
void sendFreq(long int f)
{
if (connected_to_flrig)
set_flrig_freq(f);
#if USE_HAMLIB
else if (progdefaults.chkUSEHAMLIBis)
hamlib_setfreq(f);
#endif
else if (progdefaults.chkUSERIGCATis)
rigCAT_setfreq(f);
else
noCAT_setfreq(f);
if (n3fjp_connected)
n3fjp_set_freq(f);
}
void qso_movFreq(Fl_Widget* w, void *data)
{
cFreqControl *fc = (cFreqControl *)w;
long int f;
long restore = reinterpret_cast<intptr_t>(data);
f = fc->value();
if (fc == qsoFreqDisp1) {
qsoFreqDisp2->value(f);
qsoFreqDisp3->value(f);
} else if (fc == qsoFreqDisp2) {
qsoFreqDisp1->value(f);
qsoFreqDisp3->value(f);
} else {
qsoFreqDisp1->value(f);
qsoFreqDisp2->value(f);
}
sendFreq(f);
if (restore == 1)
restoreFocus();
return;
}
void qso_selectFreq(long int rfcarrier, int carrier)
{
if (rfcarrier > 0) {
qsoFreqDisp1->value(rfcarrier);
qsoFreqDisp2->value(rfcarrier);
qsoFreqDisp3->value(rfcarrier);
sendFreq(rfcarrier);
}
if (carrier > 0) {
active_modem->set_freq(carrier);
}
}
void qso_selectFreq()
{
int n = qso_opBrowser->value();
if (!n) return;
n -= 1;
// transceiver mode
if (freqlist[n].rmode != "NONE") {
qso_opMODE->value(freqlist[n].rmode.c_str());
cb_qso_opMODE();
}
// transceiver frequency
if (freqlist[n].rfcarrier > 0) {
qsoFreqDisp1->value(freqlist[n].rfcarrier);
qsoFreqDisp2->value(freqlist[n].rfcarrier);
qsoFreqDisp3->value(freqlist[n].rfcarrier);
sendFreq(freqlist[n].rfcarrier);
}
// modem type & audio sub carrier
if (freqlist[n].mode != NUM_MODES) {
if (freqlist[n].mode != active_modem->get_mode())
init_modem_sync(freqlist[n].mode);
if (freqlist[n].carrier > 0)
active_modem->set_freq(freqlist[n].carrier);
}
}
void qso_setFreq(long int f)
{
// transceiver frequency
if (f > 0) {
qsoFreqDisp->value(f);
sendFreq(f);
}
}
void qso_setFreq()
{
int n = qso_opBrowser->value();
if (!n) return;
n -= 1;
// transceiver frequency
qso_setFreq(freqlist[n].rfcarrier);
}
void qso_delFreq()
{
int v = qso_opBrowser->value() - 1;
if (v >= 0) {
freqlist.erase(freqlist.begin() + v);
qso_opBrowser->remove(v + 1);
}
}
void qso_addFreq()
{
long freq = qsoFreqDisp->value();
if (freq) {
size_t pos = addtoList(freq);
qso_opBrowser->insert(pos+1, freqlist[pos].str().c_str());
}
}
void qso_updateEntry(int i, std::string usage)
{
int v = i - 1;
int sz = (int)freqlist.size();
if ((v >= 0) && (v < sz)) {
freqlist[v].usage = usage;
}
}
void setTitle()
{
update_main_title();
}
bool init_Xml_RigDialog()
{
LOG_DEBUG("xml rig");
initOptionMenus();
xcvr_title = xmlrig.rigTitle;
setTitle();
return true;
}
bool init_NoRig_RigDialog()
{
LOG_DEBUG("no rig");
qso_opBW->clear();
qso_opBW->add(" ");
qso_opBW->index(0);
qso_opBW->redraw();
qso_opBW->deactivate();
qso_opMODE->clear();
//printf("init_NoRig_RigDialog()\n");
for (size_t i = 0; i < sizeof(modes)/sizeof(modes[0]); i++) {
//printf("adding %s\n", modes[i].name);
qso_opMODE->add(modes[i].name);
}
// list of LSB type modes that various xcvrs report via flrig
LSBmodes.clear();
LSBmodes.push_back("LSB");
LSBmodes.push_back("LSB-D");
LSBmodes.push_back("LSB-D1");
LSBmodes.push_back("LSB-D2");
LSBmodes.push_back("LSB-D3");
LSBmodes.push_back("CW");
LSBmodes.push_back("LCW");
LSBmodes.push_back("CW-N");
LSBmodes.push_back("CWL");
LSBmodes.push_back("RTTY");
LSBmodes.push_back("RTTY-L");
LSBmodes.push_back("PKTLSB");
LSBmodes.push_back("PKT-L");
LSBmodes.push_back("USER-L");
LSBmodes.push_back("DATA-L");
LSBmodes.push_back("DATA");
LSBmodes.push_back("D-LSB");
qso_opMODE->index(3);
qso_opMODE->activate();
xcvr_title.clear();
setTitle();
return true;
}
#if USE_HAMLIB
bool init_Hamlib_RigDialog()
{
LOG_DEBUG("hamlib");
qso_opBW->deactivate();
qso_opMODE->clear();
for (size_t i = 0; i < sizeof(modes)/sizeof(modes[0]); i++) {
mode_nums[modes[i].name] = modes[i].mode;
mode_names[modes[i].mode] = modes[i].name;
qso_opMODE->add(modes[i].name);
}
xcvr_title = "Hamlib ";
xcvr_title.append(xcvr->getName());
setTitle();
return true;
}
#endif
| 14,018
|
C++
|
.cxx
| 515
| 25.184466
| 94
| 0.654021
|
w1hkj/fldigi
| 109
| 27
| 38
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
751,036
|
FreqControl.cxx
|
w1hkj_fldigi/src/rigcontrol/FreqControl.cxx
|
// ----------------------------------------------------------------------------
// Frequency Control Widget
//
// Copyright (C) 2014
// David Freese, W1HKJ
//
// This file is part of flrig.
//
// flrig 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 3 of the License, or
// (at your option) any later version.
//
// flrig 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, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include <config.h>
#include <FL/Fl.H>
#include <FL/Fl_Float_Input.H>
#include <FL/fl_draw.H>
#include <FL/Fl_Box.H>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <stdio.h>
#include "fl_digi.h"
#include "qrunner.h"
#include "FreqControl.h"
#include "gettext.h"
#include "configuration.h"
const char *cFreqControl::Label[10] = {
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
void cFreqControl::IncFreq (int nbr) {
double v = (double)val + (double)mult[nbr] * precision;
if (v <= maxVal) val = (unsigned long int)v;
updatevalue();
do_callback();
}
void cFreqControl::DecFreq (int nbr) {
double v = (double)val - (double)mult[nbr] * precision;
if (v >= minVal) val = (unsigned long int)v;
updatevalue();
do_callback();
}
void cbSelectDigit (Fl_Widget *btn, void * nbr)
{
Fl_Button *b = (Fl_Button *)btn;
int Nbr = reinterpret_cast<intptr_t> (nbr);
cFreqControl *fc = (cFreqControl *)b->parent();
if (fc->hrd_buttons) {
int yclick = Fl::event_y();
int fc_yc = fc->y() + fc->h()/2;
if (yclick <= fc_yc)
fc->IncFreq(Nbr);
else
fc->DecFreq(Nbr);
} else {
if (Fl::event_button1())
fc->IncFreq(Nbr);
else if (Fl::event_button3())
fc->DecFreq(Nbr);
}
fc->redraw();
}
//#define FCDEBUG 1
#ifdef FCDEBUG
static int instance = 0;
#endif
cFreqControl::cFreqControl(int x, int y, int w, int h, const char *lbl):
Fl_Group(x,y,w,h,"") {
font_number = progdefaults.FreqControlFontnbr;
ONCOLOR = FL_YELLOW;
OFFCOLOR = FL_BLACK;
SELCOLOR = fl_rgb_color(100, 100, 100);
ILLUMCOLOR = FL_GREEN;
oldval = val = 0;
precision = 1;
dpoint = 3;
W = w;
nD = atoi(lbl);
if (nD > MAX_DIGITS) nD = MAX_DIGITS;
if (nD < MIN_DIGITS) nD = MIN_DIGITS;
bdr = 1;
fcHeight = h - 2 * bdr;
int fw, fh, ht = fcHeight;
char widest = '0';
fl_font(font_number, ++ht);
fh = fl_height() + 1;
fw = fl_width(widest);
for (char ch = '1'; ch <= '9'; ch++) {
if (fl_width(ch) > fw) {
widest = ch;
fw = fl_width(ch);
}
}
#ifdef FCDEBUG
std::ofstream fc_dump;
if (instance++ == 0) {
fc_dump.open("fc_dump.txt", std::ios::out);
} else {
fc_dump.open("fc_dump.txt", std::ios::app);
}
fc_dump << "=========================================================" << std::endl;
fc_dump << "Frequency Control widget: # " << instance << " : " << this << std::endl;
fc_dump << "---------------------------------------------------------" << std::endl;
fc_dump << "adjust for height" << std::endl;
fc_dump << "fh = font height, fc = control height" << std::endl;
fc_dump << "font " << font_number << ", size " << ht << ", fh >? fc " << fh << " ? " << fcHeight << std::endl;
fc_dump << "widest numeral is " << widest << std::endl;
#endif
while (fh > fcHeight) {
--ht;
assert(ht > 0);
fl_font(font_number, ht);
fh = fl_height();
#ifdef FCDEBUG
fc_dump << "font " << font_number << ", size " << ht << ", fh >? fc " << fh << " ? " << fcHeight << std::endl;
#endif
}
fl_font(font_number, ht);
fw = fl_width(widest) + 4;
pw = fw / 2;
#ifdef FCDEBUG
fc_dump << "---------------------------------------------------------" << std::endl;
fc_dump << "adjust for width" << std::endl;
fc_dump << "fw = font width of '0' + 4 pixels for font size 'ht'" << std::endl;
fc_dump << "ht = " << ht << ", fw = " << fw << ", (nD*fw+pw): " << (nD*fw+pw) << ", (W-2*bdr): " << (W-2*bdr) << std::endl;
#endif
while( (nD * fw + pw) >= (W - 2*bdr)) {
--ht;
assert(ht > 0);
fl_font(font_number, ht);
fw = fl_width(widest) + 4;
#ifdef FCDEBUG
fc_dump << "ht = " << ht << ", fw = " << fw << std::endl;
#endif
pw = fw / 2;
}
fh = fl_height();
#ifdef FCDEBUG
fc_dump << "---------------------------------------------------------" << std::endl;
fc_dump <<
"font " << font_number << "\n" <<
"size " << ht << "\n" <<
"height in pixels: " << fh << "\n" <<
"width in pixels: " << fw << std::endl;
fc_dump << "=========================================================" << std::endl;
fc_dump.close();
#endif
wfill = (w - nD * fw - pw - 2*bdr) / 2;
int wf2 = w - nD * fw - pw - 2*bdr - wfill;
fcWidth = fw;
fcTop = y + bdr;
int xpos;
box(FL_DOWN_BOX);
color(OFFCOLOR);
minVal = 0;
double fmaxval = (pow(10.0, nD) - 1) * precision;
unsigned long int UMAX = maximum();
if (fmaxval > UMAX) fmaxval = UMAX;
maxVal = fmaxval;
fmaxval /= 1000.0;
static char tt[100];
snprintf(tt, sizeof(tt), "Enter frequency (max %.3f) or\nLeft/Right/Up/Down/Pg_Up/Pg_Down", fmaxval);
tooltip(tt);
hfill2 = new Fl_Box(x + w - bdr - wf2, fcTop, wf2, fcHeight, "");
hfill2->box(FL_FLAT_BOX);
hfill2->labelcolor(ONCOLOR);
hfill2->color(OFFCOLOR);
xpos = x + w - bdr - wfill;
for (int n = 0; n < 3; n++) {
xpos -= fcWidth;
Digit[n] = new Fl_Repeat_Button (
xpos,
fcTop,
fcWidth,
fcHeight,
" ");
Digit[n]->box(FL_FLAT_BOX);
Digit[n]->labelfont(font_number);
Digit[n]->labelcolor(ONCOLOR);
Digit[n]->color(OFFCOLOR, SELCOLOR);
Digit[n]->labelsize(fh);
Digit[n]->callback(cbSelectDigit, reinterpret_cast<void*>(n));
if (n == 0) mult[n] = 1;
else mult[n] = 10 * mult[n-1];
}
xpos -= pw;
decbx = new Fl_Box(xpos, fcTop, pw, fcHeight,".");
decbx->box(FL_FLAT_BOX);
decbx->labelfont(font_number);
decbx->labelcolor(ONCOLOR);
decbx->color(OFFCOLOR);
decbx->labelsize(fh);
for (int n = 3; n < nD; n++) {
xpos -= fcWidth;
Digit[n] = new Fl_Repeat_Button (
xpos,
fcTop,
fcWidth,
fcHeight,
" ");
Digit[n]->box(FL_FLAT_BOX);
Digit[n]->labelfont(font_number);
Digit[n]->labelcolor(ONCOLOR);
Digit[n]->color(OFFCOLOR, SELCOLOR);
Digit[n]->labelsize(fh);
Digit[n]->callback(cbSelectDigit, reinterpret_cast<void*>(n));
if (n == 0) mult[n] = 1;
else mult[n] = 10 * mult[n-1];
}
hfill1 = new Fl_Box(x + bdr, fcTop, Digit[nD-1]->x() - x - bdr, fcHeight, "");
hfill1->box(FL_FLAT_BOX);
hfill1->labelcolor(ONCOLOR);
hfill1->color(OFFCOLOR);
cbFunc = NULL;
end();
finp = new Fl_Float_Input(0, 0, 24,24);//1, 1);
finp->callback(freq_input_cb, this);
finp->when(FL_WHEN_CHANGED);
parent()->remove(finp);
precision = 1;
hrd_buttons = true;
enable_arrow_keys = false;
}
cFreqControl::~cFreqControl()
{
for (int i = 0; i < nD; i++) {
delete Digit[i];
}
delete finp;
}
void cFreqControl::updatevalue()
{
unsigned long int v = val / precision;
int i;
if (likely(v > 0L)) {
for (i = 0; i < nD; i++) {
Digit[i]->label(v == 0 ? "" : Label[v % 10]);
v /= 10;
}
}
else {
for (i = 0; i < 4; i++)
Digit[i]->label("0");
for (; i < nD; i++)
Digit[i]->label("");
}
decbx->label(".");
decbx->redraw_label();
redraw();
}
void cFreqControl::font(Fl_Font fnt)
{
font_number = fnt;
set_ndigits(nD);
updatevalue();
}
void cFreqControl::SetONOFFCOLOR( Fl_Color ONcolor, Fl_Color OFFcolor)
{
OFFCOLOR = REVONCOLOR = OFFcolor;
ONCOLOR = REVOFFCOLOR = ONcolor;
for (int n = 0; n < nD; n++) {
Digit[n]->labelcolor(ONCOLOR);
Digit[n]->color(OFFCOLOR);
Digit[n]->redraw();
Digit[n]->redraw_label();
}
decbx->labelcolor(ONCOLOR);
decbx->color(OFFCOLOR);
decbx->redraw();
decbx->redraw_label();
hfill1->labelcolor(ONCOLOR);
hfill1->color(OFFCOLOR);
hfill1->redraw();
hfill1->redraw_label();
hfill2->labelcolor(ONCOLOR);
hfill2->color(OFFCOLOR);
hfill2->redraw();
hfill2->redraw_label();
color(OFFCOLOR);
redraw();
}
void cFreqControl::SetONCOLOR (uchar r, uchar g, uchar b)
{
ONCOLOR = fl_rgb_color (r, g, b);
REVOFFCOLOR = ONCOLOR;
for (int n = 0; n < nD; n++) {
Digit[n]->labelcolor(ONCOLOR);
Digit[n]->color(OFFCOLOR);
Digit[n]->redraw();
Digit[n]->redraw_label();
}
decbx->labelcolor(ONCOLOR);
decbx->color(OFFCOLOR);
decbx->redraw();
decbx->redraw_label();
hfill1->color(OFFCOLOR);
hfill1->labelcolor(ONCOLOR);
hfill1->redraw();
hfill1->redraw_label();
hfill2->labelcolor(ONCOLOR);
hfill2->color(OFFCOLOR);
hfill2->redraw();
hfill2->redraw_label();
color(OFFCOLOR);
redraw();
}
void cFreqControl::SetOFFCOLOR (uchar r, uchar g, uchar b)
{
OFFCOLOR = fl_rgb_color (r, g, b);
REVONCOLOR = OFFCOLOR;
for (int n = 0; n < nD; n++) {
Digit[n]->labelcolor(ONCOLOR);
Digit[n]->color(OFFCOLOR);
}
decbx->labelcolor(ONCOLOR);
decbx->color(OFFCOLOR);
decbx->redraw();
decbx->redraw_label();
hfill1->color(OFFCOLOR);
hfill1->labelcolor(ONCOLOR);
hfill1->redraw();
hfill1->redraw_label();
hfill2->labelcolor(ONCOLOR);
hfill2->color(OFFCOLOR);
hfill2->redraw();
hfill2->redraw_label();
color(OFFCOLOR);
redraw();
}
static void blink_point(Fl_Widget* w)
{
w->label(*w->label() ? "" : ".");
Fl::add_timeout(0.2, (Fl_Timeout_Handler)blink_point, w);
}
void cFreqControl::value(unsigned long int lv)
{
oldval = val = lv;
Fl::remove_timeout((Fl_Timeout_Handler)blink_point, decbx);
updatevalue();
}
unsigned long int cFreqControl::maximum(void)
{
return (unsigned long int)(pow(2.0, 32) - 1);
}
void cFreqControl::restore_colors()
{
enable_arrow_keys = false;
for (int n = 0; n < nD; n++) {
Digit[n]->labelcolor(ONCOLOR);
Digit[n]->color(OFFCOLOR);
Digit[n]->redraw();
Digit[n]->redraw_label();
}
decbx->labelcolor(ONCOLOR);
decbx->color(OFFCOLOR);
decbx->redraw();
decbx->redraw_label();
hfill1->labelcolor(ONCOLOR);
hfill1->color(OFFCOLOR);
hfill1->redraw();
hfill1->redraw_label();
hfill2->labelcolor(ONCOLOR);
hfill2->color(OFFCOLOR);
hfill2->redraw();
hfill2->redraw_label();
color(OFFCOLOR);
redraw();
}
void cFreqControl::reverse_colors()
{
enable_arrow_keys = true;
for (int n = 0; n < nD; n++) {
Digit[n]->labelcolor(REVONCOLOR);
Digit[n]->color(REVOFFCOLOR);
Digit[n]->redraw();
Digit[n]->redraw_label();
}
decbx->labelcolor(REVONCOLOR);
decbx->color(REVOFFCOLOR);
decbx->redraw();
decbx->redraw_label();
hfill1->labelcolor(REVONCOLOR);
hfill1->color(REVOFFCOLOR);
hfill1->redraw();
hfill1->redraw_label();
hfill2->labelcolor(REVONCOLOR);
hfill2->color(REVOFFCOLOR);
hfill2->redraw();
hfill2->redraw_label();
color(REVOFFCOLOR);
redraw();
}
#define KEEP_FOCUS (void *)0
#define LOSE_FOCUS (void *)1
void cFreqControl::cancel_kb_entry(void)
{
val = oldval;
Fl::remove_timeout((Fl_Timeout_Handler)blink_point, decbx);
updatevalue();
}
int cFreqControl::handle(int event)
{
// static Fl_Widget* fw = NULL;
int d;
switch (event) {
case FL_FOCUS:
return 1;
case FL_UNFOCUS:
return 1;
case FL_ENTER:
// fw = Fl::focus();
// if (fw != NULL) // if NULL then fldigi did not have focus
// take_focus();
break;
case FL_LEAVE:
// if (fw)
// fw->take_focus();
// if (Fl::has_timeout((Fl_Timeout_Handler)blink_point, this))
// cancel_kb_entry();
// clear_focus();
// updatevalue();
// return 1;
break;
case FL_KEYBOARD:
switch (d = Fl::event_key()) {
case FL_Right:
if (Fl::event_shift())
d = 100 * lsd;
else
d = lsd;
val += d;
updatevalue();
do_callback();
return 1;
break;
case FL_Left:
if (Fl::event_shift())
d = -100 * lsd;
else
d = -1 * lsd;
val += d;
updatevalue();
do_callback();
return 1;
break;
case FL_Up:
if (Fl::event_shift())
d = 1000 * lsd;
else
d = 10 * lsd;
val += d;
updatevalue();
do_callback();
return 1;
break;
case FL_Down:
if (Fl::event_shift())
d = -1000 * lsd;
else
d = -10 * lsd;
val += d;
updatevalue();
do_callback();
return 1;
break;
default:
if (Fl::event_ctrl()) {
if (Fl::event_key() == 'v') {
finp->handle(event);
Fl::remove_timeout((Fl_Timeout_Handler)blink_point, decbx);
return 1;
}
}
if (Fl::has_timeout((Fl_Timeout_Handler)blink_point, decbx)) {
if (d == FL_Escape) {
cancel_kb_entry();
return 1;
}
else if (d == FL_Enter || d == FL_KP_Enter) {
finp->position(finp->size());
finp->replace(finp->position(), finp->mark(), "\n", 1);
clear_focus();
updatevalue();
do_callback();
return 1;
}
}
else {
if (d == FL_Escape && window() != Fl::first_window()) {
window()->do_callback();
return 1;
} else if (d == FL_Enter) {
clear_focus();
updatevalue();
do_callback();
return 1;
}
int ch = Fl::event_text()[0];
if (ch < '0' || ch > '9') return Fl_Group::handle(event);
Fl::add_timeout(0.0, (Fl_Timeout_Handler)blink_point, decbx);
finp->static_value("");
oldval = val;
if (!enable_arrow_keys) reverse_colors();
}
return finp->handle(event);
}
val += d;
updatevalue();
do_callback();
break;
case FL_MOUSEWHEEL:
if ( !((d = Fl::event_dy()) || (d = Fl::event_dx())) )
return 1;
for (int i = 0; i < nD; i++) {
if (Fl::event_inside(Digit[i])) {
d > 0 ? DecFreq(i) : IncFreq(i);
return 1;//break;
}
}
break;
case FL_PUSH:
if (Fl::event_button() == FL_MIDDLE_MOUSE)
Fl::paste(*this, 0);
else
return Fl_Group::handle(event);
break;
case FL_PASTE:
finp->value(Fl::event_text());
finp->position(finp->size());
finp->insert(" \n", 2); // space before newline for pasted text
finp->do_callback();
break;
}
return Fl_Group::handle(event);
}
void cFreqControl::freq_input_cb(Fl_Widget*, void* arg)
{
cFreqControl* fc = reinterpret_cast<cFreqControl*>(arg);
double val = strtod(fc->finp->value(), NULL);
unsigned long int lval;
val *= 1e3;
val += 0.5;
lval = (long)val;
if (lval <= fc->maxVal) {
fc->val = (long)val;
fc->updatevalue();
if (fc->finp->index(fc->finp->size() - 1) == '\n' && val > 0.0) {
Fl::remove_timeout((Fl_Timeout_Handler)blink_point, fc->decbx);
fc->do_callback();
}
}
}
static void restore_color(void* w)
{
cFreqControl *fc = (cFreqControl *)w;
fc->restore_colors();
}
void cFreqControl::visual_beep()
{
reverse_colors();
Fl::add_timeout(0.1, restore_color, this);
}
void cFreqControl::set_ndigits(int nbr)
{
delete decbx;
for (int n = 0; n < nD; n++) {
this->remove(Digit[n]);
delete Digit[n];
}
nD = nbr;
if (nD > MAX_DIGITS) nD = MAX_DIGITS;
if (nD < MIN_DIGITS) nD = MIN_DIGITS;
int fw, fh, ht = h() - 2*bdr;
font_number = progdefaults.FreqControlFontnbr;
fl_font(font_number, ht);
fh = fl_height();// + 1;
while (fh > fcHeight) {
ht--;
fl_font(font_number, ht);
fh = fl_height();
}
fl_font(font_number, ht);
fw = fl_width("9") + 2;
pw = fw / 2;
while( (nD * fw + pw) >= (W - 2*bdr)) {
ht--;
fl_font(font_number, ht);
fw = fl_width("9") + 2;
pw = fw / 2;
}
fh = fl_height();
fcWidth = fw;
int wf1 = (w() - nD * fcWidth - pw - 2*bdr)/2;
int wf2 = w() - nD * fcWidth - pw - 2*bdr - wf1;
fcTop = y() + bdr;
int xpos;
minVal = 0;
double fmaxval = (pow(10.0, nD) - 1) * precision;
unsigned long int UMAX = (unsigned long int)(pow(2.0, 32) - 1);
if (fmaxval > UMAX) fmaxval = UMAX;
maxVal = fmaxval;
fmaxval /= 1000.0;
static char tt[100];
snprintf(tt, sizeof(tt), "Enter frequency (max %.3f) or\nLeft/Right/Up/Down/Pg_Up/Pg_Down", fmaxval);
tooltip(tt);
hfill2->resize(x() + w() - bdr - wf2, fcTop, wf2, fcHeight);
xpos = x() + w() - bdr - wf2;
for (int n = 0; n < dpoint; n++) {
xpos -= fcWidth;
Digit[n] = new Fl_Repeat_Button (
xpos,
fcTop,
fcWidth,
fcHeight,
" ");
Digit[n]->box(FL_FLAT_BOX);
Digit[n]->labelfont(font_number);
Digit[n]->labelcolor(ONCOLOR);
Digit[n]->color(OFFCOLOR, SELCOLOR);
Digit[n]->labelsize(fh);
Digit[n]->callback(cbSelectDigit, reinterpret_cast<void*>(n));
if (n == 0) mult[n] = 1;
else mult[n] = 10 * mult[n-1];
this->add(Digit[n]);
}
xpos -= pw;
decbx = new Fl_Box(xpos, fcTop, pw, fcHeight,".");
decbx->box(FL_FLAT_BOX);
decbx->labelfont(font_number);
decbx->labelcolor(ONCOLOR);
decbx->color(OFFCOLOR);
decbx->labelsize(fh);
this->add(decbx);
for (int n = dpoint; n < nD; n++) {
xpos -= fcWidth;
Digit[n] = new Fl_Repeat_Button (
xpos,
fcTop,
fcWidth,
fcHeight,
" ");
Digit[n]->box(FL_FLAT_BOX);
Digit[n]->labelfont(font_number);
Digit[n]->labelcolor(ONCOLOR);
Digit[n]->color(OFFCOLOR, SELCOLOR);
Digit[n]->labelsize(fh);
Digit[n]->callback(cbSelectDigit, reinterpret_cast<void*>(n));
if (n == 0) mult[n] = 1;
else mult[n] = 10 * mult[n-1];
this->add(Digit[n]);
}
hfill1->resize(x() + bdr, fcTop, wf1, fcHeight);
redraw();
}
void cFreqControl::resize(int x, int y, int w, int h)
{
Fl_Group::resize(x,y,w,h);
int wf1 = (w - nD * fcWidth - pw - 2*bdr) / 2;
int wf2 = w - nD * fcWidth - pw - 2*bdr - wf1;
hfill2->resize(x + w - bdr - wf2, y + bdr, wf2, h - 2*bdr);
int xpos = x + w - bdr - wf2;
int ypos = y + bdr;
for (int n = 0; n < dpoint; n++) {
xpos -= fcWidth;
Digit[n]->resize(xpos, ypos, fcWidth, fcHeight);
}
xpos -= pw;
decbx->resize(xpos, ypos, pw, fcHeight);
for (int n = dpoint; n < nD; n++) {
xpos -= fcWidth;
Digit[n]->resize(xpos, ypos, fcWidth, fcHeight);
}
hfill1->resize(x + bdr, y + bdr, wf1, h - 2*bdr);
Fl_Group::redraw();
}
| 17,722
|
C++
|
.cxx
| 682
| 23.42522
| 124
| 0.609391
|
w1hkj/fldigi
| 109
| 27
| 38
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
751,037
|
rigio.cxx
|
w1hkj_fldigi/src/rigcontrol/rigio.cxx
|
// ----------------------------------------------------------------------------
// rigio.cxx
//
// Copyright (C) 2007-2009
// Dave Freese, W1HKJ
//
// This file is part of fldigi.
//
// Fldigi 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 3 of the License, or
// (at your option) any later version.
//
// Fldigi 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 fldigi. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include <config.h>
#include <ctime>
#include <sys/time.h>
#include <iostream>
#include <list>
#include <vector>
#include <queue>
#include <string>
#ifdef RIGCATTEST
#include "rigCAT.h"
#else
#include "fl_digi.h"
#include "misc.h"
#include "configuration.h"
#endif
#include "rigsupport.h"
#include "rigxml.h"
#include "trx.h"
#include "serial.h"
#include "rigio.h"
#include "debug.h"
#include "qrunner.h"
#include "confdialog.h"
#include "status.h"
LOG_FILE_SOURCE(debug::LOG_RIGCONTROL);
Cserial rigio;
static pthread_t rigCAT_thread;
pthread_mutex_t rigCAT_mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_t cmdque_mutex = PTHREAD_MUTEX_INITIALIZER;
static bool rigCAT_exit = false;
static bool rigCAT_open = false;
static std::string sRigWidth = "";
static std::string sRigMode = "";
static long long llFreq = 0;
static void *rigCAT_loop(void *args);
#define RXBUFFSIZE 2000
static unsigned char replybuff[RXBUFFSIZE+1];
static unsigned char retbuf[3];
struct CMDQUEUE {
std::string cmd;
std::string s;
int retnbr;
int waitval;
CMDQUEUE(std::string _cmd, std::string _s, int _retnbr, int _waitval) {
cmd = _cmd;
s = _s;
retnbr = _retnbr;
waitval = _waitval;
}
CMDQUEUE() {cmd.clear(); s.clear(); retnbr = 0; waitval = 0;}
~CMDQUEUE() {};
};
std::queue<CMDQUEUE> cmdque;
void add_to_cmdque( std::string cmd, std::string s, int retnbr, int waitval)
{
guard_lock quelock(&cmdque_mutex);
cmdque.push(CMDQUEUE(cmd, s, retnbr, waitval));
}
void cmdque_exec()
{
bool sendcmd = false;
CMDQUEUE cmdq;
{
guard_lock quelock(&cmdque_mutex);
if (!cmdque.empty()) {
cmdq = cmdque.front();
cmdque.pop();
sendcmd = true;
}
}
if (sendcmd) sendCommand(cmdq.cmd, cmdq.s, cmdq.retnbr, cmdq.waitval);
}
bool sendCommand (std::string cmd, std::string s, int retnbr, int waitval)
{
int numwrite = (int)s.length();
int readafter = 0;
int numread = 0;
int retval = 0;
numread = retnbr;
if (progdefaults.RigCatECHO)
numread += numwrite;
readafter =
waitval + (int) ceilf (
numread * (9 + progdefaults.RigCatStopbits) *
1000.0 / rigio.Baud() );
if (xmlrig.debug)
LOG_INFO(
"%s: '%s', Expect: %d after %d msec",
cmd.c_str(),
(xmlrig.ascii ? s.c_str() : str2hex(s.data(), s.length())),
numread,
readafter);
if (xmlrig.noserial) {
memset(replybuff, 0, RXBUFFSIZE + 1);
numread = 0;
return true;
}
retval = rigio.WriteBuffer((unsigned char *)s.c_str(), numwrite);
if (retval <= 0)
LOG_ERROR("Write error %d", retval);
if (retnbr == 0) return true;
memset(replybuff, 0, RXBUFFSIZE + 1);
numread = 0;
while (readafter > 50) {
MilliSleep(50);
Fl::awake();
readafter -= 50;
}
if (readafter) {
MilliSleep(readafter);
Fl::awake();
}
while (numread < RXBUFFSIZE) {
memset(retbuf, 0, 2);
retval = rigio.ReadBuffer(retbuf, 1);
if (retval == 0) break;
replybuff[numread] = retbuf[0];
numread++;
}
if (xmlrig.debug)
LOG_INFO(
"Reply (%d): '%s'",
numread,
(xmlrig.ascii ? reinterpret_cast<const char *>(replybuff) : str2hex(reinterpret_cast<const char *>(replybuff), numread)));
if (numread > retnbr) {
memmove(replybuff, replybuff + numread - retnbr, retnbr);
numread = retnbr;
}
return (numread == retnbr);
}
std::string to_bcd_be(long long freq, int len)
{
std::string bcd = "";
unsigned char a;
int numchars = len / 2;
if (len & 1) numchars ++;
for (int i = 0; i < numchars; i++) {
a = 0;
a |= freq%10;
freq /= 10;
a |= (freq%10)<<4;
freq /= 10;
bcd += a;
}
return bcd;
}
std::string to_bcd(long long freq, int len)
{
std::string bcd = "";
std::string bcd_be = to_bcd_be(freq, len);
int bcdlen = bcd_be.size();
for (int i = bcdlen - 1; i >= 0; i--)
bcd += bcd_be[i];
return bcd;
}
long long fm_bcd (size_t p, int len)
{
int i;
long long f = 0;
int numchars = len/2;
if (len & 1) numchars ++;
for (i = 0; i < numchars; i++) {
f *=10;
f += (replybuff[p + i] >> 4) & 0x0F;
f *= 10;
f += replybuff[p + i] & 0x0F;
}
return f;
}
long long fm_bcd_be(size_t p, int len)
{
unsigned char temp;
int numchars = len/2;
if (len & 1) numchars++;
for (int i = 0; i < numchars / 2; i++) {
temp = replybuff[p + i];
replybuff[p + i] = replybuff[p + numchars -1 - i];
replybuff[p + numchars -1 - i] = temp;
}
return fm_bcd(p, len);
}
std::string to_binary_be(long long freq, int len)
{
std::string bin = "";
for (int i = 0; i < len; i++) {
bin += freq & 0xFF;
freq >>= 8;
}
return bin;
}
std::string to_binary(long long freq, int len)
{
std::string bin = "";
std::string bin_be = to_binary_be(freq, len);
int binlen = bin_be.size();
for (int i = binlen - 1; i >= 0; i--)
bin += bin_be[i];
return bin;
}
long long fm_binary(size_t p, int len)
{
int i;
long long f = 0;
for (i = 0; i < len; i++) {
f *= 256;
f += replybuff[p + i];
}
return f;
}
long long fm_binary_be(size_t p, int len)
{
unsigned char temp;
int numchars = len/2;
if (len & 1) numchars++;
for (int i = 0; i < numchars / 2; i++) {
temp = replybuff[p + i];
replybuff[p + i] = replybuff[p + numchars -1 - i];
replybuff[p + numchars -1 - i] = temp;
}
return fm_binary(p, len);
}
std::string to_decimal_be(long long d, int len)
{
std::string sdec_be = "";
for (int i = 0; i < len; i++) {
sdec_be += (char)((d % 10) + '0');
d /= 10;
}
return sdec_be;
}
std::string to_decimal(long long d, int len)
{
std::string sdec = "";
std::string sdec_be = to_decimal_be(d, len);
int bcdlen = sdec_be.size();
for (int i = bcdlen - 1; i >= 0; i--)
sdec += sdec_be[i];
return sdec;
}
long long fm_decimal(size_t p, int len)
{
long long d = 0;
for (int i = 0; i < len; i++) {
d *= 10;
d += replybuff[p + i] - '0';
}
return d;
}
long long fm_decimal_be(size_t p, int len)
{
unsigned char temp;
int numchars = len/2;
if (len & 1) numchars++;
for (int i = 0; i < numchars / 2; i++) {
temp = replybuff[p + i];
replybuff[p + i] = replybuff[p + numchars -1 - i];
replybuff[p + numchars -1 - i] = temp;
}
return fm_decimal(p, len);
}
std::string to_freqdata(DATA d, long long f)
{
int num, den;
num = 100;
den = (int)(d.resolution * 100);
if (d.size == 0) return "";
if (d.dtype == "BCD") {
if (d.reverse == true)
return to_bcd_be((long long int)(f * num / den), d.size);
else
return to_bcd((long long int)(f * num / den), d.size);
} else if (d.dtype == "BINARY") {
if (d.reverse == true)
return to_binary_be((long long int)(f * num / den), d.size);
else
return to_binary((long long int)(f * num / den), d.size);
} else if (d.dtype == "DECIMAL") {
if (d.reverse == true)
return to_decimal_be((long long int)(f * num / den), d.size);
else
return to_decimal((long long int)(f * num / den), d.size);
}
return "";
}
long long fm_freqdata(DATA d, size_t p)
{
int num, den;
num = (int)(d.resolution * 100);
den = 100;
long long fret = 0;
if (d.dtype == "BCD") {
if (d.reverse == true)
fret = (long long int)(fm_bcd_be(p, d.size) * num / den);
else
fret = (long long int)(fm_bcd(p, d.size) * num / den);
} else if (d.dtype == "BINARY") {
if (d.reverse == true)
fret = (long long int)(fm_binary_be(p, d.size) * num / den);
else
fret = (long long int)(fm_binary(p, d.size) * num / den);
} else if (d.dtype == "DECIMAL") {
if (d.reverse == true)
fret = (long long int)(fm_decimal_be(p, d.size) * num / den);
else
fret = (long long int)(fm_decimal(p, d.size) * num / den);
}
return fret;
}
long long rigCAT_getfreq(int retries, bool &failed, int waitval)
{
const char symbol[] = "GETFREQ";
failed = false;
if (rigCAT_exit || xmlrig.noserial || !xmlrig.xmlok) {
failed = true;
return progStatus.noCATfreq;
}
if (waitval == 0) waitval = progdefaults.RigCatWait;
XMLIOS modeCmd;
std::list<XMLIOS>::iterator itrCmd;
std::string strCmd;
size_t p = 0, len1 = 0, len2 = 0, pData = 0;
long long f = 0;
itrCmd = commands.begin();
while (itrCmd != commands.end()) {
if ((*itrCmd).SYMBOL == symbol)
break;
++itrCmd;
}
if (itrCmd == commands.end()) {
failed = true;
if (xmlrig.debug) LOG_INFO("%s not defined", symbol);
return progStatus.noCATfreq; // get_freq command is not defined!
}
modeCmd = *itrCmd;
if ( modeCmd.str1.empty() == false)
strCmd.append(modeCmd.str1);
if (modeCmd.str2.empty() == false)
strCmd.append(modeCmd.str2);
if ( !modeCmd.info.size() ) {
failed = true;
return 0;
}
for (std::list<XMLIOS>::iterator preply = reply.begin(); preply != reply.end(); ++preply) {
if (preply->SYMBOL != modeCmd.info)
continue;
XMLIOS rTemp = *preply;
len1 = rTemp.str1.size();
len2 = rTemp.str2.size();
for (int n = 0; n < retries; n++) {
if (n && progdefaults.RigCatTimeout > 0)
{
int timeout = progdefaults.RigCatTimeout;
while (timeout > 50) {
MilliSleep(50);
Fl::awake();
timeout -= 50;
}
if (timeout) {
MilliSleep(timeout);
Fl::awake();
}
}
// send the command
int sendok;
{
guard_lock ser_guard(&rigCAT_mutex);
sendok = sendCommand(symbol, strCmd, rTemp.size, waitval);
}
if ( !sendok ) {
if (xmlrig.debug)
LOG_INFO("sendCommand failed");
goto retry_get_freq;
}
// check the pre data std::string
p = 0;
pData = 0;
if (len1) {
for (size_t i = 0; i < len1; i++) {
if ((char)rTemp.str1[i] != (char)replybuff[i]) {
unsigned int ui = i;
LOG_ERROR("failed pre data string test @ %u", ui);
goto retry_get_freq;
}
}
p = len1;
}
if (rTemp.fill1) p += rTemp.fill1;
pData = p;
if (rTemp.data.dtype == "BCD") {
p += rTemp.data.size / 2;
if (rTemp.data.size & 1) p++;
} else
p += rTemp.data.size;
// check the post data string
if (rTemp.fill2) p += rTemp.fill2;
if (len2) {
for (size_t i = 0; i < len2; i++)
if ((char)rTemp.str2[i] != (char)replybuff[p + i]) {
LOG_ERROR("failed post data string test @ %d", static_cast<int>(i));
goto retry_get_freq;
}
}
// convert the data field
f = fm_freqdata(rTemp.data, pData);
if ( f >= rTemp.data.min && f <= rTemp.data.max)
return f;
LOG_VERBOSE("freq: %d", static_cast<int>(f));
retry_get_freq: ;
}
}
if (progdefaults.RigCatVSP == false)
LOG_ERROR("%s failed", symbol);
failed = true;
return 0;
}
void rigCAT_setfreq(long long f)
{
const char symbol[] = "SETFREQ";
if (rigCAT_exit || xmlrig.noserial || !xmlrig.xmlok) {
progStatus.noCATfreq = f;
}
if (rigCAT_exit || !xmlrig.xmlok) return;
XMLIOS modeCmd;
std::list<XMLIOS>::iterator itrCmd;
std::string strCmd;
itrCmd = commands.begin();
while (itrCmd != commands.end()) {
if ((*itrCmd).SYMBOL == symbol)
break;
++itrCmd;
}
if (itrCmd == commands.end()) {
if (xmlrig.debug) LOG_INFO("%s not defined", symbol);
return;
}
modeCmd = *itrCmd;
if ( modeCmd.str1.empty() == false)
strCmd.append(modeCmd.str1);
strCmd.append( to_freqdata(modeCmd.data, f) );
if (modeCmd.str2.empty() == false)
strCmd.append(modeCmd.str2);
if (modeCmd.ok.size()) {
std::list<XMLIOS>::iterator preply = reply.begin();
while (preply != reply.end()) {
if (preply->SYMBOL == modeCmd.ok) {
XMLIOS rTemp = *preply;
// send the command
for (int n = 0; n < progdefaults.RigCatRetries; n++) {
if (rigCAT_exit) return;
guard_lock ser_guard( &rigCAT_mutex );
if (sendCommand(symbol, strCmd, rTemp.size, progdefaults.RigCatWait))
return;
MilliSleep(50);
}
return;
}
preply++;
}
} else {
for (int n = 0; n < progdefaults.RigCatRetries; n++) {
if (rigCAT_exit) return;
guard_lock ser_guard( &rigCAT_mutex );
if (sendCommand(symbol, strCmd, 0, progdefaults.RigCatWait)) return;
MilliSleep(50);
}
}
if (progdefaults.RigCatVSP == false)
LOG_ERROR("%s failed", symbol);
}
std::string rigCAT_getmode()
{
const char symbol[] = "GETMODE";
if (rigCAT_exit || xmlrig.noserial || !xmlrig.xmlok)
return progStatus.noCATmode;
XMLIOS modeCmd;
std::list<XMLIOS>::iterator itrCmd;
std::list<MODE>::iterator mode;
std::list<MODE> *pmode;
std::string strCmd, mData;
size_t len;
itrCmd = commands.begin();
while (itrCmd != commands.end()) {
if ((*itrCmd).SYMBOL == symbol)
break;
++itrCmd;
}
if (itrCmd == commands.end()) {
if (xmlrig.debug) LOG_INFO("%s not defined", symbol);
return progStatus.noCATmode;
}
modeCmd = *itrCmd;
if ( modeCmd.str1.empty() == false)
strCmd.append(modeCmd.str1);
if (modeCmd.str2.empty() == false)
strCmd.append(modeCmd.str2);
if (!modeCmd.info.size()) return "";
for (std::list<XMLIOS>::iterator preply = reply.begin(); preply != reply.end(); ++preply) {
if (preply->SYMBOL != modeCmd.info)
continue;
XMLIOS rTemp = *preply;
for (int n = 0; n < progdefaults.RigCatRetries; n++) {
if (progdefaults.RigCatTimeout > 50)
{
int timeout = progdefaults.RigCatTimeout;
while (timeout > 50) {
MilliSleep(50);
Fl::awake();
timeout -= 50;
}
if (timeout) {
MilliSleep(timeout);
Fl::awake();
}
}
size_t p = 0, pData = 0;
// send the command
{
guard_lock ser_guard(&rigCAT_mutex);
if (!sendCommand(symbol, strCmd, rTemp.size, progdefaults.RigCatWait)) goto retry_get_mode;
}
// check the pre data string
len = rTemp.str1.size();
if (len) {
for (size_t i = 0; i < len; i++)
if ((char)rTemp.str1[i] != (char)replybuff[i]) {
unsigned int ui = i;
LOG_ERROR("failed pre data string test @ %u", ui);
goto retry_get_mode;
}
p = len;
}
if (rTemp.fill1) p += rTemp.fill1;
pData = p;
// check the post data string
p += rTemp.data.size;
len = rTemp.str2.size();
if (rTemp.fill2) p += rTemp.fill2;
if (len) {
for (size_t i = 0; i < len; i++)
if ((char)rTemp.str2[i] != (char)replybuff[p + i])
goto retry_get_mode;
}
// convert the data field
mData = "";
for (int i = 0; i < rTemp.data.size; i++)
mData += (char)replybuff[pData + i];
// for FT100 and the ilk that use bit fields
if (rTemp.data.size == 1) {
unsigned char d = mData[0];
if (rTemp.data.shiftbits)
d >>= rTemp.data.shiftbits;
d &= rTemp.data.andmask;
mData[0] = d;
}
if (lmodes.empty() == false)
pmode = &lmodes;
else if (lmodeREPLY.empty() == false)
pmode = &lmodeREPLY;
else
goto retry_get_mode;
mode = pmode->begin();
while (mode != pmode->end()) {
if ((*mode).BYTES == mData)
break;
mode++;
}
if (mode != pmode->end())
return ((*mode).SYMBOL);
retry_get_mode: ;
}
}
if (progdefaults.RigCatVSP == false)
LOG_ERROR("%s failed", symbol);
return "";
}
void rigCAT_setmode(const std::string& md)
{
const char symbol[] = "SETMODE";
if (rigCAT_exit || xmlrig.noserial || !xmlrig.xmlok)
progStatus.noCATmode = md;
if (rigCAT_exit || !xmlrig.xmlok) return;
XMLIOS modeCmd;
std::list<XMLIOS>::iterator itrCmd;
std::string strCmd;
itrCmd = commands.begin();
while (itrCmd != commands.end()) {
if ((*itrCmd).SYMBOL == symbol)
break;
++itrCmd;
}
modeCmd = *itrCmd;
if ( modeCmd.str1.empty() == false)
strCmd.append(modeCmd.str1);
if ( modeCmd.data.size > 0 ) {
std::list<MODE>::iterator mode;
std::list<MODE> *pmode;
if (lmodes.empty() == false)
pmode = &lmodes;
else if (lmodeCMD.empty() == false)
pmode = &lmodeCMD;
else
return;
mode = pmode->begin();
while (mode != pmode->end()) {
if ((*mode).SYMBOL == md)
break;
mode++;
}
if (mode != pmode->end())
strCmd.append( (*mode).BYTES );
}
if (modeCmd.str2.empty() == false)
strCmd.append(modeCmd.str2);
if (modeCmd.ok.size()) {
std::list<XMLIOS>::iterator preply = reply.begin();
while (preply != reply.end()) {
if (preply->SYMBOL == modeCmd.ok) {
XMLIOS rTemp = *preply;
// send the command
for (int n = 0; n < progdefaults.RigCatRetries; n++) {
if (rigCAT_exit) return;
guard_lock ser_guard( &rigCAT_mutex );
if (sendCommand(symbol, strCmd, rTemp.size, progdefaults.RigCatWait)) return;
MilliSleep(50);
}
return;
}
preply++;
}
} else {
for (int n = 0; n < progdefaults.RigCatRetries; n++) {
if (rigCAT_exit) return;
guard_lock ser_guard( &rigCAT_mutex );
if (sendCommand(symbol, strCmd, 0, progdefaults.RigCatWait)) return;
MilliSleep(50);
}
}
if (progdefaults.RigCatVSP == false)
LOG_ERROR("%s failed", symbol);
}
std::string rigCAT_getwidth()
{
const char symbol[] = "GETBW";
if (rigCAT_exit || xmlrig.noserial || !xmlrig.xmlok)
return progStatus.noCATwidth;
XMLIOS widthCmd;
std::list<XMLIOS>::iterator itrCmd;
std::list<BW>::iterator bw;
std::list<BW> *pbw;
std::string strCmd, mData;
size_t len = 0, p = 0, pData = 0;
itrCmd = commands.begin();
while (itrCmd != commands.end()) {
if ((*itrCmd).SYMBOL == symbol)
break;
++itrCmd;
}
if (itrCmd == commands.end()) {
if (xmlrig.debug) LOG_INFO("%s not defined", symbol);
return "";
}
widthCmd = *itrCmd;
if ( widthCmd.str1.empty() == false)
strCmd.append(widthCmd.str1);
if (widthCmd.str2.empty() == false)
strCmd.append(widthCmd.str2);
if (!widthCmd.info.size()) return "";
for (std::list<XMLIOS>::iterator preply = reply.begin(); preply != reply.end(); ++preply) {
if (preply->SYMBOL != widthCmd.info)
continue;
XMLIOS rTemp = *preply;
for (int n = 0; n < progdefaults.RigCatRetries; n++) {
if (progdefaults.RigCatTimeout > 50)
{
int timeout = progdefaults.RigCatTimeout;
while (timeout > 50) {
MilliSleep(50);
Fl::awake();
timeout -= 50;
}
if (timeout) {
MilliSleep(timeout);
Fl::awake();
}
}
p = 0;
pData = 0;
// send the command
int sendok;
{
guard_lock ser_guard(&rigCAT_mutex);
sendok = sendCommand(symbol, strCmd, rTemp.size, progdefaults.RigCatWait);
}
if ( !sendok ) {
goto retry_get_width;
}
// check the pre data string
len = rTemp.str1.size();
if (len) {
for (size_t i = 0; i < len; i++)
if ((char)rTemp.str1[i] != (char)replybuff[i]) {
unsigned int ui = i;
LOG_ERROR("failed pre data string test @ %u", ui);
goto retry_get_width;
}
p = pData = len;
}
if (rTemp.fill1) p += rTemp.fill1;
pData = p;
p += rTemp.data.size;
// check the post data string
if (rTemp.fill2) p += rTemp.fill2;
len = rTemp.str2.size();
if (len) {
for (size_t i = 0; i < len; i++)
if ((char)rTemp.str2[i] != (char)replybuff[p + i]) {
unsigned int ui = i;
LOG_ERROR("failed pre data string test @ %u", ui);
goto retry_get_width;
}
}
// convert the data field
mData = "";
for (int i = 0; i < rTemp.data.size; i++)
mData += (char)replybuff[pData + i];
// new for FT100 and the ilk that use bit fields
if (rTemp.data.size == 1) {
unsigned char d = mData[0];
if (rTemp.data.shiftbits)
d >>= rTemp.data.shiftbits;
d &= rTemp.data.andmask;
mData[0] = d;
}
if (!lbwREPLY.empty())
pbw = &lbwREPLY;
else if (lbws.empty() == false)
pbw = &lbws;
else
goto retry_get_width;
bw = pbw->begin();
while (bw != pbw->end()) {
if ((*bw).BYTES == mData)
break;
bw++;
}
if (bw != pbw->end())
return ((*bw).SYMBOL);
retry_get_width: ;
}
}
if (progdefaults.RigCatVSP == false)
LOG_ERROR("%s failed", symbol);
return "";
}
void rigCAT_setwidth(const std::string& w)
{
const char symbol[] = "SETBW";
if (rigCAT_exit || xmlrig.noserial || !xmlrig.xmlok)
progStatus.noCATwidth = w;
if (rigCAT_exit || !xmlrig.xmlok) return;
XMLIOS modeCmd;
std::list<XMLIOS>::iterator itrCmd;
std::string strCmd;
itrCmd = commands.begin();
while (itrCmd != commands.end()) {
if ((*itrCmd).SYMBOL == symbol)
break;
++itrCmd;
}
if (itrCmd == commands.end()) {
if (xmlrig.debug) LOG_INFO("%s not defined", symbol);
progStatus.noCATwidth = w;
return;
}
modeCmd = *itrCmd;
if ( modeCmd.str1.empty() == false)
strCmd.append(modeCmd.str1);
if ( modeCmd.data.size > 0 ) {
std::list<BW>::iterator bw;
std::list<BW> *pbw;
if (lbws.empty() == false)
pbw = &lbws;
else if (lbwCMD.empty() == false)
pbw = &lbwCMD;
else
return;
bw = pbw->begin();
while (bw != pbw->end()) {
if ((*bw).SYMBOL == w)
break;
bw++;
}
if (bw != pbw->end())
strCmd.append( (*bw).BYTES );
}
if (modeCmd.str2.empty() == false)
strCmd.append(modeCmd.str2);
if (modeCmd.ok.size()) {
std::list<XMLIOS>::iterator preply = reply.begin();
while (preply != reply.end()) {
if (preply->SYMBOL == modeCmd.ok) {
XMLIOS rTemp = *preply;
// send the command
for (int n = 0; n < progdefaults.RigCatRetries; n++) {
if (rigCAT_exit) return;
guard_lock ser_guard( &rigCAT_mutex );
if (sendCommand(symbol, strCmd, rTemp.size, progdefaults.RigCatWait)) return;
MilliSleep(50);
}
}
preply++;
}
} else {
for (int n = 0; n < progdefaults.RigCatRetries; n++) {
if (rigCAT_exit) return;
guard_lock ser_guard( &rigCAT_mutex );
if (sendCommand(symbol, strCmd, 0, progdefaults.RigCatWait)) return;
MilliSleep(50);
}
}
LOG_ERROR("%s failed", symbol);
}
void rigCAT_pttON()
{
const char symbol[] = "PTTON";
if (rigCAT_exit) return;
XMLIOS modeCmd;
std::list<XMLIOS>::iterator itrCmd;
std::string strCmd;
rigio.SetPTT(1); // always execute the h/w ptt if enabled
itrCmd = commands.begin();
while (itrCmd != commands.end()) {
if ((*itrCmd).SYMBOL == symbol)
break;
++itrCmd;
}
if (itrCmd == commands.end()) {
if (xmlrig.debug) LOG_INFO("%s not defined", symbol);
return;
}
modeCmd = *itrCmd;
if ( modeCmd.str1.empty() == false)
strCmd.append(modeCmd.str1);
if (modeCmd.str2.empty() == false)
strCmd.append(modeCmd.str2);
if (modeCmd.ok.size()) {
// if (xmlrig.debug)
// LOG_INFO("OK string: %s", str2hex(modeCmd.ok.c_str(), modeCmd.ok.size()) );
std::list<XMLIOS>::iterator preply = reply.begin();
while (preply != reply.end()) {
if (preply->SYMBOL == modeCmd.ok) {
XMLIOS rTemp = *preply;
// send the command
for (int n = 0; n < progdefaults.RigCatRetries; n++) {
if (rigCAT_exit) return;
guard_lock ser_guard( &rigCAT_mutex );
if (sendCommand(symbol, strCmd, rTemp.size, progdefaults.RigCatWait)) return;
MilliSleep(50);
}
return;
}
preply++;
}
} else {
for (int n = 0; n < progdefaults.RigCatRetries; n++) {
if (rigCAT_exit) return;
guard_lock ser_guard( &rigCAT_mutex );
if (sendCommand(symbol, strCmd, 0, progdefaults.RigCatWait)) return;
MilliSleep(50);
}
}
LOG_VERBOSE("%s failed", symbol);
}
void rigCAT_pttOFF()
{
const char symbol[] = "PTTOFF";
if (rigCAT_exit) return;
XMLIOS modeCmd;
std::list<XMLIOS>::iterator itrCmd;
std::string strCmd;
rigio.SetPTT(0); // always execute the h/w ptt if enabled
itrCmd = commands.begin();
while (itrCmd != commands.end()) {
if ((*itrCmd).SYMBOL == symbol)
break;
++itrCmd;
}
if (itrCmd == commands.end()) {
if (xmlrig.debug) LOG_INFO("%s not defined", symbol);
return;
}
modeCmd = *itrCmd;
if ( modeCmd.str1.empty() == false)
strCmd.append(modeCmd.str1);
if (modeCmd.str2.empty() == false)
strCmd.append(modeCmd.str2);
if (modeCmd.ok.size()) {
std::list<XMLIOS>::iterator preply = reply.begin();
while (preply != reply.end()) {
if (preply->SYMBOL == modeCmd.ok) {
XMLIOS rTemp = *preply;
// send the command
for (int n = 0; n < progdefaults.RigCatRetries; n++) {
if (rigCAT_exit) return;
guard_lock ser_guard( &rigCAT_mutex );
if (sendCommand(symbol, strCmd, rTemp.size, progdefaults.RigCatWait)) return;
MilliSleep(50);
}
return;
}
preply++;
}
} else {
for (int n = 0; n < progdefaults.RigCatRetries; n++) {
if (rigCAT_exit) return;
guard_lock ser_guard( &rigCAT_mutex );
if (sendCommand(symbol, strCmd, 0, progdefaults.RigCatWait)) return;
MilliSleep(50);
}
}
LOG_ERROR("%s failed", symbol);
}
void rigCAT_sendINIT(const std::string& icmd, int multiplier)
{
if (rigCAT_exit) return;
const char symbol[] = "INIT";
XMLIOS modeCmd;
std::list<XMLIOS>::iterator itrCmd;
std::string strCmd;
itrCmd = commands.begin();
while (itrCmd != commands.end()) {
if ((*itrCmd).SYMBOL == icmd)
break;
++itrCmd;
}
if (itrCmd == commands.end())
return;
modeCmd = *itrCmd;
if ( modeCmd.str1.empty() == false)
strCmd.append(modeCmd.str1);
if (modeCmd.str2.empty() == false)
strCmd.append(modeCmd.str2);
if (modeCmd.ok.size()) {
std::list<XMLIOS>::iterator preply = reply.begin();
while (preply != reply.end()) {
if (preply->SYMBOL == modeCmd.ok) {
XMLIOS rTemp = *preply;
// send the command
for (int n = 0; n < progdefaults.RigCatRetries; n++) {
if (rigCAT_exit) return;
guard_lock ser_guard( &rigCAT_mutex );
if (sendCommand(symbol, strCmd, rTemp.size, progdefaults.RigCatInitDelay)) return;
MilliSleep(50);
}
return;
}
preply++;
}
} else {
for (int n = 0; n < progdefaults.RigCatRetries; n++) {
if (rigCAT_exit) return;
guard_lock ser_guard( &rigCAT_mutex );
if (sendCommand(symbol, strCmd, 0, progdefaults.RigCatInitDelay)) return;
MilliSleep(50);
}
}
LOG_ERROR("INIT failed");
}
void rigCAT_defaults()
{
listbox_xml_rig_baudrate->index(xmlrig.baud);
valRigCatStopbits->value(xmlrig.stopbits);
btnRigCatRTSplus->value(xmlrig.rts);
btnRigCatDTRplus->value(xmlrig.dtr);
btnRigCatRTSptt->value(xmlrig.rtsptt);
btnRigCatDTRptt->value(xmlrig.dtrptt);
chk_restore_tio->value(xmlrig.restore_tio);
chkRigCatRTSCTSflow->value(xmlrig.rtscts);
cntRigCatRetries->value(xmlrig.retries);
cntRigCatTimeout->value(xmlrig.timeout);
cntRigCatWait->value(xmlrig.write_delay);
cntRigCatInitDelay->value(xmlrig.init_delay);
// cntRigCatWaitForDevice->value(xmlrig.wait_for_device);
btnRigCatEcho->value(xmlrig.echo);
btnRigCatCMDptt->value(xmlrig.cmdptt);
chkRigCatVSP->value(xmlrig.vsp);
}
void rigCAT_init_defaults()
{
progdefaults.XmlRigDevice = inpXmlRigDevice->value();
progdefaults.XmlRigBaudrate = listbox_xml_rig_baudrate->index();
progdefaults.RigCatStopbits = static_cast<int>(valRigCatStopbits->value());
progdefaults.RigCatRTSplus = btnRigCatRTSplus->value();
progdefaults.RigCatDTRplus = btnRigCatDTRplus->value();
progdefaults.RigCatRTSptt = btnRigCatRTSptt->value();
progdefaults.RigCatDTRptt = btnRigCatDTRptt->value();
progdefaults.RigCatRestoreTIO = chk_restore_tio->value();
progdefaults.RigCatRTSCTSflow = chkRigCatRTSCTSflow->value();
progdefaults.RigCatRetries = static_cast<int>(cntRigCatRetries->value());
progdefaults.RigCatTimeout = static_cast<int>(cntRigCatTimeout->value());
progdefaults.RigCatWait = static_cast<int>(cntRigCatWait->value());
progdefaults.RigCatInitDelay = static_cast<int>(cntRigCatInitDelay->value());
progdefaults.RigCatECHO = btnRigCatEcho->value();
progdefaults.RigCatCMDptt = btnRigCatCMDptt->value();
progdefaults.RigCatVSP = chkRigCatVSP->value();
}
bool rigCAT_init()
{
if (rigCAT_open == true) {
LOG_ERROR("RigCAT already open");
return false;
}
sRigMode = "";
sRigWidth = "";
rigCAT_init_defaults();
rigio.Device(progdefaults.XmlRigDevice);
rigio.Baud(progdefaults.BaudRate(progdefaults.XmlRigBaudrate));
rigio.RTS(progdefaults.RigCatRTSplus);
rigio.DTR(progdefaults.RigCatDTRplus);
rigio.RTSptt(progdefaults.RigCatRTSptt);
rigio.DTRptt(progdefaults.RigCatDTRptt);
rigio.RestoreTIO(progdefaults.RigCatRestoreTIO);
rigio.RTSCTS(progdefaults.RigCatRTSCTSflow);
rigio.Stopbits(progdefaults.RigCatStopbits);
LOG_INFO("\n\
Serial port parameters:\n\
device : %s\n\
baudrate : %d\n\
stopbits : %d\n\
retries : %d\n\
timeout : %d\n\
wait : %d\n\
initial rts: %+d\n\
use rts ptt: %c\n\
initial dtr: %+d\n\
use dtr ptt: %c\n\
restore tio: %c\n\
flowcontrol: %c\n\
echo : %c\n",
rigio.Device().c_str(),
rigio.Baud(),
rigio.Stopbits(),
progdefaults.RigCatRetries,
progdefaults.RigCatTimeout,
progdefaults.RigCatWait,
(rigio.RTS() ? +12 : -12), (rigio.RTSptt() ? 'T' : 'F'),
(rigio.DTR() ? +12 : -12), (rigio.DTRptt() ? 'T' : 'F'),
(rigio.RestoreTIO() ? 'T' : 'F'),
(rigio.RTSCTS() ? 'T' : 'F'),
progdefaults.RigCatECHO ? 'T' : 'F');
if (xmlrig.noserial == false && xmlrig.xmlok) {
if (rigio.OpenPort() == false) {
LOG_ERROR("Cannot open serial port %s", rigio.Device().c_str());
xmlrig.xmlok = true;
}
}
sRigMode = "";
sRigWidth = "";
if (xmlrig.wait_for_device) {
int delay = xmlrig.wait_for_device / 10;
while (delay) {
MilliSleep(10);
if (delay % 10) Fl::awake();
delay--;
}
}
rigCAT_sendINIT("INIT", progdefaults.RigCatInitDelay);
bool failed = false;
if (xmlrig.noserial)
rigCAT_getfreq(1, failed, 0);
else if (xmlrig.xmlok) {
rigCAT_getfreq(3, failed, progdefaults.RigCatInitDelay);
if (failed) {
LOG_ERROR("*****************Failed to read xcvr frequency");
if (xmlrig.noserial == false)
rigio.ClosePort();
xmlrig.xmlok = false;
} else
LOG_INFO("Passed serial port test");
}
llFreq = 0;
if (pthread_create(&rigCAT_thread, NULL, rigCAT_loop, NULL) < 0) {
LOG_ERROR("%s", "pthread_create failed");
if (xmlrig.xmlok && !xmlrig.noserial)
rigio.ClosePort();
xmlrig.xmlok = false;
return false;
}
LOG_INFO("Created rigCAT thread");
rigCAT_open = true;
init_Xml_RigDialog();
return true;
}
void rigCAT_close(void)
{
if ( rigCAT_open == false || rigCAT_exit == true)
return;
rigCAT_sendINIT("CLOSE");
{
guard_lock ser_guard( &rigCAT_mutex );
rigCAT_exit = true;
}
LOG_INFO("%s", "Waiting for rigCAT_thread");
pthread_join(rigCAT_thread, NULL);
rigio.ClosePort();
rigCAT_exit = false;
rigCAT_open = false;
wf->USB(true);
}
bool rigCAT_active(void)
{
return (rigCAT_open);
}
void rigCAT_set_ptt(int ptt)
{
if (progdefaults.CATkeying_disable_ptt &&
( progdefaults.use_ELCTkeying ||
progdefaults.use_ICOMkeying ||
progdefaults.use_KNWDkeying ||
progdefaults.use_YAESUkeying ) &&
active_modem->get_mode() == MODE_CW )
return;
if (rigCAT_open == false)
return;
if (ptt) {
rigCAT_pttON();
} else{
rigCAT_pttOFF();
}
}
#ifndef RIGCATTEST
void rigCAT_set_qsy(long long f)
{
if (rigCAT_open == false)
return;
// send new freq to rig
rigCAT_setfreq(f);
wf->rfcarrier(f);
wf->movetocenter();
}
#endif
bool ModeIsLSB(std::string s)
{
if (connected_to_flrig) return !xmlrpc_USB();
#if USE_HAMLIB
if (hamlib_active()) return !hamlib_USB();
#endif
std::list<std::string>::iterator pM = LSBmodes.begin();
while (pM != LSBmodes.end() ) {
if (*pM == s)
return true;
pM++;
}
return false;
}
int smeter_data(DATA d, size_t p)
{
int val = 0;
if (d.dtype == "BCD") {
if (d.reverse == true)
val = (int)(fm_bcd_be(p, d.size));
else
val = (int)(fm_bcd(p, d.size));
} else if (d.dtype == "BINARY") {
if (d.reverse == true)
val = (int)(fm_binary_be(p, d.size));
else
val = (int)(fm_binary(p, d.size));
} else if (d.dtype == "DECIMAL") {
if (d.reverse == true)
val = (int)(fm_decimal_be(p, d.size));
else
val = (int)(fm_decimal(p, d.size));
}
size_t n;
int sm1, sm2, val1, val2;
for (n = 0; n < xmlrig.smeter.size() - 1; n++) {
if ((val >= xmlrig.smeter[n].val) && (val < xmlrig.smeter[n+1].val)) break;
}
if (n == xmlrig.smeter.size() - 1) return 0;
sm1 = xmlrig.smeter[n].mtr;
sm2 = xmlrig.smeter[n+1].mtr;
val1 = xmlrig.smeter[n].val;
val2 = xmlrig.smeter[n+1].val;
if (val1 == val2) return 0;
int mtr = sm1 + (val - val1) * (sm2 - sm1) / (val2 - val1);
return mtr;
}
static void rigcat_set_smeter(void *data)
{
if (pwrlevel_grp->visible()) return;
if (!smeter && !pwrmeter) return;
if (smeter && progStatus.meters) {
if (!smeter->visible()) {
pwrmeter->hide();
smeter->show();
}
int val = reinterpret_cast<intptr_t>(data);
smeter->value(val);
}
}
void rigCAT_get_smeter()
{
const char symbol[] = "GET_SMETER";
if (rigCAT_exit || xmlrig.noserial) return;
XMLIOS modeCmd;
std::list<XMLIOS>::iterator itrCmd;
std::string strCmd;
size_t p = 0, len1 = 0, len2 = 0, pData = 0;
long mtr = 0;
itrCmd = commands.begin();
while (itrCmd != commands.end()) {
if ((*itrCmd).SYMBOL == symbol)
break;
++itrCmd;
}
if (itrCmd == commands.end()) {
if (xmlrig.debug) LOG_INFO("%s not defined", symbol);
return;
}
modeCmd = *itrCmd;
if ( !modeCmd.str1.empty() ) strCmd.append(modeCmd.str1);
if ( !modeCmd.str2.empty() ) strCmd.append(modeCmd.str2);
if ( !modeCmd.info.size() ) return;
std::list<XMLIOS>::iterator preply;
for (preply = reply.begin(); preply != reply.end(); ++preply) {
if (preply->SYMBOL == modeCmd.info)
break;
}
if (preply == reply.end()) return;
XMLIOS rTemp = *preply;
len1 = rTemp.str1.size();
len2 = rTemp.str2.size();
int timeout = progdefaults.RigCatTimeout;
while (timeout > 50) {
MilliSleep(50);
Fl::awake();
timeout -= 50;
}
if (timeout) {
MilliSleep(timeout);
Fl::awake();
}
// send the command
int sendok;
{
guard_lock ser_guard(&rigCAT_mutex);
sendok = sendCommand(symbol, strCmd, rTemp.size, progdefaults.RigCatWait);
}
if ( !sendok ) {
LOG_ERROR("sendCommand failed");
return;
}
// check the pre data string
p = 0;
pData = 0;
if (len1) {
for (size_t i = 0; i < len1; i++) {
if ((char)rTemp.str1[i] != (char)replybuff[i]) {
unsigned int ui = i;
LOG_ERROR("failed pre data string test @ %u", ui);
return;
}
}
p = len1;
}
if (rTemp.fill1) p += rTemp.fill1;
pData = p;
if (rTemp.data.dtype == "BCD") {
p += rTemp.data.size / 2;
if (rTemp.data.size & 1) p++;
} else
p += rTemp.data.size;
// check the post data string
if (rTemp.fill2) p += rTemp.fill2;
if (len2) {
for (size_t i = 0; i < len2; i++)
if ((char)rTemp.str2[i] != (char)replybuff[p + i]) {
LOG_ERROR("failed post data string test @ %d", static_cast<int>(i));
return;
}
}
// convert the data field
mtr = smeter_data(rTemp.data, pData);
// if (xmlrig.debug) LOG_INFO("Converted %s value to %d", symbol, (int)mtr);
REQ(rigcat_set_smeter, reinterpret_cast<void *>(mtr));
}
int pmeter_data(DATA d, size_t p)
{
int val = 0;
if (d.dtype == "BCD") {
if (d.reverse == true)
val = (int)(fm_bcd_be(p, d.size));
else
val = (int)(fm_bcd(p, d.size));
} else if (d.dtype == "BINARY") {
if (d.reverse == true)
val = (int)(fm_binary_be(p, d.size));
else
val = (int)(fm_binary(p, d.size));
} else if (d.dtype == "DECIMAL") {
if (d.reverse == true)
val = (int)(fm_decimal_be(p, d.size));
else
val = (int)(fm_decimal(p, d.size));
}
size_t n;
int pm1, pm2, val1, val2;
for (n = 0; n < xmlrig.pmeter.size() - 1; n++) {
if ((val > xmlrig.pmeter[n].val) && (val <= xmlrig.pmeter[n+1].val)) break;
}
if (n == xmlrig.pmeter.size() - 1) return 0;
pm1 = xmlrig.pmeter[n].mtr;
pm2 = xmlrig.pmeter[n+1].mtr;
val1 = xmlrig.pmeter[n].val;
val2 = xmlrig.pmeter[n+1].val;
if (val1 == val2) return 0;
int mtr = pm1 + (val - val1) * (pm2 - pm1) / (val2 - val1);
return mtr;
}
static void rigcat_set_pmeter(void *data)
{
if (pwrlevel_grp->visible()) return;
if (!smeter && !pwrmeter) return;
if (pwrmeter && progStatus.meters) {
if (!pwrmeter->visible()) {
smeter->hide();
pwrmeter->show();
}
int val = reinterpret_cast<intptr_t>(data);
pwrmeter->value(val);
}
}
void rigCAT_get_pwrmeter()
{
const char symbol[] = "GET_PWRMETER";
if (rigCAT_exit || xmlrig.noserial) return;
XMLIOS modeCmd;
std::list<XMLIOS>::iterator itrCmd;
std::string strCmd;
size_t p = 0, len1 = 0, len2 = 0, pData = 0;
long mtr = 0;
itrCmd = commands.begin();
while (itrCmd != commands.end()) {
if ((*itrCmd).SYMBOL == symbol)
break;
++itrCmd;
}
if (itrCmd == commands.end()) {
if (xmlrig.debug) LOG_INFO("%s not defined", symbol);
return;
}
modeCmd = *itrCmd;
if ( !modeCmd.str1.empty() ) strCmd.append(modeCmd.str1);
if ( !modeCmd.str2.empty() ) strCmd.append(modeCmd.str2);
if ( !modeCmd.info.size() ) return;
std::list<XMLIOS>::iterator preply;
for (preply = reply.begin(); preply != reply.end(); ++preply) {
if (preply->SYMBOL == modeCmd.info)
break;
}
if (preply == reply.end()) return;
XMLIOS rTemp = *preply;
len1 = rTemp.str1.size();
len2 = rTemp.str2.size();
int timeout = progdefaults.RigCatTimeout;
while (timeout > 50) {
MilliSleep(50);
Fl::awake();
timeout -= 50;
}
if (timeout) {
MilliSleep(timeout);
Fl::awake();
}
// send the command
int sendok;
{
guard_lock ser_guard(&rigCAT_mutex);
sendok = sendCommand(symbol, strCmd, rTemp.size, progdefaults.RigCatWait);
}
if ( !sendok ) {
LOG_ERROR("sendCommand failed");
return;
}
// check the pre data string
p = 0;
pData = 0;
if (len1) {
for (size_t i = 0; i < len1; i++) {
if ((char)rTemp.str1[i] != (char)replybuff[i]) {
unsigned int ui = i;
LOG_ERROR("failed pre data string test @ %u", ui);
return;
}
}
p = len1;
}
if (rTemp.fill1) p += rTemp.fill1;
pData = p;
if (rTemp.data.dtype == "BCD") {
p += rTemp.data.size / 2;
if (rTemp.data.size & 1) p++;
} else
p += rTemp.data.size;
// check the post data string
if (rTemp.fill2) p += rTemp.fill2;
if (len2) {
for (size_t i = 0; i < len2; i++)
if ((char)rTemp.str2[i] != (char)replybuff[p + i]) {
LOG_ERROR("failed post data string test @ %d", static_cast<int>(i));
return;
}
}
// convert the data field
mtr = pmeter_data(rTemp.data, pData);
if (xmlrig.debug) LOG_INFO("Converted %s to %d", symbol, (int)mtr);
REQ(rigcat_set_pmeter, reinterpret_cast<void *>(mtr));
}
static void rigcat_notch(void *data)
{
int val = reinterpret_cast<intptr_t>(data);
notch_frequency = val;
}
int notch_data(DATA d, size_t p)
{
int val = 0;
if (d.dtype == "BCD") {
if (d.reverse == true)
val = (int)(fm_bcd_be(p, d.size));
else
val = (int)(fm_bcd(p, d.size));
} else if (d.dtype == "BINARY") {
if (d.reverse == true)
val = (int)(fm_binary_be(p, d.size));
else
val = (int)(fm_binary(p, d.size));
} else if (d.dtype == "DECIMAL") {
if (d.reverse == true)
val = (int)(fm_decimal_be(p, d.size));
else
val = (int)(fm_decimal(p, d.size));
}
size_t n;
int ntch1, ntch2, val1, val2;
for (n = 0; n < xmlrig.notch.size() - 1; n++) {
if ((val > xmlrig.notch[n].val) && (val <= xmlrig.notch[n+1].val))
break;
}
if (n == xmlrig.notch.size() - 1)
return 0;
val1 = xmlrig.notch[n].val;
val2 = xmlrig.notch[n+1].val;
if (val1 == val2)
return 0;
ntch1 = xmlrig.notch[n].mtr;
ntch2 = xmlrig.notch[n+1].mtr;
return ntch1 + (val - val1) * (ntch2 - ntch1) / (val2 - val1);
}
int notch_val(int freq)
{
size_t n;
int val1, val2, freq1, freq2;
for (n = 0; n < xmlrig.notch.size() - 1; n++) {
if ((freq > xmlrig.notch[n].mtr) && (freq <= xmlrig.notch[n+1].mtr))
break;
}
if (n == xmlrig.notch.size() - 1)
return 0;
freq1 = xmlrig.notch[n].mtr;
freq2 = xmlrig.notch[n+1].mtr;
if (freq1 == freq2)
return 0;
val1 = xmlrig.notch[n].val;
val2 = xmlrig.notch[n+1].val;
return val1 + (freq - freq1) * (val2 - val1) / (freq2 - freq1);
}
bool rigCAT_notchON()
{
const char symbol[] = "GET_NOTCH_ON";
if (rigCAT_exit) return 0;
XMLIOS modeCmd;
std::list<XMLIOS>::iterator itrCmd;
std::string strCmd;
size_t len1 = 0;
itrCmd = commands.begin();
while (itrCmd != commands.end()) {
if ((*itrCmd).SYMBOL == symbol)
break;
++itrCmd;
}
if (itrCmd == commands.end()) {
if (xmlrig.debug) LOG_INFO("%s not defined", symbol);
return 0;
}
modeCmd = *itrCmd;
if ( !modeCmd.str1.empty() ) strCmd.append(modeCmd.str1);
if ( !modeCmd.str2.empty() ) strCmd.append(modeCmd.str2);
if ( !modeCmd.info.size() ) return 0;
std::list<XMLIOS>::iterator preply;
for (preply = reply.begin(); preply != reply.end(); ++preply) {
if (preply->SYMBOL == modeCmd.info)
break;
}
if (preply == reply.end()) return 0;
XMLIOS rTemp = *preply;
len1 = rTemp.str1.size();
int timeout = progdefaults.RigCatTimeout;
while (timeout > 50) {
MilliSleep(50);
Fl::awake();
timeout -= 50;
}
if (timeout) {
MilliSleep(timeout);
Fl::awake();
}
// send the command
int sendok;
{
guard_lock ser_guard(&rigCAT_mutex);
sendok = sendCommand(symbol, strCmd, rTemp.size, progdefaults.RigCatWait );
}
if ( !sendok ) {
LOG_ERROR("sendCommand failed");
return 0;
}
bool is_on = true;
if (len1) {
for (size_t i = 0; i < len1; i++) {
if ((char)rTemp.str1[i] != (char)replybuff[i]) {
is_on = false;
break;
}
}
} else
is_on = false;
// if (xmlrig.debug) LOG_INFO("%s is %s", symbol, is_on ? "ON" : "OFF");
return is_on;
}
void rigCAT_get_notch()
{
const char symbol[] = "GET_NOTCH";
if (rigCAT_exit) return;
if (!rigCAT_notchON()) {
REQ(rigcat_notch, reinterpret_cast<void *>(0));
return;
}
XMLIOS modeCmd;
std::list<XMLIOS>::iterator itrCmd;
std::string strCmd;
size_t p = 0, len1 = 0, len2 = 0, pData = 0;
long ntch = 0;
itrCmd = commands.begin();
while (itrCmd != commands.end()) {
if ((*itrCmd).SYMBOL == symbol)
break;
++itrCmd;
}
if (itrCmd == commands.end()) {
if (xmlrig.debug) LOG_INFO("%s not defined", symbol);
return;
}
modeCmd = *itrCmd;
if ( !modeCmd.str1.empty() ) strCmd.append(modeCmd.str1);
if ( !modeCmd.str2.empty() ) strCmd.append(modeCmd.str2);
if ( !modeCmd.info.size() ) return;
std::list<XMLIOS>::iterator preply;
for (preply = reply.begin(); preply != reply.end(); ++preply) {
if (preply->SYMBOL == modeCmd.info)
break;
}
if (preply == reply.end()) return;
XMLIOS rTemp = *preply;
len1 = rTemp.str1.size();
len2 = rTemp.str2.size();
int timeout = progdefaults.RigCatTimeout;
while (timeout > 50) {
MilliSleep(50);
Fl::awake();
timeout -= 50;
}
if (timeout) {
MilliSleep(timeout);
Fl::awake();
}
// send the command
int sendok;
{
guard_lock ser_guard(&rigCAT_mutex);
sendok = sendCommand(symbol, strCmd, rTemp.size,progdefaults.RigCatWait);
}
if ( !sendok ) {
LOG_ERROR("sendCommand failed");
return;
}
// check the pre data string
p = 0;
pData = 0;
if (len1) {
for (size_t i = 0; i < len1; i++) {
if ((char)rTemp.str1[i] != (char)replybuff[i]) {
unsigned int ui = i;
LOG_ERROR("failed pre data string test @ %u", ui);
return;
}
}
p = len1;
}
if (rTemp.fill1) p += rTemp.fill1;
pData = p;
if (rTemp.data.dtype == "BCD") {
p += rTemp.data.size / 2;
if (rTemp.data.size & 1) p++;
} else
p += rTemp.data.size;
// check the post data string
if (rTemp.fill2) p += rTemp.fill2;
if (len2) {
for (size_t i = 0; i < len2; i++)
if ((char)rTemp.str2[i] != (char)replybuff[p + i]) {
LOG_ERROR("failed post data string test @ %d", static_cast<int>(i));
return;
}
}
// convert the data field
ntch = notch_data(rTemp.data, pData);
if (xmlrig.debug) LOG_INFO("%s converted to %d", symbol, (int)ntch);
REQ(rigcat_notch, reinterpret_cast<void *>(ntch));
}
void rigCAT_notch_ON()
{
const char symbol[] = "SET_NOTCH_ON";
if (rigCAT_exit) return;
XMLIOS modeCmd;
std::list<XMLIOS>::iterator itrCmd;
std::string strCmd;
itrCmd = commands.begin();
while (itrCmd != commands.end()) {
if ((*itrCmd).SYMBOL == symbol)
break;
++itrCmd;
}
if (itrCmd == commands.end()) {
if (xmlrig.debug) LOG_INFO("%s not defined", symbol);
return;
}
modeCmd = *itrCmd;
if ( modeCmd.str1.empty() == false)
strCmd.append(modeCmd.str1);
if (modeCmd.str2.empty() == false)
strCmd.append(modeCmd.str2);
if (modeCmd.ok.size()) {
std::list<XMLIOS>::iterator preply = reply.begin();
while (preply != reply.end()) {
if (preply->SYMBOL == modeCmd.ok) {
XMLIOS rTemp = *preply;
// send the command
for (int n = 0; n < progdefaults.RigCatRetries; n++) {
if (rigCAT_exit) return;
guard_lock ser_guard( &rigCAT_mutex );
if (sendCommand(symbol, strCmd, rTemp.size, progdefaults.RigCatWait)) return;
MilliSleep(50);
}
return;
}
preply++;
}
} else {
for (int n = 0; n < progdefaults.RigCatRetries; n++) {
if (rigCAT_exit) return;
guard_lock ser_guard( &rigCAT_mutex );
if (sendCommand(symbol, strCmd, 0, progdefaults.RigCatWait)) return;
MilliSleep(50);
}
}
LOG_ERROR("%s failed", symbol);
}
void rigCAT_notch_OFF()
{
const char symbol[] = "SET_NOTCH_OFF";
if (rigCAT_exit) return;
XMLIOS modeCmd;
std::list<XMLIOS>::iterator itrCmd;
std::string strCmd;
itrCmd = commands.begin();
while (itrCmd != commands.end()) {
if ((*itrCmd).SYMBOL == symbol)
break;
++itrCmd;
}
if (itrCmd == commands.end()) {
if (xmlrig.debug) LOG_INFO("%s not defined", symbol);
return;
}
modeCmd = *itrCmd;
if ( modeCmd.str1.empty() == false)
strCmd.append(modeCmd.str1);
if (modeCmd.str2.empty() == false)
strCmd.append(modeCmd.str2);
if (modeCmd.ok.size()) {
std::list<XMLIOS>::iterator preply = reply.begin();
while (preply != reply.end()) {
if (preply->SYMBOL == modeCmd.ok) {
XMLIOS rTemp = *preply;
// send the command
for (int n = 0; n < progdefaults.RigCatRetries; n++) {
if (rigCAT_exit) return;
guard_lock ser_guard( &rigCAT_mutex );
if (sendCommand(symbol, strCmd, rTemp.size, progdefaults.RigCatWait)) return;
MilliSleep(50);
}
return;
}
preply++;
}
} else {
for (int n = 0; n < progdefaults.RigCatRetries; n++) {
if (rigCAT_exit) return;
guard_lock ser_guard( &rigCAT_mutex );
if (sendCommand(symbol, strCmd, 0, progdefaults.RigCatWait)) return;
MilliSleep(50);
}
}
LOG_ERROR("%s failed", symbol);
}
void rigCAT_set_notch(int freq)
{
const char symbol[] = "SET_NOTCH_VAL";
if (rigCAT_exit) return;
if (!freq) {
rigCAT_notch_OFF();
return;
}
rigCAT_notch_ON();
XMLIOS modeCmd;
std::list<XMLIOS>::iterator itrCmd;
std::string strCmd;
itrCmd = commands.begin();
while (itrCmd != commands.end()) {
if ((*itrCmd).SYMBOL == symbol)
break;
++itrCmd;
}
if (itrCmd == commands.end()) {
if (xmlrig.debug) LOG_INFO("%s not defined", symbol);
return;
}
modeCmd = *itrCmd;
if ( modeCmd.str1.empty() == false)
strCmd.append(modeCmd.str1);
std::string strval = "";
long long int val = notch_val(freq);
if (modeCmd.data.size != 0) {
if (modeCmd.data.dtype == "BCD") {
if (modeCmd.data.reverse == true)
strval = to_bcd_be(val, modeCmd.data.size);
else
strval = to_bcd(val, modeCmd.data.size);
} else if (modeCmd.data.dtype == "BINARY") {
if (modeCmd.data.reverse == true)
strval = to_binary_be(val, modeCmd.data.size);
else
strval = to_binary(val, modeCmd.data.size);
} else if (modeCmd.data.dtype == "DECIMAL") {
if (modeCmd.data.reverse == true)
strval = to_decimal_be(val, modeCmd.data.size);
else
strval = to_decimal(val, modeCmd.data.size);
}
}
strCmd.append(strval);
if (modeCmd.str2.empty() == false)
strCmd.append(modeCmd.str2);
if (modeCmd.ok.size()) {
std::list<XMLIOS>::iterator preply = reply.begin();
while (preply != reply.end()) {
if (preply->SYMBOL == modeCmd.ok) {
XMLIOS rTemp = *preply;
// send the command
for (int n = 0; n < progdefaults.RigCatRetries; n++) {
if (rigCAT_exit) return;
guard_lock ser_guard( &rigCAT_mutex );
if (sendCommand(symbol, strCmd, rTemp.size, progdefaults.RigCatWait)) return;
MilliSleep(50);
}
return;
}
preply++;
}
} else {
for (int n = 0; n < progdefaults.RigCatRetries; n++) {
if (rigCAT_exit) return;
guard_lock ser_guard( &rigCAT_mutex );
if (sendCommand(symbol, strCmd, 0, progdefaults.RigCatWait)) return;
MilliSleep(50);
}
}
if (progdefaults.RigCatVSP == false)
LOG_ERROR("%s failed", symbol);
}
long pwrlevel_data(DATA d, size_t p)
{
long val = 0;
if (d.dtype == "BCD") {
if (d.reverse == true)
val = (int)(fm_bcd_be(p, d.size));
else
val = (int)(fm_bcd(p, d.size));
} else if (d.dtype == "BINARY") {
if (d.reverse == true)
val = (int)(fm_binary_be(p, d.size));
else
val = (int)(fm_binary(p, d.size));
} else if (d.dtype == "DECIMAL") {
if (d.reverse == true)
val = (int)(fm_decimal_be(p, d.size));
else
val = (int)(fm_decimal(p, d.size));
}
size_t n;
long pwr1, pwr2, val1, val2;
for (n = 0; n < xmlrig.pwrlevel.size() - 1; n++) {
if ((val > xmlrig.pwrlevel[n].val) && (val <= xmlrig.pwrlevel[n+1].val))
break;
}
if (n == xmlrig.pwrlevel.size() - 1)
return 0;
val1 = xmlrig.pwrlevel[n].val;
val2 = xmlrig.pwrlevel[n+1].val;
if (val1 == val2)
return 0;
pwr1 = xmlrig.pwrlevel[n].mtr;
pwr2 = xmlrig.pwrlevel[n+1].mtr;
return pwr1 + (val - val1) * (pwr2 - pwr1) / (val2 - val1);
}
int pwrlevel_val(int pwr)
{
size_t n;
int val1, val2, pwr1, pwr2;
for (n = 0; n < xmlrig.pwrlevel.size() - 1; n++) {
if ((pwr >= xmlrig.pwrlevel[n].mtr) && (pwr <= xmlrig.pwrlevel[n+1].mtr))
break;
}
if (n == xmlrig.pwrlevel.size() - 1)
return 0;
pwr1 = xmlrig.pwrlevel[n].mtr;
pwr2 = xmlrig.pwrlevel[n+1].mtr;
if (pwr1 == pwr2)
return 0;
val1 = xmlrig.pwrlevel[n].val;
val2 = xmlrig.pwrlevel[n+1].val;
return val1 + (pwr - pwr1) * (val2 - val1) / (pwr2 - pwr1);
}
// called by rigio thread
// must use REQ(...) to set the power level control
static void rigCAT_update_pwrlevel(const long v)
{
long pwr = v;
char szpwr[10];
snprintf(szpwr, sizeof(szpwr), "%ld", pwr);
progdefaults.mytxpower = szpwr;
inpMyPower->value(szpwr);
pwr_level->value(pwr);
// if (xmlrig.debug) LOG_INFO("Read power level %s", szpwr);
}
void rigCAT_get_pwrlevel()
{
const char symbol[] = "GET_PWRLEVEL";
if (rigCAT_exit || xmlrig.noserial || !xmlrig.xmlok) return;
XMLIOS modeCmd;
std::list<XMLIOS>::iterator itrCmd;
std::string strCmd;
size_t p = 0, len1 = 0, len2 = 0, pData = 0;
long pwr = 0;
itrCmd = commands.begin();
while (itrCmd != commands.end()) {
if ((*itrCmd).SYMBOL == symbol)
break;
++itrCmd;
}
if (itrCmd == commands.end()) {
if (xmlrig.debug) LOG_INFO("%s not defined", symbol);
return;
}
modeCmd = *itrCmd;
if ( !modeCmd.str1.empty() ) strCmd.append(modeCmd.str1);
if ( !modeCmd.str2.empty() ) strCmd.append(modeCmd.str2);
if ( !modeCmd.info.size() ) return;
std::list<XMLIOS>::iterator preply;
for (preply = reply.begin(); preply != reply.end(); ++preply) {
if (preply->SYMBOL == modeCmd.info)
break;
}
if (preply == reply.end()) return;
XMLIOS rTemp = *preply;
len1 = rTemp.str1.size();
len2 = rTemp.str2.size();
int timeout = progdefaults.RigCatTimeout;
while (timeout > 50) {
MilliSleep(50);
Fl::awake();
timeout -= 50;
}
if (timeout) {
MilliSleep(timeout);
Fl::awake();
}
// send the command
{
guard_lock ser_guard( &rigCAT_mutex );
if ( !sendCommand(symbol, strCmd, rTemp.size, progdefaults.RigCatWait) ) {
LOG_ERROR("sendCommand failed");
return;
}
}
// check the pre data string
p = 0;
pData = 0;
if (len1) {
for (size_t i = 0; i < len1; i++) {
if ((char)rTemp.str1[i] != (char)replybuff[i]) {
unsigned int ui = i;
LOG_ERROR("failed pre data string test @ %u", ui);
return;
}
}
p = len1;
}
if (rTemp.fill1) p += rTemp.fill1;
pData = p;
if (rTemp.data.dtype == "BCD") {
p += rTemp.data.size / 2;
if (rTemp.data.size & 1) p++;
} else
p += rTemp.data.size;
// check the post data string
if (rTemp.fill2) p += rTemp.fill2;
if (len2) {
for (size_t i = 0; i < len2; i++)
if ((char)rTemp.str2[i] != (char)replybuff[p + i]) {
LOG_ERROR("failed post data string test @ %d", static_cast<int>(i));
return;
}
}
// convert the data field
pwr = pwrlevel_data(rTemp.data, pData);
REQ(rigCAT_update_pwrlevel, pwr);
}
void rigCAT_set_pwrlevel(int pwr)
{
const char symbol[] = "SET_PWRLEVEL";
if (rigCAT_exit || !xmlrig.use_pwrlevel) return;
XMLIOS modeCmd;
std::list<XMLIOS>::iterator itrCmd;
std::string strCmd;
itrCmd = commands.begin();
while (itrCmd != commands.end()) {
if ((*itrCmd).SYMBOL == symbol)
break;
++itrCmd;
}
if (itrCmd == commands.end()) {
if (xmlrig.debug) LOG_INFO("%s not defined", symbol);
return;
}
modeCmd = *itrCmd;
if ( modeCmd.str1.empty() == false)
strCmd.append(modeCmd.str1);
std::string strval = "";
int val = pwrlevel_val(pwr);
if (modeCmd.data.size != 0) {
if (modeCmd.data.dtype == "BCD") {
if (modeCmd.data.reverse == true)
strval = to_bcd_be(val, modeCmd.data.size);
else
strval = to_bcd(val, modeCmd.data.size);
} else if (modeCmd.data.dtype == "BINARY") {
if (modeCmd.data.reverse == true)
strval = to_binary_be(val, modeCmd.data.size);
else
strval = to_binary(val, modeCmd.data.size);
} else if (modeCmd.data.dtype == "DECIMAL") {
if (modeCmd.data.reverse == true)
strval = to_decimal_be(val, modeCmd.data.size);
else
strval = to_decimal(val, modeCmd.data.size);
}
}
strCmd.append(strval);
if (modeCmd.str2.empty() == false)
strCmd.append(modeCmd.str2);
if (modeCmd.ok.size()) {
std::list<XMLIOS>::iterator preply = reply.begin();
while (preply != reply.end()) {
if (preply->SYMBOL == modeCmd.ok) {
XMLIOS rTemp = *preply;
// send the command
for (int n = 0; n < progdefaults.RigCatRetries; n++) {
if (rigCAT_exit) return;
guard_lock ser_guard( &rigCAT_mutex );
if (sendCommand(symbol, strCmd, rTemp.size, progdefaults.RigCatWait)) {
if (xmlrig.debug) LOG_INFO("Power set to %s", strval.c_str());
return;
}
MilliSleep(50);
}
if (xmlrig.debug) LOG_ERROR("%s failed", symbol);
return;
}
preply++;
}
} else {
for (int n = 0; n < progdefaults.RigCatRetries; n++) {
if (rigCAT_exit) return;
guard_lock ser_guard( &rigCAT_mutex );
if (sendCommand(symbol, strCmd, 0, progdefaults.RigCatWait)) {
if (xmlrig.debug) LOG_INFO("Power set to %s", strval.c_str());
return;
MilliSleep(50);
}
}
}
if (progdefaults.RigCatVSP == false)
if (xmlrig.debug) LOG_ERROR("%s failed", symbol);
}
static void *rigCAT_loop(void *args)
{
SET_THREAD_ID(RIGCTL_TID);
long long freq = 0L;
std::string sWidth, sMode;
bool failed;
for (;;) {
for (int i = 0; i < xmlrig.pollinterval / 10; i++) {
MilliSleep(10);
if (rigCAT_exit == true) {
LOG_INFO("%s", "Exited rigCAT loop");
return NULL;
}
}
if (trx_state == STATE_RX) {
cmdque_exec();
freq = rigCAT_getfreq(progdefaults.RigCatRetries, failed);
if (rigCAT_exit) continue;
if ((freq > 0) && (freq != llFreq)) {
llFreq = freq;
show_frequency(freq);
wf->rfcarrier(freq);
}
sWidth = rigCAT_getwidth();
if (rigCAT_exit) continue;
if (sWidth.size() && sWidth != sRigWidth) {
sRigWidth = sWidth;
show_bw(sWidth);
}
sMode = rigCAT_getmode();
if (rigCAT_exit) continue;
if (sMode.size() && sMode != sRigMode) {
sRigMode = sMode;
if (ModeIsLSB(sMode))
wf->USB(false);
else
wf->USB(true);
show_mode(sMode);
}
if (xmlrig.use_pwrlevel) rigCAT_get_pwrlevel();
if (xmlrig.use_smeter) rigCAT_get_smeter();
if (xmlrig.use_notch) rigCAT_get_notch();
} else {
if ( (trx_state == STATE_TUNE) || (trx_state == STATE_TX) )
if (xmlrig.use_pwrmeter) rigCAT_get_pwrmeter();
}
}
return NULL;
}
| 55,915
|
C++
|
.cxx
| 2,096
| 23.744275
| 125
| 0.642162
|
w1hkj/fldigi
| 109
| 27
| 38
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
751,038
|
rigclass.cxx
|
w1hkj_fldigi/src/rigcontrol/rigclass.cxx
|
// ----------------------------------------------------------------------------
// rigclass.cxx
//
// Hamlib C++ interface is a frontend implementing wrapper functions
// to the hamlib library
//
// derived from rigclass.cc distributed with hamlib
//
// Copyright (C) 2007-2009
// Dave Freese, W1HKJ
//
// This file is part of fldigi.
//
// Fldigi 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 3 of the License, or
// (at your option) any later version.
//
// Fldigi 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 fldigi. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include <config.h>
#include <hamlib/rig.h>
#include "rigclass.h"
#include "debug.h"
LOG_FILE_SOURCE(debug::LOG_RIGCONTROL);
#define NUMTRIES 10
Rig::Rig() : rig(0) { }
Rig::Rig(rig_model_t rig_model)
{
rig = rig_init(rig_model);
fnull = 3580.0;
if (!rig)
throw RigException ("Could not initialize rig");
}
Rig::~Rig()
{
LOG_INFO("Rig destroy %p", rig);
if (!rig) return;
close();
}
void Rig::init(rig_model_t rig_model)
{
close();
if ((rig = rig_init(rig_model)) == NULL)
throw RigException ("Could not initialize rig");
LOG_INFO("Initialised rig model %d: %s", rig_model, getName());
}
const char *Rig::getName()
{
return rig ? rig->caps->model_name : "";
}
const struct rig_caps* Rig::getCaps(void)
{
return rig ? rig->caps : 0;
}
void Rig::open(void)
{
int err = rig_open(rig);
if (err != RIG_OK)
throw RigException(err);
}
void Rig::close(bool abort)
{
if (abort)
rig = NULL;
else if (rig) {
rig_close(rig);
rig_cleanup(rig);
rig = NULL;
}
}
bool Rig::canSetFreq()
{
if (!rig) return false;
return (rig->caps->set_freq != NULL);
}
bool Rig::canGetFreq()
{
if (!rig) return false;
return (rig->caps->get_freq != NULL);
}
bool Rig::canSetMode()
{
if (!rig) return false;
return (rig->caps->set_mode != NULL);
}
bool Rig::canGetMode()
{
if (!rig) return false;
return (rig->caps->get_mode != NULL);
}
bool Rig::canSetPTT()
{
if (!rig) return false;
return (rig->caps->set_ptt != NULL);
}
bool Rig::canGetPTT()
{
if (!rig) return false;
return (rig->caps->get_ptt != NULL);
}
void Rig::setFreq(freq_t freq, vfo_t vfo)
{
fnull = freq;
if (!canSetFreq()) { // rig does not support set_freq
return;
}
int err;
for (int i = 0; i < NUMTRIES; i++) {
err = rig_set_freq(rig, vfo, freq);
if (err == RIG_OK)
return;
}
throw RigException(err);
}
freq_t Rig::getFreq(vfo_t vfo)
{
if (!canGetFreq()) { // rig does not support get_freq
return fnull;
}
freq_t freq = fnull;
int ret;
for (int i = 0; i < NUMTRIES; i++) {
ret = rig_get_freq(rig, vfo, &freq);
if (ret == RIG_OK && freq != 0) {
break;
}
}
return freq;
}
void Rig::setMode(rmode_t mode, pbwidth_t width, vfo_t vfo)
{
if (!canSetMode())
throw RigException(RIG_ENAVAIL);
int err;
for (int i = 0; i < NUMTRIES; i++) {
if ((err = rig_set_mode(rig, vfo, mode, width)) == RIG_OK)
return;
}
throw RigException(err);
}
rmode_t Rig::getMode(pbwidth_t& width, vfo_t vfo)
{
if (!canGetMode())
throw RigException(RIG_ENAVAIL);
int err;
rmode_t mode;
for (int i = 0; i < NUMTRIES; i++) {
if ((err = rig_get_mode(rig, vfo, &mode, &width)) == RIG_OK)
return mode;
}
throw RigException(err);
}
void Rig::setPTT(ptt_t ptt, vfo_t vfo)
{
if (!canSetPTT())
throw RigException(RIG_ENAVAIL);
int err;
for (int i = 0; i < NUMTRIES; i++) {
if ((err = rig_set_ptt(rig, vfo, ptt)) == RIG_OK)
return;
}
throw RigException(err);
}
ptt_t Rig::getPTT(vfo_t vfo)
{
if (!canGetPTT())
throw RigException(RIG_ENAVAIL);
int err;
ptt_t ptt;
for (int i = 0; i < NUMTRIES; i++) {
if ((err = rig_get_ptt(rig, vfo, &ptt)) == RIG_OK)
return ptt;
}
throw RigException(err);
}
void Rig::setConf(token_t token, const char *val)
{
int err = rig_set_conf(rig, token, val);
if (err != RIG_OK)
throw RigException(err);
}
void Rig::setConf(const char *name, const char *val)
{
LOG_INFO("setting \"%s\" to \"%s\"", name, val);
int err = rig_set_conf(rig, tokenLookup(name), val);
if (err != RIG_OK)
throw RigException(name, err);
}
void Rig::getConf(token_t token, char *val)
{
int err = rig_get_conf(rig, token, val);
if (err != RIG_OK)
throw RigException(err);
}
void Rig::getConf(const char *name, char *val)
{
int err = rig_get_conf(rig, tokenLookup(name), val);
if (err != RIG_OK)
throw RigException(name, err);
}
token_t Rig::tokenLookup(const char *name)
{
return rig_token_lookup(rig, name);
}
pbwidth_t Rig::passbandNormal (rmode_t mode)
{
return rig_passband_normal(rig, mode);
}
pbwidth_t Rig::passbandNarrow (rmode_t mode)
{
return rig_passband_narrow(rig, mode);
}
pbwidth_t Rig::passbandWide (rmode_t mode)
{
return rig_passband_wide(rig, mode);
}
| 5,192
|
C++
|
.cxx
| 223
| 21.457399
| 79
| 0.656136
|
w1hkj/fldigi
| 109
| 27
| 38
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
751,039
|
xmlrpc_rig.cxx
|
w1hkj_fldigi/src/rigcontrol/xmlrpc_rig.cxx
|
// =====================================================================
//
// xmlrpc_rig.cxx
//
// connect to flrig xmlrpc server
//
// Copyright (C) 2007-2009
// Dave Freese, W1HKJ
//
// This file is part of fldigi.
//
// Fldigi 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 3 of the License, or
// (at your option) any later version.
//
// Fldigi 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 fldigi. If not, see <http://www.gnu.org/licenses/>.
// =====================================================================
#include <iostream>
#include <cmath>
#include <cstring>
#include <vector>
#include <list>
#include <stdlib.h>
#include <FL/Fl.H>
#include <FL/filename.H>
#include <FL/fl_ask.H>
#include "rigsupport.h"
#include "modem.h"
#include "trx.h"
#include "fl_digi.h"
#include "configuration.h"
#include "main.h"
#include "waterfall.h"
#include "macros.h"
#include "qrunner.h"
#include "debug.h"
#include "status.h"
#include "icons.h"
LOG_FILE_SOURCE(debug::debug::LOG_RPC_CLIENT);
using namespace XmlRpc;
static int xmlrpc_verbosity = 0;
//======================================================================
// flrig xmlrpc client
//======================================================================
pthread_t *flrig_thread = 0;
pthread_mutex_t mutex_flrig = PTHREAD_MUTEX_INITIALIZER;
void movFreq(Fl_Widget *w, void *d);
void show_freq(void *);
void flrig_get_vfo();
void flrig_get_frequency();
void post_mode(void *);
void flrig_get_mode();
void post_modes(void *);
void flrig_get_modes();
void post_bw(void *);
void flrig_get_bw();
void post_bws(void *);
void flrig_get_bws();
void flrig_get_notch();
void flrig_set_notch(int);
bool flrig_get_xcvr();
void flrig_connection();
void set_ptt();
void connect_to_flrig();
XmlRpcClient *flrig_client = (XmlRpcClient *)0;
//----------------------------------------------------------------------
// declared as extern in rigsupport.h
//----------------------------------------------------------------------
bool connected_to_flrig = false;
//----------------------------------------------------------------------
static bool bws_posted = false;
static bool modes_posted = false;
static bool freq_posted = true;
static std::string xcvr_name;
static std::string str_freq;
static std::string mode_result;
static XmlRpcValue modes_result;
static XmlRpcValue bws_result;
static XmlRpcValue bw_result;
static XmlRpcValue notch_result;
static double timeout = 5.0;
static int wait_bws_timeout = 0;
//======================================================================
void xmlrpc_rig_set_qsy(long long rfc)
{
unsigned long int freq = static_cast<unsigned long int>(rfc);
set_flrig_freq(freq);
wf->rfcarrier(freq);
wf->movetocenter();
show_frequency(freq);
LOG_VERBOSE("set qsy: %lu", freq);
}
//======================================================================
// set / get pairs
//======================================================================
//----------------------------------------------------------------------
// push to talk
//----------------------------------------------------------------------
static int ptt_state = 0;
static int new_ptt = -1;
void exec_flrig_ptt() {
if (!connected_to_flrig) {
new_ptt = -1;
return;
}
XmlRpcValue val, result, result2;
try {
bool ret;
{
guard_lock flrig_lock(&mutex_flrig);
ret = flrig_client->execute("rig.set_ptt", new_ptt, result, timeout);
}
if (ret) {
LOG_VERBOSE("ptt %s", ptt_state ? "ON" : "OFF");
new_ptt = -1;
return;
}
} catch (...) {
new_ptt = -1;
return;
}
LOG_ERROR("fldigi/flrig PTT %s failure", new_ptt ? "ON" : "OFF");
new_ptt = -1;
return;
}
void set_flrig_ptt(int on) {
if (!active_modem)
return;
if (active_modem->get_mode() == MODE_CW) {
if (progdefaults.CATkeying_disable_ptt &&
active_modem->get_mode() == MODE_CW &&
( progdefaults.use_ELCTkeying ||
progdefaults.use_ICOMkeying ||
progdefaults.use_KNWDkeying ||
progdefaults.use_YAESUkeying ||
progStatus.nanoCW_online ) ) {
return;
} else if (progdefaults.use_FLRIGkeying) {
if (progdefaults.CATkeying_disable_ptt)
return;
if (on) flrig_cwio_send_text("[");
else flrig_cwio_send_text("]");
}
}
new_ptt = on;
}
pthread_mutex_t mutex_flrig_ptt = PTHREAD_MUTEX_INITIALIZER;
void xmlrpc_rig_show_ptt(void *data)
{
guard_lock flrig_lock(&mutex_flrig_ptt);
int on = reinterpret_cast<intptr_t>(data);
if (wf && (trx_state != STATE_TUNE)) {
wf->xmtrcv->value(on);
wf->xmtrcv->do_callback();
}
}
void flrig_get_ptt()
{
try {
XmlRpcValue result;
bool ret;
{
guard_lock flrig_lock(&mutex_flrig);
ret = flrig_client->execute("rig.get_ptt", XmlRpcValue(), result, timeout);
}
if (ret) {
int val = (int)result;
ptt_state = val;
LOG_VERBOSE("get_ptt: %s", ptt_state ? "ON" : "OFF");
return;
}
connected_to_flrig = false;
LOG_ERROR("%s", "get_ptt failed!");
} catch (...) {}
}
void flrig_get_wpm()
{
if (!connected_to_flrig) {
return;
}
try {
XmlRpcValue result;
bool ret;
{
guard_lock flrig_lock(&mutex_flrig);
ret = flrig_client->execute("rig.cwio_get_wpm", XmlRpcValue(), result, timeout);
}
if (ret) {
int val = (int)result;
progdefaults.CWspeed = val;
LOG_VERBOSE("rig.cwio_get_wpm = %d", val);
return;
}
connected_to_flrig = false;
LOG_ERROR("%s failed!", "flrig_get_wpm");
} catch (...) {
LOG_ERROR("rig.cwio_get_wpm FAILED");
}
}
void flrig_set_wpm() {
if (!connected_to_flrig) {
return;
}
XmlRpcValue val, result;
try {
bool ret;
val = (int)static_cast<int>(progdefaults.CWspeed);
{
guard_lock flrig_lock(&mutex_flrig);
ret = flrig_client->execute("rig.cwio_set_wpm", val, result, timeout);
}
if (ret) {
LOG_VERBOSE("set wpm %f", progdefaults.CWspeed);
return;
}
} catch (...) {
}
LOG_ERROR("set wpm failed");
return;
}
//----------------------------------------------------------------------
// transceiver radio frequency
//----------------------------------------------------------------------
static bool wait_freq = false; // wait for transceiver to respond
static int wait_freq_timeout = 5; // 5 polls and then disable wait
static unsigned long int xcvr_freq = 0;
pthread_mutex_t mutex_flrig_freq = PTHREAD_MUTEX_INITIALIZER;
void xmlrpc_rig_show_freq(void * fr)
{
guard_lock flrig_lock(&mutex_flrig_freq);
if (!wf) return;
unsigned long int freq = reinterpret_cast<intptr_t>(fr);
LOG_VERBOSE("xmlrpc_rig_show_freq %lu", freq);
wf->rfcarrier(freq);
wf->movetocenter();
show_frequency(freq);
}
void set_flrig_freq(unsigned long int fr)
{
if (!connected_to_flrig) return;
XmlRpcValue val, result;
try {
val = (double)fr;
bool ret;
{
guard_lock flrig_lock(&mutex_flrig);
ret = flrig_client->execute("rig.set_vfo", val, result, timeout);
}
if (ret) {
LOG_VERBOSE("set freq: %lu", fr);
return;
}
LOG_ERROR("%s", "rig.set_vfo failed");
wait_freq = false;
wait_freq_timeout = 0;
} catch (...) {
LOG_ERROR("rig.set_vfo FAILED");
}
}
void flrig_get_frequency()
{
XmlRpcValue result;
try {
if (!freq_posted) return;
bool ret;
{
guard_lock flrig_lock(&mutex_flrig);
ret = flrig_client->execute("rig.get_vfo", XmlRpcValue(), result, timeout);
}
if (ret) {
str_freq = (std::string)result;
unsigned long int fr = atoll(str_freq.c_str());
if (!wait_freq && (fr != xcvr_freq)) {
xcvr_freq = fr;
guard_lock flrig_lock(&mutex_flrig_freq);
Fl::awake(xmlrpc_rig_show_freq, reinterpret_cast<void*>(fr));
LOG_VERBOSE("get freq: %lu", fr);
} else if (wait_freq && (fr == xcvr_freq)) {
wait_freq = false;
wait_freq_timeout = 0;
} else if (wait_freq_timeout == 0) {
wait_freq = false;
} else if (wait_freq_timeout)
--wait_freq_timeout;
} else {
connected_to_flrig = false;
wait_freq = false;
wait_freq_timeout = 5;
LOG_ERROR("%s", "get freq failed");
}
} catch (...) {}
}
//----------------------------------------------------------------------
// transceiver set / get mode
// transceiver get modes (mode table)
//----------------------------------------------------------------------
static bool wait_mode = false; // wait for transceiver to respond
static int wait_mode_timeout = 5; // 5 polls and then disable wait
static std::string posted_mode = "";
static bool wait_bw = false; // wait for transceiver to respond
static int wait_bw_timeout = 5; // 5 polls and then disable wait
static bool need_sideband = false;
static std::string posted_bw = "";
static std::string posted_bw1 = "";
static std::string posted_bw2 = "";
void set_flrig_mode(const char *md)
{
if (!connected_to_flrig) return;
XmlRpcValue val, result;
try {
val = std::string(md);
bool ret;
{
guard_lock flrig_lock(&mutex_flrig);
ret = flrig_client->execute("rig.set_mode", val, result, timeout);
}
if (ret) {
posted_mode = md;
need_sideband = true;
bws_posted = false;
wait_mode = true;
wait_mode_timeout = 10;
wait_bws_timeout = 5;
qso_opBW->hide();
qso_opGROUP->hide();
LOG_VERBOSE("set mode: %s", md);
} else {
LOG_ERROR("%s", "rig.set_mode failed");
wait_mode = false;
wait_mode_timeout = 10;
}
} catch (...) {}
}
pthread_mutex_t mutex_flrig_mode = PTHREAD_MUTEX_INITIALIZER;
static bool xml_USB = true;
bool xmlrpc_USB()
{
return xml_USB;
}
void xmlrpc_rig_post_mode(void *data)
{
guard_lock flrig_lock(&mutex_flrig_mode);
if (!qso_opMODE) return;
std::string *s = reinterpret_cast<std::string *>(data);
qso_opMODE->value(s->c_str());
bws_posted = false;
need_sideband = false;
}
void flrig_get_mode()
{
XmlRpcValue res;
try {
bool ret;
{
guard_lock flrig_lock(&mutex_flrig);
ret = flrig_client->execute("rig.get_mode", XmlRpcValue(), res, timeout);
}
if (ret) {
static std::string md;
md = (std::string)res;
bool posted = (md == posted_mode);
if (!wait_mode && (!posted || need_sideband)) {
posted_mode = md;
guard_lock flrig_modelock(&mutex_flrig_mode);
{
guard_lock flrig_lock(&mutex_flrig);
ret = flrig_client->execute("rig.get_sideband", XmlRpcValue(), res, timeout);
}
if (ret) {
static std::string sb;
sb = (std::string)res;
xml_USB = (sb[0] == 'U');
} else {
xml_USB = true;
}
if (posted) {
need_sideband = false;
return;
}
Fl::awake(xmlrpc_rig_post_mode, reinterpret_cast<void*>(&md));
LOG_VERBOSE("get mode: %s:%s", md.c_str(), xml_USB ? "USB" : "LSB");
} else if (wait_mode && posted) {
wait_mode = false;
wait_mode_timeout = 0;
} else if (wait_mode_timeout == 0) {
wait_mode = false;
} else if (wait_mode_timeout)
--wait_mode_timeout;
} else {
connected_to_flrig = false;
wait_mode = false;
wait_freq_timeout = 0;
LOG_ERROR("%s", "get mode failed");
}
} catch (...) {}
}
pthread_mutex_t mutex_flrig_modes = PTHREAD_MUTEX_INITIALIZER;
void xmlrpc_rig_post_modes(void *)
{
guard_lock flrig_lock(&mutex_flrig_modes);
if (!qso_opMODE) return;
int nargs = modes_result.size();
qso_opMODE->clear();
if (nargs == 0) {
qso_opMODE->add("");
qso_opMODE->index(0);
qso_opMODE->deactivate();
return;
}
std::string smodes;
for (int i = 0; i < nargs; i++)
smodes.append((std::string)modes_result[i]).append("|");
qso_opMODE->add(smodes.c_str());
qso_opMODE->index(0);
qso_opMODE->activate();
modes_posted = true;
bws_posted = false;
}
void flrig_get_modes()
{
try {
bool ret;
{
guard_lock flrig_lock(&mutex_flrig);
ret = flrig_client->execute("rig.get_modes", XmlRpcValue(), modes_result, timeout);
}
if (ret) {
guard_lock flrig_lock(&mutex_flrig_modes);
Fl::awake(xmlrpc_rig_post_modes);
posted_mode = posted_bw = posted_bw1 = posted_bw2 = "GETME";
{
int nargs = modes_result.size();
static std::string debugstr;
debugstr.assign("Mode table: ");
for (int i = 0; i < nargs - 1; i++)
debugstr.append((std::string)modes_result[i]).append(",");
debugstr.append(modes_result[nargs-1]);
LOG_VERBOSE("%s", debugstr.c_str());
}
} else {
LOG_ERROR("%s", "get modes failed");
}
} catch (...) {}
}
//----------------------------------------------------------------------
// transceiver get / set bandwidth
// transceiver get bandwidth table
//----------------------------------------------------------------------
void set_flrig_bw(int bw2, int bw1)
{
if (!connected_to_flrig) return;
XmlRpcValue val, result;
try {
int ival = bw2;
if (bw1 > -1) ival = 256*(bw1+128) + bw2;
val = ival;
LOG_VERBOSE("set_flrig_bw %04X", ival);
bool ret;
{
guard_lock flrig_lock(&mutex_flrig);
ret = flrig_client->execute("rig.set_bw", val, result, timeout);
}
if (ret) {
wait_bw = true;
wait_bw_timeout = 5;
} else {
LOG_ERROR("%s", "rig.set_bw failed");
wait_bw = false;
wait_bw_timeout = 0;
}
} catch (...) {}
}
pthread_mutex_t mutex_flrig_bw = PTHREAD_MUTEX_INITIALIZER;
void xmlrpc_rig_post_bw(void *)
{
guard_lock flrig_lock(&mutex_flrig_bw);
if (!qso_opBW) return;
if (posted_bw != (std::string)(qso_opBW->value())) {
qso_opBW->value(posted_bw);//.c_str());
qso_opBW->redraw();
LOG_VERBOSE("Update BW %s", posted_bw.c_str());
}
qso_opBW->show();
}
void xmlrpc_rig_post_bw1(void *)
{
guard_lock flrig_lock(&mutex_flrig_bw);
if (!qso_opBW1) return;
if (posted_bw1 != (std::string)(qso_opBW1->value())) {
qso_opBW1->value(posted_bw1);//.c_str());
qso_opBW1->redraw();
LOG_VERBOSE("Update combo BW1 %s", posted_bw1.c_str());
}
qso_opGROUP->show();
}
void xmlrpc_rig_post_bw2(void *)
{
guard_lock flrig_lock(&mutex_flrig_bw);
if (!qso_opBW2) return;
if (posted_bw2 != (std::string)(qso_opBW2->value())) {
qso_opBW2->value(posted_bw2);//.c_str());
qso_opBW2->redraw();
LOG_VERBOSE("Update combo BW2 %s", posted_bw2.c_str());
}
qso_opGROUP->show();
}
void do_flrig_get_bw()
{
XmlRpcValue res;
try {
bool ret;
{
guard_lock flrig_lock(&mutex_flrig);
ret = flrig_client->execute("rig.get_bw", XmlRpcValue(), res, timeout);
}
if (ret) {
static std::string s1;
static std::string s2;
s2 = (std::string)res[0];
s1 = (std::string)res[1];
if (!s1.empty()) {
posted_bw1 = s1;
Fl::awake(xmlrpc_rig_post_bw1);
posted_bw2 = s2;
Fl::awake(xmlrpc_rig_post_bw2);
} else {
if (!s2.empty()) {
posted_bw = s2;
Fl::awake(xmlrpc_rig_post_bw);
}
}
wait_bw_timeout = 0;
} else {
connected_to_flrig = false;
wait_bw_timeout = 0;
LOG_ERROR("%s", "get bw failed!");
}
} catch (...) {
}
}
void flrig_get_bw()
{
if (wait_bw_timeout) {
wait_bw_timeout--;
return;
}
do_flrig_get_bw();
}
pthread_mutex_t mutex_flrig_bws = PTHREAD_MUTEX_INITIALIZER;
void xmlrpc_rig_post_bws(void *)
{
if (!qso_opBW) return;
int nargs;
try { // two BW controls
nargs = bws_result[1].size();
static std::string bwstr;
qso_opBW1->clear();
for (int i = 1; i < nargs; i++) {
bwstr = (std::string)bws_result[1][i];
qso_opBW1->add(bwstr.c_str());
}
std::string labels1 = (std::string)bws_result[1][0];
static char btn1_label[2];
btn1_label[0] = labels1[0]; btn1_label[1] = 0;
qso_btnBW1->label(btn1_label);
qso_btnBW1->redraw_label();
qso_btnBW1->redraw();
static char tooltip1[20];
snprintf(tooltip1,sizeof(tooltip1),"%s",labels1.substr(2).c_str());
qso_opBW1->tooltip(tooltip1);
qso_opBW1->index(0);
qso_opBW1->redraw();
{
static std::string debugstr;
debugstr.assign("\nBW1 table: ");
for (int i = 1; i < nargs-1; i++)
debugstr.append((std::string)bws_result[1][i]).append(", ");
debugstr.append((std::string)bws_result[1][nargs - 1]).append("\n");
debugstr.append(labels1);
LOG_VERBOSE("%s", debugstr.c_str());
}
try {
nargs = bws_result[0].size();
static std::string bwstr;
qso_opBW2->clear();
for (int i = 1; i < nargs; i++) {
bwstr = (std::string)bws_result[0][i];
qso_opBW2->add(bwstr.c_str());
}
std::string labels2 = (std::string)bws_result[0][0];
static char btn2_label[2];
btn2_label[0] = labels2[0]; btn2_label[1] = 0;
qso_btnBW2->label(btn2_label);
qso_btnBW2->redraw_label();
qso_btnBW2->redraw();
static char tooltip2[20];
snprintf(tooltip2,sizeof(tooltip2),"%s",labels2.substr(2).c_str());
qso_opBW2->tooltip(tooltip2);
qso_opBW2->index(0);
qso_opBW2->redraw();
{
static std::string debugstr;
debugstr.assign("\nBW2 table: ");
for (int i = 1; i < nargs-1; i++)
debugstr.append((std::string)bws_result[0][i]).append(", ");
debugstr.append((std::string)bws_result[0][nargs - 1]).append("\n");
debugstr.append(labels2);
LOG_VERBOSE("%s", debugstr.c_str());
}
} catch ( XmlRpcException err) {
bws_posted = false;
return;
}
qso_opBW->hide();
bws_posted = true;
return;
} catch (XmlRpcException err) {
try { // one BW control
nargs = bws_result[0].size();
std::string bwstr;
qso_opBW->clear();
for (int i = 1; i < nargs; i++) {
bwstr.append((std::string)bws_result[0][i]).append("|");
}
qso_opBW->add(bwstr.c_str());
qso_opBW->index(0);
qso_opBW->activate();
qso_opBW->tooltip("xcvr bandwidth");
qso_opGROUP->hide();
{
static std::string debugstr;
debugstr.assign("BW table: ");
for (int i = 1; i < nargs-1; i++)
debugstr.append((std::string)bws_result[0][i]).append(", ");
debugstr.append((std::string)bws_result[0][nargs - 1]);
LOG_VERBOSE("%s", debugstr.c_str());
}
} catch (XmlRpcException err) {
LOG_ERROR("%s", "no bandwidths specified");
qso_opBW->add("");
qso_opBW->index(0);
qso_opBW->deactivate();
return;
}
}
bws_posted = true;
do_flrig_get_bw();
}
void flrig_get_bws()
{
if (bws_posted)
return;
if (wait_bws_timeout) {
wait_bws_timeout--;
return;
}
XmlRpcValue result;
try {
bool ret;
{
guard_lock flrig_lock(&mutex_flrig);
ret = flrig_client->execute("rig.get_bws", XmlRpcValue(), bws_result, timeout);
}
if (ret) {
bws_posted = false;
wait_bw = true;
wait_bw_timeout = 5;
posted_bw.clear();
Fl::awake(xmlrpc_rig_post_bws);
} else {
LOG_ERROR("%s", "get bws failed");
}
} catch (...) {}
}
//----------------------------------------------------------------------
// transceiver get / set vfo A / B
//----------------------------------------------------------------------
void set_flrig_ab(int n)
{
}
void show_A(void *)
{
}
void show_B(void *)
{
}
void flrig_get_vfo()
{
XmlRpcValue result;
try {
bool ret;
{
guard_lock flrig_lock(&mutex_flrig);
ret = flrig_client->execute("rig.get_AB", XmlRpcValue(), result, timeout);
}
if (ret) {
} else {
connected_to_flrig = false;
}
} catch (...) {}
}
//==============================================================================
// transceiver set / get notch
//==============================================================================
static int wait_notch_timeout = 0; // # polls and then disable wait
void set_flrig_notch()
{
if (!connected_to_flrig) return;
XmlRpcValue val, result;
try {
val = (int)notch_frequency;
bool ret;
{
guard_lock flrig_lock(&mutex_flrig);
ret = flrig_client->execute("rig.set_notch", val, result, timeout);
}
if (ret) {
wait_notch_timeout = 2;
} else {
LOG_ERROR("%s", "rig.set_notch failed");
wait_notch_timeout = 0;
}
} catch (...) {}
}
void flrig_get_notch()
{
if (wait_notch_timeout == 0)
try {
bool ret;
{
guard_lock flrig_lock(&mutex_flrig);
ret = flrig_client->execute("rig.get_notch", XmlRpcValue(), notch_result, timeout);
}
if (ret) {
notch_frequency = (int)notch_result;
LOG_VERBOSE("rig_get_notch: %d", notch_frequency);
}
} catch (...) {
LOG_ERROR("rig.get_notch FAILED");
}
else
wait_notch_timeout--;
}
//==============================================================================
// transceiver get smeter
// transceiver get power meter
//==============================================================================
pthread_mutex_t mutex_flrig_smeter = PTHREAD_MUTEX_INITIALIZER;
static void xmlrpc_rig_set_smeter(void *data)
{
guard_lock flrig_lock(&mutex_flrig_smeter);
if (smeter && progStatus.meters) {
if (!smeter->visible()) {
if (pwrmeter) pwrmeter->hide();
smeter->show();
}
int val = reinterpret_cast<intptr_t>(data);
LOG_VERBOSE("xmlrpc_rig_set_smeter: %d", val);
smeter->value(val);
}
}
void flrig_get_smeter()
{
XmlRpcValue result;
try {
bool ret;
{
guard_lock flrig_lock(&mutex_flrig);
ret = flrig_client->execute("rig.get_smeter", XmlRpcValue(), result, timeout);
}
if (ret) {
std::string smeter = (std::string)result;
int sm = atoll(smeter.c_str());
guard_lock lck(&mutex_flrig_smeter);
Fl::awake(xmlrpc_rig_set_smeter, reinterpret_cast<void*>(sm));
LOG_VERBOSE("rig.get_smeter: %d", sm);
}
} catch (...) {
LOG_ERROR("rig.get_smeter FAILED");
}
}
pthread_mutex_t mutex_flrig_pwrmeter = PTHREAD_MUTEX_INITIALIZER;
static void xmlrpc_rig_set_pwrmeter(void *data)
{
guard_lock flrig_lock(&mutex_flrig_pwrmeter);
if (!smeter && !pwrmeter) return;
if (pwrmeter && progStatus.meters) {
if (!pwrmeter->visible()) {
smeter->hide();
pwrmeter->show();
}
int val = reinterpret_cast<intptr_t>(data);
pwrmeter->value(val);
}
}
void flrig_get_pwrmeter()
{
XmlRpcValue val, result;
try {
bool ret;
{
guard_lock flrig_lock(&mutex_flrig);
ret = flrig_client->execute("rig.get_pwrmeter", val, result, timeout);
}
if (ret) {
std::string meter = (std::string)result;
int sm = atoll(meter.c_str());
guard_lock lck(&mutex_flrig_pwrmeter);
Fl::awake(xmlrpc_rig_set_pwrmeter, reinterpret_cast<void*>(sm));
}
} catch (...) {
LOG_ERROR("rig.get_pwrmeter FAILED");
}
}
//==============================================================================
// transceiver get name
//==============================================================================
static void xmlrpc_rig_show_xcvr_name(void *)
{
xcvr_title = xcvr_name;
setTitle();
}
static void no_rig_init(void *)
{
init_NoRig_RigDialog();
}
bool flrig_get_xcvr()
{
XmlRpcValue result;
try {
bool ret;
{
guard_lock flrig_lock(&mutex_flrig);
ret = flrig_client->execute("rig.get_xcvr", XmlRpcValue(), result, timeout);
}
if (ret) {
std::string nuxcvr = (std::string)result;
if (nuxcvr != xcvr_name) {
xcvr_name = nuxcvr;
modes_posted = false;
bws_posted = false;
flrig_get_modes();
flrig_get_bws();
flrig_get_mode();
flrig_get_bw();
Fl::awake(xmlrpc_rig_show_xcvr_name);
LOG_VERBOSE("flrig_get_xcvr %s", nuxcvr.c_str());
}
return true;
} else {
if (xcvr_name != "") {
xcvr_name = "";
Fl::awake(xmlrpc_rig_show_xcvr_name);
Fl::awake(no_rig_init);
}
connected_to_flrig = false;
}
} catch (XmlRpcException *err) {
if (xcvr_name != "") {
xcvr_name = "";
Fl::awake(xmlrpc_rig_show_xcvr_name);
Fl::awake(no_rig_init);
LOG_ERROR("rig.get_xcvr FAILED");
}
connected_to_flrig = false;
}
return false;
}
//======================================================================
// xmlrpc read polling thread
//======================================================================
static bool run_flrig_thread = true;
static int poll_interval = 1000; // 1 second
//----------------------------------------------------------------------
// Set QSY to true if xmlrpc client connection is OK
//----------------------------------------------------------------------
void flrig_setQSY(void *)
{
if (!wf) return;
wf->setQSY(true);
}
void flrig_connection()
{
XmlRpcValue noArgs, result;
try {
bool ret;
{
guard_lock flrig_lock(&mutex_flrig);
ret = flrig_client->execute("system.listMethods", noArgs, result, timeout);
}
if (ret) {
int nargs = result.size();
std::string method_str = "\nMethods:\n";
for (int i = 0; i < nargs; i++)
method_str.append(" ").append(result[i]).append("\n");
LOG_VERBOSE("%s", method_str.c_str());
connected_to_flrig = true;
poll_interval = progdefaults.flrig_poll;
flrig_get_xcvr();
Fl::awake(flrig_setQSY);
} else {
LOG_VERBOSE("%s", "Waiting for flrig");
connected_to_flrig = false;
poll_interval = 2000; // every 2 seconds
}
} catch (...) {
LOG_ERROR("%s", "failure in flrig_client");
}
}
void connect_to_flrig()
{
XmlRpc::setVerbosity(xmlrpc_verbosity);
if (flrig_client) {
delete flrig_client;
flrig_client = (XmlRpcClient *)0;
}
try {
flrig_client = new XmlRpcClient(
progdefaults.flrig_ip_address.c_str(),
atol(progdefaults.flrig_ip_port.c_str()));
LOG_VERBOSE("created flrig xmlrpc client %s, %ld",
progdefaults.flrig_ip_address.c_str(),
atol(progdefaults.flrig_ip_port.c_str()));
flrig_connection();
} catch (...) {
LOG_ERROR("Cannot create flrig xmlrpc client %s, %s",
progdefaults.flrig_ip_address.c_str(),
progdefaults.flrig_ip_port.c_str());
}
}
void * flrig_thread_loop(void *d)
{
int poll = poll_interval;
while (run_flrig_thread) {
MilliSleep(10);
if (connected_to_flrig) {
if (new_ptt > -1) {
exec_flrig_ptt();
continue;
}
}
if (connected_to_flrig && poll_interval != progdefaults.flrig_poll)
poll_interval = progdefaults.flrig_poll;
if ((poll -= 10) <= 0) {
poll = poll_interval;
if (progdefaults.fldigi_client_to_flrig) {
if (!flrig_client)
connect_to_flrig();
else {
if (!connected_to_flrig)
flrig_connection();
else {
if (progdefaults.flrig_keys_modem) flrig_get_ptt();
if (trx_state == STATE_RX) {
flrig_get_frequency();
flrig_get_smeter();
flrig_get_notch();
flrig_get_wpm();
if (modes_posted)
flrig_get_mode();
else
flrig_get_modes();
if (bws_posted)
flrig_get_bw();
else
flrig_get_bws();
}
else {
flrig_get_pwrmeter();
flrig_get_wpm();
}
}
}
}
}
}
return NULL;
}
void FLRIG_start_flrig_thread()
{
flrig_thread = new pthread_t;
poll_interval = 1000; // every second
if (pthread_create(flrig_thread, NULL, flrig_thread_loop, NULL)) {
LOG_ERROR("%s", "flrig_thread create");
exit(EXIT_FAILURE);
}
}
void stop_flrig_thread()
{
if (!flrig_client) return;
LOG_INFO("%s", "lock mutex_flrig");
pthread_mutex_lock(&mutex_flrig);
run_flrig_thread = false;
pthread_mutex_unlock(&mutex_flrig);
LOG_INFO("%s", "wait for joined thread");
pthread_join(*flrig_thread, NULL);
LOG_INFO("%s", "flrig thread closed");
LOG_INFO("%s", "flrig_client->close()");
flrig_client->close();
}
void reconnect_to_flrig()
{
flrig_client->close();
guard_lock flrig_lock(&mutex_flrig);
delete flrig_client;
flrig_client = (XmlRpcClient *)0;
connected_to_flrig = false;
}
unsigned long st, et;
void xmlrpc_send_command(std::string cmd)
{
if (!connected_to_flrig) return;
XmlRpcValue val, result;
try {
guard_lock flrig_lock(&mutex_flrig);
val = std::string(cmd);
flrig_client->execute("rig.cat_string", val, result, timeout);
std::string ans = std::string(result);
} catch (...) {}
return;
}
void xmlrpc_priority(std::string cmd)
{
if (!connected_to_flrig) return;
XmlRpcValue val, result;
try {
guard_lock flrig_lock(&mutex_flrig);
val = std::string(cmd);
flrig_client->execute("rig.cat_priority", val, result, 0.20);//timeout);
} catch (...) {}
return;
}
void xmlrpc_shutdown_flrig()
{
if (!connected_to_flrig) return;
XmlRpcValue val, result;
try {
guard_lock flrig_lock(&mutex_flrig);
if (!flrig_client->execute("rig.shutdown", XmlRpcValue(), result, timeout)) {
LOG_ERROR("%s", "rig.shutdown failed");
} else {
LOG_VERBOSE("%s", "rig.shutdown OK");
}
} catch (...) {}
}
void flrig_cwio_send_text(std::string s)
{
if (!connected_to_flrig) return;
XmlRpcValue val, result;
try {
guard_lock flrig_lock(&mutex_flrig);
val = std::string(s);
flrig_client->execute("rig.cwio_text", val, result, 0.20);//timeout);
} catch (...) {
}
return;
}
void flrig_fskio_send_text(std::string s)
{
if (!connected_to_flrig) return;
XmlRpcValue val, result;
try {
guard_lock flrig_lock(&mutex_flrig);
val = std::string(s);
flrig_client->execute("rig.fskio_text", val, result, 0.20);
} catch (...) {
}
return;
}
| 28,724
|
C++
|
.cxx
| 1,076
| 23.857807
| 86
| 0.604049
|
w1hkj/fldigi
| 109
| 27
| 38
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
751,040
|
hamlib.cxx
|
w1hkj_fldigi/src/rigcontrol/hamlib.cxx
|
// ----------------------------------------------------------------------------
// hamlib.cxx -- Hamlib (rig control) interface for fldigi
//
// Copyright (C) 2007-2009
// Dave Freese, W1HKJ
// Copyright (C) 2008-2009
// Stelios Bounanos, M0GLD
//
// This file is part of fldigi.
//
// Fldigi 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 3 of the License, or
// (at your option) any later version.
//
// Fldigi 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 fldigi. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include <config.h>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include "trx.h"
#include "configuration.h"
#include "confdialog.h"
#include "rigclass.h"
#include "threads.h"
#include "misc.h"
#include "fl_digi.h"
#include "main.h"
#include "misc.h"
#include "rigsupport.h"
#include "stacktrace.h"
#ifdef __WOE32__
# include "serial.h"
#endif
#include "debug.h"
#include "re.h"
LOG_FILE_SOURCE(debug::LOG_RIGCONTROL);
static pthread_mutex_t hamlib_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_t *hamlib_thread = 0;
static bool hamlib_exit = false;
static bool hamlib_ptt = false;
static bool hamlib_qsy = false;
static bool need_freq = false;
static bool need_mode = false;
static bool hamlib_bypass = false;
static bool hamlib_closed = true;//false;
static int hamlib_passes = 20;
static long int hamlib_freq;
static rmode_t hamlib_rmode = RIG_MODE_USB;
static pbwidth_t hamlib_pbwidth = 3000;
typedef std::vector<const struct rig_caps *> rig_list_t;
rig_list_t hamlib_rigs;
enum { SIDEBAND_RIG, SIDEBAND_LSB, SIDEBAND_USB };
static void *hamlib_loop(void *args);
void show_error(const char* msg1, const char* msg2 = 0)
{
std::string error = msg1;
if (msg2)
error.append(": ").append(msg2);
put_status(error.c_str(), 10.0);
LOG_ERROR("%s", error.c_str());
}
void hamlib_get_defaults()
{
char szParam[40];
int i;
Rig testrig;
rig_model_t rigmodel;
rigmodel = hamlib_get_rig_model(cboHamlibRig->index());
testrig.init(rigmodel);
testrig.getConf("timeout", szParam);
sscanf(szParam, "%d", &i);
cntHamlibTimeout->value(i);
LOG_VERBOSE("Hamlib default Timeout: %d", i);
testrig.getConf("retry", szParam);
sscanf(szParam, "%d", &i);
cntHamlibRetries->value(i);
LOG_VERBOSE("Hamlib default Retry: %d", i);
testrig.getConf("post_write_delay", szParam);
sscanf(szParam, "%d", &i);
cntHamlibWait->value(i);
LOG_VERBOSE("Hamlib default Post write delay: %d", i);
testrig.getConf("write_delay", szParam);
sscanf(szParam, "%d", &i);
cntHamlibWriteDelay->value(i);
LOG_VERBOSE("Hamlib default Write delay: %d", i);
if (testrig.getCaps()->port_type == RIG_PORT_SERIAL) {
testrig.getConf("serial_speed", szParam);
listbox_baudrate->value(szParam);
LOG_VERBOSE("Hamlib default serial speed: %s", szParam);
testrig.getConf("rts_state", szParam);
chkHamlibRTSplus->value( strcmp(szParam, "ON") == 0 ? true : false);
LOG_VERBOSE("Hamlib default RTS state: %s", szParam);
testrig.getConf("dtr_state", szParam);
btnHamlibDTRplus->value( strcmp(szParam, "ON") == 0 ? true : false);
LOG_VERBOSE("Hamlib default DTR state: %s", szParam);
testrig.getConf("serial_handshake", szParam);
chkHamlibRTSCTSflow->value(strcmp(szParam, "Hardware") == 0 ? true : false);
chkHamlibXONXOFFflow->value(strcmp(szParam, "XONXOFF") == 0 ? true : false);
LOG_VERBOSE("Hamlib default serial handshake: %s", szParam);
testrig.getConf("stop_bits", szParam);
valHamRigStopbits->value(strcmp(szParam, "1") == 0 ? 1 : 2);
LOG_VERBOSE("Hamlib default stop bits: %s", szParam);
}
if (!testrig.canSetPTT()) {
btnHamlibCMDptt->value(0);
btnHamlibCMDptt->deactivate();
} else {
btnHamlibCMDptt->value(1);
btnHamlibCMDptt->activate();
}
inpHamlibConfig->value("");
testrig.close();
}
void hamlib_init_defaults()
{
progdefaults.HamRigModel = hamlib_get_rig_model(cboHamlibRig->index());
progdefaults.HamRigDevice = inpRIGdev->value();
progdefaults.HamlibRetries = static_cast<int>(cntHamlibRetries->value());
progdefaults.HamlibTimeout = static_cast<int>(cntHamlibTimeout->value());
progdefaults.HamlibWriteDelay = static_cast<int>(cntHamlibWriteDelay->value());
progdefaults.HamlibWait = static_cast<int>(cntHamlibWait->value());
progdefaults.HamlibCMDptt = btnHamlibCMDptt->value();
progdefaults.HamlibDTRplus = btnHamlibDTRplus->value();
progdefaults.HamlibRTSCTSflow = chkHamlibRTSCTSflow->value();
progdefaults.HamlibRTSplus = chkHamlibRTSplus->value();
progdefaults.HamlibXONXOFFflow = chkHamlibXONXOFFflow->value();
progdefaults.HamlibSideband = listbox_sideband->index();
progdefaults.HamRigStopbits = static_cast<int>(valHamRigStopbits->value());
progdefaults.HamRigBaudrate = listbox_baudrate->index();
progdefaults.HamlibCMDptt = btnHamlibCMDptt->value();
progdefaults.HamConfig = inpHamlibConfig->value();
}
bool hamlib_init(bool bPtt)
{
freq_t freq;
hamlib_ptt = bPtt;
hamlib_init_defaults();
#ifdef __CYGWIN__
std::string port = progdefaults.HamRigDevice;
com_to_tty(port);
#endif
if (progdefaults.HamRigModel == 0) {
LOG_ERROR("No such hamlib rig model");
return false;
}
try {
char szParam[20];
xcvr->init(progdefaults.HamRigModel);
#ifdef __CYGWIN__
xcvr->setConf("rig_pathname", port.c_str());
#else
xcvr->setConf("rig_pathname", progdefaults.HamRigDevice.c_str());
#endif
snprintf(szParam, sizeof(szParam), "%d", progdefaults.HamlibWait);
xcvr->setConf("post_write_delay", szParam);
snprintf(szParam, sizeof(szParam), "%d", progdefaults.HamlibWriteDelay);
xcvr->setConf("write_delay", szParam);
snprintf(szParam, sizeof(szParam), "%d", progdefaults.HamlibTimeout);
xcvr->setConf("timeout", szParam);
snprintf(szParam, sizeof(szParam), "%d", progdefaults.HamlibRetries);
xcvr->setConf("retry", szParam);
if (xcvr->getCaps()->port_type == RIG_PORT_SERIAL) {
xcvr->setConf("serial_speed", progdefaults.strBaudRate());
if (progdefaults.HamlibDTRplus)
xcvr->setConf("dtr_state", "ON");
else
xcvr->setConf("dtr_state", "OFF");
if (progdefaults.HamlibRTSCTSflow) {
xcvr->setConf("serial_handshake", "Hardware");
} else if (progdefaults.HamlibXONXOFFflow) {
xcvr->setConf("serial_handshake", "XONXOFF");
} else {
xcvr->setConf("serial_handshake", "None");
}
if (!progdefaults.HamlibRTSCTSflow) {
if (progdefaults.HamlibRTSplus)
xcvr->setConf("rts_state", "ON");
else
xcvr->setConf("rts_state", "OFF");
}
xcvr->setConf("stop_bits", progdefaults.HamRigStopbits == 1 ? "1" : "2");
}
std::string::size_type c = progdefaults.HamConfig.find('#');
if (c != std::string::npos)
progdefaults.HamConfig.erase(c);
if (!progdefaults.HamConfig.empty()) {
re_t re("([^, =]+) *= *([^, =]+)", REG_EXTENDED);
const char* conf = progdefaults.HamConfig.c_str();
int end;
while (re.match(conf)) {
xcvr->setConf(re.submatch(1).c_str(), re.submatch(2).c_str());
re.suboff(0, NULL, &end);
conf += end;
}
}
xcvr->open();
}
catch (const RigException& Ex) {
show_error(__func__, Ex.what());
xcvr->close();
return false;
}
try {
if ( !xcvr->canGetFreq() ) need_freq = false; // getFreq will return setFreq value
else {
need_freq = true;
freq = xcvr->getFreq(RIG_VFO_A);
if ((long)freq < 0) { //<= 0) {
xcvr->close(true);
LOG_ERROR("%s","Hamlib xcvr not responding");
return false;
}
}
}
catch (const RigException& Ex) {
show_error("Get Freq", Ex.what());
need_freq = false;
}
if (!need_freq) {
xcvr->close(true);
LOG_INFO("Failed freq test");
return false;
}
LOG_INFO("trying mode request");
try {
need_mode = xcvr->canGetMode();
}
catch (const RigException& Ex) {
LOG_ERROR("Get Mode %s", Ex.what());
need_mode = false;
}
try {
if (hamlib_ptt == true) {
LOG_INFO("trying PTT");
if (!xcvr->canSetPTT())
hamlib_ptt = false;
else
xcvr->setPTT(RIG_PTT_OFF);
}
}
catch (const RigException& Ex) {
LOG_ERROR("Set Ptt %s", Ex.what());
hamlib_ptt = false;
}
hamlib_freq = 0;
hamlib_rmode = RIG_MODE_NONE;
hamlib_exit = false;
hamlib_bypass = false;
hamlib_thread = new pthread_t;
if (pthread_create(hamlib_thread, NULL, hamlib_loop, NULL) < 0) {
show_error(__func__, "pthread_create failed");
xcvr->close();
hamlib_thread = 0;
return false;
}
init_Hamlib_RigDialog();
hamlib_closed = false;
return true;
}
void hamlib_close(void)
{
ENSURE_THREAD(FLMAIN_TID);
if (hamlib_closed)
return;
pthread_mutex_lock(&hamlib_mutex);
hamlib_exit = true;
pthread_mutex_unlock(&hamlib_mutex);
pthread_join(*hamlib_thread, NULL);
delete hamlib_thread;
hamlib_thread = 0;
if (xcvr->isOnLine()) xcvr->close();
wf->USB(true);
}
bool hamlib_active(void)
{
if (!xcvr) return false;
return (xcvr->isOnLine());
}
void hamlib_set_ptt(int ptt)
{
if (xcvr->isOnLine() == false)
return;
if (!hamlib_ptt)
return;
guard_lock hamlib(&hamlib_mutex);
try {
xcvr->setPTT( ptt ?
(progdefaults.hamlib_ptt_on_data ? RIG_PTT_ON_DATA : RIG_PTT_ON_MIC) :
RIG_PTT_OFF );
hamlib_bypass = ptt ? true : false;
}
catch (const RigException& Ex) {
show_error("Rig PTT", Ex.what());
hamlib_ptt = false;
}
}
void hamlib_set_qsy(long long f)
{
if (xcvr->isOnLine() == false)
return;
guard_lock hamlib(&hamlib_mutex);
double fdbl = f;
hamlib_qsy = false;
try {
xcvr->setFreq(fdbl);
wf->rfcarrier(f);
wf->movetocenter();
}
catch (const RigException& Ex) {
show_error("QSY", Ex.what());
hamlib_passes = 0;
}
}
int hamlib_setfreq(long f)
{
if (xcvr->isOnLine() == false)
return -1;
guard_lock hamlib(&hamlib_mutex);
try {
LOG_DEBUG("%ld", f);
xcvr->setFreq(f);
}
catch (const RigException& Ex) {
show_error("SetFreq", Ex.what());
hamlib_passes = 0;
}
return 1;
}
static int hamlib_wait = 0;
int hamlib_setmode(rmode_t m)
{
if (need_mode == false)
return -1;
if (xcvr->isOnLine() == false)
return -1;
guard_lock hamlib(&hamlib_mutex);
try {
hamlib_rmode = xcvr->getMode(hamlib_pbwidth);
xcvr->setMode(m, hamlib_pbwidth);
hamlib_rmode = m;
}
catch (const RigException& Ex) {
show_error("Set Mode", Ex.what());
hamlib_passes = 0;
}
hamlib_wait = progdefaults.hamlib_mode_delay / 50;
return 1;
}
// width control via hamlib is not implemented
int hamlib_setwidth(pbwidth_t w)
{
if (xcvr->isOnLine() == false)
return -1;
guard_lock hamlib(&hamlib_mutex);
try {
hamlib_rmode = xcvr->getMode(hamlib_pbwidth);
xcvr->setMode(hamlib_rmode, w);
hamlib_pbwidth = w;
}
catch (const RigException& Ex) {
show_error("Set Width", Ex.what());
hamlib_passes = 0;
}
return 1;
}
rmode_t hamlib_getmode()
{
return hamlib_rmode;
}
pbwidth_t hamlib_getwidth()
{
return hamlib_pbwidth;
}
bool hamlib_USB()
{
if (hamlib_wait) return wf->USB();
bool islsb = false;
if (progdefaults.HamlibSideband == SIDEBAND_RIG) {
islsb = (hamlib_rmode == RIG_MODE_LSB ||
hamlib_rmode == RIG_MODE_PKTLSB ||
hamlib_rmode == RIG_MODE_ECSSLSB);
if (hamlib_rmode == RIG_MODE_CW) {
if (progdefaults.hamlib_cw_islsb) islsb = true;
else islsb = false;
}
if (hamlib_rmode == RIG_MODE_CWR) {
if (progdefaults.hamlib_cw_islsb) islsb = false;
else islsb = true;
}
if (hamlib_rmode == RIG_MODE_RTTY) {
if (progdefaults.hamlib_rtty_isusb) islsb = false;
else islsb = true;
}
if (hamlib_rmode == RIG_MODE_RTTYR) {
if (progdefaults.hamlib_rtty_isusb) islsb = true;
else islsb = false;
}
} else if (progdefaults.HamlibSideband == SIDEBAND_LSB)
islsb = true;
return !islsb;
}
static void *hamlib_loop(void *args)
{
SET_THREAD_ID(RIGCTL_TID);
long int freq = 0L;
rmode_t numode = RIG_MODE_NONE;
int skips = 0;
for (;;) {
bool cont = false;
MilliSleep(50);
if (skips) {
skips--;
cont = true;
} if (hamlib_wait) {
hamlib_wait--;
cont = true;
}
if (cont)
continue;
else {
skips = valHamRigPollrate->value() / 50;
}
if (hamlib_exit)
break;
if (hamlib_bypass)
continue;
{
guard_lock hamlib(&hamlib_mutex);
if (need_freq) {
freq_t f;
try {
f = xcvr->getFreq();
freq = (long int) f;
if (freq == 0) continue;
hamlib_freq = freq;
show_frequency(hamlib_freq);
wf->rfcarrier(hamlib_freq);
}
catch (const RigException& Ex) {
show_error(__func__, "Rig not responding: freq");
}
}
}
if (hamlib_exit)
break;
if (hamlib_bypass)
continue;
{
guard_lock hamlib(&hamlib_mutex);
if (need_mode) {
try {
numode = xcvr->getMode(hamlib_pbwidth);
if (numode != hamlib_rmode) {
hamlib_rmode = numode;
show_mode(modeString(hamlib_rmode));
wf->USB(hamlib_USB());
}
}
catch (const RigException& Ex) {
show_error(__func__, "Rig not responding: mode");
}
}
}
if (hamlib_exit)
break;
if (hamlib_bypass)
continue;
}
hamlib_closed = true;
return NULL;
}
static int add_to_list(const struct rig_caps* rc, void*)
{
hamlib_rigs.push_back(rc);
return 1;
}
static bool rig_cmp(const struct rig_caps* rig1, const struct rig_caps* rig2)
{
int ret;
ret = strcasecmp(rig1->mfg_name, rig2->mfg_name);
if (ret > 0) return false;
if (ret < 0) return true;
ret = strcasecmp(rig1->model_name, rig2->model_name);
if (ret > 0) return false;
if (ret < 0) return true;
if (rig1->rig_model < rig2->rig_model)
return true;
return false;
}
void hamlib_get_rigs(void)
{
if (!hamlib_rigs.empty())
return;
enum rig_debug_level_e dblv = RIG_DEBUG_NONE;
#ifndef NDEBUG
const char* hd = getenv("FLDIGI_HAMLIB_DEBUG");
if (hd) {
dblv = static_cast<enum rig_debug_level_e>(strtol(hd, NULL, 10));
dblv = CLAMP(dblv, RIG_DEBUG_NONE, RIG_DEBUG_TRACE);
}
#endif
rig_set_debug(dblv);
rig_load_all_backends();
rig_list_foreach(add_to_list, 0);
sort(hamlib_rigs.begin(), hamlib_rigs.end(), rig_cmp);
}
rig_model_t hamlib_get_rig_model_compat(const char* name)
{
for (rig_list_t::const_iterator i = hamlib_rigs.begin(); i != hamlib_rigs.end(); ++i)
if (strstr(name, (*i)->mfg_name) && strstr(name, (*i)->model_name))
return (*i)->rig_model;
return 0;
}
size_t hamlib_get_index(rig_model_t model)
{
for (rig_list_t::const_iterator i = hamlib_rigs.begin(); i != hamlib_rigs.end(); ++i)
if ((*i)->rig_model == model)
return i - hamlib_rigs.begin();
return hamlib_rigs.size();
}
rig_model_t hamlib_get_rig_model(size_t i)
{
try {
return hamlib_rigs.at(i)->rig_model;
}
catch (...) {
return 0;
}
}
void hamlib_get_rig_str(int (*func)(const char*))
{
std::string rigstr;
for (rig_list_t::const_iterator i = hamlib_rigs.begin(); i != hamlib_rigs.end(); ++i) {
rigstr.clear();
rigstr.append((*i)->mfg_name).append(" ").append((*i)->model_name);
rigstr.append(" (").append(rig_strstatus((*i)->status)).append(")");
if (!(*func)(rigstr.c_str()))
break;
}
}
| 15,396
|
C++
|
.cxx
| 549
| 25.264117
| 88
| 0.677966
|
w1hkj/fldigi
| 109
| 27
| 38
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
751,041
|
serial.cxx
|
w1hkj_fldigi/src/rigcontrol/serial.cxx
|
// ----------------------------------------------------------------------------
// serial.cxx - Serial I/O class
//
// Copyright (C) 2007-2010
// Dave Freese, W1HKJ
//
// This file is part of fldigi.
//
// Fldigi 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 3 of the License, or
// (at your option) any later version.
//
// Fldigi 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 fldigi. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include <FL/fl_utf8.h>
#include <config.h>
#include <string>
#include "serial.h"
#include "debug.h"
LOG_FILE_SOURCE(debug::LOG_RIGCONTROL);
#ifndef __MINGW32__
#include <cstdio>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <memory>
Cserial::Cserial() {
device = "/dev/ttyS0";
baud = 1200;
timeout = 50; //msec
retries = 5;
rts = dtr = false;
rtsptt = dtrptt = false;
rtscts = false;
status = 0;
stopbits = 2;
fd = -1;
restore_tio = true;
}
Cserial::~Cserial() {
ClosePort();
}
///////////////////////////////////////////////////////
// Function name : Cserial::OpenPort
// Description : Opens the port specified by strPortName
// Return type : BOOL
// Argument : c_string strPortName
///////////////////////////////////////////////////////
bool Cserial::OpenPort() {
#ifdef __CYGWIN__
com_to_tty(device);
#endif
int oflags = O_RDWR | O_NOCTTY | O_NDELAY;
# ifdef HAVE_O_CLOEXEC
oflags = oflags | O_CLOEXEC;
# endif
if ((fd = fl_open( device.c_str(), oflags)) < 0)
return false;
// the status port must be set before any other control attributes are
// changed. Failure to do so will cause DTR/RTS h/w transients !!
ioctl(fd, TIOCMGET, &status);
origstatus = status;
if (dtr)
status |= TIOCM_DTR; // set the DTR bit
else
status &= ~TIOCM_DTR; // clear the DTR bit
if (rtscts == false) { // rts OK for ptt if RTSCTS not used
if (rts)
status |= TIOCM_RTS; // set the RTS bit
else
status &= ~TIOCM_RTS; // clear the RTS bit
}
ioctl(fd, TIOCMSET, &status);
// save current port settings
tcflush (fd, TCIFLUSH);
tcgetattr (fd, &oldtio);
// newtio = oldtio;
// 8 data bits
newtio.c_cflag &= ~CSIZE;
newtio.c_cflag |= CS8;
// enable receiver, set local mode
newtio.c_cflag |= (CLOCAL | CREAD);
// no parity
newtio.c_cflag &= ~PARENB;
if (stopbits == 1)
// 1 stop bit
newtio.c_cflag &= ~CSTOPB;
else
// 2 stop bit
newtio.c_cflag |= CSTOPB;
if (rtscts)
// h/w handshake
newtio.c_cflag |= CRTSCTS;
else
// no h/w handshake
newtio.c_cflag &= ~CRTSCTS;
// raw input
newtio.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
// raw output
newtio.c_oflag &= ~OPOST;
// software flow control disabled
newtio.c_iflag &= ~IXON;
// do not translate CR to NL
newtio.c_iflag &= ~ICRNL;
switch(baud) {
case 50:
speed = B50;
break;
case 300:
speed = B300;
break;
case 1200:
speed = B1200;
break;
case 2400:
speed = B2400;
break;
case 4800:
speed = B4800;
break;
case 9600:
speed = B9600;
break;
case 19200:
speed = B19200;
break;
case 38400:
speed = B38400;
break;
case 57600:
speed = B57600;
break;
case 115200:
speed = B115200;
break;
default:
speed = B1200;
}
cfsetispeed(&newtio, speed);
cfsetospeed(&newtio, speed);
tcsetattr (fd, TCSANOW, &newtio);
return true;
}
void Cserial::SetDTR(bool b)
{
ioctl(fd, TIOCMGET, &status);
origstatus = status;
if (b)
status |= TIOCM_DTR; // set the DTR bit
else
status &= ~TIOCM_DTR; // clear the DTR bit
ioctl(fd, TIOCMSET, &status);
}
void Cserial::SetRTS(bool b)
{
ioctl(fd, TIOCMGET, &status);
origstatus = status;
if (b)
status |= TIOCM_RTS; // set the RTS bit
else
status &= ~TIOCM_RTS; // clear the RTS bit
ioctl(fd, TIOCMSET, &status);
}
///////////////////////////////////////////////////////
// Function name : Cserial::setPTT
// Return type : void
///////////////////////////////////////////////////////
void Cserial::SetPTT(bool b)
{
if (fd < 0) {
LOG_DEBUG("PTT fd < 0");
return;
}
if (dtrptt || rtsptt) {
ioctl(fd, TIOCMGET, &status);
LOG_DEBUG("H/W PTT %d, status %X", b, status);
if (b == true) { // ptt enabled
if (dtrptt && dtr) status &= ~TIOCM_DTR; // toggle low
if (dtrptt && !dtr) status |= TIOCM_DTR; // toggle high
if (rtscts == false) {
if (rtsptt && rts) status &= ~TIOCM_RTS; // toggle low
if (rtsptt && !rts) status |= TIOCM_RTS; // toggle high
}
} else { // ptt disabled
if (dtrptt && dtr) status |= TIOCM_DTR; // toggle high
if (dtrptt && !dtr) status &= ~TIOCM_DTR; // toggle low
if (rtscts == false) {
if (rtsptt && rts) status |= TIOCM_RTS; // toggle high
if (rtsptt && !rts) status &= ~TIOCM_RTS; // toggle low
}
}
LOG_DEBUG("Status %02X, %s", status & 0xFF, uint2bin(status, 8));
ioctl(fd, TIOCMSET, &status);
}
LOG_DEBUG("No PTT specified");
}
///////////////////////////////////////////////////////
// Function name : Cserial::ClosePort
// Description : Closes the Port
// Return type : void
///////////////////////////////////////////////////////
void Cserial::ClosePort()
{
if (fd < 0) return;
if (restore_tio) {
// Some serial drivers force RTS and DTR high immediately upon
// opening the port, so our origstatus will indicate those bits
// high (though the lines weren't actually high before we opened).
// But then when we "restore" RTS and DTR from origstatus here
// it can result in PTT activation upon program exit! To avoid
// this possibility, we ignore the apparentl initial settings, and
// instead force RTS and DTR low before closing the port. (Just
// omitting the ioctl(TIOCMSET) would also resolve the problem).
// Kamal Mostafa <kamal@whence.com>
origstatus &= ~(TIOCM_RTS|TIOCM_DTR);
ioctl(fd, TIOCMSET, &origstatus);
tcsetattr (fd, TCSANOW, &oldtio);
}
close(fd);
fd = -1;
LOG_INFO("Serial port closed, fd = %d", fd);
return;
}
bool Cserial::IOselect ()
{
fd_set rfds;
struct timeval tv;
int retval;
FD_ZERO (&rfds);
FD_SET (fd, &rfds);
tv.tv_sec = timeout/1000;
tv.tv_usec = (timeout % 1000) * 1000;
retval = select (FD_SETSIZE, &rfds, (fd_set *)0, (fd_set *)0, &tv);
if (retval <= 0) // no response from serial port or error returned
return false;
return true;
}
///////////////////////////////////////////////////////
// Function name : Cserial::ReadByte
// Description : Reads 1 char from the selected port
// Return type : 1 - success, 0 - failure
// Argument : reference to character
///////////////////////////////////////////////////////
bool Cserial::ReadByte(unsigned char &c)
{
static char ch[2];
c = ch[0] = ch[1] = 0;
if (fd < 0) return 0;
if (!IOselect())
return 0;
if (read (fd, (void *)ch, 1) < 0)
return 0;
c = ch[0];
return 1;
}
///////////////////////////////////////////////////////
// Function name : Cserial::ReadBuffer
// Description : Reads upto nchars from the selected port
// Return type : # characters received
// Argument : pointer to buffer; # chars to read
///////////////////////////////////////////////////////
int Cserial::ReadBuffer (unsigned char *buf, int nchars)
{
if (fd < 0) return 0;
int retnum, nread = 0;
while (nchars > 0) {
if (!IOselect()) {
return nread;
}
retnum = read (fd, (char *)(buf + nread), nchars);
if (retnum < 0)
return 0;//nread;
if (retnum == 0)
return nread;
nread += retnum;
nchars -= retnum;
}
return nread;
}
///////////////////////////////////////////////////////
// Function name : Cserial::WriteBuffer
// Description : Writes a string to the selected port
// Return type : BOOL
// Argument : BYTE by
///////////////////////////////////////////////////////
int Cserial::WriteBuffer(unsigned char *buff, int n)
{
if (fd < 0) return 0;
int ret = write (fd, buff, n);
return ret;
}
///////////////////////////////////////////////////////
// Function name : Cserial::FlushBuffer
// Description : flushes the pending rx chars
// Return type : void
///////////////////////////////////////////////////////
void Cserial::FlushBuffer()
{
if (fd < 0)
return;
tcflush (fd, TCIFLUSH);
}
#else // __MINGW32__
//======================================================================
// Win32 support code
//======================================================================
#include <winbase.h>
#include "estrings.h"
#define HCOMM_DEBUG 1
///////////////////////////////////////////////////////
// Function name : Cserial::OpenPort
// Description : Opens the port specified by strPortName
// Return type : BOOL
// Argument : CString strPortName
///////////////////////////////////////////////////////
BOOL Cserial::OpenPort()
{
std::string COMportname = "//./";
tty_to_com(device);
COMportname += device;
hComm = CreateFile(COMportname.c_str(),
GENERIC_READ | GENERIC_WRITE,
0,
0,
OPEN_EXISTING,
0,
0);
if(hComm == INVALID_HANDLE_VALUE) {
errno = GetLastError();
LOG_PERROR(win_error_string(errno).c_str());
return FALSE;
}
if (!ConfigurePort( baud, 8, FALSE, NOPARITY, stopbits)) {
errno = GetLastError();
CloseHandle(hComm);
hComm = INVALID_HANDLE_VALUE;
LOG_PERROR(win_error_string(errno).c_str());
return FALSE;
}
LOG_INFO("COM port %s opened, handle = %p", device.c_str(), hComm);
FlushBuffer();
return TRUE;
}
///////////////////////////////////////////////////////
// Function name : Cserial::ClosePort
// Description : Closes the Port
// Return type : void
///////////////////////////////////////////////////////
void Cserial::ClosePort()
{
if (hComm == INVALID_HANDLE_VALUE)
return;
if (HCOMM_DEBUG)
LOG_INFO("Closing COM port, handle = %p", hComm);
if (restore_tio) {
if (HCOMM_DEBUG)
LOG_INFO("Closing COM port#1, handle = %p", hComm);
bPortReady = SetCommTimeouts (hComm, &CommTimeoutsSaved);
}
if (CloseHandle(hComm) == 0) {
if (HCOMM_DEBUG)
LOG_INFO("Closing COM port#2, handle = %p", hComm);
errno = GetLastError();
if (HCOMM_DEBUG)
LOG_INFO("Closing COM port#3, handle = %p", hComm);
LOG_PERROR(win_error_string(errno).c_str());
if (HCOMM_DEBUG)
LOG_INFO("Closing COM port#4, handle = %p", hComm);
}
if (HCOMM_DEBUG)
LOG_INFO("Closing COM port#5, handle = %p", hComm);
hComm = INVALID_HANDLE_VALUE;
return;
}
int Cserial::ReadData (unsigned char *buf, int nchars)
{
if (hComm == INVALID_HANDLE_VALUE)
return 0;
DWORD dwRead = 0;
if (ReadFile(hComm, buf, nchars, &dwRead, NULL))
return static_cast<int>(dwRead);
if (dwRead == 0) return 0;
errno = GetLastError();
LOG_PERROR(win_error_string(errno).c_str());
return 0;
}
BOOL Cserial::ReadByte(unsigned char & by)
{
static BYTE byResByte[2];
if (ReadData(byResByte, 1) == 1) {
by = byResByte[0];
return true;
}
return false;
}
void Cserial::FlushBuffer()
{
unsigned char c;
while (ReadByte(c) == true);
}
///////////////////////////////////////////////////////
// Function name : Cserial::WriteByte
// Description : Writes a Byte to teh selected port
// Return type : BOOL
// Argument : BYTE by
///////////////////////////////////////////////////////
BOOL Cserial::WriteByte(UCHAR by)
{
if (hComm == INVALID_HANDLE_VALUE)
return FALSE;
nBytesWritten = 0;
if (WriteFile(hComm,&by,1,&nBytesWritten,NULL)==0) {
errno = GetLastError();
LOG_PERROR(win_error_string(errno).c_str());
return FALSE;
}
return TRUE;
}
///////////////////////////////////////////////////////
// Function name : Cserial::WriteBuffer
// Description : Writes a string to the selected port
// Return type : BOOL
// Argument : BYTE by
///////////////////////////////////////////////////////
int Cserial::WriteBuffer(unsigned char *buff, int n)
{
if (hComm == INVALID_HANDLE_VALUE)
return 0;
if (WriteFile (hComm, buff, n, &nBytesWritten, NULL) == 0) {
errno = GetLastError();
LOG_PERROR(win_error_string(errno).c_str());
return 0;
}
return nBytesWritten;
}
///////////////////////////////////////////////////////
// Function name : Cserial::SetCommunicationTimeouts
// Description : Sets the timeout for the selected port
// Return type : BOOL
// Argument : DWORD ReadIntervalTimeout
// Argument : DWORD ReadTotalTimeoutMultiplier
// Argument : DWORD ReadTotalTimeoutConstant
// Argument : DWORD WriteTotalTimeoutMultiplier
// Argument : DWORD WriteTotalTimeoutConstant
///////////////////////////////////////////////////////
BOOL Cserial::SetCommunicationTimeouts(
DWORD ReadIntervalTimeout, // msec
DWORD ReadTotalTimeoutMultiplier,
DWORD ReadTotalTimeoutConstant,
DWORD WriteTotalTimeoutMultiplier,
DWORD WriteTotalTimeoutConstant
)
{
CommTimeouts.ReadIntervalTimeout = ReadIntervalTimeout;
CommTimeouts.ReadTotalTimeoutMultiplier = ReadTotalTimeoutMultiplier;
CommTimeouts.ReadTotalTimeoutConstant = ReadTotalTimeoutConstant;
CommTimeouts.WriteTotalTimeoutConstant = WriteTotalTimeoutConstant;
CommTimeouts.WriteTotalTimeoutMultiplier = WriteTotalTimeoutMultiplier;
LOG_DEBUG("\n\
Read Interval Timeout............... %8ld %8ld\n\
Read Total Timeout Multiplier....... %8ld %8ld\n\
Read Total Timeout Constant Timeout. %8ld %8ld\n\
Write Total Timeout Constant........ %8ld %8ld\n\
Write Total Timeout Multiplier...... %8ld %8ld",
CommTimeoutsSaved.ReadIntervalTimeout,
CommTimeouts.ReadIntervalTimeout,
CommTimeoutsSaved.ReadTotalTimeoutMultiplier,
CommTimeouts.ReadTotalTimeoutMultiplier,
CommTimeoutsSaved.ReadTotalTimeoutConstant,
CommTimeouts.ReadTotalTimeoutConstant,
CommTimeoutsSaved.WriteTotalTimeoutConstant,
CommTimeouts.WriteTotalTimeoutConstant,
CommTimeoutsSaved.WriteTotalTimeoutMultiplier,
CommTimeouts.WriteTotalTimeoutMultiplier);
bPortReady = SetCommTimeouts (hComm, &CommTimeouts);
if(bPortReady ==0) {
LOG_PERROR(win_error_string(GetLastError()).c_str());
CloseHandle(hComm);
hComm = INVALID_HANDLE_VALUE;
return FALSE;
}
return TRUE;
}
/*
* ReadIntervalTimeout
*
* The maximum time allowed to elapse between the arrival of two bytes on the
* communications line, in milliseconds. During a ReadFile operation, the time
* period begins when the first byte is received. If the interval between the
* arrival of any two bytes exceeds this amount, the ReadFile operation is
* completed and any buffered data is returned. A value of zero indicates that
* interval time-outs are not used.
*
* A value of MAXDWORD, combined with zero values for both the
* ReadTotalTimeoutConstant and ReadTotalTimeoutMultiplier members, specifies
* that the read operation is to return immediately with the bytes that have
* already been received, even if no bytes have been received.
*
* ReadTotalTimeoutMultiplier
*
* The multiplier used to calculate the total time-out period for read
* operations, in milliseconds. For each read operation, this value is
* multiplied by the requested number of bytes to be read.
*
* ReadTotalTimeoutConstant
*
* A constant used to calculate the total time-out period for read operations,
* in milliseconds. For each read operation, this value is added to the product
* of the ReadTotalTimeoutMultiplier member and the requested number of bytes.
*
* A value of zero for both the ReadTotalTimeoutMultiplier and
* ReadTotalTimeoutConstant members indicates that total time-outs are not
* used for read operations.
*
* WriteTotalTimeoutMultiplier
*
* The multiplier used to calculate the total time-out period for write
* operations, in milliseconds. For each write operation, this value is
* multiplied by the number of bytes to be written.
*
* WriteTotalTimeoutConstant
*
* A constant used to calculate the total time-out period for write operations,
* in milliseconds. For each write operation, this value is added to the product
* of the WriteTotalTimeoutMultiplier member and the number of bytes to be
* written.
*
* A value of zero for both the WriteTotalTimeoutMultiplier and
* WriteTotalTimeoutConstant members indicates that total time-outs are not
* used for write operations.
*
* Remarks
*
* If an application sets ReadIntervalTimeout and ReadTotalTimeoutMultiplier to
* MAXDWORD and sets ReadTotalTimeoutConstant to a value greater than zero and
* less than MAXDWORD, one of the following occurs when the ReadFile function
* is called:
*
* If there are any bytes in the input buffer, ReadFile returns immediately
* with the bytes in the buffer.
*
* If there are no bytes in the input buffer, ReadFile waits until a byte
* arrives and then returns immediately.
*
* If no bytes arrive within the time specified by ReadTotalTimeoutConstant,
* ReadFile times out.
*/
BOOL Cserial::SetCommTimeout() {
return SetCommunicationTimeouts (
MAXDWORD, // Read Interval Timeout
MAXDWORD, // Read Total Timeout Multiplier
10, // Read Total Timeout Constant
50, // Write Total Timeout Constant
5 // Write Total Timeout Multiplier
);
}
///////////////////////////////////////////////////////
// Function name : ConfigurePort
// Description : Configures the Port
// Return type : BOOL
// Argument : DWORD BaudRate
// Argument : BYTE ByteSize
// Argument : DWORD fParity
// Argument : BYTE Parity
// Argument : BYTE StopBits
///////////////////////////////////////////////////////
BOOL Cserial::ConfigurePort(DWORD BaudRate,
BYTE ByteSize,
DWORD dwParity,
BYTE Parity,
BYTE StopBits)
{
if((bPortReady = GetCommState(hComm, &dcb))==0) {
errno = GetLastError();
LOG_PERROR(win_error_string(errno).c_str());
CloseHandle(hComm);
hComm = INVALID_HANDLE_VALUE;
return FALSE;
}
LOG_INFO("\n\
Get Comm State:\n\
DCB.DCBlength %d\n\
DCB.Baudrate %d\n\
DCB.ByteSize %d\n\
DCB.Parity %d\n\
DCB.StopBits %d\n\
DCB.Binary %d\n\
DCB.fDtrControl %d\n\
DCB.fRtsControl %d\n\
DCB.fDsrSensitivity %d\n\
DCB.fParity %d\n\
DCB.fOutX %d\n\
DCB.fInX %d\n\
DCB.fNull %d\n\
DCB.XonChar %d\n\
DCB.XoffChar %d\n\
DCB.fAbortOnError %d\n\
DCB.fOutxCtsFlow %d\n\
DCB.fOutxDsrFlow %d\n",
(int)dcb.DCBlength,
(int)dcb.BaudRate,
(int)dcb.ByteSize,
(int)dcb.Parity,
(int)dcb.StopBits,
(int)dcb.fBinary,
(int)dcb.fDtrControl,
(int)dcb.fRtsControl,
(int)dcb.fDsrSensitivity,
(int)dcb.fParity,
(int)dcb.fOutX,
(int)dcb.fInX,
(int)dcb.fNull,
(int)dcb.XonChar,
(int)dcb.XoffChar,
(int)dcb.fAbortOnError,
(int)dcb.fOutxCtsFlow,
(int)dcb.fOutxDsrFlow);
dcb.BaudRate = BaudRate;
dcb.ByteSize = ByteSize;
dcb.Parity = Parity;
dcb.StopBits = (StopBits == 1) ? 0 : 2;
// dcb.fBinary = TRUE;
// dcb.fDsrSensitivity = FALSE;
// dcb.fParity = dwParity;
// dcb.fOutX = FALSE;
// dcb.fInX = FALSE;
// dcb.fNull = FALSE;
// dcb.fAbortOnError = TRUE;
// dcb.fOutxCtsFlow = FALSE;
// dcb.fOutxDsrFlow = FALSE;
if (dtr)
dcb.fDtrControl = DTR_CONTROL_ENABLE;
else
dcb.fDtrControl = DTR_CONTROL_DISABLE;
dcb.fDsrSensitivity = FALSE;
if (rtscts)
dcb.fRtsControl = RTS_CONTROL_ENABLE;
else {
if (rts)
dcb.fRtsControl = RTS_CONTROL_ENABLE;
else
dcb.fRtsControl = RTS_CONTROL_DISABLE;
}
LOG_INFO("\n\
Set Comm State:\n\
DCB.DCBlength %d\n\
DCB.Baudrate %d\n\
DCB.ByteSize %d\n\
DCB.Parity %d\n\
DCB.StopBits %d\n\
DCB.Binary %d\n\
DCB.fDtrControl %d\n\
DCB.fRtsControl %d\n\
DCB.fDsrSensitivity %d\n\
DCB.fParity %d\n\
DCB.fOutX %d\n\
DCB.fInX %d\n\
DCB.fNull %d\n\
DCB.XonChar %d\n\
DCB.XoffChar %d\n\
DCB.fAbortOnError %d\n\
DCB.fOutxCtsFlow %d\n\
DCB.fOutxDsrFlow %d\n",
(int)dcb.DCBlength,
(int)dcb.BaudRate,
(int)dcb.ByteSize,
(int)dcb.Parity,
(int)dcb.StopBits,
(int)dcb.fBinary,
(int)dcb.fDtrControl,
(int)dcb.fRtsControl,
(int)dcb.fDsrSensitivity,
(int)dcb.fParity,
(int)dcb.fOutX,
(int)dcb.fInX,
(int)dcb.fNull,
(int)dcb.XonChar,
(int)dcb.XoffChar,
(int)dcb.fAbortOnError,
(int)dcb.fOutxCtsFlow,
(int)dcb.fOutxDsrFlow);
bPortReady = SetCommState(hComm, &dcb);
if(bPortReady == 0) {
errno = GetLastError();
LOG_PERROR(win_error_string(errno).c_str());
CloseHandle(hComm);
hComm = INVALID_HANDLE_VALUE;
return FALSE;
}
if ( (bPortReady = GetCommTimeouts (hComm, &CommTimeoutsSaved) ) == 0)
return FALSE;
return SetCommTimeout();
}
///////////////////////////////////////////////////////
// Function name : Cserial::setPTT
// Return type : void
///////////////////////////////////////////////////////
void Cserial::SetPTT(bool b)
{
if ( !(dtrptt || rtsptt) )
return;
if(hComm == INVALID_HANDLE_VALUE) {
LOG_PERROR("Invalid handle");
return;
}
LOG_DEBUG("PTT = %d, DTRptt = %d, DTR = %d, RTSptt = %d, RTS = %d",
b, dtrptt, dtr, rtsptt, rts);
if (b == true) { // ptt enabled
if (dtrptt && dtr)
SetDTR(0);
if (dtrptt && !dtr)
SetDTR(1);
if (rtscts == false) {
if (rtsptt && rts)
SetRTS(0);
if (rtsptt && !rts)
SetRTS(1);
}
} else { // ptt disabled
if (dtrptt && dtr)
SetDTR(1);
if (dtrptt && !dtr)
SetDTR(0);
if (rtscts == false) {
if (rtsptt && rts)
SetRTS(1);
if (rtsptt && !rts)
SetRTS(0);
}
}
}
void Cserial::SetDTR(bool b)
{
if(hComm == INVALID_HANDLE_VALUE) {
LOG_PERROR("Invalid handle");
return;
}
if (b) EscapeCommFunction(hComm, SETDTR);
else EscapeCommFunction(hComm, CLRDTR);
}
void Cserial::SetRTS(bool b)
{
if(hComm == INVALID_HANDLE_VALUE) {
LOG_PERROR("Invalid handle");
return;
}
if (b) EscapeCommFunction(hComm, SETRTS);
else EscapeCommFunction(hComm, CLRRTS);
}
//======================================================================
// end Win32 code
//======================================================================
#endif //__MINGW32__
#ifdef __WOE32__
#include <sstream>
#include "re.h"
// convert COMx to /dev/ttySy with y = x - 1
void com_to_tty(std::string& port)
{
re_t re("com([0-9]+)", REG_EXTENDED | REG_ICASE);
if (!(re.match(port.c_str()) && re.nsub() == 2))
return;
std::stringstream ss;
int n;
ss << re.submatch(1);
ss >> n;
if (--n < 0)
n = 0;
ss.clear(); ss.str("");
ss << "/dev/ttyS" << n;
ss.seekp(0);
port = ss.str();
}
// convert /dev/ttySx to COMy with y = x + 1
void tty_to_com(std::string& port)
{
re_t re("/dev/tty.([0-9]+)", REG_EXTENDED | REG_ICASE);
if (!(re.match(port.c_str()) && re.nsub() == 2))
return;
std::stringstream ss;
int n;
ss << re.submatch(1);
ss >> n;
ss.clear(); ss.str("");
ss << "COM" << n + 1;
ss.seekp(0);
port = ss.str();
}
#endif
| 23,051
|
C++
|
.cxx
| 799
| 26.713392
| 80
| 0.633968
|
w1hkj/fldigi
| 109
| 27
| 38
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
751,042
|
rigxml.cxx
|
w1hkj_fldigi/src/rigcontrol/rigxml.cxx
|
// ----------------------------------------------------------------------------
// rigxml.cxx - parse a rig control xml file
//
// Copyright (C) 2007-2009
// Dave Freese, W1HKJ
//
// This file is part of fldigi.
//
// Fldigi 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 3 of the License, or
// (at your option) any later version.
//
// Fldigi 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 fldigi. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include <config.h>
#include <fstream>
#include <string>
#include <list>
#include <FL/filename.H>
#include "gettext.h"
#include "rigio.h"
#include "rigxml.h"
#include "rigsupport.h"
#ifdef RIGCATTEST
#include "rigCAT.h"
#else
#include "main.h"
#endif
#include "debug.h"
#include "configuration.h"
#include "fileselect.h"
#include "confdialog.h"
#include "icons.h"
#include "fl_digi.h"
//#define DEBUGXML 1
void parseRIGDEF(size_t &);
void parseRIG(size_t &);
void parseCOMMAND(size_t &);
void parseREPLY(size_t &);
void parseMODES(size_t &);
void parseBANDWIDTHS(size_t &);
void parseBWCMD(size_t &);
void parseBWREPLY(size_t &);
void parseMODECMD(size_t &);
void parseMODEREPLY(size_t &);
void parseTITLE(size_t &);
void parseLSBMODES(size_t &);
void parseDISCARD(size_t &);
void parseDEBUG(size_t &);
void parseNOSERIAL(size_t &);
void parseASCII(size_t &);
void parseWRITE_DELAY(size_t &);
void parseINIT_DELAY(size_t &);
void parseWAIT_FOR_DEVICE(size_t &);
void parsePOST_WRITE_DELAY(size_t &);
void parseRETRIES(size_t &);
void parseTIMEOUT(size_t &);
void parseBAUDRATE(size_t &);
void parseSTOPBITS(size_t &);
void parseRTSCTS(size_t &);
void parseCMDPTT(size_t &);
void parseRTSPLUS(size_t &);
void parseDTRPLUS(size_t &);
void parseRTSPTT(size_t &);
void parseDTRPTT(size_t &);
void parseRESTORE_TIO(size_t &);
void parseECHO(size_t &);
void parseVSP(size_t &);
void parseLOGSTR(size_t &);
void parsePOLLINT(size_t &);
void parseSMETER(size_t &);
void parsePMETER(size_t &);
void parseNOTCH(size_t &);
void parsePWRLEVEL(size_t &);
void parseIOSsymbol(size_t &);
void parseIOSsize(size_t &);
void parseIOSbytes(size_t &);
void parseIOSbyte(size_t &);
void parseIOSdata(size_t &);
void parseIOSinfo(size_t &);
void parseIOSok(size_t &);
void parseIOSbad(size_t &);
void parseIOSstring(size_t &);
void parseIOSint(size_t &);
void parseIOSfill(size_t &);
void parseDTYPE(size_t &);
void parseDSIZE(size_t &);
void parseDMAX(size_t &);
void parseDMIN(size_t &);
void parseDRESOL(size_t &);
void parseDREV(size_t &);
void parseDMAKS(size_t &);
void parseDSHIFT(size_t &);
void print(size_t &);
std::list<XMLIOS> commands;
std::list<XMLIOS> reply;
std::list<MODE> lmodes;
std::list<BW> lbws;
std::list<BW> lbwCMD;
std::list<BW> lbwREPLY;
std::list<MODE> lmodeCMD;
std::list<MODE> lmodeREPLY;
std::list<std::string> LSBmodes;
XMLRIG xmlrig;
XMLIOS iosTemp;
std::string strXML;
TAGS rigdeftags[] = {
{"<RIGDEF", parseRIGDEF},
{"<RIG", parseRIG},
{"<COMMAND", parseCOMMAND},
{"<REPLY", parseREPLY},
{"<BANDWIDTHS", parseBANDWIDTHS},
{"<BW-CMD", parseBWCMD},
{"<BW-REPLY", parseBWREPLY},
{"<MODES", parseMODES},
{"<MODE-CMD", parseMODECMD},
{"<MODE-REPLY", parseMODEREPLY},
{"<TITLE", parseTITLE},
{"<LSBMODES", parseLSBMODES},
{"<PROGRAMMER", parseDISCARD},
{"<STATUS", parseDISCARD},
{"<WRITE_DELAY", parseWRITE_DELAY},
{"<INIT_DELAY", parseINIT_DELAY},
{"<POST_WRITE_DELAY", parsePOST_WRITE_DELAY},
{"<RETRIES", parseRETRIES},
{"<TIMEOUT", parseTIMEOUT},
{"<BAUDRATE", parseBAUDRATE},
{"<RTSCTS", parseRTSCTS},
{"<RTSPLUS", parseRTSPLUS},
{"<DTRPLUS", parseDTRPLUS},
{"<RTSPTT", parseRTSPTT},
{"<DTRPTT", parseDTRPTT},
{"<WAIT_FOR_DEVICE", parseWAIT_FOR_DEVICE},
{"<RESTORE_TIO", parseRESTORE_TIO},
{"<ECHO", parseECHO},
{"<CMDPTT", parseCMDPTT},
{"<STOPBITS", parseSTOPBITS},
{"<VSP", parseVSP},
{"<LOGSTR", parseLOGSTR},
{"<POLLINT", parsePOLLINT},
{"<SMETER", parseSMETER},
{"<PMETER", parsePMETER},
{"<NOTCH", parseNOTCH},
{"<PWRLEVEL", parsePWRLEVEL},
{"<DEBUG", parseDEBUG},
{"<NOSERIAL", parseNOSERIAL},
{"<ASCII", parseASCII},
{0, 0}
};
TAGS commandtags[] = {
{"<SIZE", parseIOSsize},
{"<SYMBOL", parseIOSsymbol},
{"<BYTES", parseIOSbytes},
{"<BYTE", parseIOSbyte},
{"<DATA", parseIOSdata},
{"<STRING", parseIOSstring},
{"<INT", parseIOSint},
{"<INFO", parseIOSinfo},
{"<OK", parseIOSok},
{"<BAD", parseIOSbad},
{0,0}
};
TAGS replytags[] = {
{"<SIZE", parseIOSsize},
{"<SYMBOL", parseIOSsymbol},
{"<BYTES", parseIOSbytes},
{"<BYTE", parseIOSbyte},
{"<DATA", parseIOSdata},
{"<STRING", parseIOSstring},
{"<INT", parseIOSint},
{"<FILL", parseIOSfill},
{0,0}
};
TAGS datatags[] = {
{"<DTYPE", parseDTYPE},
{"<SIZE", parseDSIZE},
{"<MAX", parseDMAX},
{"<MIN", parseDMIN},
{"<RESOL", parseDRESOL},
{"<REV", parseDREV},
{"<MASK", parseDMAKS},
{"<SHIFT", parseDSHIFT},
{0,0}
}
;
//=====================================================================
void print(size_t &p0, int indent)
{
#ifdef DEBUGXML
std::string istr(indent, '\t');
size_t tend = strXML.find(">", p0);
LOG_INFO("%s%s", istr.c_str(), strXML.substr(p0, tend - p0 + 1).c_str());
#endif
}
size_t tagEnd(size_t p0)
{
size_t p1, p2, p3;
p1 = p0;
std::string strtag = "</";
p2 = strXML.find(">", p0);
p3 = strXML.find(" ", p0);
if (p2 == std::string::npos) {
return p2;
}
if (p3 < p2)
p2 = p3;
strtag.append(strXML.substr(p1 + 1, p2 - p1 - 1));
strtag.append(">");
p3 = strXML.find(strtag, p1);
return p3;
}
size_t nextTag(size_t p0)
{
p0 = strXML.find("<", p0+1);
return p0;
}
std::string getElement(size_t p0)
{
size_t p1 = strXML.find(">",p0),
p2 = nextTag(p1+1);
if (p1 == std::string::npos || p2 == std::string::npos)
return "";
p1++; p2--;
while (p1 < p2 && strXML[p1] == ' ') p1++; // skip leading spaces
while (p1 < p2 && strXML[p2] == ' ') p2--; // skip trailing spaces
return strXML.substr(p1, p2 - p1 + 1);
}
int getInt(size_t p0)
{
std::string stemp = getElement(p0);
if (stemp.length() == 0)
return 0;
return atoi(stemp.c_str());
}
float getFloat(size_t p0)
{
std::string stemp = getElement(p0);
if (stemp.length() == 0)
return 0;
return atof(stemp.c_str());
}
bool getBool( size_t p0)
{
std::string stemp = getElement(p0);
if (stemp.length() == 0)
return false;
if (strcasecmp(stemp.c_str(), "true") == 0)
return true;
if (stemp == "1") return true;
return false;
}
char getByte(size_t p0)
{
unsigned int val;
if (sscanf( getElement(p0).c_str(), "%x", &val ) != 1)
return 0;
return (val & 0xFF);
}
std::string getBytes(size_t p0)
{
unsigned int val;
size_t space;
std::string stemp = getElement(p0);
std::string s;
while ( stemp.length() ) {
if (sscanf( stemp.c_str(), "%x", &val) != 1) {
s = "";
return s;
}
s += (char)(val & 0xFF);
space = stemp.find(" ");
if (space == std::string::npos) break;
stemp.erase(0, space + 1);
}
return s;
}
bool isInt(size_t p0, int &i)
{
// p0 = nextTag(p0);
if (strXML.find("<INT", p0) != p0)
return false;
i = getInt(p0);
return true;
}
bool isByte(size_t p0, char &ch)
{
// p0 = nextTag(p0);
if (strXML.find("<BYTE", p0) != p0)
return false;
ch = getByte(p0);
return true;
}
bool isBytes( size_t p0, std::string &s )
{
// p0 = nextTag(p0);
if (strXML.find ("<BYTES", p0) != p0)
return false;
s = getBytes(p0);
return true;
}
bool isString( size_t p0, std::string &s )
{
// p0 = nextTag(p0);
if (strXML.find("<STRING", p0) != p0)
return false;
s = getElement(p0);
return true;
}
bool isSymbol( size_t p0, std::string &s)
{
if (strXML.find("<SYMBOL", p0) != p0)
return false;
s = getElement(p0);
return true;
}
bool tagIs(size_t &p0, std::string tag)
{
return (strXML.find(tag,p0) == p0);
}
//---------------------------------------------------------------------
// Parse modesTO definitions
//---------------------------------------------------------------------
void parseMODEdefs(size_t &p0, std::list<MODE> &lmd)
{
size_t pend = tagEnd(p0);
size_t elend;
char ch;
int n;
std::string stemp;
std::string strELEMENT;
if (pend == std::string::npos) {
p0++;
return;
}
print(p0,0);
p0 = nextTag(p0);
while (p0 != std::string::npos && p0 < pend && tagIs(p0, "<ELEMENT")) {
elend = tagEnd(p0);
p0 = nextTag(p0);
if (isSymbol(p0, strELEMENT)) {
p0 = tagEnd(p0);
p0 = nextTag(p0);
while (p0 != std::string::npos && p0 < elend) {
print(p0,1);
if ( isBytes(p0, stemp) ) {
lmd.push_back(MODE(strELEMENT,stemp));
}
else if ( isByte(p0, ch) ) {
stemp = ch;
lmd.push_back(MODE(strELEMENT,stemp));
}
else if ( isInt(p0, n) ) {
stemp = (char)(n & 0xFF);
lmd.push_back(MODE(strELEMENT, stemp));
}
else if ( isString(p0, stemp) ) {
lmd.push_back(MODE(strELEMENT,stemp));
}
p0 = tagEnd(p0);
p0 = nextTag(p0);
}
}
p0 = nextTag(p0);
}
p0 = pend;
}
void parseMODES(size_t &p0)
{
parseMODEdefs(p0, lmodes);
}
void parseMODECMD(size_t &p0)
{
parseMODEdefs(p0, lmodeCMD);
}
void parseMODEREPLY(size_t &p0)
{
parseMODEdefs(p0, lmodeREPLY);
}
void parseLSBMODES(size_t &p0)
{
size_t pend = tagEnd(p0);
std::string sMode;
print(p0,0);
p0 = nextTag(p0);
while (p0 < pend && isString(p0, sMode)) {
LSBmodes.push_back(sMode);
print (p0,1);
p0 = tagEnd(p0);
p0 = nextTag(p0);
}
p0 = pend;
}
//---------------------------------------------------------------------
// Parse Bandwidth definitions
//---------------------------------------------------------------------
void parseBWdefs(size_t &p0, std::list<BW> &lbw)
{
size_t pend = tagEnd(p0);
size_t elend;
char ch;
int n;
std::string strELEMENT;
std::string stemp;
if (pend == std::string::npos) {
LOG_ERROR("Unmatched tag %s", strXML.substr(p0, 10).c_str());
p0++;
return;
}
print(p0,0);
size_t p1 = nextTag(p0);
while (p1 != std::string::npos && p1 < pend && tagIs(p1, "<ELEMENT")) {
elend = tagEnd(p1);
if (elend == std::string::npos || elend > pend) {
LOG_ERROR("Unmatched tag %s", "<ELEMENT");
p0 = pend;
return;
}
p1 = nextTag(p1);
if (isSymbol(p1, strELEMENT)) {
p1 = tagEnd(p1);
p1 = nextTag(p1);
while (p1 != std::string::npos && p1 < elend) {
print(p1,1);
if ( isBytes(p1, stemp) ) {
lbw.push_back(BW(strELEMENT,stemp));
p1 = tagEnd(p1);
}
else if ( isByte(p1, ch) ) {
stemp = ch;
lbw.push_back(BW(strELEMENT,stemp));
p1 = tagEnd(p1);
}
else if ( isInt(p1, n) ) {
stemp = (char)(n & 0xFF);
lbw.push_back(BW(strELEMENT, stemp));
p1 = tagEnd(p1);
}
else if ( isString(p1, stemp) ) {
lbw.push_back(BW(strELEMENT,stemp));
p1 = tagEnd(p1);
} else {
LOG_ERROR("Invalid tag: %s", strXML.substr(p1, 10).c_str());
parseDISCARD(p1);
}
p1 = nextTag(p1);
}
}
p1 = nextTag(p1);
}
p0 = pend;
}
void parseBANDWIDTHS(size_t &p0)
{
parseBWdefs(p0, lbws);
}
void parseBWCMD(size_t &p0)
{
parseBWdefs(p0, lbwCMD);
}
void parseBWREPLY(size_t &p0)
{
parseBWdefs(p0, lbwREPLY);
}
//---------------------------------------------------------------------
// Parse Title definition
//---------------------------------------------------------------------
void parseTITLE(size_t &p0)
{
size_t pend = tagEnd(p0);
xmlrig.rigTitle = getElement(p0);
p0 = pend;
}
//---------------------------------------------------------------------
// Parse Rig definition
//---------------------------------------------------------------------
void parseRIG(size_t &p0)
{
size_t pend = tagEnd(p0);
p0 = pend;
}
//---------------------------------------------------------------------
// Parse DEBUG, use during xml file creation/testing
//---------------------------------------------------------------------
void parseDEBUG(size_t &p0){
bool val = getBool(p0);
xmlrig.debug = val;
size_t pend = tagEnd(p0);
p0 = pend;
}
//---------------------------------------------------------------------
// Parse NOSERIAL, use during xml file creation/testing
// suppresses serial port i/o
//---------------------------------------------------------------------
void parseNOSERIAL(size_t &p0){
bool val = getBool(p0);
xmlrig.noserial = val;
size_t pend = tagEnd(p0);
p0 = pend;
}
//---------------------------------------------------------------------
// Parse ASCII, use during xml file creation/testing
// prints events as ASCII string vice HEX sequence
//---------------------------------------------------------------------
void parseASCII(size_t &p0){
bool val = getBool(p0);
xmlrig.ascii = val;
size_t pend = tagEnd(p0);
p0 = pend;
}
//---------------------------------------------------------------------
// Parse Baudrate, write_delay, post_write_delay, timeout, retries
// RTSCTS handshake
//---------------------------------------------------------------------
void parseBAUDRATE(size_t &p0)
{
std::string sVal = getElement(p0);
xmlrig.baud = progdefaults.nBaudRate(sVal.c_str());
size_t pend = tagEnd(p0);
p0 = pend;
}
void parseSTOPBITS(size_t &p0){
int val = getInt(p0);
if (val < 0 || val > 2) val = 2;
xmlrig.stopbits = val;
size_t pend = tagEnd(p0);
p0 = pend;
}
void parseWRITE_DELAY(size_t &p0){
int val = getInt(p0);
xmlrig.write_delay = val;
size_t pend = tagEnd(p0);
p0 = pend;
}
void parseINIT_DELAY(size_t &p0){
int val = getInt(p0);
xmlrig.init_delay = val;
size_t pend = tagEnd(p0);
p0 = pend;
}
void parseWAIT_FOR_DEVICE(size_t &p0){
int val = getInt(p0);
xmlrig.wait_for_device = val;
size_t pend = tagEnd(p0);
p0 = pend;
}
void parsePOST_WRITE_DELAY(size_t &p0){
int val = getInt(p0);
xmlrig.post_write_delay = val;
size_t pend = tagEnd(p0);
p0 = pend;
}
void parseRETRIES(size_t &p0){
int val = getInt(p0);
xmlrig.retries = val;
size_t pend = tagEnd(p0);
p0 = pend;
}
void parseTIMEOUT(size_t &p0){
int val = getInt(p0);
xmlrig.timeout = val;
size_t pend = tagEnd(p0);
p0 = pend;
}
void parseRTSCTS(size_t &p0){
bool val = getBool(p0);
xmlrig.rtscts = val;
size_t pend = tagEnd(p0);
p0 = pend;
}
void parseRTSPLUS(size_t &p0)
{
bool val = getBool(p0);
xmlrig.rts = val;
size_t pend = tagEnd(p0);
p0 = pend;
}
void parseDTRPLUS(size_t &p0)
{
bool val = getBool(p0);
xmlrig.dtr = val;
size_t pend = tagEnd(p0);
p0 = pend;
}
void parseRTSPTT(size_t &p0)
{
bool val = getBool(p0);
xmlrig.rtsptt = val;
size_t pend = tagEnd(p0);
p0 = pend;
}
void parseDTRPTT(size_t &p0)
{
bool val = getBool(p0);
xmlrig.dtrptt = val;
size_t pend = tagEnd(p0);
p0 = pend;
}
void parseRESTORE_TIO(size_t &p0)
{
bool val = getBool(p0);
xmlrig.restore_tio = val;
size_t pend = tagEnd(p0);
p0 = pend;
}
void parseCMDPTT(size_t &p0) {
bool val = getBool(p0);
xmlrig.cmdptt = val;
size_t pend = tagEnd(p0);
p0 = pend;
}
void parseECHO(size_t &p0) {
bool val = getBool(p0);
xmlrig.echo = val;
size_t pend = tagEnd(p0);
p0 = pend;
}
void parseVSP(size_t &p0)
{
bool val = getBool(p0);
xmlrig.vsp = val;
size_t pend = tagEnd(p0);
p0 = pend;
}
void parseLOGSTR(size_t &p0) {
bool val = getBool(p0);
xmlrig.logstr = val;
size_t pend = tagEnd(p0);
p0 = pend;
}
void parsePOLLINT(size_t &p0) {
int val = getInt(p0);
if (val < 100) val = 1000;
if (val > 20000) val = 20000;
xmlrig.pollinterval = val;
size_t pend = tagEnd(p0);
p0 = pend;
}
void parseSMETER(size_t &p0) {
std::string strmeter = getElement(p0);
size_t pend = tagEnd(p0);
p0 = pend;
xmlrig.smeter.clear();
int val, sm;
size_t p = strmeter.find(",");
while ( !strmeter.empty() && (p != std::string::npos) ) {
val = atoi(&strmeter[0]);
sm = atoi(&strmeter[p+1]);
xmlrig.smeter.push_back(PAIR(val,sm));
p = strmeter.find(";");
if (p == std::string::npos) strmeter.clear();
else {
strmeter.erase(0, p+1);
p = strmeter.find(",");
}
}
xmlrig.use_smeter = true;
}
void parsePMETER(size_t &p0) {
std::string strmeter = getElement(p0);
size_t pend = tagEnd(p0);
p0 = pend;
xmlrig.pmeter.clear();
int val, sm;
size_t p = strmeter.find(",");
while ( !strmeter.empty() && (p != std::string::npos) ) {
val = atoi(&strmeter[0]);
sm = atoi(&strmeter[p+1]);
xmlrig.pmeter.push_back(PAIR(val,sm));
p = strmeter.find(";");
if (p == std::string::npos) strmeter.clear();
else {
strmeter.erase(0, p+1);
p = strmeter.find(",");
}
}
xmlrig.use_pwrmeter = true;
}
void parseNOTCH(size_t &p0) {
std::string strnotch = getElement(p0);
size_t pend = tagEnd(p0);
p0 = pend;
xmlrig.notch.clear();
int val, ntch;
size_t p = strnotch.find(",");
while ( !strnotch.empty() && (p != std::string::npos) ) {
val = atoi(&strnotch[0]);
ntch = atoi(&strnotch[p+1]);
xmlrig.notch.push_back(PAIR(val,ntch));
p = strnotch.find(";");
if (p == std::string::npos) strnotch.clear();
else {
strnotch.erase(0, p+1);
p = strnotch.find(",");
}
}
xmlrig.use_notch = true;
}
void parsePWRLEVEL(size_t &p0) {
std::string strpwrlevel = getElement(p0);
size_t pend = tagEnd(p0);
p0 = pend;
xmlrig.pwrlevel.clear();
int val, pwr;
float min = 500, max = 0;
size_t p = strpwrlevel.find(",");
while ( !strpwrlevel.empty() && (p != std::string::npos) ) {
val = atoi(&strpwrlevel[0]);
pwr = atoi(&strpwrlevel[p+1]);
if (pwr < min) min = pwr;
if (pwr > max) max = pwr;
xmlrig.pwrlevel.push_back(PAIR(val,pwr));
p = strpwrlevel.find(";");
if (p == std::string::npos) strpwrlevel.clear();
else {
strpwrlevel.erase(0, p+1);
p = strpwrlevel.find(",");
}
}
pwr_level->range(min, max);
xmlrig.use_pwrlevel = true;
}
//---------------------------------------------------------------------
// Parse IOS (serial stream format) definitions
//---------------------------------------------------------------------
void parseIOSsize(size_t &p0)
{
iosTemp.size = getInt(p0);
}
void parseIOSbytes(size_t &p0)
{
if (iosTemp.data.size == 0)
iosTemp.str1.append(getBytes(p0));
else
iosTemp.str2.append(getBytes(p0));
}
void parseIOSbyte(size_t &p0)
{
if (iosTemp.data.size == 0)
iosTemp.str1 += getByte(p0);
else
iosTemp.str2 += getByte(p0);
}
void parseIOSstring(size_t &p0)
{
if (iosTemp.data.size == 0)
iosTemp.str1 += getElement(p0);
else
iosTemp.str2 += getElement(p0);
}
void parseIOSint(size_t &p0)
{
if (iosTemp.data.size == 0)
iosTemp.str1 += (char)(getInt(p0) & 0xFF);
else
iosTemp.str2 += (char)(getInt(p0) & 0xFF);
}
void parseDTYPE(size_t &p1)
{
print(p1,2);
iosTemp.data.dtype = getElement(p1);
}
void parseDSIZE(size_t &p1)
{
print(p1,2);
iosTemp.data.size = getInt(p1);
}
void parseDMAX(size_t &p1)
{
print(p1,2);
iosTemp.data.max = getInt(p1);
}
void parseDMIN(size_t &p1)
{
print(p1,2);
iosTemp.data.min = getInt(p1);
}
void parseDRESOL(size_t &p1)
{
print(p1,2);
iosTemp.data.resolution = getFloat(p1);
}
void parseDREV(size_t &p1)
{
print(p1,2);
iosTemp.data.reverse = getBool(p1);
}
void parseDMAKS(size_t &p1)
{
print(p1,2);
iosTemp.data.andmask = getInt(p1);
}
void parseDSHIFT(size_t &p1)
{
print(p1,2);
iosTemp.data.shiftbits = getInt(p1);
}
void parseIOSdata(size_t &p0)
{
size_t pend = tagEnd(p0);
size_t p1;
TAGS *pv;
p1 = nextTag(p0);
while (p1 < pend) {
pv = datatags;
while (pv->tag) {
if (strXML.find(pv->tag, p1) == p1)
break;
pv++;
}
if (pv->fp) {
print(p1, 1);
(pv->fp)(p1);
p1 = tagEnd(p1);
} else {
LOG_ERROR("Invalid tag: %s", strXML.substr(p1, 10).c_str());
parseDISCARD(p1);
}
p1 = nextTag(p1);
}
}
void parseIOSinfo(size_t &p0)
{
std::string strR = getElement(p0);
if (strR.empty()) return;
iosTemp.info = strR;
}
void parseIOSok(size_t &p0)
{
std::string strR = getElement(p0);
if (strR.empty()) return;
iosTemp.ok = strR;
}
void parseIOSbad(size_t &p0)
{
std::string strR = getElement(p0);
if (strR.empty()) return;
iosTemp.bad = strR;
}
void parseIOSsymbol(size_t &p0)
{
std::string strR = getElement(p0);
if (strR.empty()) return;
iosTemp.SYMBOL = strR;
}
void parseIOSfill(size_t &p0)
{
if (iosTemp.data.size == 0)
iosTemp.fill1 = getInt(p0);
else
iosTemp.fill2 = getInt(p0);
}
//=======================================================================
bool parseIOS(size_t &p0, TAGS *valid)
{
size_t pend = tagEnd(p0);
size_t p1;
TAGS *pv;
print(p0,0);
iosTemp.clear();
p1 = nextTag(p0);
while (p1 < pend) {
pv = valid;
while (pv->tag) {
if (strXML.find(pv->tag, p1) == p1)
break;
pv++;
}
if (pv->fp) {
print(p1, 1);
(pv->fp)(p1);
p1 = tagEnd(p1);
} else {
LOG_ERROR("Invalid tag: %s", strXML.substr(p1, 10).c_str());
parseDISCARD(p1);
}
p1 = nextTag(p1);
}
p0 = pend;
return (!iosTemp.SYMBOL.empty());
}
void parseCOMMAND(size_t &p0)
{
if (parseIOS(p0, commandtags))
commands.push_back(iosTemp);
}
void parseREPLY(size_t &p0)
{
if (parseIOS(p0, replytags))
reply.push_back(iosTemp);
}
void parseRIGDEF(size_t &p0)
{
print(p0,0);
size_t p1 = tagEnd(p0);
if (p1 != std::string::npos)
strXML.erase(p1);
}
void parseDISCARD(size_t &p0)
{
size_t pend = tagEnd(p0);
if (pend == std::string::npos) p0++;
else p0 = pend;
}
void parseXML()
{
size_t p0 = 0;
TAGS *pValid = rigdeftags;
p0 = strXML.find("<");
while (p0 != std::string::npos) {
pValid = rigdeftags;
while (pValid->tag) {
if (strXML.find(pValid->tag, p0) == p0)
break;
pValid++;
}
if (pValid->tag) {
(pValid->fp)(p0);
} else {
LOG_ERROR("Invalid tag: %s", strXML.substr(p0, 10).c_str());
parseDISCARD(p0);
}
p0 = nextTag(p0);
}
}
bool remove_comments()
{
size_t p0 = 0;
size_t p1 = 0;
// remove comments from xml text
while ((p0 = strXML.find("<!--")) != std::string::npos) {
p1 = strXML.find("-->", p0);
if (p1 == std::string::npos) {
fl_alert2("Corrupt rig XML definition file\nMismatched comment tags!");
return false;
}
strXML.erase(p0, p1 - p0 + 3);
}
if (strXML.find("-->") != std::string::npos) {
fl_alert2("Corrupt rig XML definition file\nMismatched comment tags!");
return false;
}
return true;
}
bool testXML()
{
if (!remove_comments()) return false;
return true;
}
bool readRigXML()
{
char szLine[256];
int lines = 0;
commands.clear();
reply.clear();
lmodes.clear();
lmodeCMD.clear();
lmodeREPLY.clear();
lbws.clear();
lbwCMD.clear();
lbwREPLY.clear();
LSBmodes.clear();
strXML = "";
std::ifstream xmlfile(progdefaults.XmlRigFilename.c_str(), std::ios::in);
if (xmlfile) {
while (!xmlfile.eof()) {
lines++;
memset(szLine, 0, sizeof(szLine));
xmlfile.getline(szLine,255);
strXML.append(szLine);
}
xmlfile.close();
if (testXML()) {
parseXML();
xmlrig.xmlok = true;
return true;
}
}
return false;
}
void selectRigXmlFilename()
{
std::string deffilename;
deffilename = progdefaults.XmlRigFilename;
const char *p = FSEL::select(_("Open rig xml file"), _("Fldigi rig xml definition file\t*.xml"), deffilename.c_str());
if (!p) return;
if (!*p) return;
progdefaults.XmlRigFilename = p;
txtXmlRigFilename->value(fl_filename_name(p));
loadRigXmlFile();
}
void loadRigXmlFile(void)
{
rigCAT_close();
readRigXML();
rigCAT_defaults();
}
| 23,452
|
C++
|
.cxx
| 1,003
| 21.279163
| 119
| 0.614199
|
w1hkj/fldigi
| 109
| 27
| 38
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
751,043
|
ptt.cxx
|
w1hkj_fldigi/src/rigcontrol/ptt.cxx
|
// ----------------------------------------------------------------------------
//
// ptt.cxx -- PTT control
//
// Copyright (C) 2006-2009
// Dave Freese, W1HKJ
// Copyright (C) 2008-2009
// Stelios Bounanos, M0GLD
// Copyright (C) 2009
// Diane Bruce, VA3DB
//
// Added gpio for PTT (Lior KK6BWA)
//
// This file is part of fldigi. Adapted from code contained in gmfsk source code
// distribution.
// gmfsk Copyright (C) 2001, 2002, 2003
// Tomi Manninen (oh2bns@sral.fi)
// Copyright (C) 2004
// Lawrence Glaister (ve7it@shaw.ca)
//
// Fldigi 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 3 of the License, or
// (at your option) any later version.
//
// Fldigi 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 fldigi. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include <config.h>
#include <iostream>
#include <unistd.h>
#include <sys/types.h>
#if HAVE_SYS_SELECT_H
# include <sys/select.h>
#endif
#include <sys/stat.h>
#include <fcntl.h>
#if HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
#endif
#if HAVE_TERMIOS_H
# include <termios.h>
#endif
#include <errno.h>
#include <cstring>
#include <stdint.h>
#include "trx.h"
#include "ptt.h"
#include "configuration.h"
#include "rigio.h"
#if USE_HAMLIB
#include "hamlib.h"
#endif
#include "serial.h"
#include "re.h"
#include "debug.h"
#include "fl_digi.h"
#include "confdialog.h"
#include "n3fjp_logger.h"
#include "cmedia.h"
LOG_FILE_SOURCE(debug::LOG_RIGCONTROL);
extern Cserial CW_KEYLINE_serial;
int cmedia_fd = -1;
PTT::PTT(ptt_t dev) : pttdev(PTT_INVALID), oldtio(0)
{
reset(dev);
}
PTT::~PTT()
{
close_all();
}
void PTT::reset(ptt_t dev)
{
close_all();
switch (pttdev = dev) {
#if HAVE_UHROUTER
case PTT_UHROUTER:
if (progdefaults.PTTdev.find(UHROUTER_FIFO_PREFIX) == 0) {
pttdev = PTT_UHROUTER;
open_uhrouter();
break;
}
else {
pttdev = PTT_NONE;
break;
}
#endif
#if HAVE_PARPORT
case PTT_PARPORT:
open_parport();
if (pttfd < 0)
pttdev = PTT_NONE;
break;
#endif
case PTT_TTY:
open_tty();
break;
case PTT_CMEDIA:
cmedia_fd = open_cmedia(progdefaults.cmedia_device);
break;
default:
break; // nothing to open
}
open_gpio();
set(false);
}
void PTT::set(bool ptt)
{
std::string ptt_temp =
pttdev == PTT_NONE ? "NONE" :
pttdev == PTT_HAMLIB ? "HAMLIB" :
pttdev == PTT_RIGCAT ? "RIGCAT" :
pttdev == PTT_TTY ? "TTY" :
pttdev == PTT_GPIO ? "GPIO" :
pttdev == PTT_CMEDIA ? "CMEDIA" :
pttdev == PTT_PARPORT ? "PARPORT" :
pttdev == PTT_UHROUTER ? "UHROUTER" : "UNKNOWN";
LOG_INFO("PTT via %s : %s", ptt_temp.c_str(), ptt ? "ON" : "OFF");
// add milliseconds - no audio to clear virtual audio card used by Flex systems
if (!ptt && progdefaults.PTT_off_delay)
MilliSleep(progdefaults.PTT_off_delay);
if (active_modem == cw_modem && (CW_KEYLINE_isopen || progdefaults.CW_KEYLINE_on_cat_port)) {
guard_lock lk(&cwio_ptt_mutex);
}
switch (pttdev) {
case PTT_NONE:
noCAT_setPTT(ptt);
break;
#if USE_HAMLIB
case PTT_HAMLIB:
hamlib_set_ptt(ptt);
break;
#endif
case PTT_RIGCAT:
rigCAT_set_ptt(ptt);
break;
case PTT_TTY:
set_tty(ptt);
break;
case PTT_GPIO:
set_gpio(ptt);
break;
#if HAVE_PARPORT
case PTT_PARPORT:
set_parport(ptt);
break;
#else
btnUsePPortPTT->hide();
#endif
#if HAVE_UHROUTER
case PTT_UHROUTER:
set_uhrouter(ptt);
break;
#endif
case PTT_CMEDIA:
if (cmedia_fd != -1) {
int bitnbr = 2;
if (progdefaults.cmedia_gpio_line == "GPIO-1") bitnbr = 0;
else if (progdefaults.cmedia_gpio_line == "GPIO-2") bitnbr = 1;
else if (progdefaults.cmedia_gpio_line == "GPIO-3") bitnbr = 2;
else if (progdefaults.cmedia_gpio_line == "GPIO-4") bitnbr = 3;
set_cmedia(bitnbr, ptt);
}
break;
default:
if (n3fjp_connected)
n3fjp_set_ptt(ptt);
}
nano_PTT(ptt);
if (ptt && progdefaults.PTT_on_delay)
MilliSleep(progdefaults.PTT_on_delay);
if (ptt) start_tx_timer();
else stop_tx_timer();
}
void PTT::close_all(void)
{
set(false);
switch (pttdev) {
case PTT_TTY:
close_tty();
break;
#if HAVE_PARPORT
case PTT_PARPORT:
close_parport();
break;
#endif
#if HAVE_UHROUTER
case PTT_UHROUTER:
close_uhrouter();
break;
#endif
default:
break;
}
close_gpio();
pttfd = -1;
}
//-------------------- gpio port PTT --------------------//
#ifndef __MINGW32__
static void gpioEXEC(std::string execstr)
{
int pfd[2];
if (pipe(pfd) == -1) {
LOG_PERROR("pipe");
return;
}
pid_t pid;
switch (pid = fork()) {
case -1:
LOG_PERROR("fork");
return;
case 0: // child
close(pfd[0]);
if (dup2(pfd[1], STDOUT_FILENO) != STDOUT_FILENO) {
LOG_PERROR("dup2");
exit(EXIT_FAILURE);
}
close(pfd[1]);
execl("/bin/sh", "sh", "-c", execstr.c_str(), (char *)NULL);
perror("execl");
exit(EXIT_FAILURE);
}
// parent
close(pfd[1]);
}
#else // !__MINGW32__
static void gpioEXEC(std::string execstr)
{
char* cmd = strdup(execstr.c_str());
STARTUPINFO si;
PROCESS_INFORMATION pi;
memset(&si, 0, sizeof(si));
si.cb = sizeof(si);
memset(&pi, 0, sizeof(pi));
if (!CreateProcess(NULL, cmd, NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi))
LOG_ERROR("CreateProcess failed with error code %ld", GetLastError());
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
free(cmd);
}
#endif // !__MINGW32__
static const char *gpio_name[] = {
"17", "18", "27", "22", "23",
"24", "25", "4", "5", "6",
"13", "19", "26", "12", "16",
"20", "21"};
void export_gpio(int bcm)
{
if (bcm < 0 || bcm > 16) return;
std::string exec_str = "gpio export ";
exec_str.append(gpio_name[bcm]).append(" out");
gpioEXEC(exec_str);
LOG_INFO("%s", exec_str.c_str());
}
void unexport_gpio(int bcm)
{
if (bcm < 0 || bcm > 16) return;
std::string exec_str = "gpio unexport ";
exec_str.append(gpio_name[bcm]);
gpioEXEC(exec_str);
LOG_INFO("%s", exec_str.c_str());
}
void PTT::open_gpio(void)
{
bool enabled = false;
for (int i = 0; i < 17; i++) {
enabled = (progdefaults.enable_gpio >> i) & 0x01;
if (enabled) export_gpio(i);
}
}
void PTT::close_gpio(void)
{
bool enabled = false;
for (int i = 0; i < 17; i++) {
enabled = (progdefaults.enable_gpio >> i) & 0x01;
if (enabled) unexport_gpio(i);
}
}
void PTT::set_gpio(bool ptt)
{
#define VALUE_MAX 30
static const char s_values_str[] = "01";
std::string portname = "/sys/class/gpio/gpio";
std::string ctrlport;
bool enabled = false;
int val = 0;
int fd;
for (int i = 0; i < 17; i++) {
enabled = (progdefaults.enable_gpio >> i) & 0x01;
if (enabled) {
val = (progdefaults.gpio_on >> i) & 0x01;
ctrlport = portname;
ctrlport.append(gpio_name[i]);
ctrlport.append("/value");
fd = fl_open(ctrlport.c_str(), O_WRONLY);
bool ok = false;
if (fd == -1) {
LOG_ERROR("Failed to open gpio (%s) for writing!", ctrlport.c_str());
} else {
if (progdefaults.gpio_pulse_width == 0) {
if (ptt) { if (val == 1) val = 1; else val = 0;}
if (!ptt) { if (val == 1) val = 0; else val = 1;}
if (write(fd, &s_values_str[val], 1) == 1)
ok = true;
} else {
if (write(fd, &s_values_str[val], 1) == 1) {
MilliSleep(progdefaults.gpio_pulse_width);
if (write(fd, &s_values_str[val == 0 ? 1 : 0], 1) == 1)
ok = true;
}
}
if (ok)
LOG_INFO("Set GPIO ptt on %s %s%s",
ctrlport.c_str(),
(progdefaults.gpio_pulse_width > 0) ?
"pulsed " : "",
(val == 1 ? "HIGH" : "LOW")
);
else
LOG_ERROR("Failed to write value!");
close(fd);
}
}
}
}
//-------------------- serial port PTT --------------------//
void PTT::open_tty(void)
{
serPort.Baud(progdefaults.BaudRate(progdefaults.XmlRigBaudrate));
serPort.Device(progdefaults.PTTdev);
serPort.RTS(progdefaults.RTSplus);
serPort.DTR(progdefaults.DTRplus);
serPort.RTSptt(progdefaults.RTSptt);
serPort.DTRptt(progdefaults.DTRptt);
if (progdefaults.SCU_17) serPort.Stopbits(0);//1);
else serPort.Stopbits(2);
if (serPort.OpenPort() == false) {
LOG_ERROR("Cannot open serial port %s", rigio.Device().c_str());
pttfd = -1;
return;
}
LOG_INFO("Serial port %s open", progdefaults.PTTdev.c_str());
}
void PTT::close_tty(void)
{
serPort.ClosePort();
pttfd = -1;
LOG_DEBUG("Serial port %s closed", progdefaults.PTTdev.c_str());
}
void PTT::set_tty(bool ptt)
{
serPort.SetPTT(ptt);
}
#if HAVE_PARPORT
//-------------------- parallel port PTT --------------------//
#if HAVE_LINUX_PPDEV_H
# include <linux/ppdev.h>
# include <linux/parport.h>
#elif HAVE_DEV_PPBUS_PPI_H
# include <dev/ppbus/ppi.h>
# include <dev/ppbus/ppbconf.h>
#endif
void PTT::open_parport(void)
{
if (progdefaults.PTTdev.find("tty") != std::string::npos) return;
int oflags = O_RDWR | O_NDELAY;
# ifdef HAVE_O_CLOEXEC
oflags = oflags | O_CLOEXEC;
# endif
if ((pttfd = fl_open(progdefaults.PTTdev.c_str(), oflags)) == -1) {
LOG_ERROR("Could not open %s: %s", progdefaults.PTTdev.c_str(), strerror(errno));
return;
}
bool isparport = false;
struct stat st;
int status;
#if HAVE_LINUX_PPDEV_H // Linux (ppdev)
isparport = (fstat(pttfd, &st) == 0 && S_ISCHR(st.st_mode) &&
ioctl(pttfd, PPGETMODE, &status) != -1);
#elif HAVE_DEV_PPBUS_PPI_H // FreeBSD (ppbus/ppi) */
isparport = (fstat(pttfd, &st) == 0 && S_ISCHR(st.st_mode) &&
ioctl(pttfd, PPISSTATUS, &status) != -1);
#else // Fallback (nothing)
isparport = false;
#endif
if (!isparport) {
LOG_VERBOSE("%s: not a supported parallel port device", progdefaults.PTTdev.c_str());
close_parport();
pttfd = -1;
}
}
void PTT::close_parport(void)
{
close(pttfd);
}
void PTT::set_parport(bool ptt)
{
#ifdef HAVE_LINUX_PPDEV_H
struct ppdev_frob_struct frob;
frob.mask = PARPORT_CONTROL_INIT;
frob.val = !ptt;
ioctl(pttfd, PPFCONTROL, &frob);
#elif HAVE_DEV_PPBUS_PPI_H
u_int8_t val;
ioctl(pttfd, PPIGCTRL, &val);
if (ptt)
val |= nINIT;
else
val &= ~nINIT;
ioctl(pttfd, PPISCTRL, &val);
#endif
}
#endif // HAVE_PARPORT
#if HAVE_UHROUTER
//-------------------- uhRouter PTT --------------------//
// See interface documentation at:
// http://homepage.mac.com/chen/w7ay/Router/Contents/routerInterface.html
#define FUNCTIONMASK 0x1f
#define ROUTERFUNCTION 0x80
#define OPENMICROKEYER (ROUTERFUNCTION + 0x01) // get a port to the microKEYER router
#define OPENCWKEYER (ROUTERFUNCTION + 0x02) // get a port to the CW KEYER router
#define OPENDIGIKEYER (ROUTERFUNCTION + 0x03) // get a port to the DIGI KEYER router
#define QUITIFNOKEYER (ROUTERFUNCTION + 0x1f) // quit if there are no keyers
#define QUITIFNOTINUSE (ROUTERFUNCTION + 0x1e) // quit if not connected
#define QUITALWAYS (ROUTERFUNCTION + 0x1d) // quit
#define CLOSEKEYER (ROUTERFUNCTION + FUNCTIONMASK)
#define KEYERFUNCTION 0x40
#define OPENPTT (KEYERFUNCTION + 0x04) // get a port to the PTT flag bit
#ifndef PATH_MAX
# define PATH_MAX 1024
#endif
static ssize_t tm_read(int fd, void* buf, size_t len, const struct timeval* to)
{
fd_set s;
FD_ZERO(&s);
FD_SET(fd, &s);
struct timeval t;
memcpy(&t, to, sizeof(t));
ssize_t n;
if ((n = select(fd + 1, &s, 0, 0, &t)) != 1)
return n;
return read(fd, buf, len);
}
static ssize_t tm_write(int fd, const void* buf, size_t len, const struct timeval* to)
{
fd_set s;
FD_ZERO(&s);
FD_SET(fd, &s);
struct timeval t;
memcpy(&t, to, sizeof(t));
ssize_t n;
if ((n = select(fd + 1, 0, &s, 0, &t)) != 1)
return n;
return write(fd, buf, len);
}
static bool open_fifos(const char* base, int fd[2])
{
struct stat st;
std::string fifo = base;
size_t len = fifo.length();
fifo += "Read";
if (stat(fifo.c_str(), &st) == -1 || !S_ISFIFO(st.st_mode)) {
LOG_ERROR("%s is not a fifo", fifo.c_str());
return false;
}
int oflags = O_RDONLY | O_NONBLOCK;
# ifdef HAVE_O_CLOEXEC
oflags = oflags | O_CLOEXEC;
# endif
if ((fd[0] = fl_open(fifo.c_str(), oflags)) == -1) {
LOG_ERROR("Could not open %s: %s", fifo.c_str(), strerror(errno));
return false;
}
fifo.erase(len);
fifo += "Write";
if (stat(fifo.c_str(), &st) == -1 || !S_ISFIFO(st.st_mode)) {
LOG_ERROR("%s is not a fifo", fifo.c_str());
return false;
}
oflags = O_WRONLY | O_NONBLOCK;
# ifdef HAVE_O_CLOEXEC
oflags = oflags | O_CLOEXEC;
# endif
if ((fd[1] = fl_open(fifo.c_str(), oflags)) == -1) {
LOG_ERROR("Could not open %s: %s", fifo.c_str(), strerror(errno));
return false;
}
return true;
}
static bool get_fifos(const int fd[2], const unsigned char* msg, size_t msglen, char* base, size_t baselen)
{
struct timeval to = { 2, 0 };
if (tm_write(fd[1], msg, msglen, &to) < (ssize_t)msglen) {
LOG_PERROR("Could not write request");
return false;
}
ssize_t r;
if ((r = tm_read(fd[0], base, baselen-1, &to)) <= 0) {
LOG_PERROR("Could not read FIFO name");
return false;
}
base[r] = '\0';
return true;
}
#ifdef __APPLE__
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#endif
static bool start_uhrouter(void)
{
bool found = false;
#ifdef __APPLE__
FILE *fd = (FILE *)0;
std::string appPath;
std::string buffer;
appPath.assign("/Applications/µH Router.app/Contents/MacOS/µH Router");
fd = fl_fopen(appPath.c_str(), "r");
if(fd) {
found = true;
fclose(fd);
}
if(found) {
buffer.clear();
buffer.assign("\"");
buffer.append(appPath);
buffer.append("\" & ");
system(buffer.c_str());
} else {
LOG_ERROR("File: /Applications/\265H Router.app Not Found!");
}
#endif // __APPLE__
return found;
}
void PTT::open_uhrouter(void)
{
struct {
unsigned char keyer;
const char* name;
const char* abbrev;
} keyers[] = {
{ OPENMICROKEYER, "microKeyer", "MK" },
{ OPENCWKEYER, "CWKeyer", "CK" },
{ OPENDIGIKEYER, "DigiKeyer", "DK" }
};
size_t start = 0, end = sizeof(keyers)/sizeof(*keyers);
// If the device string is something like /tmp/microHamRouter/microKeyer,
// or /tmp/microHamRouter/MK, try that keyer only.
re_t keyer_re("^" UHROUTER_FIFO_PREFIX "/(.+)$", REG_EXTENDED);
if (keyer_re.match(progdefaults.PTTdev.c_str()) && keyer_re.nsub() == 2) {
const char* keyer = keyer_re.submatch(1).c_str();
// do we recognise this keyer name?
for (size_t i = 0; i < sizeof(keyers)/sizeof(*keyers); i++) {
if (!strcasecmp(keyers[i].name, keyer) || !strcasecmp(keyers[i].abbrev, keyer)) {
start = i;
end = start + 1;
break;
}
}
}
LOG_VERBOSE("Will try %s", (start == end ? keyers[start].name : "all keyers"));
int uhrfd[2];
uhrfd[0] = uhrfd[1] = uhkfd[0] = uhkfd[1] = uhfd[0] = uhfd[1] = -1;
if (!open_fifos(UHROUTER_FIFO_PREFIX, uhrfd)) {
// if we just started uhrouter we will retry open_fifos a few times
unsigned retries = start_uhrouter() ? 30 : 0;
while (retries-- && !open_fifos(UHROUTER_FIFO_PREFIX, uhrfd))
MilliSleep(100);
if (uhrfd[0] == -1 || uhrfd[1] == -1) {
LOG_ERROR("Could not open router");
return;
}
}
char fifo_name[PATH_MAX];
size_t len = PATH_MAX - 8;
memset(fifo_name, 0, sizeof(fifo_name));
for (size_t i = start; i < end; i++) {
// open keyer
if (!get_fifos(uhrfd, &keyers[i].keyer, 1, fifo_name, len) || *fifo_name == '\0') {
LOG_VERBOSE("Keyer \"%s\" not found", keyers[i].name);
continue;
}
// open ptt port
if (!open_fifos(fifo_name, uhkfd)) {
LOG_ERROR("Could not open keyer %s", keyers[i].name);
continue;
}
LOG_VERBOSE("Opened keyer %s", keyers[i].name);
unsigned char port = OPENPTT;
if (!get_fifos(uhkfd, &port, 1, fifo_name, len)) {
LOG_ERROR("Could not get PTT port");
continue;
}
if (!open_fifos(fifo_name, uhfd)) {
LOG_ERROR("Could not open PTT port %s", fifo_name);
continue;
}
LOG_VERBOSE("Successfully opened PTT port of keyer %s", keyers[i].name);
break;
}
// close router FIFOs
close(uhrfd[0]);
close(uhrfd[1]);
}
void PTT::close_uhrouter(void)
{
close(uhfd[0]);
close(uhfd[1]);
unsigned char c = QUITIFNOTINUSE;
write(uhkfd[1], &c, 1);
close(uhkfd[0]);
close(uhkfd[1]);
}
void PTT::set_uhrouter(bool ptt)
{
if (uhfd[0] == -1 || uhfd[1] == -1)
return;
unsigned char buf[_POSIX_PIPE_BUF];
// empty the fifo
while (read(uhfd[0], buf, sizeof(buf)) > 0);
// send command
*buf = '0' + ptt;
LOG_VERBOSE("Sending PTT=%uc", *buf);
struct timeval t = { 2, 0 };
if (tm_write(uhfd[1], buf, 1, &t) != 1) {
LOG_ERROR("Could not set PTT: %s", strerror(errno));
return;
}
// wait for status
ssize_t n = tm_read(uhfd[0], buf, sizeof(buf), &t);
switch (n) {
case -1:
LOG_PERROR("tm_read");
break;
case 0:
LOG_ERROR("No reply to PTT command within %jd seconds", (intmax_t)t.tv_sec);
break;
default:
LOG_VERBOSE("Received \"%s\"", str2hex(buf, n));
// last received char should be '1'(?)
break;
}
}
#endif // HAVE_UHROUTER
| 17,175
|
C++
|
.cxx
| 649
| 24.040062
| 107
| 0.642996
|
w1hkj/fldigi
| 109
| 27
| 38
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
751,044
|
analysis.cxx
|
w1hkj_fldigi/src/wwv/analysis.cxx
|
// ----------------------------------------------------------------------------
// anal.cxx -- anal modem
//
// Copyright (C) 2006-2009
// Dave Freese, W1HKJ
//
// This file is part of fldigi.
//
// Modified by J C Gibbons / N8OBJ - May 2019
// Added info.txt file option for control of header - Feb 2020
// Added analysis file output modifications
// - Removed relative time from output file, added full ISO date/time stamp
// - Added keeping present days data is the file already exist when program started
//
// Fldigi 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 3 of the License, or
// (at your option) any later version.
//
// Fldigi 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 fldigi. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include <config.h>
#include <string>
#include <cstdio>
#include <ctime>
#include "configuration.h"
#include "analysis.h"
#include "modem.h"
#include "misc.h"
#include "filters.h"
#include "fftfilt.h"
#include "digiscope.h"
#include "waterfall.h"
#include "main.h"
#include "fl_digi.h"
#include "timeops.h"
#include "debug.h"
// added for file support tasks 2-18-20 JC Gibbons N8OBJ
#include <iostream>
#include <fstream>
static char msg1[80];
void anal::tx_init()
{
}
void anal::rx_init()
{
phaseacc = 0;
put_MODEstatus(mode);
}
void anal::init()
{
modem::init();
rx_init();
set_scope_mode(Digiscope::RTTY);
rxcorr = progdefaults.RX_corr;
}
anal::~anal()
{
delete bpfilt;
delete ffilt;
delete afilt;
progdefaults.RX_corr = rxcorr;
}
// used for checking file exists function
#define F_OK 0
void anal::createfilename()
{
// Function to find or create the working directory [if not exist yet]
// also creates the filename that should be open for today's date [w and w/o full path]
// Create embedded date YYMMDD for file creation naming
time_t now = time(NULL);
gmtime_r(&now, &File_Start_Date);
// create the embedded filename date image as YYMMDD
strftime((char*)FileDate,sizeof(FileDate),"%y%m%d", &File_Start_Date);
// create the embedded file date image as YYYY-MM-DD
strftime((char*)FileData,sizeof(FileData),"%Y-%m-%d", &File_Start_Date);
// create the new analysis file name only
OpenAnalalysisFile.assign("analysis_").append(FileDate).append(".csv");
// Full name with path
// Added new file naming and storage by N8OBJ 5-7-19
analysisFilename.assign(AnalysisDir).append(OpenAnalalysisFile);
}
void anal::restart()
{
double fhi = ANAL_BW * 1.1 / samplerate;
double flo = 0.0;
if (bpfilt)
bpfilt->create_filter(flo, fhi);
else
bpfilt = new fftfilt(flo, fhi, 2048);
set_bandwidth(ANAL_BW);
ffilt->reset();
afilt->reset();
elapsed = 0.0;
fout = 0.0;
wf_freq = frequency;
if (clock_gettime(CLOCK_REALTIME, &start_time) == -1) {
LOG_PERROR("clock_gettime");
abort();
}
passno = 0;
dspcnt = DSP_CNT;
for (int i = 0; i < PIPE_LEN; i++) pipe[i] = 0;
if (write_to_csv) stop_csv();
start_csv();
}
anal::anal()
{
mode = MODE_ANALYSIS;
samplerate = ANAL_SAMPLERATE;
bpfilt = (fftfilt *)0;
ffilt = new Cmovavg(FILT_LEN * samplerate);
afilt = new Cmovavg(FILT_LEN * samplerate);
createfilename();
cap &= ~CAP_TX;
write_to_csv = false;
restart();
}
void anal::clear_syncscope()
{
set_scope(0, 0, false);
}
cmplx anal::mixer(cmplx in)
{
cmplx z = cmplx( cos(phaseacc), sin(phaseacc)) * in;
phaseacc -= TWOPI * frequency / samplerate;
if (phaseacc < 0) phaseacc += TWOPI;
return z;
}
void anal::start_csv()
{
std::string InfoPathname(AnalysisDir);
InfoPathname.append("info.txt");
createfilename();
//Open the data file for creation (write) operation
//first check to see if already created
if (fl_access(analysisFilename.c_str(), F_OK) == 0) { // file exists! - use it and keep adding to it
// indicate in status line that file write in progress
write_to_csv = true; //say to do writes to file
} else {
FILE *out = fl_fopen(analysisFilename.c_str(), "w"); //create new data file
if (unlikely(!out)) {
LOG_PERROR("fl_fopen");
return;
}
std::string InfoText;
std::ifstream InfoTextFile( InfoPathname.c_str() );
if (InfoTextFile.is_open()) {
// files exists, obtain info in text file
getline (InfoTextFile, InfoText);
InfoTextFile.close();
// since file exists, write out full ISO date as first element of todays header
// along with the contents of info.txt for 1st line of header info
fprintf(out, "%s, %s\n", FileData, InfoText.c_str());
}
// Always write out the normal column header to the new .csv file
fprintf(out, "UTC, Freq, Freq Err, Vpk, dBV(Vpk)\n");
fclose(out);
write_to_csv = true;
}
}
void anal::stop_csv()
{
write_to_csv = false;
put_status("");
}
void anal::writeFile()
{
if (!write_to_csv) return;
time_t now = time(NULL);
struct tm tm;
// put check for date rollover here
gmtime_r(&now, &tm);
char DateNow [10];
// Create embedded date stamp in the YYMMDD format
strftime((char*)DateNow,sizeof(DateNow),"%y%m%d", &tm);
// printf("Date now is =%s\n",DateNow); //diag printout
// check if date rolled over
if (tm.tm_mday != File_Start_Date.tm_mday)
{
start_csv();
}
FILE *out = fl_fopen(analysisFilename.c_str(), "a");
if (unlikely(!out)) {
LOG_PERROR("fl_fopen");
return;
}
// N8OBJ 5-7-19 changed 8.3f to 8.6f (more decimal places on signal strength - show uV level)
// Changed /added new .csv fields
// header is: fprintf(out, "UTC,Freq,Freq Err,Vpk,dBV(Vpk)\n");
fprintf(out, "%02d:%02d:%02d, %13.3f, %6.3f, %8.6f, %6.2f\n",
tm.tm_hour, tm.tm_min, tm.tm_sec,
(wf->rfcarrier() + (wf->USB() ? 1.0 : -1.0) * (frequency + fout) + progdefaults.RIT), fout + progdefaults.RIT,
amp, 20.0 * log10( (amp == 0 ? 1e-6 : amp) ) );
fclose(out);
char TimeNow[9];
snprintf( TimeNow, sizeof(TimeNow), "%02d:%02d:%02d", tm.tm_hour, tm.tm_min, tm.tm_sec );
put_Status1( TimeNow, 5, STATUS_CLEAR);
char StatusMsg [80];
sprintf( StatusMsg, "File: %s", OpenAnalalysisFile.c_str());
put_status(StatusMsg);
}
int anal::rx_process(const double *buf, int len)
{
cmplx z, *zp;
double fin;
int n = 0;
if (wf_freq != frequency) {
restart();
set_scope(pipe, PIPE_LEN, false);
}
for (int i = 0; i < len; i++) {
// create analytic signal from sound card input samples
z = cmplx( *buf, *buf );
buf++;
// mix it with the audio carrier frequency to create a baseband signal
z = mixer(z);
// low pass filter using Windowed Sinc - Overlap-Add convolution filter
n = bpfilt->run(z, &zp);
if (n) {
for (int j = 0; j < n; j++) {
// measure phase difference between successive samples to determine
// the frequency of the baseband signal (+anal_baud or -anal_baud)
// see class cmplx definiton for operator %
fin = arg( conj(prevsmpl) * zp[j] ) * samplerate / TWOPI;
prevsmpl = zp[j];
// filter using moving average filter
fout = ffilt->run(fin);
amp = afilt->run(abs(zp[j]));
}
} //else prevsmpl = z;
}
if (passno++ > 10) {
dspcnt -= (1.0 * n / samplerate);
if (dspcnt <= 0) {
for (int i = 0; i < PIPE_LEN -1; i++)
pipe[i] = pipe[i+1];
double fdsp = fout / 4.0;
if (fabs(fdsp) < 2.6) {
elapsed += DSP_CNT - dspcnt;
pipe[PIPE_LEN - 1] = fout / 4.0;
set_scope(pipe, PIPE_LEN, false);
if (wf->USB())
snprintf(msg1, sizeof(msg1), "%13.3f", wf->rfcarrier() + frequency + fout + progdefaults.RIT);
else
snprintf(msg1, sizeof(msg1), "%13.3f", wf->rfcarrier() - frequency - fout + progdefaults.RIT);
put_Status2(msg1, 2.0);
writeFile();
}
// reset the display counter & the pipe pointer
dspcnt = DSP_CNT;
}
}
return 0;
}
//=====================================================================
// anal transmit
//=====================================================================
int anal::tx_process()
{
return -1;
}
| 8,219
|
C++
|
.cxx
| 268
| 28.514925
| 113
| 0.663919
|
w1hkj/fldigi
| 109
| 27
| 38
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
751,045
|
wwv.cxx
|
w1hkj_fldigi/src/wwv/wwv.cxx
|
// ----------------------------------------------------------------------------
// wwv.cxx -- wwv monitoring modem
//
// Copyright (C) 2006-2009
// Dave Freese, W1HKJ
//
// This file is part of fldigi.
//
// Fldigi 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 3 of the License, or
// (at your option) any later version.
//
// Fldigi 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 fldigi. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
//
// This modem is only used for reception of WWV "tick" signals to determine
// the correction factor to be applied to the sound card oscillator.
#include <config.h>
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <string.h>
#include "wwv.h"
#include "fl_digi.h"
void wwv::tx_init()
{
phaseacc = 0;
}
void wwv::rx_init()
{
phaseacc = 0.0;
smpl_ctr = 0; // sample counter for timing wwv rx
agc = 0.0; // threshold for tick detection
ticks = 0;
calc = false;
zoom = false;
set_scope_mode(Digiscope::WWV);
put_MODEstatus(mode);
}
void wwv::init()
{
modem::init();
rx_init();
}
wwv::~wwv() {
if (hilbert) delete hilbert;
if (lpfilter) delete lpfilter;
if (vidfilter) delete vidfilter;
}
wwv::wwv() : modem()
{
double lp;
mode = MODE_WWV;
frequency = 1000;
bandwidth = 200;
samplerate = 8000;
// phase increment expected at the tick freq
phaseincr = 2.0 * M_PI * frequency / samplerate;
hilbert = new C_FIR_filter();
hilbert->init_hilbert(37, 1);
lp = 0.5 * bandwidth / samplerate;
lpfilter = new C_FIR_filter();
lpfilter->init_lowpass (FIRLEN_1, DEC_1, lp);
vidfilter = new Cmovavg(16);
makeaudio();
}
//=======================================================================
//update_syncscope()
//Routine called to update the display on the sync scope display.
//For wwv this is video signal much like a FAX display
//=======================================================================
//
void wwv::update_syncscope()
{
double max = 0, min = 1e6, range;
for (int i = 0; i < 1000; i++ ) {
if (max < buffer[i]) max = buffer[i];
if (min > buffer[i]) min = buffer[i];
}
range = max - min;
for (int i = 0; i < 1000; i++ ) {
buffer[i] = 255*(buffer[i] - min) / range;
}
if (zoom)
set_video(&buffer[400], 200);
else
set_video(buffer, 1000);
buffer.next(); // change buffers
}
//=====================================================================
// wwv_rxprocess()
// Called with a block (512 samples) of audio.
// Nominal sound card sampling rate is set to 8000 Hz
//=======================================================================
int wwv::rx_process(const double *buf, int len)
{
cmplx z, znco;
while (len-- > 0) {
z = cmplx ( *buf, *buf );
buf++;
hilbert->run(z, z);
znco = cmplx ( cos(phaseacc), sin(phaseacc) );
z = znco * z;
phaseacc += phaseincr;
if (phaseacc > TWOPI) phaseacc -= TWOPI;
if (lpfilter->run ( z, z )) {
buffer[smpl_ctr % 1000] = vidfilter->run( abs(z) );
if (++smpl_ctr >= 1000) {
update_syncscope();
smpl_ctr = 0;
}
}
}
return 0;
}
void wwv::set1(int x, int y)
{
int zfactor = 500;
if (zoom) zfactor = 100;
smpl_ctr -= ((2*x - y) * zfactor) / y;
if (smpl_ctr < 0) smpl_ctr += 1000;
if (smpl_ctr > 1000) smpl_ctr -= 1000;
}
char strPPM[20];
void wwv::set2(int x, int y)
{
zoom = !zoom;
}
//======================================================================
// transmit time tick
//======================================================================
void wwv::makeshape()
{
for (int i = 0; i < 32; i++)
keyshape[i] = 0.5 * (1.0 - cos (M_PI * i / 32));
}
double wwv::nco(double freq)
{
phaseacc += 2.0 * M_PI * freq / samplerate;
if (phaseacc > M_PI)
phaseacc -= 2.0 * M_PI;
return sin(phaseacc);
}
void wwv::makeaudio()
{
phaseacc = 0.0;
makeshape();
for (int i = 0; i < 400; i++) {
audio[i] = (i < 200 ? nco(1000) : 0);
quiet[i] = 0;
}
for (int i = 0; i < 32; i++) {
audio[i] *= keyshape[i];
audio[199 - i] *= keyshape[i];
}
}
int wwv::tx_process()
{
static int cycle = 4;
int c = get_tx_char();
if (c == GET_TX_CHAR_ETX || stopflag) {
stopflag = false;
return -1;
}
if (--cycle == 0) {
memcpy(play, audio, 400 * sizeof(double));
ModulateXmtr(play, 400);
cycle = 4;
} else
ModulateXmtr(quiet, 400);
ModulateXmtr(quiet, 400);
ModulateXmtr(quiet, 400);
ModulateXmtr(quiet, 400);
ModulateXmtr(quiet, 400);
return 0;
}
| 4,860
|
C++
|
.cxx
| 183
| 24.622951
| 79
| 0.576691
|
w1hkj/fldigi
| 109
| 27
| 38
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
751,046
|
throb.cxx
|
w1hkj_fldigi/src/throb/throb.cxx
|
// ----------------------------------------------------------------------------
// throb.cxx -- throb modem
//
// Copyright (C) 2006-2010
// Dave Freese, W1HKJ
// ThrobX additions by Joe Veldhuis, KD8ATU
//
// This file is part of fldigi. Adapted from code contained in gmfsk source code
// distribution.
// gmfsk Copyright (C) 2001, 2002, 2003
// Tomi Manninen (oh2bns@sral.fi)
//
// This file is part of fldigi.
//
// Fldigi 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 3 of the License, or
// (at your option) any later version.
//
// Fldigi 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 fldigi. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include <config.h>
#include <stdlib.h>
#include <iostream>
#include "throb.h"
#include "ascii.h"
#include "configuration.h"
#include "fl_digi.h"
#include "status.h"
#define MAX_TONES 15
#undef CLAMP
#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x)))
char throbmsg[80];
void throb::tx_init()
{
preamble = 4;
reset_syms();
videoText();
}
void throb::rx_init()
{
rxcntr = rxsymlen;
waitsync = 1;
deccntr = 0;
symptr = 0;
shift = 0;
lastchar = '\0';
reset_syms();
put_MODEstatus(mode);
}
void throb::init()
{
modem::init();
rx_init();
set_scope_mode(Digiscope::SCOPE);
if (progdefaults.StartAtSweetSpot)
set_freq(progdefaults.PSKsweetspot);
else if (progStatus.carrier != 0) {
set_freq(progStatus.carrier);
#if !BENCHMARK_MODE
progStatus.carrier = 0;
#endif
} else
set_freq(wf->Carrier());
}
throb::~throb()
{
if (hilbert) delete hilbert;
if (syncfilt) delete syncfilt;
if (fftfilter) delete fftfilter;
if (snfilter) delete snfilter;
if (scope_data) delete [] scope_data;
if (txpulse) delete [] txpulse;
if (outbuf) delete[] outbuf;
for (int i = 0; i < num_tones; i++)
if (rxtone[i]) delete [] rxtone[i];
}
void throb::flip_syms() //call this whenever a space or idle is sent or received
{
switch(mode) {
case MODE_THROBX1:
case MODE_THROBX2:
case MODE_THROBX4:
if (idlesym == 0) {
idlesym = 1;
spacesym = 0;
} else {
idlesym = 0;
spacesym = 1;
}
break;
default:
//if we're not running a ThrobX mode, do nothing
break;
}
}
void throb::reset_syms() //call when switching from TX to RX or vice versa
{
switch(mode) {
case MODE_THROBX1:
case MODE_THROBX2:
case MODE_THROBX4:
idlesym = 0;
spacesym = 1;
break;
default: //paranoia
idlesym = 0;
spacesym = 44;
break;
}
}
throb::throb(trx_mode throb_mode) : modem()
{
cap |= CAP_AFC | CAP_REV;
double bw;
double *fp = 0;
mode = throb_mode;
switch (mode) {
case MODE_THROB1:
symlen = SYMLEN_1;
txpulse = mk_semi_pulse(symlen);
fp = mk_semi_pulse(symlen / DOWN_SAMPLE);
num_tones = 9;
num_chars = 45;
idlesym = 0;
spacesym = 44;
for (int i = 0; i < num_tones; i++)
freqs[i] = ThrobToneFreqsNar[i];
bw = 36.0 / THROB_SAMPLE_RATE;
break;
case MODE_THROB2:
symlen = SYMLEN_2;
txpulse = mk_semi_pulse(symlen);
fp = mk_semi_pulse(symlen / DOWN_SAMPLE);
num_tones = 9;
num_chars = 45;
idlesym = 0;
spacesym = 44;
for (int i = 0; i < num_tones; i++)
freqs[i] = ThrobToneFreqsNar[i];
bw = 36.0 / THROB_SAMPLE_RATE;
break;
case MODE_THROB4:
default:
symlen = SYMLEN_4;
txpulse = mk_full_pulse(symlen);
fp = mk_full_pulse(symlen / DOWN_SAMPLE);
num_tones = 9;
num_chars = 45;
idlesym = 0;
spacesym = 44;
for (int i = 0; i < num_tones; i++)
freqs[i] = ThrobToneFreqsWid[i];
bw = 72.0 / THROB_SAMPLE_RATE;
break;
case MODE_THROBX1:
symlen = SYMLEN_1;
txpulse = mk_semi_pulse(symlen);
fp = mk_semi_pulse(symlen / DOWN_SAMPLE);
num_tones = 11;
num_chars = 55;
idlesym = 0;
spacesym = 1;
for (int i = 0; i < num_tones; i++)
freqs[i] = ThrobXToneFreqsNar[i];
bw = 47.0 / THROB_SAMPLE_RATE;
break;
case MODE_THROBX2:
symlen = SYMLEN_2;
txpulse = mk_semi_pulse(symlen);
fp = mk_semi_pulse(symlen / DOWN_SAMPLE);
num_tones = 11;
num_chars = 55;
idlesym = 0;
spacesym = 1;
for (int i = 0; i < num_tones; i++)
freqs[i] = ThrobXToneFreqsNar[i];
bw = 47.0 / THROB_SAMPLE_RATE;
break;
case MODE_THROBX4: //NONSTANDARD
symlen = SYMLEN_4;
txpulse = mk_full_pulse(symlen);
fp = mk_full_pulse(symlen / DOWN_SAMPLE);
num_tones = 11;
num_chars = 55;
idlesym = 0;
spacesym = 1;
for (int i = 0; i < num_tones; i++)
freqs[i] = ThrobXToneFreqsWid[i];
bw = 94.0 / THROB_SAMPLE_RATE;
break;
}
outbuf = new double[symlen];
rxsymlen = symlen / DOWN_SAMPLE;
hilbert = new C_FIR_filter();
hilbert->init_hilbert(37, 1);
fftfilter = new fftfilt(0, bw, FilterFFTLen);
syncfilt = new C_FIR_filter();
syncfilt->init(symlen / DOWN_SAMPLE, 1, fp, NULL);
delete [] fp;
snfilter = new Cmovavg(16);
for (int i = 0; i < num_tones; i++)
rxtone[i] = mk_rxtone(freqs[i], txpulse, symlen);
reverse = 0;
samplerate = THROB_SAMPLE_RATE;
fragmentsize = symlen;
bandwidth = freqs[num_tones - 1] - freqs[0];
syncpos = 0.5;
scope_data = new double [SCOPE_DATA_LEN];
phaseacc = 0.0;
metric = 0.0;
symptr = 0;
for (int i = 0; i < MAX_RX_SYMLEN; i++)
syncbuf[i] = dispbuf[i] = 0.0;
// init();
}
//=====================================================================
// receive processing
//=====================================================================
// Make a 32 times down sampled cmplx prototype tone for rx.
cmplx *throb::mk_rxtone(double freq, double *pulse, int len)
{
cmplx *tone;
double x;
int i;
tone = new cmplx [len / DOWN_SAMPLE];
for (i = 0; i < len; i += DOWN_SAMPLE) {
x = -2.0 * M_PI * freq * i / THROB_SAMPLE_RATE;
tone[i / DOWN_SAMPLE] =
cmplx ( pulse[i] * cos(x), pulse[i] * sin(x) );
}
return tone;
}
cmplx throb::mixer(cmplx in)
{
double f;
cmplx z (cos(phaseacc), sin(phaseacc));
z = z * in;
f = frequency;
phaseacc -= 2.0 * M_PI * f / THROB_SAMPLE_RATE;
if (phaseacc < 0) phaseacc += TWOPI;
return z;
}
int throb::findtones(cmplx *word, int &tone1, int &tone2)
{
double max1, max2;
int maxtone, i;
max1 = 0;
tone1 = 0;
for (i = 0; i < num_tones; i++) {
if ( abs(word[i]) > max1 ) {
max1 = abs(word[i]);
tone1 = i;
}
}
maxtone = tone1;
max2 = 0;
tone2 = 0;
for (i = 0; i < num_tones; i++) {
if (i == tone1)
continue;
if ( abs(word[i]) > max2) {
max2 = abs(word[i]);
tone2 = i;
}
}
//handle single-tone symbols (Throb only)
if (mode == MODE_THROB1 ||
mode == MODE_THROB2 ||
mode == MODE_THROB4)
if (max1 > max2 * 2)
tone2 = tone1;
if (tone1 > tone2) {
i = tone1;
tone1 = tone2;
tone2 = i;
}
signal = noise = 0.0;
for (i = 0; i < num_tones; i++) {
if ( i == tone1 || i == tone2)
signal += abs(word[i]) / 2.0;
else
noise += abs(word[i]) / (num_tones - 2.0);
}
metric = snfilter->run( signal / (noise + 1e-6));
s2n = CLAMP( 10.0*log10( metric ) - 3.0, 0.0, 100.0);
return maxtone;
}
void throb::show_char(int c) {
if (metric > progStatus.sldrSquelchValue || progStatus.sqlonoff == false)
put_rx_char(progdefaults.rx_lowercase ? tolower(c) : c);
}
void throb::decodechar(int tone1, int tone2)
{
int i;
switch(mode) {
case MODE_THROB1:
case MODE_THROB2:
case MODE_THROB4:
if (shift == true) {
if (tone1 == 0 && tone2 == 8)
show_char('?');
if (tone1 == 1 && tone2 == 7)
show_char('@');
if (tone1 == 2 && tone2 == 6)
show_char('=');
if (tone1 == 4 && tone2 == 4)
show_char('\n');
shift = false;
return;
}
if (tone1 == 3 && tone2 == 5) {
shift = true;
return;
}
for (i = 0; i < num_chars; i++) {
if (ThrobTonePairs[i][0] == tone1 + 1 &&
ThrobTonePairs[i][1] == tone2 + 1) {
show_char(ThrobCharSet[i]);
break;
}
}
break;
//ThrobX mode. No shifted case, but idle and space symbols alternate
default:
for (i = 0; i < num_chars; i++) {
if (ThrobXTonePairs[i][0] == tone1 + 1 && ThrobXTonePairs[i][1] == tone2 + 1) {
if (i == spacesym || i == idlesym) {
if (lastchar != '\0' && lastchar != ' ') {
show_char(ThrobXCharSet[1]);
lastchar = ' ';
}
else {
lastchar = '\0';
}
flip_syms();
} else {
show_char(ThrobXCharSet[i]);
lastchar = ThrobXCharSet[i];
}
}
}
break;
}
return;
}
void throb::rx(cmplx in)
{
cmplx rxword[MAX_TONES];
int i, tone1, tone2, maxtone;
symbol[symptr] = in;
if (rxcntr > 0.0)
return;
// correlate against all tones
for (i = 0; i < num_tones; i++)
rxword[i] = cmac(rxtone[i], symbol, symptr + 1, rxsymlen);
// find the strongest tones
maxtone = findtones(rxword, tone1, tone2);
// decode
if (reverse)
decodechar (num_tones - 1 - tone2, num_tones - 1 - tone1);
else
decodechar (tone1, tone2);
if (progStatus.afconoff == true && (metric >= progStatus.sldrSquelchValue || progStatus.sqlonoff == false)) {
cmplx z1, z2;
double f;
z1 = rxword[maxtone];
z2 = cmac(rxtone[maxtone], symbol, symptr + 2, rxsymlen);
f = arg( conj(z1) * z2 ) / (2 * DOWN_SAMPLE * M_PI / THROB_SAMPLE_RATE);
f -= freqs[maxtone];
set_freq(frequency + f / (num_tones - 1));
}
/* done with this symbol, start over */
rxcntr = rxsymlen;
waitsync = 1;
snprintf(throbmsg, sizeof(throbmsg), "S/N: %3d dB", (int)(floor(s2n)));
put_Status1(throbmsg);
display_metric(metric);
}
void throb::sync(cmplx in)
{
double f, maxval = 0;
double mag;
int i, maxpos = 0;
/* "rectify", filter and store input */
mag = abs(in);
syncfilt->Irun( mag, f);
syncbuf[symptr] = f;
/* check counter if we are waiting for sync */
if (waitsync == 0 || rxcntr > (rxsymlen / 2.0))
return;
for (i = 0; i < rxsymlen; i++) {
f = syncbuf[(i + symptr + 1) % rxsymlen];
dispbuf[i] = f;
}
for (i = 0; i < rxsymlen; i++) {
if (dispbuf[i] > maxval) {
maxpos = i;
maxval = dispbuf[i];
}
}
/* correct sync */
rxcntr += (maxpos - rxsymlen / 2) / (num_tones - 1);
waitsync = 0;
if (metric >= progStatus.sldrSquelchValue || progStatus.sqlonoff == false)
set_scope(dispbuf, rxsymlen);
else {
dispbuf[0] = 0.0;
set_scope(dispbuf, 1);
}
dispbuf.next(); // change buffers
}
int throb::rx_process(const double *buf, int len)
{
cmplx z, *zp;
int i, n;
while (len-- > 0) {
z = cmplx( *buf, *buf );
buf++;
hilbert->run(z, z);
z = mixer(z);
n = fftfilter->run(z, &zp);
/* DOWN_SAMPLE by 32 and push to the receiver */
for (i = 0; i < n; i++) {
if (++deccntr >= DOWN_SAMPLE) {
rxcntr -= 1.0;
/* do symbol sync */
sync(zp[i]);
/* decode */
rx(zp[i]);
symptr = (symptr + 1) % rxsymlen;
deccntr = 0;
}
}
}
return 0;
}
//=====================================================================
// transmit processing
//=====================================================================
double *throb::mk_semi_pulse(int len)
{
double *pulse, x;
int i, j;
pulse = new double [len];
for (i = 0; i < len; i++) {
if (i < len / 5) {
x = M_PI * i / (len / 5.0);
pulse[i] = 0.5 * (1 - cos(x));
}
if (i >= len / 5 && i < len * 4 / 5)
pulse[i] = 1.0;
if (i >= len * 4 / 5) {
j = i - len * 4 / 5;
x = M_PI * j / (len / 5.0);
pulse[i] = 0.5 * (1 + cos(x));
}
}
return pulse;
}
double *throb::mk_full_pulse(int len)
{
double *pulse;
int i;
pulse = new double [len];
for (i = 0; i < len; i++)
pulse[i] = 0.5 * (1 - cos(2 * M_PI * i / len));
return pulse;
}
void throb::send(int symbol)
{
int tone1, tone2;
double w1, w2;
int i;
if (symbol < 0 || symbol >= num_chars)
return;
switch(mode) {
case MODE_THROB1:
case MODE_THROB2:
case MODE_THROB4:
tone1 = ThrobTonePairs[symbol][0] - 1;
tone2 = ThrobTonePairs[symbol][1] - 1;
break;
default:
tone1 = ThrobXTonePairs[symbol][0] -1;
tone2 = ThrobXTonePairs[symbol][1] -1;
break;
}
if (reverse) {
tone1 = (num_tones - 1) - tone1;
tone2 = (num_tones - 1) - tone2;
}
w1 = 2.0 * M_PI * (get_txfreq_woffset() + freqs[tone1]) / THROB_SAMPLE_RATE;
w2 = 2.0 * M_PI * (get_txfreq_woffset() + freqs[tone2]) / THROB_SAMPLE_RATE;
for (i = 0; i < symlen; i++)
outbuf[i] = txpulse[i] *
(sin(w1 * i) + sin(w2 * i)) / 2.0;
ModulateXmtr(outbuf, symlen);
}
int throb::tx_process()
{
modem::tx_process();
int i, c, sym;
if (preamble > 0) {
send(idlesym); /* send idle throbs */
flip_syms();
preamble--;
return 0;
}
c = get_tx_char();
// end of transmission
if (c == GET_TX_CHAR_ETX || stopflag) {
send(idlesym);
// reset_syms(); //prepare RX. idle/space syms always start as 0 and 1, respectively.
return -1;
}
// TX buffer empty
if (c == GET_TX_CHAR_NODATA) {
send(idlesym); /* send idle throbs */
flip_syms();
return 0;
}
switch(mode) {
case MODE_THROB1:
case MODE_THROB2:
case MODE_THROB4:
/* handle the special cases first, if we're doing regular Throb */
switch (c) {
case '?':
send(5); /* shift */
send(20);
put_echo_char(c);
return 0;
case '@':
send(5); /* shift */
send(13);
put_echo_char(c);
return 0;
case '-':
send(5); /* shift */
send(9);
put_echo_char(c);
return 0;
case '\r':
return 0;
case '\n':
send(5); /* shift */
send(0);
put_echo_char(c);
return 0;
default:
break;
}
break;
default:
//If we're doing ThrobX, no need to handle shifts
break;
}
/* map lower case character to upper case */
if (islower(c))
c = toupper(c);
/* see if the character can be found in our character set */
switch(mode) {
case MODE_THROB1:
case MODE_THROB2:
case MODE_THROB4:
for (sym = -1, i = 0; i < num_chars; i++)
if (c == ThrobCharSet[i])
sym = i;
break;
default:
for (sym = -1, i = 0; i < num_chars; i++)
if (c == ThrobXCharSet[i])
sym = i;
break;
}
// send a space for unknown chars
if (sym == -1) c = ' ';
// handle spaces for throbx
if (c == ' ') {
sym = spacesym;
flip_syms();
}
send(sym);
put_echo_char(progdefaults.rx_lowercase ? tolower(c) : c);
return 0;
}
//=====================================================================
// throb static declarations
//=====================================================================
int throb::ThrobTonePairs[45][2] = {
{5, 5}, /* idle... no print */
{4, 5}, /* A */
{1, 2}, /* B */
{1, 3}, /* C */
{1, 4}, /* D */
{4, 6}, /* SHIFT (was E) */
{1, 5}, /* F */
{1, 6}, /* G */
{1, 7}, /* H */
{3, 7}, /* I */
{1, 8}, /* J */
{2, 3}, /* K */
{2, 4}, /* L */
{2, 8}, /* M */
{2, 5}, /* N */
{5, 6}, /* O */
{2, 6}, /* P */
{2, 9}, /* Q */
{3, 4}, /* R */
{3, 5}, /* S */
{1, 9}, /* T */
{3, 6}, /* U */
{8, 9}, /* V */
{3, 8}, /* W */
{3, 3}, /* X */
{2, 2}, /* Y */
{1, 1}, /* Z */
{3, 9}, /* 1 */
{4, 7}, /* 2 */
{4, 8}, /* 3 */
{4, 9}, /* 4 */
{5, 7}, /* 5 */
{5, 8}, /* 6 */
{5, 9}, /* 7 */
{6, 7}, /* 8 */
{6, 8}, /* 9 */
{6, 9}, /* 0 */
{7, 8}, /* , */
{7, 9}, /* . */
{8, 8}, /* ' */
{7, 7}, /* / */
{6, 6}, /* ) */
{4, 4}, /* ( */
{9, 9}, /* E */
{2, 7} /* space */
};
int throb::ThrobXTonePairs[55][2] = {
{6, 11}, /* idle (initially) */
{1, 6}, /* space (initially) */
{2, 6}, /* A */
{2, 5}, /* B */
{2, 7}, /* C */
{2, 8}, /* D */
{5, 6}, /* E */
{2, 9}, /* F */
{2, 10}, /* G */
{4, 8}, /* H */
{4, 6}, /* I */
{2, 11}, /* J */
{3, 4}, /* K */
{3, 5}, /* L */
{3, 6}, /* M */
{6, 9}, /* N */
{6, 10}, /* O */
{3, 7}, /* P */
{3, 8}, /* Q */
{3, 9}, /* R */
{6, 8}, /* S */
{6, 7}, /* T */
{3, 10}, /* U */
{3, 11}, /* V */
{4, 5}, /* W */
{4, 7}, /* X */
{4, 9}, /* Y */
{4, 10}, /* Z */
{1, 2}, /* 1 */
{1, 3}, /* 2 */
{1, 4}, /* 3 */
{1, 5}, /* 4 */
{1, 7}, /* 5 */
{1, 8}, /* 6 */
{1, 9}, /* 7 */
{1, 10}, /* 8 */
{2, 3}, /* 9 */
{2, 4}, /* 0 */
{4, 11}, /* , */
{5, 7}, /* . */
{5, 8}, /* ' */
{5, 9}, /* / */
{5, 10}, /* ) */
{5, 11}, /* ( */
{7, 8}, /* # */
{7, 9}, /* " */
{7, 10}, /* + */
{7, 11}, /* - */
{8, 9}, /* ; */
{8, 10}, /* : */
{8, 11}, /* ? */
{9, 10}, /* ! */
{9, 11}, /* @ */
{10, 11}, /* = */
{1, 11} /* cr */ //FIXME: !!COMPLETELY NONSTANDARD!!
};
unsigned char throb::ThrobCharSet[45] = {
'\0', /* idle */
'A',
'B',
'C',
'D',
'\0', /* shift */
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'0',
',',
'.',
'\'',
'/',
')',
'(',
'E',
' '
};
unsigned char throb::ThrobXCharSet[55] = {
'\0', /* idle (initially) */
' ', /* space (initially) */
'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',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'0',
',',
'.',
'\'',
'/',
')',
'(',
'#',
'"',
'+',
'-',
';',
':',
'?',
'!',
'@',
'=',
'\n'
};
double throb::ThrobToneFreqsNar[9] = {-32, -24, -16, -8, 0, 8, 16, 24, 32};
double throb::ThrobToneFreqsWid[9] = {-64, -48, -32, -16, 0, 16, 32, 48, 64};
double throb::ThrobXToneFreqsNar[11] = {-39.0625, -31.25, -23.4375, -15.625, -7.8125, 0, 7.8125, 15.625, 23.4375, 31.25, 39.0625};
double throb::ThrobXToneFreqsWid[11] = {-78.125, -62.5, -46.875, -31.25, -15.625, 0, 15.625, 31.25, 46.875, 62.5, 78.125};
| 19,835
|
C++
|
.cxx
| 808
| 20.513614
| 130
| 0.483193
|
w1hkj/fldigi
| 109
| 27
| 38
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
751,047
|
trx.cxx
|
w1hkj_fldigi/src/trx/trx.cxx
|
// ----------------------------------------------------------------------------
// trx.cxx -- Main transmit/receive control loop / thread
//
// Copyright (C) 2006-2010
// Dave Freese, W1HKJ
// Copyright (C) 2007-2010
// Stelios Bounanos, M0GLD
//
// This file is part of fldigi. Adapted in part from code contained in gmfsk
// source code distribution.
//
// Fldigi 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 3 of the License, or
// (at your option) any later version.
//
// Fldigi 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 fldigi. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include <config.h>
#include <sys/time.h>
#include <fcntl.h>
#include <semaphore.h>
#include <cstdlib>
#include <string>
#include <string.h>
#include "trx.h"
#include "main.h"
#include "fl_digi.h"
#include "ascii.h"
#include "misc.h"
#include "configuration.h"
#include "status.h"
#include "dtmf.h"
#include "soundconf.h"
#include "ringbuffer.h"
#include "qrunner.h"
#include "debug.h"
#include "nullmodem.h"
#include "macros.h"
#include "rigsupport.h"
#include "psm/psm.h"
#include "icons.h"
#include "fft-monitor.h"
#include "audio_alert.h"
extern fftmon *fft_modem;
#include "spectrum_viewer.h"
#if BENCHMARK_MODE
# include "benchmark.h"
#endif
LOG_FILE_SOURCE(debug::LOG_MODEM);
void trx_reset_loop();
void trx_start_modem_loop();
void trx_receive_loop();
void trx_transmit_loop();
void trx_tune_loop();
static void trx_signal_state(void);
//#define DEBUG
/* ---------------------------------------------------------------------- */
static sem_t* trx_sem;
static pthread_t trx_thread;
state_t trx_state;
modem *active_modem = 0;
cRsId *ReedSolomon = 0;
cDTMF *dtmf = 0;
SoundBase *RXscard = 0;
bool RXsc_is_open = false;
bool TXsc_is_open = false;
SoundBase *TXscard = 0;
static int current_RXsamplerate = 0;
static int current_TXsamplerate = 0;
static int _trx_tune;
// Ringbuffer for the audio "history". A pointer into this buffer
// is also passed to the waterfall signal drawing routines.
#define NUMMEMBUFS 1024
static ringbuffer<double> trxrb(ceil2(NUMMEMBUFS * SCBLOCKSIZE));
static float fbuf[SCBLOCKSIZE];
bool bHistory = false;
bool bHighSpeed = false;
static double hsbuff[SCBLOCKSIZE];
static bool trxrunning = false;
extern bool trx_inhibit;
bool rx_only = false;
#include "tune.cxx"
//=============================================================================
// Draws the xmit data one WF_BLOCKSIZE-sized block at a time
static void trx_xmit_wfall_draw(int samplerate)
{
ENSURE_THREAD(TRX_TID);
ringbuffer<double>::vector_type rv[2];
rv[0].buf = 0;
rv[1].buf = 0;
#define block_read_(vec_) \
while (vec_.len >= WF_BLOCKSIZE) { \
wf->sig_data(vec_.buf, WF_BLOCKSIZE); \
REQ(&waterfall::handle_sig_data, wf); \
vec_.len -= WF_BLOCKSIZE; \
vec_.buf += WF_BLOCKSIZE; \
trxrb.read_advance(WF_BLOCKSIZE); \
}
trxrb.get_rv(rv);
block_read_(rv[0]); // read blocks from the first vector
if (rv[0].len + rv[1].len < WF_BLOCKSIZE)
return;
if (rv[0].len == 0)
block_read_(rv[1]);
#undef block_read_
// read non-contiguous data into tmp buffer so that we can
// still draw it one block at a time
if (unlikely(trxrb.read_space() >= WF_BLOCKSIZE)) {
double buf[WF_BLOCKSIZE];
do {
trxrb.read(buf, WF_BLOCKSIZE);
wf->sig_data(buf, WF_BLOCKSIZE);
REQ(&waterfall::handle_sig_data, wf);
} while (trxrb.read_space() >= WF_BLOCKSIZE);
}
}
// Called by trx_trx_transmit_loop() to handle data that may be left in the
// ringbuffer when we stop transmitting. Will pad with zeroes to a multiple of
// WF_BLOCKSIZE.
static void trx_xmit_wfall_end(int samplerate)
{
ENSURE_THREAD(TRX_TID);
size_t pad = WF_BLOCKSIZE - trxrb.read_space() % WF_BLOCKSIZE;
if (pad == WF_BLOCKSIZE) // rb empty or multiple of WF_BLOCKSIZE
return;
ringbuffer<double>::vector_type wv[2];
wv[0].buf = wv[1].buf = 0;
trxrb.get_wv(wv, pad);
assert(wv[0].len + wv[1].len == pad);
if (likely(wv[0].len)) { // fill first vector, write rest to second vector
memset(wv[0].buf, 0, wv[0].len * sizeof(*wv[0].buf));
if (pad > wv[0].len)
memset(wv[1].buf, 0, (pad - wv[0].len) * sizeof(*wv[1].buf));
}
else // all write space is in the second write vector
memset(wv[1].buf, 0, pad * sizeof(*wv[1].buf));
trxrb.write_advance(pad);
trx_xmit_wfall_draw(samplerate);
}
// Copy buf to the ringbuffer if it has enough space. Queue a waterfall
// request whenever there are at least WF_BLOCKSIZE samples to draw.
void trx_xmit_wfall_queue(int samplerate, const double* buf, size_t len)
{
ENSURE_THREAD(TRX_TID);
if (fft_modem && spectrum_viewer->visible())
fft_modem->rx_process(buf, len);
ringbuffer<double>::vector_type wv[2];
wv[0].buf = wv[1].buf = 0;
trxrb.get_wv(wv, len);
if (unlikely(wv[0].len + wv[1].len < len)) // not enough space
return;
size_t n = MIN(wv[0].len, len);
for (size_t i = 0; i < n; i++)
wv[0].buf[i] = buf[i] * progdefaults.TxMonitorLevel;
if (len > n) { // write the remainder to the second vector
buf += n;
n = len - n;
for (size_t i = 0; i < n; i++)
wv[1].buf[i] = buf[i] * progdefaults.TxMonitorLevel;
}
trxrb.write_advance(len);
if (trxrb.read_space() >= WF_BLOCKSIZE)
trx_xmit_wfall_draw(samplerate);
}
//=============================================================================
void audio_select_failure(std::string errmsg)
{
progdefaults.btnAudioIOis = SND_IDX_NULL; // file i/o
sound_update(progdefaults.btnAudioIOis);
btnAudioIO[0]->value(0);
btnAudioIO[1]->value(0);
btnAudioIO[2]->value(0);
btnAudioIO[3]->value(1);
delete RXscard;
RXscard = 0;
fl_alert2("Could not open audio device: %s\nCheck for h/w connection, and restart fldigi", errmsg.c_str());
}
void trx_trx_receive_loop()
{
size_t numread;
assert(powerof2(SCBLOCKSIZE));
if (unlikely(!active_modem)) {
MilliSleep(10);
return;
}
#if BENCHMARK_MODE
do_benchmark();
trx_state = STATE_ENDED;
return;
#endif
if (!RXscard) {
MilliSleep(10);
return;
}
try {
if (!progdefaults.is_full_duplex || !RXsc_is_open ||
current_RXsamplerate != active_modem->get_samplerate() ) {
current_RXsamplerate = active_modem->get_samplerate();
if (RXscard) {
RXscard->Close(O_RDONLY);
RXscard->Open(O_RDONLY, current_RXsamplerate);
REQ(sound_update, progdefaults.btnAudioIOis);
RXsc_is_open = true;
}
}
}
catch (const SndException& e) {
LOG_ERROR("%s. line: %i", e.what(), __LINE__);
put_status(e.what(), 5);
if (RXscard) RXscard->Close();
RXsc_is_open = false;
current_RXsamplerate = 0;
if (progdefaults.btnAudioIOis == SND_IDX_PORT) {
sound_close();
sound_init();
}
REQ(audio_select_failure, e.what());
MilliSleep(100);
return;
}
active_modem->rx_init();
ringbuffer<double>::vector_type rbvec[2];
rbvec[0].buf = rbvec[1].buf = 0;
if (RXscard) RXscard->flush(O_RDONLY);
while (1) {
try {
numread = 0;
if (current_RXsamplerate != active_modem->get_samplerate() ) {
current_RXsamplerate = active_modem->get_samplerate();
if (RXscard) {
RXscard->Close(O_RDONLY);
RXscard->Open(O_RDONLY, current_RXsamplerate);
REQ(sound_update, progdefaults.btnAudioIOis);
RXsc_is_open = true;
}
}
if (RXscard) {
while (numread < SCBLOCKSIZE && trx_state == STATE_RX)
numread += RXscard->Read(fbuf + numread, SCBLOCKSIZE - numread);
}
if (numread > SCBLOCKSIZE) {
LOG_ERROR("numread error %lu", (unsigned long) numread);
numread = SCBLOCKSIZE;
}
if (bHighSpeed) {
for (size_t i = 0; i < numread; i++)
hsbuff[i] = fbuf[i];
} else {
if (trxrb.write_space() == 0) // diRXscard some old data
trxrb.read_advance(SCBLOCKSIZE);
size_t room = trxrb.get_wv(rbvec, numread);
if (room < numread) {
LOG_ERROR("trxrb.get_wv(rbvec) = %d, numread = %d", (int)room, (int)numread);
} else {
// convert to double and write to rb
for (size_t i = 0; i < numread; i++)
rbvec[0].buf[i] = fbuf[i];
}
}
}
catch (const SndException& e) {
if (RXscard) RXscard->Close();
RXsc_is_open = false;
LOG_ERROR("%s. line: %i", e.what(), __LINE__);
put_status(e.what(), 5);
MilliSleep(10);
return;
}
if (trx_state != STATE_RX)
break;
if (bHighSpeed) {
bool afc = progStatus.afconoff;
progStatus.afconoff = false;
QRUNNER_DROP(true);
if (progdefaults.rsid)
ReedSolomon->receive(fbuf, numread);
else if (active_modem->get_mode() == MODE_OFDM_500F || active_modem->get_mode() == MODE_OFDM_750F || active_modem->get_mode() == MODE_OFDM_2000F)
ReedSolomon->receive(fbuf, numread); // OFDM modes use RSID as AFC mechanism. Force RxRSID.
active_modem->HistoryON(true);
active_modem->rx_process(hsbuff, numread);
QRUNNER_DROP(false);
progStatus.afconoff = afc;
active_modem->HistoryON(false);
} else {
trxrb.write_advance(numread);
wf->sig_data(rbvec[0].buf, numread);
if (!trx_inhibit)
REQ(&waterfall::handle_sig_data, wf);
if (!bHistory) {
if (fft_modem && spectrum_viewer->visible())
fft_modem->rx_process(rbvec[0].buf, numread);
active_modem->rx_process(rbvec[0].buf, numread);
if (audio_alert)
audio_alert->monitor(rbvec[0].buf, numread, current_RXsamplerate);
if (progdefaults.rsid)
ReedSolomon->receive(fbuf, numread);
else if (active_modem->get_mode() == MODE_OFDM_500F || active_modem->get_mode() == MODE_OFDM_750F || active_modem->get_mode() == MODE_OFDM_2000F)
ReedSolomon->receive(fbuf, numread); // OFDM modes use RSID as AFC mechanism. Force RxRSID.
dtmf->receive(fbuf, numread);
} else {
bool afc = progStatus.afconoff;
progStatus.afconoff = false;
QRUNNER_DROP(true);
active_modem->HistoryON(true);
trxrb.get_rv(rbvec);
if (rbvec[0].len)
active_modem->rx_process(rbvec[0].buf, rbvec[0].len);
if (rbvec[1].len)
active_modem->rx_process(rbvec[1].buf, rbvec[1].len);
QRUNNER_DROP(false);
progStatus.afconoff = afc;
bHistory = false;
active_modem->HistoryON(false);
}
}
}
if (trx_state == STATE_RESTART)
return;
if (!progdefaults.is_full_duplex ) {
if (RXscard) RXscard->Close(O_RDONLY);
RXsc_is_open = false;
}
}
//=============================================================================
void trx_trx_transmit_loop()
{
if (rx_only) return;
if (!TXscard) {
MilliSleep(10);
return;
}
if (active_modem) {
try {
if (current_TXsamplerate != active_modem->get_samplerate() || !TXsc_is_open) {
current_TXsamplerate = active_modem->get_samplerate();
if (TXscard) {
TXscard->Close(O_WRONLY);
TXscard->Open(O_WRONLY, current_TXsamplerate);
TXsc_is_open = true;
}
}
} catch (const SndException& e) {
LOG_ERROR("%s. line: %i", e.what(), __LINE__);
put_status(e.what(), 1);
current_TXsamplerate = 0;
MilliSleep(10);
return;
}
if ((active_modem != ssb_modem) &&
(active_modem != anal_modem) &&
!active_modem->XMLRPC_CPS_TEST &&
!PERFORM_CPS_TEST ) {
push2talk->set(true);
REQ(&waterfall::set_XmtRcvBtn, wf, true);
}
active_modem->tx_init();
bool _txrsid = false;
if ( ReedSolomon->assigned(active_modem->get_mode()) && (progdefaults.TransmitRSid || progStatus.n_rsids != 0))
_txrsid = true;
else if (ReedSolomon->assigned(active_modem->get_mode()) && (active_modem->get_mode() == MODE_OFDM_500F || active_modem->get_mode() == MODE_OFDM_750F || active_modem->get_mode() == MODE_OFDM_2000F) )
_txrsid = true; // RSID is used as header/preamble for OFDM modes. Make mandatory.
if (_txrsid) {
if (progStatus.n_rsids < 0) {
for (int i = 0; i > progStatus.n_rsids; i--) {
ReedSolomon->send(true);
MilliSleep(200);
}
} else if ( progStatus.n_rsids > 0 ) {
for (int i = 0; i < progStatus.n_rsids; i++) {
ReedSolomon->send(true);
MilliSleep(200);
}
MilliSleep(200);
if (progStatus.n_rsids == 1) progStatus.n_rsids = 0;
} else
ReedSolomon->send(true);
}
if (progStatus.n_rsids >= 0) {
active_modem->tx_sample_count = 0;
active_modem->tx_sample_rate = active_modem->get_samplerate();
while (trx_state == STATE_TX) {
try {
if (!progdefaults.DTMFstr.empty())
dtmf->send();
if (active_modem->tx_process() < 0) {
active_modem->cwid();
if (trx_state != STATE_ABORT)
trx_state = STATE_RX;
}
}
catch (const SndException& e) {
if (TXscard) TXscard->Close();
TXsc_is_open = false;
LOG_ERROR("%s", e.what());
put_status(e.what(), 5);
current_TXsamplerate = 0;
MilliSleep(10);
return;
}
}
} else
if (trx_state != STATE_ABORT && trx_state != STATE_RESTART)
trx_state = STATE_RX;
if (ReedSolomon->assigned(active_modem->get_mode()) &&
progdefaults.rsid_eot_squelch && // test for RsID_EOT
progdefaults.TransmitRSid &&
progStatus.n_rsids >= 0) ReedSolomon->send_eot();
if (ReedSolomon->assigned(active_modem->get_mode()) &&
progdefaults.TransmitRSid &&
progdefaults.rsid_post &&
progStatus.n_rsids >= 0) ReedSolomon->send(false);
progStatus.n_rsids = 0;
trx_xmit_wfall_end(current_TXsamplerate);
if (TXscard) TXscard->flush();
if (trx_state == STATE_RX) {
if (!progdefaults.is_full_duplex) {
if (TXscard) TXscard->Close(O_WRONLY);
TXsc_is_open = false;
}
}
} else
MilliSleep(10);
push2talk->set(false);
REQ(&waterfall::set_XmtRcvBtn, wf, false);
psm_transmit_ended(PSM_STOP);
if (progStatus.timer)
REQ(startMacroTimer);
WriteARQ(0x06);
}
//=============================================================================
void trx_tune_loop()
{
if (rx_only) return;
if (!TXscard) {
MilliSleep(10);
return;
}
if (active_modem) {
try {
if (!progdefaults.is_full_duplex || !TXsc_is_open ||
current_TXsamplerate != active_modem->get_samplerate() ) {
current_TXsamplerate = active_modem->get_samplerate();
if (TXscard) TXscard->Close(O_WRONLY);
if (TXscard) {
TXscard->Open(O_WRONLY, current_TXsamplerate);
TXsc_is_open = true;
}
}
} catch (const SndException& e) {
LOG_ERROR("%s. line: %i", e.what(), __LINE__);
put_status(e.what(), 1);
MilliSleep(10);
current_TXsamplerate = 0;
return;
}
push2talk->set(true);
active_modem->tx_init();
try {
if (active_modem->get_mode() == MODE_CW &&
(use_nanoIO ||
progStatus.WK_online ||
progdefaults.CW_KEYLINE_on_cat_port ||
CW_KEYLINE_isopen)) {
if (CW_KEYLINE_isopen || progdefaults.CW_KEYLINE_on_cat_port)
active_modem->CW_KEYLINE(1);
else if (use_nanoIO)
nanoCW_tune(1);
else WK_tune(1);
cwio_ptt(1);
cwio_key(1);
REQ(&waterfall::set_XmtRcvBtn, wf, true);
while (trx_state == STATE_TUNE) MilliSleep(10);
if (CW_KEYLINE_isopen) active_modem->CW_KEYLINE(0);
else if (use_nanoIO) nanoCW_tune(0);
else WK_tune(0);
cwio_key(0);
cwio_ptt(0);
} else {
while (trx_state == STATE_TUNE) {
if (_trx_tune == 0) {
REQ(&waterfall::set_XmtRcvBtn, wf, true);
xmttune::keydown(active_modem->get_txfreq_woffset(), TXscard);
_trx_tune = 1;
} else
xmttune::tune(active_modem->get_txfreq_woffset(), TXscard);
}
xmttune::keyup(active_modem->get_txfreq_woffset(), TXscard);
}
}
catch (const SndException& e) {
if (TXscard) TXscard->Close();
TXsc_is_open = false;
LOG_ERROR("%s. line: %i", e.what(), __LINE__);
put_status(e.what(), 5);
MilliSleep(10);
current_TXsamplerate = 0;
return;
}
if (TXscard) TXscard->flush();
if (trx_state == STATE_RX) {
if (!progdefaults.is_full_duplex) {
if (TXscard) TXscard->Close(O_WRONLY);
TXsc_is_open = false;
}
}
_trx_tune = 0;
} else
MilliSleep(10);
push2talk->set(false);
REQ(&waterfall::set_XmtRcvBtn, wf, false);
}
//=============================================================================
void *trx_loop(void *args)
{
SET_THREAD_ID(TRX_TID);
state_t old_state = STATE_NOOP;
for (;;) {
if (unlikely(old_state != trx_state)) {
old_state = trx_state;
if (trx_state == STATE_TX || trx_state == STATE_TUNE)
trxrb.reset();
trx_signal_state();
}
LOG_DEBUG("trx state %s",
trx_state == STATE_ABORT ? "abort" :
trx_state == STATE_ENDED ? "ended" :
trx_state == STATE_RESTART ? "restart" :
trx_state == STATE_NEW_MODEM ? "new modem" :
trx_state == STATE_TX ? "tx" :
trx_state == STATE_TUNE ? "tune" :
trx_state == STATE_RX ? "rx" :
"unknown");
switch (trx_state) {
case STATE_ABORT:
delete RXscard;
RXscard = 0;
delete TXscard;
TXscard = 0;
trx_state = STATE_ENDED;
// fall through
case STATE_ENDED:
REQ(set_flrig_ptt, 0);
stop_deadman();
return 0;
case STATE_RESTART:
REQ(set_flrig_ptt, 0);
stop_deadman();
trx_reset_loop();
break;
case STATE_NEW_MODEM:
REQ(set_flrig_ptt, 0);
trx_start_modem_loop();
break;
case STATE_TX:
REQ(set_flrig_ptt, 1);
start_deadman();
trx_trx_transmit_loop();
break;
case STATE_TUNE:
REQ(set_flrig_ptt, 1);
start_deadman();
trx_tune_loop();
break;
case STATE_RX:
REQ(set_flrig_ptt, 0);
stop_deadman();
trx_trx_receive_loop();
break;
default:
LOG(debug::ERROR_LEVEL, debug::LOG_MODEM, "trx in bad state %d\n", trx_state);
MilliSleep(100);
}
}
}
//=============================================================================
static modem* new_modem;
static int new_freq;
void trx_start_modem_loop()
{
if (new_modem == active_modem) {
if (new_freq > 0 && !progdefaults.retain_freq_lock)
active_modem->set_freq(new_freq);
else if (new_freq > 0 && (active_modem->get_mode() == MODE_OFDM_500F || active_modem->get_mode() == MODE_OFDM_750F || active_modem->get_mode() == MODE_OFDM_2000F || active_modem->get_mode() == MODE_OFDM_2000))
active_modem->set_freq(new_freq); // OFDM modes use RSID as AFC mechanism. Always allow QSY of Rx Frequency.
active_modem->restart();
trx_state = STATE_RX;
if (progdefaults.show_psm_btn &&
progStatus.kpsql_enabled &&
progStatus.psm_use_histogram)
psm_reset_histogram();
return;
}
modem* old_modem = active_modem;
new_modem->init();
active_modem = new_modem;
if (new_freq > 0 && !progdefaults.retain_freq_lock)
active_modem->set_freq(new_freq);
else if (new_freq > 0 && (active_modem->get_mode() == MODE_OFDM_500F || active_modem->get_mode() == MODE_OFDM_750F || active_modem->get_mode() == MODE_OFDM_2000F || active_modem->get_mode() == MODE_OFDM_2000))
active_modem->set_freq(new_freq); // OFDM modes use RSID as AFC mechanism. Always allow QSY of Rx Frequency.
trx_state = STATE_RX;
REQ(&waterfall::opmode, wf);
REQ(set599);
if (old_modem) {
*mode_info[old_modem->get_mode()].modem = 0;
delete old_modem;
}
}
//=============================================================================
void trx_start_modem(modem* m, int f)
{
new_modem = m;
new_freq = f;
trx_state = STATE_NEW_MODEM;
}
//=============================================================================
static std::string reset_loop_msg;
void show_reset_loop_alert()
{
// if (btnAudioIO[0]) {
btnAudioIO[0]->value(0);
btnAudioIO[1]->value(0);
btnAudioIO[2]->value(0);
btnAudioIO[3]->value(1);
fl_alert2("%s", reset_loop_msg.c_str());
// }
}
void trx_reset_loop()
{
if (RXscard) {
RXscard->Close();
RXsc_is_open = false;
delete RXscard;
RXscard = 0;
}
if (TXscard) {
TXscard->Close();
TXsc_is_open = false;
delete TXscard;
TXscard = 0;
}
switch (progdefaults.btnAudioIOis) {
#if USE_OSS
case SND_IDX_OSS:
try {
RXscard = new SoundOSS(scDevice[0].c_str());
if (!RXscard) break;
RXscard->Open(O_RDONLY, current_RXsamplerate = 8000);
RXsc_is_open = true;
TXscard = new SoundOSS(scDevice[0].c_str());
if (!TXscard) break;
TXscard->Open(O_WRONLY, current_TXsamplerate = 8000);
TXsc_is_open = true;
} catch (...) {
reset_loop_msg = "OSS open failure";
progdefaults.btnAudioIOis = SND_IDX_NULL; // file i/o
sound_update(progdefaults.btnAudioIOis);
REQ(show_reset_loop_alert);
}
break;
#endif
#if USE_PORTAUDIO
/// All of this very convoluted logic is needed to allow a Linux user
/// to switch from PulseAudio to PortAudio. PulseAudio does not immediately
/// release the sound card resources after closing the pulse audio object.
case SND_IDX_PORT:
{
RXscard = new SoundPort(scDevice[0].c_str(), scDevice[1].c_str());
TXscard = new SoundPort(scDevice[0].c_str(), scDevice[1].c_str());
unsigned long tm1 = zmsec();
int RXret = 0, TXret = 0;
int i;
RXsc_is_open = false;
TXsc_is_open = false;
for (i = 0; i < 10; i++) { // try 10 times
try {
if (!RXret)
RXret = RXscard->Open(O_RDONLY, current_RXsamplerate = 8000);
if (progdefaults.is_full_duplex) {
if (!TXret)
TXret = TXscard->Open(O_WRONLY, current_TXsamplerate = 8000);
}
if (RXret) RXsc_is_open = true;
if (TXret) TXsc_is_open = true;
break;
} catch (const SndException& e) {
MilliSleep(50);
Fl::awake();
}
}
unsigned long tm = zmsec() - tm1;
if (tm < 0) tm = 0;
if (i == 10) {
if (RXscard) delete RXscard;
if (TXscard) delete TXscard;
RXscard = 0;
TXscard = 0;
LOG_PERROR("Port Audio device not available");
reset_loop_msg = "Port Audio device not available";
progdefaults.btnAudioIOis = SND_IDX_NULL; // file i/o
sound_update(progdefaults.btnAudioIOis);
REQ(show_reset_loop_alert);
} else {
LOG_INFO ("Port Audio device available after %0.1f seconds", tm / 1000.0 );
}
break;
}
#endif
#if USE_PULSEAUDIO
case SND_IDX_PULSE:
try {
RXscard = new SoundPulse(scDevice[0].c_str());
if (!RXscard) break;
RXscard->Open(O_RDONLY, current_RXsamplerate = 8000);
RXsc_is_open = true;
TXscard = new SoundPulse(scDevice[0].c_str());
if (!TXscard) break;
// needed to open playback device in PaVolumeControl
TXscard->Open(O_WRONLY, current_TXsamplerate = 8000);
double buffer[1024];
for (int i = 0; i < 1024; buffer[i++] = 0);
TXscard->Write_stereo(buffer, buffer, 1024);
if (progdefaults.is_full_duplex)
TXsc_is_open = true;
else {
TXscard->Close();
TXsc_is_open = false;
}
} catch (const SndException& e) {
LOG_ERROR("%s", e.what());
if (RXscard) delete RXscard;
if (TXscard) delete TXscard;
RXscard = 0;
TXscard = 0;
reset_loop_msg = "Pulse Audio error:\n";
reset_loop_msg.append(e.what());
reset_loop_msg.append("\n\nIs the server running?\nClose fldigi and execute 'pulseaudio --start'");
progdefaults.btnAudioIOis = SND_IDX_NULL; // file i/o
sound_update(progdefaults.btnAudioIOis);
REQ(show_reset_loop_alert);
}
break;
#endif
case SND_IDX_NULL:
RXscard = new SoundNull;
TXscard = new SoundNull;
current_RXsamplerate = current_TXsamplerate = 0;
break;
default:
abort();
}
trx_state = STATE_RX;
}
//=============================================================================
void trx_reset(void)
{
trx_state = STATE_RESTART;
}
//=============================================================================
void trx_start(void)
{
#if !BENCHMARK_MODE
if (trxrunning) {
LOG(debug::ERROR_LEVEL, debug::LOG_MODEM, "trx already running!");
return;
}
if (RXscard) {
delete RXscard;
RXscard = 0;
}
if (TXscard) {
delete TXscard;
TXscard = 0;
}
if (ReedSolomon) delete ReedSolomon;
if (dtmf) delete dtmf;
switch (progdefaults.btnAudioIOis) {
#if USE_OSS
case SND_IDX_OSS:
RXscard = new SoundOSS(scDevice[0].c_str());
TXscard = new SoundOSS(scDevice[0].c_str());
break;
#endif
#if USE_PORTAUDIO
case SND_IDX_PORT:
RXscard = new SoundPort(scDevice[0].c_str(), scDevice[1].c_str());
TXscard = new SoundPort(scDevice[0].c_str(), scDevice[1].c_str());
break;
#endif
#if USE_PULSEAUDIO
case SND_IDX_PULSE:
try {
RXscard = new SoundPulse(scDevice[0].c_str());
if (!RXscard) break;
TXscard = new SoundPulse(scDevice[0].c_str());
if (!TXscard) break;
// needed to open playback device in PaVolumeControl
TXscard->Open(O_WRONLY, current_TXsamplerate = 8000);
double buffer[1024];
for (int i = 0; i < 1024; buffer[i++] = 0);
TXscard->Write_stereo(buffer, buffer, 1024);
if (progdefaults.is_full_duplex)
TXsc_is_open = true;
else {
TXscard->Close();
TXsc_is_open = false;
}
} catch (const SndException& e) {
LOG_ERROR("%s", e.what());
if (RXscard) delete RXscard;
if (TXscard) delete TXscard;
RXscard = 0;
TXscard = 0;
reset_loop_msg = "Pulse Audio error:\n";
reset_loop_msg.append(e.what());
reset_loop_msg.append("\n\nIs the server running?");
progdefaults.btnAudioIOis = SND_IDX_NULL; // file i/o
sound_update(progdefaults.btnAudioIOis);
REQ(show_reset_loop_alert);
}
break;
#endif
case SND_IDX_NULL:
RXscard = new SoundNull;
TXscard = new SoundNull;
break;
default:
abort();
}
current_RXsamplerate = current_TXsamplerate = 0;
ReedSolomon = new cRsId;
dtmf = new cDTMF;
#endif // !BENCHMARK_MODE
#if USE_NAMED_SEMAPHORES
char sname[32];
snprintf(sname, sizeof(sname), "trx-%u-%s", getpid(), PACKAGE_TARNAME);
if ((trx_sem = sem_open(sname, O_CREAT | O_EXCL, 0600, 0)) == (sem_t*)SEM_FAILED) {
LOG_PERROR("sem_open");
abort();
}
# if HAVE_SEM_UNLINK
if (sem_unlink(sname) == -1) {
LOG_PERROR("sem_unlink");
abort();
}
# endif
#else
trx_sem = new sem_t;
if (sem_init(trx_sem, 0, 0) == -1) {
LOG_PERROR("sem_init");
abort();
}
#endif
trx_state = STATE_RX;
_trx_tune = 0;
active_modem = 0;
if (pthread_create(&trx_thread, NULL, trx_loop, NULL) < 0) {
LOG(debug::ERROR_LEVEL, debug::LOG_MODEM, "pthread_create failed");
trxrunning = false;
exit(1);
}
trxrunning = true;
}
//=============================================================================
void trx_close()
{
LOG_INFO("%s", "closing trx thread");
int count = 1000;
active_modem->set_stopflag(true);
while (trx_state != STATE_RX && count--)
MilliSleep(10);
if (trx_state != STATE_RX) {
LOG_INFO("%s", "trx_state != STATE_RX");
exit(1);
}
count = 1000;
trx_state = STATE_ABORT;
while (trx_state != STATE_ENDED && count--)
MilliSleep(10);
if (trx_state != STATE_ENDED) {
LOG_INFO("%s", "trx_state != STATE_ENDED");
exit(2);
}
#if USE_NAMED_SEMAPHORES
if (sem_close(trx_sem) == -1)
LOG_PERROR("sem_close");
#else
if (sem_destroy(trx_sem) == -1)
LOG_PERROR("sem_destroy");
delete trx_sem;
#endif
if (RXscard) {
delete RXscard;
RXscard = 0;
}
LOG_INFO("%s", "trx thread closed");
}
//=============================================================================
void trx_transmit_psm(void) { trx_state = STATE_TX; };
void trx_transmit(void) {
if (progdefaults.show_psm_btn &&
progStatus.kpsql_enabled &&
(!PERFORM_CPS_TEST || !active_modem->XMLRPC_CPS_TEST))
psm_transmit();
else
trx_state = STATE_TX;
}
void trx_tune(void) { trx_state = STATE_TUNE; }
void trx_receive(void) { trx_state = STATE_RX; }
//=============================================================================
void trx_wait_state(void)
{
ENSURE_NOT_THREAD(TRX_TID);
sem_wait(trx_sem);
}
static void trx_signal_state(void)
{
ENSURE_THREAD(TRX_TID);
sem_post(trx_sem);
}
| 27,715
|
C++
|
.cxx
| 926
| 26.790497
| 211
| 0.634689
|
w1hkj/fldigi
| 109
| 27
| 38
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
751,048
|
tune.cxx
|
w1hkj_fldigi/src/trx/tune.cxx
|
// ----------------------------------------------------------------------------
// tune.cxx -- create a single sinewave output with controlled start/end shape
//
// Copyright (C) 2006-2007
// Dave Freese, W1HKJ
//
// This file is part of fldigi.
//
// Fldigi 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 3 of the License, or
// (at your option) any later version.
//
// Fldigi 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 fldigi. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include <math.h>
#include "sound.h"
#include "confdialog.h"
#include "test_signal.h"
namespace xmttune {
// use same wave shaping for tune key down / key up as for the CW tx_process
// produces a 4 msec leading / trailing edge
#define KNUM 32
// keydown wave shape
double kdshape[KNUM] = {
0.00240750255310301, 0.00960708477768751,
0.02152941088003600, 0.03805966253618680,
0.05903864465505320, 0.08426431851158830,
0.11349374748686800, 0.14644543667658500,
0.18280204383628200, 0.22221343555548300,
0.26430005922814900, 0.30865659834558700,
0.35485587590940700, 0.40245296837259500,
0.45098949048925500, 0.49999800980765500,
0.54900654829266300, 0.59754312772456200,
0.64514031509964400, 0.69133972425796200,
0.73569643038517400, 0.77778325487450100,
0.81719487928327800, 0.85355174876454100,
0.88650372738152000, 0.91573347010241700,
0.94095947900139100, 0.96193881423287900,
0.97846943367117300, 0.99039213868324900,
0.99759210729604500, 0.99999999999295900
};
// keyup wave shape
double kushape[KNUM] = {
0.99999999999295900, 0.99759210729604500,
0.99039213868324900, 0.97846943367117300,
0.96193881423287900, 0.94095947900139100,
0.91573347010241700, 0.88650372738152000,
0.85355174876454100, 0.81719487928327800,
0.77778325487450100, 0.73569643038517400,
0.69133972425796200, 0.64514031509964400,
0.59754312772456200, 0.54900654829266300,
0.49999800980765500, 0.45098949048925500,
0.40245296837259500, 0.35485587590940700,
0.30865659834558700, 0.26430005922814900,
0.22221343555548300, 0.18280204383628200,
0.14644543667658500, 0.11349374748686800,
0.08426431851158830, 0.05903864465505320,
0.03805966253618680, 0.02152941088003600,
0.00960708477768751, 0.00240750255310301
};
#define BUFLEN 512
double phaseacc = 0.0;
double phaseincr = 0.0;
double pttacc = 0.0;
double outbuf[BUFLEN];
double pttbuf[BUFLEN];
//===========================================================================
inline double nco()
{
phaseacc += phaseincr;
if (phaseacc > TWOPI) phaseacc -= TWOPI;
return cos(phaseacc);
}
inline double pttnco()
{
pttacc += TWOPI * 1000 / active_modem->get_samplerate();
if (pttacc > TWOPI) pttacc -= TWOPI;
return sin(pttacc);
}
//=====================================================================
//=====================================================================
void keydown(double freq, SoundBase *scard)
{
int i;
phaseincr = 2.0 * M_PI * freq / active_modem->get_samplerate();
for (i = 0; i < KNUM; i++){
outbuf[i] = nco() * kdshape[i];
pttbuf[i] = pttnco();
}
for (; i < BUFLEN; i++) {
outbuf[i] = nco();
pttbuf[i] = pttnco();
}
if ((active_modem == cw_modem) && progdefaults.QSK) {
active_modem->ModulateStereo(
outbuf, pttbuf,
BUFLEN, false);
} else {
active_modem->ModulateXmtr(outbuf, BUFLEN);
}
}
//=====================================================================
void keyup(double freq, SoundBase *scard)
{
int i;
phaseincr = 2.0 * M_PI * freq / active_modem->get_samplerate();
for (i = 0; i < KNUM; i++) {
outbuf[i] = nco() * kushape[i];
pttbuf[i] = pttnco();
}
for (; i < BUFLEN; i++) {
outbuf[i] = 0.0;
pttbuf[i] = pttnco();
}
if ((active_modem == cw_modem) && progdefaults.QSK) {
active_modem->ModulateStereo(
outbuf, pttbuf,
BUFLEN, false);
} else {
active_modem->ModulateXmtr(outbuf, BUFLEN);
}
}
//=====================================================================
void tune(double freq, SoundBase *scard)
{
int i;
if (test_signal_window && test_signal_window->visible() && btnOffsetOn->value())
freq += ctrl_freq_offset->value();
phaseincr = 2.0 * M_PI * freq / active_modem->get_samplerate();
for (i = 0; i < BUFLEN; i++) {
outbuf[i] = nco();
pttbuf[i] = pttnco();
}
if ((active_modem == cw_modem) && progdefaults.QSK) {
active_modem->ModulateStereo(
outbuf, pttbuf,
BUFLEN, false);
} else {
active_modem->ModulateXmtr(outbuf, BUFLEN);
}
}
}; // namespace tune
| 4,918
|
C++
|
.cxx
| 149
| 31.04698
| 81
| 0.660767
|
w1hkj/fldigi
| 109
| 27
| 38
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
751,050
|
nullmodem.cxx
|
w1hkj_fldigi/src/trx/nullmodem.cxx
|
// ----------------------------------------------------------------------------
// NULLMODEM.cxx -- NULLMODEM modem
//
// Copyright (C) 2006
// Dave Freese, W1HKJ
//
// This file is part of fldigi. Adapted from code contained in gMFSK source code
// distribution.
// gMFSK Copyright (C) 2001, 2002, 2003
// Tomi Manninen (oh2bns@sral.fi)
//
// Fldigi 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 3 of the License, or
// (at your option) any later version.
//
// Fldigi 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 fldigi. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include <config.h>
#include <stdlib.h>
#include <iostream>
#include "nullmodem.h"
#include "fl_digi.h"
#include "ascii.h"
#define null_bw 1
// a NULLMODEM and will be instantiated before the dynamic member wf,
// digiscope, and fl_digi_main, the main dialog
NULLMODEM:: NULLMODEM() : modem()
{
mode = MODE_NULL;
samplerate = 8000;
restart();
}
NULLMODEM::~NULLMODEM() {};
void NULLMODEM::tx_init()
{
}
void NULLMODEM::rx_init()
{
if (fl_digi_main)
put_MODEstatus(mode);
}
void NULLMODEM::init()
{
modem::init();
rx_init();
if (digiscope)
digiscope->mode(Digiscope::SCOPE);
}
void NULLMODEM::restart()
{
if (wf) set_bandwidth(null_bw);
}
//=====================================================================
// receive processing
//=====================================================================
int NULLMODEM::rx_process(const double *buf, int len)
{
return 0;
}
//=====================================================================
// transmit processing
//=====================================================================
int NULLMODEM::tx_process()
{
modem::tx_process();
MilliSleep(10);
if (!fl_digi_main) {
return 0;
}
int c = get_tx_char();
if (c == GET_TX_CHAR_ETX) {
stopflag = false;
return -1;
}
if ( stopflag ) {
stopflag = false;
return -1;
}
return 0;
}
| 2,394
|
C++
|
.cxx
| 87
| 25.885057
| 81
| 0.581111
|
w1hkj/fldigi
| 109
| 27
| 38
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
751,051
|
test_signal.cxx
|
w1hkj_fldigi/src/trx/test_signal.cxx
|
// ----------------------------------------------------------------------------
// test_signal.cxx
//
// Copyright (C) 2017
// Dave Freese, W1HKJ
//
// This file is part of fldigi.
//
// Fldigi 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 3 of the License, or
// (at your option) any later version.
//
// Fldigi 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 fldigi. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include "test_signal.h"
Fl_Double_Window* test_signal_window = (Fl_Double_Window *)0;
void show_testdialog(void)
{
if (!test_signal_window)
test_signal_window = make_testdialog();
test_signal_window->show();
}
| 1,112
|
C++
|
.cxx
| 29
| 37.068966
| 79
| 0.637627
|
w1hkj/fldigi
| 109
| 27
| 38
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
751,054
|
mt63.cxx
|
w1hkj_fldigi/src/mt63/mt63.cxx
|
// ----------------------------------------------------------------------------
// mt63.cxx -- MT63 modem for fldigi
//
// Copyright (C) 1999-2004 Pawel Jalocha, SP9VRC
// Copyright (c) 2007-2011 Dave Freese, W1HKJ
//
// This file is part of fldigi.
//
// Fldigi 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 3 of the License, or
// (at your option) any later version.
//
// Fldigi 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 fldigi. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include <config.h>
#include "configuration.h"
#include "fl_digi.h"
#include "status.h"
#include "mt63.h"
//------------------------------------------------------------------------------
#include "threads.h"
static pthread_mutex_t mt63_mutex = PTHREAD_MUTEX_INITIALIZER;
//------------------------------------------------------------------------------
bool startflag = true;
void mt63::tx_init()
{
guard_lock dsp_lock(&mt63_mutex);
Tx->Preset(get_txfreq_woffset(), (int)bandwidth, Interleave == 64 ? 1 : 0);
flush = Tx->DataInterleave;
videoText();
startflag = true;
}
void mt63::rx_init()
{
guard_lock dsp_lock(&mt63_mutex);
Rx->Preset( frequency,
(int)bandwidth,
Interleave == 64 ? 1 : 0,
long_integral ? 32 : 16 );
InpLevel->Preset(64.0, 0.75);
escape = 0;
}
int mt63::tx_process()
{
rx_flush();
// do not put above rx_flush()
modem::tx_process();
guard_lock dsp_lock(&mt63_mutex);
int c;
if (startflag == true) {
startflag = false;
maxval = 0.0;
if (progdefaults.mt63_usetones) {
double w1 = 2.0 * M_PI * (get_txfreq_woffset() - bandwidth / 2.0) / samplerate;
double w2 = 2.0 * M_PI * (get_txfreq_woffset() + 31.0 * bandwidth / 64.0) / samplerate;
double phi1 = 0.0;
double phi2 = 0.0;
double buff[512];
int numsmpls = samplerate * progdefaults.mt63_tone_duration / 512;
for (int i = 0; i < numsmpls; i++) {
for (int j = 0; j < 512; j++) {
buff[j] = TONE_AMP * (progdefaults.mt63_twotones ? 0.5 : 1.0) * cos(phi1) +
TONE_AMP * (progdefaults.mt63_twotones ? 0.5 : 0.0) * cos(phi2);
phi1 += w1;
phi2 += w2;
if (i == 0) buff[j] *= (1.0 - exp(-1.0 * j / 40.0));
if (i == progdefaults.mt63_tone_duration - 1)
buff[j] *= (1.0 - exp(-1.0 * (samplerate - j) / 40.0));
}
Fl::awake();
ModulateXmtr(buff, 512);
}
}
for (int i = 0; i < Tx->DataInterleave; i++) {
Tx->SendChar(0);
Fl::awake();
}
}
c = get_tx_char();
if (c == GET_TX_CHAR_ETX) {
stopflag = true;
flush = Tx->DataInterleave;
}
if (c == GET_TX_CHAR_NODATA || stopflag == true) c = 0;
if (stopflag) {
stopflag = false;
while (--flush) {
Tx->SendChar(0);
double buff[Tx->Comb.Output.Len];
for (int i = 0; i < Tx->Comb.Output.Len; i++)
if (fabs(Tx->Comb.Output.Data[i]) > maxval)
maxval = fabs(Tx->Comb.Output.Data[i]);
for (int i = 0; i < Tx->Comb.Output.Len; i++)
buff[i] = Tx->Comb.Output.Data[i] /= maxval;
ModulateXmtr(buff,Tx->Comb.Output.Len);
}
Tx->SendJam();
maxval = 0.0;
double buff[Tx->Comb.Output.Len];
for (int i = 0; i < Tx->Comb.Output.Len; i++)
if (fabs(Tx->Comb.Output.Data[i]) > maxval)
maxval = fabs(Tx->Comb.Output.Data[i]);
for (int i = 0; i < Tx->Comb.Output.Len; i++)
buff[i] = Tx->Comb.Output.Data[i] * 1.0 / maxval;
ModulateXmtr(buff,Tx->Comb.Output.Len);
return -1; /* we're done */
}
if (c > 255 || (!progdefaults.mt63_8bit && c > 127))
c = '.';
int sendc = c;
if (sendc > 127) {
sendc &= 127;
Tx->SendChar(127);
double buff[Tx->Comb.Output.Len];
for (int i = 0; i < Tx->Comb.Output.Len; i++)
if (fabs(Tx->Comb.Output.Data[i]) > maxval)
maxval = fabs(Tx->Comb.Output.Data[i]);
for (int i = 0; i < Tx->Comb.Output.Len; i++)
buff[i] = Tx->Comb.Output.Data[i] * 1.0 / maxval;
ModulateXmtr(buff,Tx->Comb.Output.Len);
}
Tx->SendChar(sendc);
double buff[Tx->Comb.Output.Len];
int len = Tx->Comb.Output.Len;
for (int i = 0; i < len; i++) {
buff[i] = Tx->Comb.Output.Data[i];
if (maxval < fabs(buff[i])) maxval = fabs(buff[i]);
}
for (int i = 0; i < len; i++) {
buff[i] *= 1.0 / maxval;
}
ModulateXmtr(buff,len);
put_echo_char(c);
return 0;
}
int mt63::rx_process(const double *buf, int len)
{
double snr;
unsigned int c;
int i;
static char msg1[20];
static char msg2[20];
double f_offset;
if (long_integral != progdefaults.mt63_rx_integration) {
long_integral = progdefaults.mt63_rx_integration;
restart();
}
if (InpBuff->EnsureSpace(len) == -1) {
fprintf(stderr, "mt63_rxprocess: buffer error\n");
return -1;
}
for (i = 0; i < len; i++)
InpBuff->Data[i] = buf[i];
{ // critical section
guard_lock dsp_lock(&mt63_mutex);
InpBuff->Len = len;
InpLevel->Process(InpBuff);
Rx->Process(InpBuff);
snr = Rx->FEC_SNR();
if (progStatus.sqlonoff && snr < progStatus.sldrSquelchValue) {
put_Status1("");
put_Status2("");
display_metric(0);
return 0;
}
for (i = 0; i < Rx->Output.Len; i++) {
c = Rx->Output.Data[i];
if (!progdefaults.mt63_8bit) {
put_rx_char(c);
continue;
}
if ((c < 8) && (escape == 0))
continue;
if (c == 127) {
escape = 1;
continue;
}
if (escape) {
c += 128;
escape = 0;
}
put_rx_char(c);
}
f_offset = Rx->TotalFreqOffset();
} // end critical section
if (snr > 99.9) snr = 99.9;
display_metric(snr);
double s2n = 10.0*log10( snr == 0 ? 0.001 : snr);
snprintf(msg1, sizeof(msg1), "s/n %2d dB", (int)(floor(s2n)));
put_Status1(msg1);
snprintf(msg2, sizeof(msg2), "f/o %+4.1f Hz", f_offset);
put_Status2(msg2, 5, STATUS_CLEAR);
flushbuffer = true;
return 0;
}
void mt63::rx_flush()
{
guard_lock dsp_lock(&mt63_mutex);
unsigned int c;
int len = 512;
int dlen = 0;
if (!flushbuffer) return;
if (emptyBuff->EnsureSpace(len) == -1) {
flushbuffer = false;
return;
}
for (int j = 0; j < len; j++)
emptyBuff->Data[j] = 0.0;
emptyBuff->Len = len;
InpLevel->Process(emptyBuff);
Rx->Process(emptyBuff);
dlen = Rx->Output.Len;
while (Rx->SYNC_LockStatus()) {
for (int i = 0; i < dlen; i++) {
c = Rx->Output.Data[i];
if (!progdefaults.mt63_8bit) {
put_rx_char(c);
continue;
}
if ((c < 8) && (escape == 0))
continue;
if (c == 127) {
escape = 1;
continue;
}
if (escape) {
c += 128;
escape = 0;
}
put_rx_char(c);
}
for (int j = 0; j < len; j++)
emptyBuff->Data[j] = 0.0;
emptyBuff->Len = len;
InpLevel->Process(emptyBuff);
Rx->Process(emptyBuff);
dlen = Rx->Output.Len;
}
flushbuffer = false;
return;
}
void mt63::restart()
{
int err;
put_MODEstatus(mode);
set_scope_mode(Digiscope::BLANK);
{ // critical section
guard_lock dsp_lock(&mt63_mutex);
err = Tx->Preset(get_txfreq_woffset(), (int)bandwidth, Interleave == 64 ? 1 : 0);
if (err)
fprintf(stderr, "mt63_txinit: init failed\n");
flush = Tx->DataInterleave;
err = Rx->Preset( frequency, (int)bandwidth,
Interleave == 64 ? 1 : 0,
long_integral ? 32 : 16);
} // end critical section
if (err)
fprintf(stderr, "mt63_rxinit: init failed\n");
InpLevel->Preset(64.0, 0.75);
stopflag = false;
}
void mt63::init()
{
modem::init();
restart();
flushbuffer = false;
maxval = 0.0;
if (progdefaults.mt63_at500) {
frequency = 500 + bandwidth / 2;
modem::set_freq(frequency);
}
else if (progdefaults.mt63_centered) {
frequency = 1500;
modem::set_freq(frequency);
}
else if (progStatus.carrier != 0) {
set_freq(progStatus.carrier);
#if !BENCHMARK_MODE
progStatus.carrier = 0;
#endif
} else
set_freq(wf->Carrier());
}
mt63::mt63 (trx_mode mt63_mode) : modem()
{
mode = mt63_mode;
switch (mode) {
case MODE_MT63_500S:
Interleave = 32;
bandwidth = 500;
break;
case MODE_MT63_500L:
Interleave = 64;
bandwidth = 500;
break;
case MODE_MT63_1000S:
Interleave = 32;
bandwidth = 1000;
break;
case MODE_MT63_1000L:
Interleave = 64;
bandwidth = 1000;
break;
case MODE_MT63_2000S:
Interleave = 32;
bandwidth = 2000;
break;
case MODE_MT63_2000L:
Interleave = 64;
bandwidth = 2000;
break;
}
long_integral = progdefaults.mt63_rx_integration;
Tx = new MT63tx;
Rx = new MT63rx;
InpLevel = new dspLevelMonitor;
InpBuff = new double_buff;
emptyBuff = new double_buff;
samplerate = 8000;
fragmentsize = 1024;
}
mt63::~mt63()
{
guard_lock dsp_lock(&mt63_mutex);
if (Tx) delete Tx;
if (Rx) delete Rx;
if (InpLevel) delete InpLevel;
if (InpBuff) delete InpBuff;
}
// W1HKJ
// user can select manual or fixed positioning of the MT63 encoder/decoder
// progdefaults.mt63_at500 TRUE ==> fixed position
void mt63::set_freq(double f)
{
if (progdefaults.mt63_at500)
frequency = 500 + bandwidth / 2;
else if (progdefaults.mt63_centered)
frequency = 1500;
else
frequency = f;
modem::set_freq(frequency);
rx_init();
}
| 9,302
|
C++
|
.cxx
| 350
| 23.725714
| 90
| 0.620216
|
w1hkj/fldigi
| 109
| 27
| 38
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
751,055
|
fsq_varicode.cxx
|
w1hkj_fldigi/src/fsq/fsq_varicode.cxx
|
int fsq_varicode[][2] = {
{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0},
{27,31}, { 0, 0}, {28, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0},
{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0},
{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0},
{ 0, 0}, {11,30}, {12,30}, {13,30}, {14,30}, {15,30}, {16,30}, {17,30},
{18,30}, {19,30}, {20,30}, {21,30}, {27,29}, {22,30}, {27, 0}, {23,30},
{10,30}, { 1,30}, { 2,30}, { 3,30}, { 4,30}, { 5,30}, { 6,30}, { 7,30},
{ 8,30}, { 9,30}, {24,30}, {25,30}, {26,30}, { 0,31}, {27,30}, {28,29},
{ 0,29}, { 1,29}, { 2,29}, { 3,29}, { 4,29}, { 5,29}, { 6,29}, { 7,29},// ' ' - 7
{ 8,29}, { 9,29}, {10,29}, {11,29}, {12,29}, {13,29}, {14,29}, {15,29},// 8, 9, 0
{16,29}, {17,29}, {18,29}, {19,29}, {20,29}, {21,29}, {22,29}, {23,29}, // ... :
{24,29}, {25,29}, {26,29}, { 1,31}, { 2,31}, { 3,31}, { 4,31}, { 5,31},
{ 9,31}, { 1, 0}, { 2, 0}, { 3, 0}, { 4, 0}, { 5, 0}, { 6, 0}, { 7, 0},// @ - g
{ 8, 0}, { 9, 0}, {10, 0}, {11, 0}, {12, 0}, {13, 0}, {14, 0}, {15, 0},// h - o
{16, 0}, {17, 0}, {18, 0}, {19, 0}, {20, 0}, {21, 0}, {22, 0}, {23, 0},// p - w
{24, 0}, {25, 0}, {26, 0}, { 6,31}, { 7,31}, { 8,31}, { 0,30}, {28,31},// x - 127
{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0},//135
{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0},//143
{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0},//151
{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0},//159
{ 0, 0}, { 0, 0}, { 0, 0}, {14,31}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0},//167
{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0},//175
{12,31}, {10,31}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0},//183
{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0},//191
{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0},//199
{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0},//207
{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, {13,31},//215
{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0},//223
{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0},//231
{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0},//239
{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, {11,31},//247
{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, { 0, 0} //255
};
/*
* The same in a format more suitable for decoding.
* The index is the varicode symbol, being 1-2 nibbles. The value is the
* ASCII character.
* NB. Do NOT use CR as a line feed, as you will get an extra space and the
* new line will be indented. Use LF = ascii 10 instead.
*/
// decode [ prev * 32 + curr] ; 0 < prev < 29; curr == 29, 30, 31
int wsq_varidecode[] = {
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
32, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122, 46, 10, 64,126, 61, // 0 - 31
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 65, 49, 91, // 32 - 63
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 66, 50, 92, // 2
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 67, 51, 93, // 3
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 68, 52, 94, // 4
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 69, 53, 95, // 5
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 70, 54,123, // 6
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 71, 55,124, // 7
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 72, 56,125, // 8
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 73, 57, 96, // 9
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 74, 48,177, // 10
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 75, 33,247, // 11
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 76, 34,176, // 12
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 77, 35,215, // 13
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 78, 36,163, // 14
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 79, 37, -1, // 15
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 80, 38, -1, // 16
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 81, 39, -1, // 17
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 82, 40, -1, // 18
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 83, 41, -1, // 19
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 84, 42, -1, // 20
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 85, 43, -1, // 21
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 86, 45, -1, // 22
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 87, 47, -1, // 23
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 88, 58, -1, // 24
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 89, 59, -1, // 25
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 90, 60, -1, // 26
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 44, 62, 8, // 27
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 63, 0,127, // 28
};
const char *fsq_ascii[256] = {
"<NUL>", "<SOH>", "<STX>", "<ETX>", "<EOT>", "<ENQ>", "<ACK>", "<BEL>",
"<BS>", "<TAB>", "<LF>", "<VT>", "<FF>", "<CR>", "<SO>", "<SI>",
"<DLE>", "<DC1>", "<DC2>", "<DC3>", "<DC4>", "<NAK>", "<SYN>", "<ETB>",
"<CAN>", "<EM>", "<SUB>", "<ESC>", "<FS>", "<GS>", "<RS>", "<US>",
" ", "!", "\"", "#", "$", "%", "&", "\'",
"(", ")", "*", "+", ",", "-", ".", "/",
"0", "1", "2", "3", "4", "5", "6", "7",
"8", "9", ":", ";", "<", "=", ">", "?",
"@", "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", "[", "\\", "]", "^", "_",
"`", "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", "{", "|", "}", "~", "<DEL>",
"<128>", "<129>", "<130>", "<131>", "<132>", "<133>", "<134>", "<135>",
"<136>", "<137>", "<138>", "<139>", "<140>", "<141>", "<142>", "<143>",
"<144>", "<145>", "<146>", "<147>", "<148>", "<149>", "<150>", "<151>",
"<152>", "<153>", "<154>", "<155>", "<156>", "<157>", "<158>", "<159>",
"<160>", "<161>", "<162>", "£", "<164>", "<165>", "<166>", "<167>",
"<168>", "<169>", "<170>", "<171>", "<172>", "<173>", "<174>", "<175>",
"°", "±", "<178>", "<179>", "<180>", "<181>", "<182>", "<183>",
"<184>", "<185>", "<186>", "<187>", "<188>", "<189>", "<190>", "<191>",
"<192>", "<193>", "<194>", "<195>", "<196>", "<197>", "<198>", "<199>",
"<200>", "<201>", "<202>", "<203>", "<204>", "<205>", "<206>", "<207>",
"<208>", "<209>", "<210>", "<211>", "<212>", "<213>", "<214>", "×",
"<216>", "<217>", "<218>", "<219>", "<220>", "<221>", "<222>", "<223>",
"<224>", "<225>", "<226>", "<227>", "<228>", "<229>", "<230>", "<231>",
"<232>", "<233>", "<234>", "<235>", "<236>", "<237>", "<238>", "<239>",
"<240>", "<241>", "<242>", "<243>", "<244>", "<245>", "<246>", "÷",
"<248>", "<249>", "<250>", "<251>", "<252>", "<253>", "<254>", "<255>"
};
| 9,346
|
C++
|
.cxx
| 108
| 83.731481
| 142
| 0.290543
|
w1hkj/fldigi
| 109
| 27
| 38
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
751,056
|
fsq.cxx
|
w1hkj_fldigi/src/fsq/fsq.cxx
|
// ----------------------------------------------------------------------------
// fsq.cxx -- fsq modem
//
// Copyright (C) 2015
// Dave Freese, W1HKJ
//
// This file is part of fldigi.
//
// Fldigi 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 3 of the License, or
// (at your option) any later version.
//
// Fldigi 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 fldigi. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include <config.h>
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <libgen.h>
#include <FL/filename.H>
#include "progress.h"
#include "fsq.h"
#include "complex.h"
#include "fl_digi.h"
#include "misc.h"
#include "fileselect.h"
#include "threads.h"
#include "debug.h"
#include "re.h"
#include "configuration.h"
#include "qrunner.h"
#include "fl_digi.h"
#include "status.h"
#include "main.h"
#include "icons.h"
#include "ascii.h"
#include "timeops.h"
#include "flmisc.h"
#include "test_signal.h"
#include "fsq_varicode.cxx"
void clear_xmt_arrays();
#define SQLFILT_SIZE 64
#define NIT std::string::npos
#define txcenterfreq 1500.0
int fsq::symlen = 4096; // nominal symbol length; 3 baud
static const char *FSQBOL = " \n";
static const char *FSQEOL = "\n ";
static const char *FSQEOT = " \b ";
static const char *fsq_lf = "\n";
static const char *fsq_bot = "<bot>";
static const char *fsq_eol = "<eol>";
static const char *fsq_eot = "<eot>";
static std::string fsq_string;
static std::string fsq_delayed_string;
static bool enable_audit_log = false;
static bool enable_heard_log = false;
#include "fsq-pic.cxx"
static notify_dialog *alert_window = 0;
void post_alert(std::string s1, double timeout = 0.0, std::string s2 = "")
{
if (active_modem && (active_modem->get_mode() == MODE_FSQ) && !s2.empty()) {
active_modem->send_ack(s2);
}
if (!alert_window) alert_window = new notify_dialog;
alert_window->notify(s1.c_str(), timeout);
REQ(show_notifier, alert_window);
display_fsq_mon_text(s1, FTextBase::ALTR);
}
// nibbles table used for fast conversion from tone difference to symbol
static std::string sz2utf8(std::string s)
{
char dest[4*s.length() + 1]; // if every char were utf8
int numbytes = fl_utf8froma(dest, sizeof(dest) - 1, s.c_str(), s.length());
if (numbytes > 0) return dest;
return s;
}
//static int nibbles[199];
void fsq::init_nibbles()
{
int nibble = 0;
for (int i = 0; i < 199; i++) {
nibble = floor(0.5 + (i - 99)/3.0);
// allow for wrap-around (33 tones for 32 tone differences)
if (nibble < 0) nibble += 33;
if (nibble > 32) nibble -= 33;
// adjust for +1 symbol at the transmitter
nibble--;
nibbles[i] = nibble;
}
}
// note:
// display_fsq_rx_text and
// display_fsq_mon_text
// use a REQ(...) access to the UI
// it is not necessary to indirectly call either write_rx_mon_char or
// write_mon_tx_char using the REQ access mechanism
void write_rx_mon_char(int ch)
{
int ach = ch & 0xFF;
if (!progdefaults.fsq_directed) {
display_fsq_rx_text(fsq_ascii[ach], FTextBase::FSQ_UND) ;
if (ach == '\n')
display_fsq_rx_text(fsq_lf, FTextBase::FSQ_UND);
}
display_fsq_mon_text(fsq_ascii[ach], FTextBase::RECV);
if (ach == '\n')
display_fsq_mon_text(fsq_lf, FTextBase::RECV);
}
void write_mon_tx_char(int ch)
{
int ach = ch & 0xFF;
display_fsq_mon_text(fsq_ascii[ach], FTextBase::FSQ_TX);
if (ach == '\n')
display_fsq_mon_text(fsq_lf, FTextBase::FSQ_TX);
}
void printit(double speed, int bandwidth, int symlen, int bksize, int peak_hits, int tone)
{
std::ostringstream it;
it << "\nSpeed.......... " << speed << "\nBandwidth...... " << bandwidth;
it << "\nSymbol length.. " << symlen << "\nBlock size..... " << bksize;
it << "\nMinimum Hits... " << peak_hits << "\nBasetone....... " << tone << "\n";
display_fsq_mon_text(it.str(), FTextBase::ALTR);
}
fsq::fsq(trx_mode md) : modem()
{
modem::set_freq(1500); // default Rx/Tx center frequency
mode = md;
samplerate = SR;
fft = new g_fft<double>(FFTSIZE);
snfilt = new Cmovavg(SQLFILT_SIZE);
noisefilt = new Cmovavg(32);
sigfilt = new Cmovavg(8);
// baudfilt = new Cmovavg(3);
movavg_size = progdefaults.fsq_movavg;
if (movavg_size < 1) movavg_size = progdefaults.fsq_movavg = 1;
if (movavg_size > MOVAVGLIMIT) movavg_size = progdefaults.fsq_movavg = MOVAVGLIMIT;
for (int i = 0; i < NUMBINS; i++) binfilt[i] = new Cmovavg(movavg_size);
spacing = 3;
txphase = 0;
basetone = 333;
picfilter = new C_FIR_filter();
picfilter->init_lowpass(257, 1, 500.0 / samplerate);
phase = 0;
phidiff = 2.0 * M_PI * frequency / samplerate;
prevz = cmplx(0,0);
bkptr = 0;
peak_counter = 0;
peak = last_peak = 0;
max = 0;
curr_nibble = prev_nibble = 0;
s2n = 0;
ch_sqlch_open = false;
memset(rx_stream, 0, sizeof(rx_stream));
rx_text.clear();
for (int i = 0; i < BLOCK_SIZE; i++)
a_blackman[i] = blackman(1.0 * i / BLOCK_SIZE);
fsq_tx_image = false;
init_nibbles();
start_aging();
show_mode();
restart();
toggle_logs();
}
fsq::~fsq()
{
delete fft;
delete snfilt;
delete sigfilt;
delete noisefilt;
for (int i = 0; i < NUMBINS; i++)
delete binfilt[i];
// delete baudfilt;
delete picfilter;
REQ(close_fsqMonitor);
stop_sounder();
stop_aging();
if (enable_audit_log)
audit_log.close();
if (enable_heard_log)
heard_log.close();
};
void fsq::tx_init()
{
tone = prevtone = 0;
txphase = 0;
send_bot = true;
mycall = progdefaults.myCall;
if (progdefaults.fsq_lowercase)
for (size_t n = 0; n < mycall.length(); n++) mycall[n] = tolower(mycall[n]);
videoText();
}
void fsq::rx_init()
{
set_freq(frequency);
bandwidth = 33 * spacing * samplerate / FSQ_SYMLEN;
bkptr = 0;
peak_counter = 0;
peak = last_peak = 0;
max = 0;
curr_nibble = prev_nibble = 0;
s2n = 0;
ch_sqlch_open = false;
memset(rx_stream, 0, sizeof(rx_stream));
rx_text.clear();
for (int i = 0; i < NUMBINS; i++) {
tones[i] = 0.0;
binfilt[i]->reset();
}
pixel = 0;
amplitude = 0;
phase = 0;
prevz = cmplx(0,0);
image_counter = 0;
RXspp = 10; // 10 samples per pixel
state = TEXT;
}
void fsq::init()
{
modem::init();
sounder_interval = progdefaults.fsq_sounder;
start_sounder(sounder_interval);
rx_init();
}
void fsq::set_freq(double f)
{
frequency = f;
modem::set_freq(frequency);
basetone = ceil(1.0*(frequency - bandwidth / 2) * FSQ_SYMLEN / samplerate);
tx_basetone = ceil((get_txfreq() - bandwidth / 2) * FSQ_SYMLEN / samplerate );
int incr = basetone % spacing;
basetone -= incr;
tx_basetone -= incr;
}
void fsq::show_mode()
{
if (speed == 1.5 )
put_MODEstatus("FSQ-1.5");
else if (speed == 2.0)
put_MODEstatus("FSQ-2");
else if (speed == 3.0)
put_MODEstatus("FSQ-3");
else if (speed == 4.5)
put_MODEstatus("FSQ-4.5");
else
put_MODEstatus("FSQ-6");
}
void fsq::adjust_for_speed()
{
speed = progdefaults.fsqbaud;
if( speed == 1.5 ) {
symlen = 8192;
} else if (speed == 2.0) {
symlen = 6144;
} else if (speed == 3.0) {
symlen = 4096;
} else if (speed == 4.5) {
symlen = 3072;
} else { // speed == 6
symlen = 2048;
}
show_mode();
}
void fsq::toggle_logs()
{
if (enable_heard_log != progdefaults.fsq_enable_heard_log) {
enable_heard_log = progdefaults.fsq_enable_heard_log;
if (heard_log.is_open()) heard_log.close();
}
if (enable_audit_log != progdefaults.fsq_enable_audit_log) {
enable_audit_log = progdefaults.fsq_enable_audit_log;
if (audit_log.is_open()) audit_log.close();
}
if (enable_heard_log) {
heard_log_fname = progdefaults.fsq_heard_log;
std::string sheard = TempDir;
sheard.append(heard_log_fname);
heard_log.open(sheard.c_str(), std::ios::app);
heard_log << "==================================================\n";
heard_log << "Heard log: " << zdate() << ", " << ztime() << "\n";
heard_log << "==================================================\n";
}
if (enable_audit_log) {
audit_log_fname = progdefaults.fsq_audit_log;
std::string saudit = TempDir;
saudit.append(audit_log_fname);
audit_log.close();
audit_log.open(saudit.c_str(), std::ios::app);
audit_log << "==================================================\n";
audit_log << "Audit log: " << zdate() << ", " << ztime() << "\n";
audit_log << "==================================================\n";
}
}
void fsq::restart()
{
set_freq(frequency);
peak_hits = progdefaults.fsqhits;
adjust_for_speed();
mycall = progdefaults.myCall;
if (progdefaults.fsq_lowercase)
for (size_t n = 0; n < mycall.length(); n++) mycall[n] = tolower(mycall[n]);
movavg_size = progdefaults.fsq_movavg;
if (movavg_size < 1) movavg_size = progdefaults.fsq_movavg = 1;
if (movavg_size > MOVAVGLIMIT) movavg_size = progdefaults.fsq_movavg = MOVAVGLIMIT;
for (int i = 0; i < NUMBINS; i++) binfilt[i]->setLength(movavg_size);
printit(speed, bandwidth, symlen, SHIFT_SIZE, peak_hits, basetone);
}
bool fsq::valid_char(int ch)
{
if ( ch == 10 || ch == 163 || ch == 176 ||
ch == 177 || ch == 215 || ch == 247 ||
(ch > 31 && ch < 128))
return true;
return false;
}
//=====================================================================
// receive processing
//=====================================================================
bool fsq::fsq_squelch_open()
{
return ch_sqlch_open || metric >= progStatus.sldrSquelchValue;
}
static std::string triggers = " !#$%&'()*+,-.;<=>?@[\\]^_{|}~";
static std::string allcall = "allcall";
static std::string cqcqcq = "cqcqcq";
static fre_t call("([[:alnum:]]?[[:alpha:]/]+[[:digit:]]+[[:alnum:]/]+)", REG_EXTENDED);
// test for valid callsign
// returns:
// 0 - not a callsign
// 1 - mycall
// 2 - allcall
// 4 - cqcqcq
// 8 - any other valid call
int fsq::valid_callsign(std::string s)
{
if (s.length() < 3) return 0;
if (s.length() > 20) return 0;
if (s == allcall) return 2;
if (s == cqcqcq) return 4;
if (s == mycall) return 1;
if (s.find("Heard") != std::string::npos) return 0;
static char sz[21];
memset(sz, 0, 21);
strcpy(sz, s.c_str());
bool matches = call.match(sz);
return (matches ? 8 : 0);
}
void fsq::parse_rx_text()
{
char ztbuf[20];
struct timeval tv;
gettimeofday(&tv, NULL);
struct tm tm;
time_t t_temp;
t_temp=(time_t)tv.tv_sec;
gmtime_r(&t_temp, &tm);
strftime(ztbuf, sizeof(ztbuf), "%Y%m%d,%H%M%S", &tm);
toprint.clear();
if (rx_text.empty()) return;
if (rx_text.length() > 65536) {
rx_text.clear();
return;
}
state = TEXT;
size_t p = rx_text.find(':');
if (p == 0) {
rx_text.erase(0,1);
return;
}
if (p == std::string::npos ||
rx_text.length() < p + 2) {
return;
}
std::string rxcrc = rx_text.substr(p+1,2);
station_calling.clear();
int max = p+1;
if (max > 20) max = 20;
std::string substr;
for (int i = 1; i < max; i++) {
if (rx_text[p-i] <= ' ' || rx_text[p-i] > 'z') {
rx_text.erase(0, p+1);
return;
}
substr = rx_text.substr(p-i, i);
if ((crc.sval(substr) == rxcrc) && valid_callsign(substr)) {
station_calling = substr;
break;
}
}
if (station_calling == mycall) { // do not display any of own rx stream
LOG_ERROR("Station calling is mycall: %s", station_calling.c_str());
rx_text.erase(0, p+3);
return;
}
if (!station_calling.empty()) {
REQ(add_to_heard_list, station_calling, szestimate);
if (enable_heard_log) {
std::string sheard = ztbuf;
sheard.append(",").append(station_calling);
sheard.append(",").append(szestimate).append("\n");
heard_log << sheard;
heard_log.flush();
}
}
// remove station_calling, colon and checksum
rx_text.erase(0, p+3);
// extract all directed callsigns
// look for 'allcall', 'cqcqcq' or mycall
bool all = false;
bool directed = false;
// test next word in std::string
size_t tr_pos = 0;
char tr = rx_text[tr_pos];
size_t trigger = triggers.find(tr);
// strip any leading spaces before either text or first directed callsign
while (rx_text.length() > 1 &&
triggers.find(rx_text[0]) != std::string::npos)
rx_text.erase(0,1);
// find first word
while ( tr_pos < rx_text.length()
&& ((trigger = triggers.find(rx_text[tr_pos])) == std::string::npos) ) {
tr_pos++;
}
while (trigger != std::string::npos && tr_pos < rx_text.length()) {
int word_is = valid_callsign(rx_text.substr(0, tr_pos));
if (word_is == 0) {
rx_text.insert(0," ");
break; // not a callsign
}
if (word_is == 1) {
directed = true; // mycall
}
// test for cqcqcq and allcall
else if (word_is != 8)
all = true;
rx_text.erase(0, tr_pos);
while (rx_text.length() > 1 &&
(rx_text[0] == ' ' && rx_text[1] == ' '))
rx_text.erase(0,1);
if (rx_text[0] != ' ') break;
rx_text.erase(0, 1);
tr_pos = 0;
tr = rx_text[tr_pos];
trigger = triggers.find(tr);
while ( tr_pos < rx_text.length() && (trigger == std::string::npos) ) {
tr_pos++;
tr = rx_text[tr_pos];
trigger = triggers.find(tr);
}
}
if ( (all == false) && (directed == false)) {
rx_text.clear();
return;
}
// remove eot if present
if (rx_text.length() > 3) rx_text.erase(rx_text.length() - 3);
toprint.assign(station_calling).append(":");
// test for trigger
tr = rx_text[0];
trigger = triggers.find(tr);
if (trigger == NIT) {
tr = ' '; // force to be text line
rx_text.insert(0, " ");
}
// if asleep suppress all but the * trigger
if (btn_SELCAL->value() == 0) {
if (tr == '*') parse_star();
rx_text.clear();
return;
}
// now process own call triggers
if (directed) {
switch (tr) {
case ' ': parse_space(false); break;
case '?': parse_qmark(); break;
case '*': parse_star(); break;
case '+': parse_plus(); break;
case '-': break;//parse_minus(); break;
case ';': parse_relay(); break;
case '!': parse_repeat(); break;
case '~': parse_delayed_repeat(); break;
case '#': parse_pound(); break;
case '$': parse_dollar(); break;
case '@': parse_at(); break;
case '&': parse_amp(); break;
case '^': parse_carat(); break;
case '%': parse_pcnt(); break;
case '|': parse_vline(); break;
case '>': parse_greater(); break;
case '<': parse_less(); break;
case '[': parse_relayed(); break;
}
}
// if allcall; only respond to the ' ', '*', '#', '%', and '[' triggers
else {
switch (tr) {
case ' ': parse_space(true); break;
case '*': parse_star(); break;
case '#': parse_pound(); break;
case '%': parse_pcnt(); break;
case '[': parse_relayed(); break;
}
}
rx_text.clear();
}
void fsq::parse_space(bool all)
{
display_fsq_rx_text(toprint.append(rx_text).append("\n"), FTextBase::FSQ_DIR);
}
void fsq::parse_qmark(std::string relay)
{
std::string response = station_calling;
if (!relay.empty()) response.append(";").append(relay);
response.append(" snr=").append(szestimate);
reply(response);
display_fsq_rx_text(toprint.append(rx_text).append("\n"), FTextBase::FSQ_DIR);
}
void fsq::parse_dollar(std::string relay)
{
std::string response = station_calling;
if (!relay.empty()) response.append(";").append(relay);
response.append(" Heard:\n");
response.append(heard_list());
reply(response);
display_fsq_rx_text(toprint.append(rx_text).append("\n"), FTextBase::FSQ_DIR);
}
void fsq::parse_star()
{
REQ(enableSELCAL);
reply(std::string(station_calling).append(" ack"));
}
// immediate repeat of msg
void fsq::parse_repeat()
{
std::string response;
rx_text.erase(0, 1);
if (rx_text[0] != ' ') rx_text.insert(0, " ");
response.assign(" ");
response.append(rx_text);
reply(response);
display_fsq_rx_text(toprint.append(rx_text).append("\n"), FTextBase::FSQ_DIR);
}
// delayed repeat of msg
void fsq::parse_delayed_repeat()
{
std::string response;
rx_text.erase(0, 1);
if (rx_text[0] != ' ') rx_text.insert(0, " ");
response.assign(" ");
response.append(rx_text);
delayed_reply(response, 15);
display_fsq_rx_text(toprint.append(rx_text).append("\n"), FTextBase::FSQ_DIR);
}
// extended relay of msg
// k2a sees : k1a:; k3a hi
// k2a sends: k2a:22k3a[k1a] hi
void fsq::parse_relay()
{
std::string send_txt = rx_text;
send_txt.erase(0,1); // remove ';'
if (send_txt.empty()) return;
while (send_txt[0] == ' ' && !send_txt.empty())
send_txt.erase(0,1); // remove leading spaces
// find trigger
size_t p = 0;
while ((triggers.find(send_txt[p]) == NIT) && p < send_txt.length()) p++;
std::string response = std::string("[").append(station_calling).append("]");
send_txt.insert(p, response);
if ((p = send_txt.find('^')) != NIT) send_txt.insert(p, "^");
display_fsq_rx_text(toprint.append(rx_text).append("\n"), FTextBase::FSQ_DIR);
reply(send_txt);
}
// k3a sees : k2a: [k1a]@
// or : k2a:[k1a]@
void fsq::parse_relayed()
{
std::string relayed = "";
size_t p1 = rx_text.find('[');
if (p1 == NIT) {
LOG_ERROR("%s", "missing open bracket");
return;
}
rx_text.erase(0,p1 + 1);
if (rx_text.empty()) return;
size_t p2 = rx_text.find(']');
if (p2 == NIT) {
LOG_ERROR("%s", "missing end bracket");
return;
}
relayed = rx_text.substr(0, p2);
rx_text.erase(0, p2 + 1);
if (rx_text.empty()) return;
if (triggers.find(rx_text[0]) == NIT) {
LOG_ERROR("%s", "invalid relay trigger");
return;
}
// execute trigger
switch (rx_text[0]) {
case ' ' : {
std::string response = station_calling;
response.append(";").append(relayed).append(rx_text);
display_fsq_rx_text(toprint.append(response).append("\n"), FTextBase::FSQ_DIR);
} break;
case '$' : parse_dollar(relayed); break;
case '&' : parse_amp(relayed); break;
case '?' : parse_qmark(relayed); break;
case '@' : parse_at(relayed); break;
case '^' : parse_carat(relayed); break;
case '|' : parse_vline(relayed); break;
case '#' : parse_pound(relayed); break;
case '<' : parse_less(relayed); break;
case '>' : parse_greater(relayed); break;
default : break;
}
}
// rx_text[0] will be '#'
void fsq::parse_pound(std::string relay)
{
size_t p1 = NIT, p2 = NIT;
std::string fname = "";
p1 = rx_text.find('[');
if (p1 != NIT) {
p2 = rx_text.find(']', p1);
if (p2 != NIT) {
fname = rx_text.substr(p1 + 1, p2 - p1 - 1);
fname = fl_filename_name(fname.c_str());
} else p2 = 0;
} else p2 = 0;
if (fname.empty()) {
if (!relay.empty()) fname = relay;
else fname = station_calling;
fname.append(".txt");
}
if (fname.find(".txt") == std::string::npos) fname.append(".txt");
if (rx_text[rx_text.length() -1] != '\n') rx_text.append("\n");
size_t p3 = NIT;
while( (p3 = fname.find("/")) != NIT) fname[p3] = '.';
while( (p3 = fname.find("\\")) != NIT) fname[p3] = '.';
std::ofstream rxfile;
fname.insert(0, TempDir);
if (progdefaults.always_append) {
rxfile.open(fname.c_str(), std::ios::app);
} else {
rxfile.open(fname.c_str(), std::ios::out);
}
if (!rxfile) return;
if (progdefaults.add_fsq_msg_dt) {
rxfile << "Received: " << zdate() << ", " << ztime() << "\n";
rxfile << rx_text.substr(p2+1) << "\n";
} else
rxfile << rx_text.substr(p2+1);
rxfile.close();
display_fsq_rx_text(toprint.append(rx_text).append("\n"), FTextBase::FSQ_DIR);
std::string response = station_calling;
if (!relay.empty()) response.append(";").append(relay);
response.append(" ack");
reply(response);
}
void fsq::parse_plus(std::string relay)
{
size_t p1 = NIT, p2 = NIT;
std::string fname = "";
p1 = rx_text.find('[');
if (p1 != NIT) {
p2 = rx_text.find(']', p1);
if (p2 != NIT) {
fname = rx_text.substr(p1 + 1, p2 - p1 - 1);
fname = fl_filename_name(fname.c_str());
} else p2 = 0;
}
if (fname.empty()) {
if (!relay.empty()) fname = relay;
else fname = station_calling;
fname.append(".txt");
}
std::ifstream txfile;
bool append = (fname == station_calling);
std::string pathname = TempDir;
if (append) {
pathname.append(fname).append(".txt");
txfile.open(pathname.c_str());
} else {
pathname.append(fname);
txfile.open(pathname.c_str());
}
if (!txfile) {
reply(std::string(station_calling).append(" not found"));
return;
}
std::stringstream outtext(station_calling);
outtext << " [" << fname << "]\n";
char ch = txfile.get();
while (!txfile.eof()) {
outtext << ch;
ch = txfile.get();
}
txfile.close();
std::string response = station_calling;
if (!relay.empty()) response.append(";").append(relay);
response.append(outtext.str());
reply(response);
}
void fsq::parse_minus()
{
display_fsq_rx_text(toprint.append(rx_text).append(" nia\n"), FTextBase::FSQ_DIR);
reply(std::string(station_calling).append(" not supported"));
}
void fsq::parse_at(std::string relay)
{
std::string response = station_calling;
if (!relay.empty()) response.append(";").append(relay);
response.append(" ").append(progdefaults.myQth);
reply(response);
display_fsq_rx_text(toprint.append(rx_text).append("\n"), FTextBase::FSQ_DIR);
}
void fsq::parse_amp(std::string relay)
{
std::string response = station_calling;
if (!relay.empty()) response.append(";").append(relay);
response.append(" ").append(progdefaults.fsqQTCtext);
reply(response);
display_fsq_rx_text(toprint.append(rx_text).append("\n"), FTextBase::FSQ_DIR);
}
void fsq::parse_carat(std::string relay)
{
std::string response = station_calling;
if (!relay.empty()) response.append(";").append(relay);
response.append(" fldigi ").append(PACKAGE_VERSION);
reply(response);
display_fsq_rx_text(toprint.append(rx_text).append("\n"), FTextBase::FSQ_DIR);
}
void fsq::parse_pcnt()
{
switch (rx_text[2]) {
case 'L' :
image_mode = 0; picW = 320; picH = 240;
break;
case 'S' :
image_mode = 1; picW = 160; picH = 120;
break;
case 'F' :
image_mode = 2; picW = 640; picH = 480;
break;
case 'V' :
image_mode = 3; picW = 640; picH = 480;
break;
case 'P' :
image_mode = 4; picW = 240; picH = 300;
break;
case 'p' :
image_mode = 5; picW = 240; picH = 300;
break;
case 'M' :
image_mode = 6; picW = 120; picH = 150;
break;
case 'm' :
image_mode = 7; picW = 120; picH = 150;
break;
}
REQ( fsq_showRxViewer, picW, picH, rx_text[2] );
image_counter = 0;
picf = 0;
row = col = rgb = 0;
state = IMAGE;
display_fsq_rx_text(toprint.append(rx_text).append("\n"), FTextBase::FSQ_DIR);
}
void fsq::parse_vline(std::string relay)
{
display_fsq_rx_text(toprint.append(rx_text).append("\n"), FTextBase::FSQ_DIR);
std::string alert = "Message received from ";
if (relay.empty()) alert.append(station_calling);
else alert.append(relay);
alert.append("\n").append("at: ").append(zshowtime()).append("\n");
alert.append(rx_text.substr(1));
REQ(post_alert, alert, progdefaults.fsq_notify_time_out, relay);
}
void fsq::send_ack(std::string relay)
{
std::string response = station_calling;
if (!relay.empty()) response.append(";").append(relay);
response.append(" ack");
reply(response);
}
void fsq::parse_greater(std::string relay)
{
std::string response;
response.assign(station_calling);
if (!relay.empty()) response.append(";").append(relay);
double spd = progdefaults.fsqbaud;
if (spd == 1.5 ) {
spd = 2.0;
response.append(" 2.0 baud");
} else if (spd == 2.0) {
spd = 3.0;
response.append(" 3.0 baud");
} else if (spd == 3.0) {
spd = 4.5;
response.append(" 4.5 baud");
} else if (spd == 4.5) {
spd = 6.0;
response.append(" 6.0 baud");
} else if (spd == 6.0) {
response.append(" 6.0 baud");
}
progdefaults.fsqbaud = spd;
adjust_for_speed();
reply(response);
display_fsq_rx_text(toprint.append(rx_text).append("\n"), FTextBase::FSQ_DIR);
}
void fsq::parse_less(std::string relay)
{
std::string response;
response.assign(station_calling);
if (!relay.empty()) response.append(";").append(relay);
double spd = progdefaults.fsqbaud;
if (spd == 2.0) {
spd = 1.5;
response.append(" 1.5 baud");
} else if (spd == 3.0) {
spd = 2.0;
response.append(" 2.0 baud");
} else if (spd == 4.5) {
spd = 3.0;
response.append(" 3.0 baud");
} else if (spd == 6.0) {
spd = 4.5;
response.append(" 4.5 baud");
}
progdefaults.fsqbaud = spd;
adjust_for_speed();
reply(response);
display_fsq_rx_text(toprint.append(rx_text).append("\n"), FTextBase::FSQ_DIR);
}
void fsq::lf_check(int ch)
{
static char lfpair[3] = "01";
static char bstrng[4] = "012";
lfpair[0] = lfpair[1];
lfpair[1] = 0xFF & ch;
bstrng[0] = bstrng[1];
bstrng[1] = bstrng[2];
bstrng[2] = 0xFF & ch;
b_bot = b_eol = b_eot = false;
if (bstrng[0] == FSQEOT[0] // find SP SP BS SP
&& bstrng[1] == FSQEOT[1]
&& bstrng[2] == FSQEOT[2]
) {
b_eot = true;
} else if (lfpair[0] == FSQBOL[0] && lfpair[1] == FSQBOL[1]) {
b_bot = true;
} else if (lfpair[0] == FSQEOL[0] && lfpair[1] == FSQEOL[1]) {
b_eol = true;
}
}
void fsq::process_symbol(int sym)
{
int nibble = 0;
int curr_ch = -1;
symbol = sym;
nibble = symbol - prev_symbol;
if (nibble < -99 || nibble > 99) {
prev_symbol = symbol;
return;
}
nibble = nibbles[nibble + 99];
// -1 is our idle symbol, indicating we already have our symbol
if (nibble >= 0) { // process nibble
curr_nibble = nibble;
// single-nibble characters
if ((prev_nibble < 29) & (curr_nibble < 29)) {
curr_ch = wsq_varidecode[prev_nibble];
// double-nibble characters
} else if ( (prev_nibble < 29) &&
(curr_nibble > 28) &&
(curr_nibble < 32)) {
curr_ch = wsq_varidecode[prev_nibble * 32 + curr_nibble];
}
if (curr_ch > 0) {
if (enable_audit_log) {
audit_log << fsq_ascii[curr_ch];// & 0xFF];
if (curr_ch == '\n') audit_log << '\n';
audit_log.flush();
}
lf_check(curr_ch);
if (b_bot) {
ch_sqlch_open = true;
rx_text.clear();
}
if (fsq_squelch_open()) {
write_rx_mon_char(curr_ch);
if (b_bot)
{
char ztbuf[20];
struct timeval tv;
gettimeofday(&tv,NULL);
struct tm tm;
time_t t_temp;
t_temp=(time_t)tv.tv_sec;
gmtime_r(&t_temp, &tm);
strftime(ztbuf,sizeof(ztbuf),"%m/%d %H:%M:%S ",&tm);
display_fsq_mon_text( ztbuf, FTextBase::CTRL);
display_fsq_mon_text( fsq_bot, FTextBase::CTRL);
}
if (b_eol) {
display_fsq_mon_text( fsq_eol, FTextBase::CTRL);
noisefilt->reset();
noisefilt->run(1);
sigfilt->reset();
sigfilt->run(1);
snprintf(szestimate, sizeof(szestimate), "%.0f db", s2n );
}
if (b_eot) {
snprintf(szestimate, sizeof(szestimate), "%.0f db", s2n );
noisefilt->reset();
noisefilt->run(1);
sigfilt->reset();
sigfilt->run(1);
display_fsq_mon_text( fsq_eot, FTextBase::CTRL);
}
}
if ( valid_char(curr_ch) || b_eol || b_eot ) {
if (rx_text.length() > 32768) rx_text.clear();
if ( fsq_squelch_open() || !progStatus.sqlonoff ) {
rx_text += curr_ch;
if (b_eot) {
parse_rx_text();
if (state == TEXT)
ch_sqlch_open = false;
}
}
}
if (fsq_squelch_open() && (b_eot || b_eol)) {
ch_sqlch_open = false;
}
}
prev_nibble = curr_nibble;
}
prev_symbol = symbol;
}
// find the maximum bin
// 908 Hz and 1351 Hz respectively for original center frequency of 1145 Hz
// 1280 to 1720 for a 1500 Hz center frequency
void fsq::process_tones()
{
max = 0;
peak = NUMBINS / 2;
// examine FFT bin contents over bandwidth +/- ~ 50 Hz
int firstbin = frequency * FSQ_SYMLEN / samplerate - NUMBINS / 2;
double sigval = 0;
double min = 3.0e8;
int minbin = NUMBINS / 2;
for (int i = 0; i < NUMBINS; ++i) {
val = norm(fft_data[i + firstbin]);
// looking for maximum signal
tones[i] = binfilt[i]->run(val);
if (tones[i] > max) {
max = tones[i];
peak = i;
}
// looking for minimum signal in a 3 bin sequence
if (tones[i] < min) {
min = tones[i];
minbin = i;
}
}
sigval = tones[(peak-1) < 0 ? (NUMBINS - 1) : (peak - 1)] +
tones[peak] +
tones[(peak+1) == NUMBINS ? 0 : (peak + 1)];
min = tones[(minbin-1) < 0 ? (NUMBINS - 1) : (minbin - 1)] +
tones[minbin] +
tones[(minbin+1) == NUMBINS ? 0 : (minbin + 1)];
if (min == 0) min = 1e-10;
s2n = 10 * log10( snfilt->run(sigval/min)) - 34.0 + movavg_size / 4;
if (s2n <= 0) metric = 2 * (25 + s2n);
if (s2n > 0) metric = 50 * ( 1 + s2n / 45);
metric = clamp(metric, 0, 100);
display_metric(metric);
if (metric < progStatus.sldrSquelchValue && ch_sqlch_open)
ch_sqlch_open = false;
// requires consecutive hits
if (peak == prev_peak) {
peak_counter++;
} else {
peak_counter = 0;
}
if ((peak_counter >= peak_hits) &&
(peak != last_peak) &&
(fsq_squelch_open() || !progStatus.sqlonoff)) {
process_symbol(peak);
peak_counter = 0;
last_peak = peak;
}
prev_peak = peak;
}
void fsq::recvpic(double smpl)
{
phase -= phidiff;
if (phase < 0) phase += 2.0 * M_PI;
cmplx z = smpl * cmplx( cos(phase), sin(phase ) );
picfilter->run( z, currz);
pixel += arg(conj(prevz) * currz);// * samplerate / TWOPI;
amplitude += norm(currz);
prevz = currz;
if (image_counter <= -RXspp) {
pixel = 0;
amplitude = 0;
image_counter++;
return;
}
if ((image_counter++ % RXspp) == 0) {
amplitude /= RXspp;
pixel /= RXspp;
pixel *= (samplerate / TWOPI);
byte = pixel / 1.5 + 128;
byte = (int)CLAMP( byte, 0.0, 255.0);
// FSQCAL sends blue-green-red
static int RGB[] = {2, 1, 0};
if (image_mode == 2 || image_mode == 5 || image_mode == 7) { // grey scale
pixelnbr = 3 * (col + row * picW);
REQ(fsq_updateRxPic, byte, pixelnbr);
REQ(fsq_updateRxPic, byte, pixelnbr + 1);
REQ(fsq_updateRxPic, byte, pixelnbr + 2);
if (++ col == picW) {
col = 0;
row++;
if (row >= picH) {
state = TEXT;
REQ(fsq_enableshift);
metric = 0;
}
}
} else {
pixelnbr = RGB[rgb] + 3 * (col + row * picW);
REQ(fsq_updateRxPic, byte, pixelnbr);
if (++col == picW) {
col = 0;
if (++rgb == 3) {
rgb = 0;
row ++;
}
}
if (row >= picH) {
state = TEXT;
REQ(fsq_enableshift);
metric = 0;
}
}
pixel = 0;
amplitude = 0;
}
}
int fsq::rx_process(const double *buf, int len)
{
if (peak_hits != progdefaults.fsqhits) restart();
if (movavg_size != progdefaults.fsq_movavg) restart();
if (speed != progdefaults.fsqbaud) restart();
if (enable_heard_log != progdefaults.fsq_enable_heard_log ||
enable_audit_log != progdefaults.fsq_enable_audit_log)
toggle_logs();
if (sounder_interval != progdefaults.fsq_sounder) {
sounder_interval = progdefaults.fsq_sounder;
start_sounder(sounder_interval);
}
if (bkptr < 0) bkptr = 0;
if (bkptr >= SHIFT_SIZE) bkptr = 0;
if (len > 512) {
LOG_ERROR("fsq rx stream overrun %d", len);
}
if (progStatus.fsq_rx_abort) {
state = TEXT;
progStatus.fsq_rx_abort = false;
REQ(fsq_clear_rximage);
}
while (len) {
if (state == IMAGE) {
recvpic(*buf);
len--;
buf++;
} else {
rx_stream[BLOCK_SIZE + bkptr] = *buf;
len--;
buf++;
bkptr++;
if (bkptr == SHIFT_SIZE) {
bkptr = 0;
memmove(rx_stream, // to
&rx_stream[SHIFT_SIZE], // from
BLOCK_SIZE*sizeof(*rx_stream)); // # bytes
// fft_data gets overwritten each time with a fixed number of
// elements. Do we need to zero it out?
//memset(fft_data, 0, sizeof(fft_data));
for (int i = 0; i < BLOCK_SIZE; i++) {
double d = rx_stream[i] * a_blackman[i];
fft_data[i] = cmplx(d, d);
}
fft->ComplexFFT(fft_data);
process_tones();
}
}
}
return 0;
}
//=====================================================================
// transmit processing
//=====================================================================
// implement the symbol counter using a new thread whose thread loop
// time is equal to a symbol length 4096/12000 = 341 milliseconds
// symbol loop decrements symbol counts and send_symbol increments them
// flush_buffer will then awake for the symbol count to be zero
// have not observed a remaining count > 1 so this might be an over kill!
// typical awake period is 90 msec
void fsq::flush_buffer()
{
for (int i = 0; i < 64; i++) outbuf[i] = 0;
ModulateXmtr(outbuf, 64);
return;
}
#include "confdialog.h"
void fsq::send_tone(int tone)
{
double phaseincr;
double freq;
if (speed != progdefaults.fsqbaud) restart();
freq = (tx_basetone + tone * spacing) * samplerate / FSQ_SYMLEN;
if (test_signal_window && test_signal_window->visible() && btnOffsetOn->value())
freq += ctrl_freq_offset->value();
phaseincr = 2.0 * M_PI * freq / samplerate;
prevtone = tone;
int send_symlen = symlen;
if (fsq_tx_image) send_symlen = 4096; // must use 3 baud symlen for image xfrs
for (int i = 0; i < send_symlen; i++) {
outbuf[i] = cos(txphase);
txphase -= phaseincr;
if (txphase < 0) txphase += TWOPI;
}
ModulateXmtr(outbuf, send_symlen);
}
void fsq::send_symbol(int sym)
{
tone = (prevtone + sym + 1) % 33;
send_tone(tone);
}
void fsq::send_idle()
{
send_symbol(28);
send_symbol(30);
}
static bool send_eot = false;
void fsq::send_char(int ch)
{
if (!ch) return send_idle();
int sym1 = fsq_varicode[ch][0];
int sym2 = fsq_varicode[ch][1];
send_symbol(sym1);
if (sym2 > 28)
send_symbol(sym2);
if (valid_char(ch) && !(send_bot || send_eot))
put_echo_char(ch);
write_mon_tx_char(ch);
}
void fsq::send_image()
{
int W = 640, H = 480; // grey scale transfer (FAX)
bool color = true;
float freq, phaseincr;
float radians = 2.0 * M_PI / samplerate;
if (!fsqpicTxWin || !fsqpicTxWin->visible()) {
return;
}
switch (selfsqpicSize->value()) {
case 0 : W = 160; H = 120; break;
case 1 : W = 320; H = 240; break;
case 2 : W = 640; H = 480; color = false; break;
case 3 : W = 640; H = 480; break;
case 4 : W = 240; H = 300; break;
case 5 : W = 240; H = 300; color = false; break;
case 6 : W = 120; H = 150; break;
case 7 : W = 120; H = 150; color = false; break;
}
REQ(fsq_clear_tximage);
stop_deadman();
freq = frequency - 200;
#define PHASE_CORR 200
phaseincr = radians * freq;
for (int n = 0; n < PHASE_CORR; n++) {
outbuf[n] = cos(txphase);
txphase -= phaseincr;
if (txphase < 0) txphase += TWOPI;
}
ModulateXmtr(outbuf, 10);
if (color == false) { // grey scale image
for (int row = 0; row < H; row++) {
memset(outbuf, 0, 10 * sizeof(*outbuf));
for (int col = 0; col < W; col++) {
if (stopflag) return;
tx_pixelnbr = col + row * W;
tx_pixel = 0.3 * fsqpic_TxGetPixel(tx_pixelnbr, 0) + // red
0.6 * fsqpic_TxGetPixel(tx_pixelnbr, 1) + // green
0.1 * fsqpic_TxGetPixel(tx_pixelnbr, 2); // blue
REQ(fsq_updateTxPic, tx_pixel, tx_pixelnbr*3 + 0);
REQ(fsq_updateTxPic, tx_pixel, tx_pixelnbr*3 + 1);
REQ(fsq_updateTxPic, tx_pixel, tx_pixelnbr*3 + 2);
freq = frequency - 200 + tx_pixel * 1.5;
phaseincr = radians * freq;
for (int n = 0; n < 10; n++) {
outbuf[n] = cos(txphase);
txphase -= phaseincr;
if (txphase < 0) txphase += TWOPI;
}
ModulateXmtr(outbuf, 10);
Fl::awake();
}
}
} else {
for (int row = 0; row < H; row++) {
for (int color = 2; color >= 0; color--) {
memset(outbuf, 0, 10 * sizeof(*outbuf));
for (int col = 0; col < W; col++) {
if (stopflag) return;
tx_pixelnbr = col + row * W;
tx_pixel = fsqpic_TxGetPixel(tx_pixelnbr, color);
REQ(fsq_updateTxPic, tx_pixel, tx_pixelnbr*3 + color);
freq = frequency - 200 + tx_pixel * 1.5;
phaseincr = radians * freq;
for (int n = 0; n < 10; n++) {
outbuf[n] = cos(txphase);
txphase -= phaseincr;
if (txphase < 0) txphase += TWOPI;
}
ModulateXmtr(outbuf, 10);
}
Fl::awake();
}
}
}
start_deadman();
}
void fsq::send_string(std::string s)
{
for (size_t n = 0; n < s.length(); n++)
send_char(s[n]);
if ((s == FSQEOT || s == FSQEOL) && fsq_tx_image) send_image();
}
void fsq::fsq_send_image(std::string s) {
fsq_tx_image = true;
fsq_string = std::string("IMAGE:").append(s);
write_fsq_que(fsq_string);
fsq_xmt(s);
}
int fsq::tx_process()
{
modem::tx_process();
if (send_bot) {
std::string send;
send.assign(" ").append(FSQBOL).append(mycall).append(":");
if (progdefaults.fsq_directed)
send.append(crc.sval(mycall));
send_string(send);
send_bot = false;
}
int c = get_tx_char();
if (c == GET_TX_CHAR_ETX || c == -1) { // end of text or empty tx buffer
send_eot = true;
if (progdefaults.fsq_directed)
send_string(std::string(FSQEOT));
else
send_string(std::string(FSQEOL));
send_eot = false;
put_echo_char('\n');
if (c == -1) REQ(&FTextTX::clear, TransmitText);
flush_buffer();
stopflag = false;
fsq_tx_image = false;
return -1;
}
if ( stopflag ) { // aborts transmission
static std::string aborted = " !ABORTED!\n";
for (size_t n = 0; n < aborted.length(); n++)
put_echo_char(aborted[n]);
fsq_tx_image = false;
stopflag = false;
clear_xmt_arrays();
return -1;
}
send_char(c);
return 0;
}
//==============================================================================
// delayed transmit
//==============================================================================
static pthread_mutex_t fsq_tx_mutex = PTHREAD_MUTEX_INITIALIZER;
static float xmt_repeat_try = 6.0;
static std::string tx_text_queue = "";
static std::vector<std::string> commands;
#define NUMCOMMANDS 10
static size_t next = 0;
void clear_xmt_arrays()
{
commands.erase(commands.begin(), commands.begin());
tx_text_queue.clear();
fsq_tx_text->clear();
}
double fsq_xmtdelay() // in seconds
{
#define MIN_DELAY 50
#define MAX_DELAY 500
srand((int)clock());
double scaled = (double)rand()/RAND_MAX;
double delay = ((MAX_DELAY - MIN_DELAY + 1 ) * scaled + MIN_DELAY) / 1000.0;
if (delay < 0.05) delay = 0.05;
if (delay > 0.5) delay = 0.5;
return delay;
}
void fsq_repeat_last_command()
{
using ::next; // disambiguate from std::next
if (commands.empty()) return;
fsq_tx_text->clear();
fsq_tx_text->addstr(sz2utf8(commands[next].c_str()));
next++;
if (next == commands.size()) {
next = 0;
}
}
int get_fsq_tx_char(void)
{
guard_lock tx_proc_lock(&fsq_tx_mutex);
if (tx_text_queue.empty()) return (GET_TX_CHAR_NODATA);
int c = tx_text_queue[0];
tx_text_queue.erase(0,1);
if (c == GET_TX_CHAR_ETX) {
return c;
}
if (c == -1)
return(GET_TX_CHAR_NODATA);
if (c == '^') {
c = tx_text_queue[0];
tx_text_queue.erase(0,1);
if (c == -1) return(GET_TX_CHAR_NODATA);
switch (c) {
case 'r':
return(GET_TX_CHAR_ETX);
break;
case 'R':
return(GET_TX_CHAR_ETX);
break;
default: ;
}
}
start_deadman();
return(c);
}
void try_transmit(void *)
{
if (active_modem != fsq_modem) return;
if (!active_modem->fsq_squelch_open() && trx_state == STATE_RX) {
::next = 0;
fsq_que_clear();
//LOG_WARN("%s", "start_tx()");
start_tx();
return;
}
if (xmt_repeat_try > 0) {
xmt_repeat_try -= 0.5;
static char szwaiting[50];
snprintf(szwaiting, sizeof(szwaiting), "Waiting %4.2f", xmt_repeat_try);
fsq_que_clear();
write_fsq_que(std::string(szwaiting).append("\n").append(fsq_string));
//LOG_WARN("%s", szwaiting);
Fl::repeat_timeout(0.5, try_transmit);
return;
} else {
static const char szsquelch[50] = "Squelch open. Transmit timed out!";
display_fsq_rx_text(std::string("\n").append(szsquelch).append("\n").c_str(), FTextBase::ALTR);
tx_text_queue.clear();
fsq_que_clear();
if (active_modem->fsq_tx_image) active_modem->fsq_tx_image = false;
//LOG_WARN("%s", szsquelch);
return;
}
return;
}
inline void _fsq_xmt(std::string s)
{
tx_text_queue.clear();
if (commands.size() > NUMCOMMANDS)
commands.pop_back();
commands.insert(commands.begin(), 1, s);
s.append("^r");
tx_text_queue = s;
xmt_repeat_try = progdefaults.fsq_time_out;
Fl::add_timeout(0.5 + fsq_xmtdelay(), try_transmit);
}
void fsq_xmt_mt(void *cs = (void *)0)
{
guard_lock tx_proc_lock(&fsq_tx_mutex);
if (active_modem != fsq_modem) return;
if (!cs) return;
std::string s;
s.assign((char *) cs);
delete (char *) cs;
if(!s.empty()) {
_fsq_xmt(s);
}
}
void fsq_xmt(std::string s)
{
guard_lock tx_proc_lock(&fsq_tx_mutex);
if (active_modem != fsq_modem) return;
if(!s.empty()) {
_fsq_xmt(s);
}
}
void fsq_transmit(void *a = (void *)0)
{
guard_lock tx_proc_lock(&fsq_tx_mutex);
if (active_modem != fsq_modem) return;
if (!tx_text_queue.empty()) {
size_t p = tx_text_queue.find("^r");
tx_text_queue.erase(p);
tx_text_queue += ' ';
int nxt = fsq_tx_text->nextChar();
while (nxt != -1) {
tx_text_queue += nxt;
nxt = fsq_tx_text->nextChar();
}
commands.erase(commands.begin(), commands.begin());
commands.insert(commands.begin(), 1, tx_text_queue);
tx_text_queue.append("^r");
fsq_tx_text->clear();
return;
//LOG_WARN("A: %s", tx_text_queue.c_str());
}
int nxt = fsq_tx_text->nextChar();
while (nxt != -1) {
tx_text_queue += nxt;
nxt = fsq_tx_text->nextChar();
}
if (commands.size() > NUMCOMMANDS)
commands.pop_back();
commands.insert(commands.begin(), 1, tx_text_queue);
tx_text_queue.append("^r");
fsq_tx_text->clear();
//LOG_WARN("B: %s", tx_text_queue.c_str());
xmt_repeat_try = progdefaults.fsq_time_out;
Fl::add_timeout(0.5 + fsq_xmtdelay(), try_transmit);
}
void timed_xmt(void *)
{
//LOG_WARN("%s", fsq_delayed_string.c_str());
fsq_xmt(fsq_delayed_string);
}
static float secs = 0;
void fsq_add_tx_timeout(void *a = 0)
{
Fl::add_timeout(secs, timed_xmt);
}
void fsq::reply(std::string s)
{
fsq_string = std::string("SEND: ").append(s);
write_fsq_que(fsq_string);
char *cs = (char *)0;
cs = new char[s.size() + 1];
if(!cs) return;
cs[s.size()] = 0;
memcpy(cs, s.c_str(), s.size());
Fl::awake(fsq_xmt_mt, (void *) cs);
}
void fsq::delayed_reply(std::string s, int delay)
{
fsq_string = std::string("DELAYED SEND: ").append(s);
write_fsq_que(fsq_string);
fsq_delayed_string = s;
secs = delay;
Fl::awake(fsq_add_tx_timeout, 0);
//LOG_WARN("%s : %d", s.c_str(), delay);
}
//==============================================================================
// Heard list aging
//==============================================================================
void aging(void *who)
{
fsq *me = (fsq *)who;
if (me != active_modem) return;
age_heard_list();
Fl::repeat_timeout(60.0, aging, me);
}
void fsq_start_aging(void *who)
{
fsq *me = (fsq *)who;
Fl::remove_timeout(aging);
Fl::add_timeout(60.0, aging, me);
}
void fsq::start_aging()
{
Fl::awake(fsq_start_aging, this);
}
void fsq_stop_aging(void *)
{
Fl::remove_timeout(aging);
}
void fsq::stop_aging()
{
Fl::awake(fsq_stop_aging);
}
//==============================================================================
// Sounder support
//==============================================================================
static int sounder_tries = 10;
static double sounder_secs = 60;
void sounder(void *)
{
if (active_modem != fsq_modem) return;
if (trx_state == STATE_TX) {
Fl::repeat_timeout(active_modem->fsq_xmtdelay(), timed_xmt);
return;
}
if (active_modem->fsq_squelch_open()) {
if (--sounder_tries < 0) {
display_fsq_rx_text("\nSounder timed out!\n", FTextBase::ALTR);
sounder_tries = 10;
Fl::repeat_timeout(sounder_secs, sounder);
return;
}
Fl::repeat_timeout(10, sounder); // retry in 10 seconds
return;
}
sounder_tries = 10;
std::string xmtstr = FSQBOL;
xmtstr.append(active_modem->fsq_mycall()).append(":").append(FSQEOT);
int numsymbols = xmtstr.length();
int xmtsecs = (int)(1.0 * numsymbols * (fsq::symlen / 4096.0) / SR);
if (fsq_tx_text->eot()) {
std::string stime = ztime();
stime.erase(4);
stime.insert(2,":");
std::string sndx = "Sounded @ ";
sndx.append(stime);
display_fsq_rx_text(sndx, FTextBase::ALTR);
fsq_xmt(" ");
}
Fl::repeat_timeout(sounder_secs - xmtsecs, sounder);
}
void fsq_start_sounder()
{
if (active_modem != fsq_modem) return;
Fl::remove_timeout(sounder);
Fl::add_timeout(sounder_secs, sounder);
}
void fsq_stop_sounder()
{
Fl::remove_timeout(sounder);
}
void fsq::stop_sounder()
{
REQ(fsq_stop_sounder);
}
void fsq::start_sounder(int interval)
{
if (interval == 0) {
REQ(fsq_stop_sounder);
return;
}
switch (interval) {
case 0: return;
case 1: sounder_secs = 60; break; // 1 minute
case 2: sounder_secs = 600; break; // 10 minutes
case 3: sounder_secs = 1800; break; // 30 minutes
case 4: sounder_secs = 3600; break; // 60 minutes
default: sounder_secs = 600;
}
REQ(fsq_start_sounder);
}
#include "bitmaps.cxx"
| 44,819
|
C++
|
.cxx
| 1,585
| 25.613249
| 97
| 0.619605
|
w1hkj/fldigi
| 109
| 27
| 38
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
751,057
|
bitmaps.cxx
|
w1hkj_fldigi/src/fsq/bitmaps.cxx
|
// ----------------------------------------------------------------------------
// Copyright (C) 2014
// David Freese, W1HKJ
//
// This file is part of flrig.
//
// flrig 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 3 of the License, or
// (at your option) any later version.
//
// flrig 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, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include <FL/Fl_Bitmap.H>
static unsigned char s2n_data[] = {
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x01, 0x00,
0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00,
0x01, 0x00, 0x01, 0x80, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00,
0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x80,
0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00,
0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x80, 0x01, 0x00, 0x01, 0x00,
0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00,
0x01, 0x00, 0x01, 0x80, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00,
0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x80,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x0c, 0x00, 0x00, 0x40, 0x0c, 0x00,
0x00, 0x80, 0x03, 0x00, 0x00, 0x60, 0x0c, 0x00, 0x00, 0x80, 0x0c, 0x00,
0x00, 0x90, 0x12, 0x00, 0x00, 0x60, 0x12, 0x00, 0x00, 0x40, 0x04, 0x00,
0x00, 0x90, 0x12, 0x00, 0x00, 0xc0, 0x12, 0x00, 0x00, 0x80, 0x12, 0x00,
0x00, 0x40, 0x12, 0x00, 0x00, 0x40, 0x04, 0x00, 0x00, 0x80, 0x12, 0x00,
0x00, 0xa0, 0x12, 0x00, 0x00, 0x46, 0x12, 0x00, 0x00, 0x4c, 0x12, 0x00,
0x00, 0x40, 0x04, 0x00, 0x00, 0x40, 0x12, 0x00, 0x00, 0x90, 0x12, 0x00,
0x00, 0x20, 0x12, 0x00, 0x00, 0x40, 0x12, 0x00, 0x00, 0x40, 0x04, 0x00,
0x00, 0x20, 0x12, 0x00, 0x00, 0xf0, 0x12, 0x00, 0x00, 0x10, 0x12, 0x00,
0x00, 0x40, 0x12, 0x00, 0x00, 0x40, 0x04, 0x00, 0x00, 0x10, 0x12, 0x00,
0x00, 0x80, 0x12, 0x00, 0x00, 0xf0, 0x0c, 0x00, 0x00, 0xe0, 0x0c, 0x00,
0x00, 0x80, 0x03, 0x00, 0x00, 0xf0, 0x0c, 0x00, 0x00, 0x80, 0x0c, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
Fl_Bitmap image_s2n(s2n_data, 160, 16);
| 2,999
|
C++
|
.cxx
| 49
| 58.408163
| 79
| 0.637445
|
w1hkj/fldigi
| 109
| 27
| 38
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
751,058
|
fsq-pic.cxx
|
w1hkj_fldigi/src/fsq/fsq-pic.cxx
|
// ----------------------------------------------------------------------------
// fsqpic.cxx -- fsq image support functions
//
// Copyright (C) 2015
// Dave Freese, W1HKJ
//
// This file is part of fldigi. Adapted from code contained in gfsq source code
// distribution.
//
// Fldigi 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 3 of the License, or
// (at your option) any later version.
//
// Fldigi 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 fldigi. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include <FL/Fl_Counter.H>
#include <FL/Fl_Choice.H>
#include "gettext.h"
#include "fileselect.h"
Fl_Double_Window *fsqpicRxWin = (Fl_Double_Window *)0;
picture *fsqpicRx = (picture *)0;
Fl_Button *btnfsqRxReset = (Fl_Button *)0;
Fl_Button *btnfsqRxSave = (Fl_Button *)0;
Fl_Button *btnfsqRxClose = (Fl_Button *)0;
Fl_Counter *cnt_phase = (Fl_Counter *)0;
Fl_Counter *cnt_slant = (Fl_Counter *)0;
Fl_Double_Window *fsqpicTxWin = (Fl_Double_Window *)0;
picture *fsqpicTx = (picture *)0;
Fl_Button *btnfsqpicTransmit = (Fl_Button *)0;
Fl_Button *btnfsqpicTxSendAbort = (Fl_Button *)0;
Fl_Button *btnfsqpicTxLoad = (Fl_Button *)0;
Fl_Button *btnfsqpicTxClose = (Fl_Button *)0;
Fl_Choice *selfsqpicSize = (Fl_Choice *)0;
Fl_Shared_Image *fsqTxImg = (Fl_Shared_Image *)0;
unsigned char *fsqxmtimg = (unsigned char *)0;
unsigned char *fsqxmtpicbuff = (unsigned char *)0;
#define RAWSIZE 640*(480 + 8)*3*10
#define RAWSTART 640*4*3*10
unsigned char rawvideo[RAWSIZE + 1];
int numpixels;
int pixelptr;
int rawcol;
int rawrow;
int rawrgb;
char image_type = 'S';
int fsq_txSPP = 8;
char fsq_txclr_tooltip[24];
char fsq_txgry_tooltip[24];
static int translate = 0;
static bool enabled = false;
void correct_video()
{
int W = fsqpicRx->w();
int H = fsqpicRx->h();
int slant = cnt_slant->value();
int vidsize = W * H;
int index, rowptr, colptr;
float ratio = (((float)vidsize - (float)slant)/(float)vidsize);
unsigned char vid[W * H * 3];
for (int row = 0; row < H; row++) {
rowptr = W * 3 * row * 10;
for (int col = 0; col < W; col++) {
colptr = 10*col;
for (int rgb = 0; rgb < 3; rgb++) {
index = ratio*(rowptr + colptr + 10*W*rgb);
index += RAWSTART - 10*pixelptr;
if (index < 2) index = 2;
if (index > RAWSIZE - 2) index = RAWSIZE - 2;
vid[2 - rgb + 3 * (col + row * W)] = rawvideo[index];
}
}
}
fsqpicRx->video(vid, W*H*3);
}
void fsq_updateRxPic(unsigned char data, int pos)
{
if (!fsqpicRxWin->shown()) fsqpicRx->show();
fsqpicRx->pixel(data, pos);
int W = fsqpicRx->w();
if (image_type == 'F' || image_type == 'p' || image_type == 'm') {
int n = RAWSTART + 10*(rawcol + W * (rawrgb + 3 * rawrow));
if (n < RAWSIZE)
for (int i = 0; i < 10; i++) rawvideo[n + i] = data;
rawrgb++;
if (rawrgb == 3) {
rawrgb = 0;
rawcol++;
if (rawcol == W) {
rawcol = 0;
rawrow++;
}
}
} else
for (int i = 0; i < 10; i++) rawvideo[RAWSTART + 10*numpixels + i] = data;
numpixels++;
if (numpixels >= (RAWSIZE - RAWSTART - 10))
numpixels = RAWSIZE - RAWSTART - 10;
}
void cb_btnfsqRxReset(Fl_Widget *, void *)
{
progStatus.fsq_rx_abort = true;
}
void cb_btnfsqRxSave(Fl_Widget *, void *)
{
fsqpicRx->save_png(PicsDir.c_str());
}
void cb_btnfsqRxClose(Fl_Widget *, void *)
{
fsqpicRxWin->hide();
progStatus.fsq_rx_abort = true;
}
void cb_cnt_phase(Fl_Widget *, void *data)
{
pixelptr = cnt_phase->value();
if (pixelptr >= RAWSTART/10) {
pixelptr = RAWSTART/10 - 1;
cnt_phase->value(pixelptr);
}
if (pixelptr < -RAWSTART/10) {
pixelptr = -RAWSTART/10;
cnt_phase->value(pixelptr);
}
correct_video();
}
void cb_cnt_slant(Fl_Widget *, void *)
{
correct_video();
}
void fsq_disableshift()
{
if (!fsqpicRxWin) return;
cnt_phase->deactivate();
cnt_slant->deactivate();
btnfsqRxSave->deactivate();
fsqpicRxWin->redraw();
}
void fsq_enableshift()
{
if (!fsqpicRxWin) return;
cnt_phase->activate();
cnt_slant->activate();
btnfsqRxSave->activate();
fsqpicRxWin->redraw();
}
void fsq_createRxViewer()
{
fsqpicRxWin = new Fl_Double_Window(324, 274, _("FSQ Rx Image"));
fsqpicRxWin->xclass(PACKAGE_NAME);
fsqpicRxWin->begin();
fsqpicRx = new picture(2, 2, 320, 240);
fsqpicRx->noslant();
Fl_Group *buttons = new Fl_Group(0, fsqpicRxWin->h() - 26, fsqpicRxWin->w(), 26, "");
buttons->box(FL_FLAT_BOX);
btnfsqRxReset = new Fl_Button(2, fsqpicRxWin->h() - 26, 40, 24, "Reset");
btnfsqRxReset->callback(cb_btnfsqRxReset, 0);
cnt_phase = new Fl_Counter(46, fsqpicRxWin->h() - 24, 80, 20, "");
cnt_phase->step(1);
cnt_phase->lstep(10);
cnt_phase->minimum(-RAWSTART + 1);
cnt_phase->maximum(RAWSTART - 1);
cnt_phase->value(0);
cnt_phase->callback(cb_cnt_phase, 0);
cnt_phase->tooltip(_("Phase correction"));
cnt_slant = new Fl_Counter(140, fsqpicRxWin->h() - 24, 80, 20, "");
cnt_slant->step(1);
cnt_slant->lstep(10);
cnt_slant->minimum(-200);
cnt_slant->maximum(200);
cnt_slant->value(0);
cnt_slant->callback(cb_cnt_slant, 0);
cnt_slant->tooltip(_("Slant correction"));
btnfsqRxSave = new Fl_Button(226, fsqpicRxWin->h() - 26, 45, 24, _("Save"));
btnfsqRxSave->callback(cb_btnfsqRxSave, 0);
btnfsqRxClose = new Fl_Button(273, fsqpicRxWin->h() - 26, 45, 24, _("Close"));
btnfsqRxClose->callback(cb_btnfsqRxClose, 0);
buttons->end();
fsqpicRxWin->end();
fsqpicRxWin->resizable(fsqpicRx);
numpixels = 0;
}
void fsq_showRxViewer(int W, int H, char itype)
{
if (!fsqpicRxWin) fsq_createRxViewer();
int winW, winH;
int fsqpicX, fsqpicY;
winW = W < 320 ? 324 : W + 4;
winH = H < 240 ? 274 : H + 34;
fsqpicX = (winW - W) / 2;
fsqpicY = (winH - 30 - H) / 2;
fsqpicRxWin->size(winW, winH);
fsqpicRx->resize(fsqpicX, fsqpicY, W, H);
fsqpicRxWin->init_sizes();
fsqpicRx->clear();
fsqpicRxWin->show();
fsq_disableshift();
memset(rawvideo, 0, RAWSIZE);
numpixels = 0;
pixelptr = 0;
rawrow = rawrgb = rawcol = 0;
image_type = itype;
}
void fsq_clear_rximage()
{
fsqpicRx->clear();
fsq_disableshift();
translate = 0;
enabled = false;
numpixels = 0;
pixelptr = 0;
cnt_phase->value(0);
cnt_slant->value(0);
rawrow = rawrgb = rawcol = 0;
}
//------------------------------------------------------------------------------
// image transmit functions
//------------------------------------------------------------------------------
int fsq_load_image(const char *n, int W, int H) {
int D = 0;
unsigned char *img_data;
switch (selfsqpicSize->value()) {
case 0 : W = 160; H = 120; break;
case 1 : W = 320; H = 240; break;
case 2 : W = 640; H = 480; break;
case 3 : W = 640; H = 480; break;
case 4 : W = 240; H = 300; break;
case 5 : W = 240; H = 300; break;
case 6 : W = 120; H = 150; break;
case 7 : W = 120; H = 150; break;
}
if (fsqTxImg) {
fsqTxImg->release();
fsqTxImg = 0;
}
fsqTxImg = Fl_Shared_Image::get(n, W, H);
if (!fsqTxImg)
return 0;
if (fsqTxImg->count() > 1) {
fsqTxImg->release();
fsqTxImg = 0;
return 0;
}
fsqpicTx->hide();
fsqpicTx->clear();
img_data = (unsigned char *)fsqTxImg->data()[0];
D = fsqTxImg->d();
if (fsqxmtimg) delete [] fsqxmtimg;
fsqxmtimg = new unsigned char [W * H * 3];
if (D == 3)
memcpy(fsqxmtimg, img_data, W*H*3);
else if (D == 4) {
int i, j, k;
for (i = 0; i < W*H; i++) {
j = i*3; k = i*4;
fsqxmtimg[j] = img_data[k];
fsqxmtimg[j+1] = img_data[k+1];
fsqxmtimg[j+2] = img_data[k+2];
}
} else if (D == 1) {
int i, j;
for (i = 0; i < W*H; i++) {
j = i * 3;
fsqxmtimg[j] = fsqxmtimg[j+1] = fsqxmtimg[j+2] = img_data[i];
}
} else
return 0;
// fsq_showTxViewer(W, H);
char* label = strdup(n);
fsqpicTxWin->copy_label(basename(label));
free(label);
// load the fsqpicture widget with the rgb image
fsqpicTx->show();
fsqpicTxWin->redraw();
fsqpicTx->video(fsqxmtimg, W * H * 3);
btnfsqpicTransmit->activate();
return 1;
}
void fsq_updateTxPic(unsigned char data, int pos)
{
if (!fsqpicTxWin->shown()) fsqpicTx->show();
fsqpicTx->pixel(data, pos);
}
void cb_fsqpicTxLoad(Fl_Widget *, void *)
{
const char *fn =
FSEL::select(_("Load image file"), "Image\t*.{png,,gif,jpg,jpeg}\n", PicsDir.c_str());
if (!fn) return;
if (!*fn) return;
fsq_load_image(fn);
}
void fsq_clear_tximage()
{
fsqpicTx->clear();
}
void cb_fsqpicTxClose( Fl_Widget *w, void *)
{
fsqpicTxWin->hide();
}
int fsqpic_TxGetPixel(int pos, int color)
{
return fsqxmtimg[3*pos + color]; // color = {RED, GREEN, BLUE}
}
void cb_fsqpicTransmit( Fl_Widget *w, void *)
{
std::string image_txt;
image_txt.assign(fsq_selected_call.c_str());
switch (selfsqpicSize->value()) {
case 0: image_txt.append("% S"); break;
case 1: image_txt.append("% L"); break;
case 2: image_txt.append("% F"); break;
case 3: image_txt.append("% V"); break;
case 4: image_txt.append("% P"); break;
case 5: image_txt.append("% p"); break;
case 6: image_txt.append("% M"); break;
case 7: image_txt.append("% m"); break;
}
active_modem->fsq_send_image(image_txt);
}
void cb_fsqpicTxSendAbort( Fl_Widget *w, void *)
{
}
void cb_selfsqpicSize( Fl_Widget *w, void *)
{
switch (selfsqpicSize->value()) {
case 0 : fsq_showTxViewer('S'); break;
case 1 : fsq_showTxViewer('L'); break;
case 2 : fsq_showTxViewer('F'); break;
case 3 : fsq_showTxViewer('V'); break;
case 4 : fsq_showTxViewer('P'); break;
case 5 : fsq_showTxViewer('p'); break;
case 6 : fsq_showTxViewer('M'); break;
case 7 : fsq_showTxViewer('m'); break;
}
}
void fsq_createTxViewer()
{
fsqpicTxWin = new Fl_Double_Window(324, 270, _("Send image"));
fsqpicTxWin->xclass(PACKAGE_NAME);
fsqpicTxWin->begin();
fsqpicTx = new picture (2, 2, 320, 240);
fsqpicTx->noslant();
fsqpicTx->hide();
selfsqpicSize = new Fl_Choice(5, 244, 110, 24);
selfsqpicSize->add("160x120 clr"); // case 0
selfsqpicSize->add("320x240 clr"); // case 1
selfsqpicSize->add("640x480 gry"); // case 2
selfsqpicSize->add("640x480 clr"); // case 3
selfsqpicSize->add("240x300 clr"); // case 4
selfsqpicSize->add("240x300 gry"); // case 5
selfsqpicSize->add("120x150 clr"); // case 6
selfsqpicSize->add("120x150 gry"); // case 7
selfsqpicSize->value(1);
selfsqpicSize->callback(cb_selfsqpicSize, 0);
btnfsqpicTxLoad = new Fl_Button(120, 244, 60, 24, _("Load"));
btnfsqpicTxLoad->callback(cb_fsqpicTxLoad, 0);
btnfsqpicTransmit = new Fl_Button(fsqpicTxWin->w() - 130, 244, 60, 24, "Xmt");
btnfsqpicTransmit->callback(cb_fsqpicTransmit, 0);
btnfsqpicTxSendAbort = new Fl_Button(fsqpicTxWin->w() - 130, 244, 60, 24, "Abort Xmt");
btnfsqpicTxSendAbort->callback(cb_fsqpicTxSendAbort, 0);
btnfsqpicTxClose = new Fl_Button(fsqpicTxWin->w() - 65, 244, 60, 24, _("Close"));
btnfsqpicTxClose->callback(cb_fsqpicTxClose, 0);
btnfsqpicTxSendAbort->hide();
btnfsqpicTransmit->deactivate();
fsqpicTxWin->end();
}
void fsq_showTxViewer(char c)
{
if (!fsqpicTxWin) fsq_createTxViewer();
int winW = 644, winH = 512, W = 480, H = 320;
int fsqpicX, fsqpicY;
fsqpicTx->clear();
switch (c) {
case 'S' :
case 's' :
W = 160; H = 120; winW = 324; winH = 154;
selfsqpicSize->value(0);
break;
case 'L' :
case 'l' :
W = 320; H = 240; winW = 324; winH = 274;
selfsqpicSize->value(1);
break;
case 'F' :
W = 640; H = 480; winW = 644; winH = 514;
selfsqpicSize->value(2);
break;
case 'V' :
W = 640; H = 480; winW = 644; winH = 514;
selfsqpicSize->value(3);
break;
case 'P' :
W = 240; H = 300; winW = 324; winH = 334;
selfsqpicSize->value(4);
break;
case 'p' :
W = 240; H = 300; winW = 324; winH = 334;
selfsqpicSize->value(5);
break;
case 'M' :
W = 120; H = 150; winW = 324; winH = 184;
selfsqpicSize->value(6);
break;
case 'm' :
W = 120; H = 150; winW = 324; winH = 184;
selfsqpicSize->value(7);
}
fsqpicTxWin->size(winW, winH);
fsqpicX = (winW - W) / 2;
fsqpicY = (winH - 26 - H) / 2;
fsqpicTx->resize(fsqpicX, fsqpicY, W, H);
selfsqpicSize->resize(5, winH - 26, 110, 24);
btnfsqpicTxLoad->resize(120, winH - 26, 60, 24);
btnfsqpicTransmit->resize(winW - 130, winH - 26, 60, 24);
btnfsqpicTxSendAbort->resize(winW - 130, winH - 26, 60, 24);
btnfsqpicTxClose->resize(winW -65, winH - 26, 60, 24);
selfsqpicSize->show();
btnfsqpicTransmit->show();
btnfsqpicTxLoad->show();
btnfsqpicTxClose->show();
btnfsqpicTxSendAbort->hide();
fsqpicTxWin->show();
}
void fsq_deleteTxViewer()
{
fsqpicTxWin->hide();
if (fsqpicTx) delete fsqpicTx;
delete [] fsqxmtimg;
fsqxmtimg = 0;
delete [] fsqxmtpicbuff;
fsqxmtpicbuff = 0;
delete fsqpicTxWin;
fsqpicTxWin = 0;
}
void fsq_deleteRxViewer()
{
fsqpicRxWin->hide();
if (fsqpicRx) {
delete fsqpicRx;
fsqpicRx = 0;
}
delete fsqpicRxWin;
fsqpicRxWin = 0;
}
int fsq_print_time_left(float time_sec, char *str, size_t len,
const char *prefix, const char *suffix)
{
int time_min = (int)(time_sec / 60);
time_sec -= time_min * 60;
if (time_min)
return snprintf(str, len, "%s %02dm %2.1fs%s",
prefix, time_min, time_sec, suffix);
else
return snprintf(str, len, "%s %2.1fs%s", prefix, time_sec, suffix);
}
| 13,506
|
C++
|
.cxx
| 460
| 27.104348
| 88
| 0.648148
|
w1hkj/fldigi
| 109
| 27
| 38
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
751,059
|
fsq_monitor.cxx
|
w1hkj_fldigi/src/fsq/fsq_monitor.cxx
|
// ----------------------------------------------------------------------------
//
// Viewer.cxx -- PSK browser
//
// Copyright (C) 2015
// David Freese, W1HKJ
//
// This file is part of fldigi.
//
// Fldigi 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 3 of the License, or
// (at your option) any later version.
//
// Fldigi 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 fldigi. If not, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include <FL/Enumerations.H>
#include "config.h"
#include "Viewer.h"
#include "trx.h"
#include "main.h"
#include "configuration.h"
#include "confdialog.h"
#include "status.h"
#include "waterfall.h"
#include "fl_digi.h"
#include "re.h"
#include "gettext.h"
#include "flmisc.h"
#include "spot.h"
#include "icons.h"
#include "qrunner.h"
//
// External fsq monitor dialog
//
Fl_Double_Window *fsqMonitor = 0;
static Fl_Button *btnCloseMonitor;
FTextRX *fsq_monitor = 0;
FTextRX *fsq_que = 0;
static void cb_btnCloseMonitor(Fl_Button*, void*) {
progStatus.fsqMONITORxpos = fsqMonitor->x();
progStatus.fsqMONITORypos = fsqMonitor->y();
progStatus.fsqMONITORwidth = fsqMonitor->w();
progStatus.fsqMONITORheight = fsqMonitor->h();
btn_MONITOR->value(0);
btn_MONITOR->redraw();
fsqMonitor->hide();
}
Fl_Double_Window* create_fsqMonitor(void)
{
Fl_Double_Window* w = new Fl_Double_Window(
progStatus.fsqMONITORxpos, progStatus.fsqMONITORypos,
progStatus.fsqMONITORwidth, progStatus.fsqMONITORheight,
_("FSQ monitor"));
Panel *monitor_panel = new Panel(
2, 2,
w->w() - 4, w->h() - 28);
fsq_monitor = new FTextRX(
monitor_panel->x(), monitor_panel->y(),
monitor_panel->w(), 7*monitor_panel->h()/8);
fsq_monitor->color(
fl_rgb_color(
0.98*progdefaults.RxColor.R,
0.98*progdefaults.RxColor.G,
0.98*progdefaults.RxColor.B),
progdefaults.RxTxSelectcolor);
fsq_monitor->setFont(progdefaults.RxFontnbr);
fsq_monitor->setFontSize(progdefaults.RxFontsize);
fsq_monitor->setFontColor(progdefaults.RxFontcolor, FTextBase::RECV);
fsq_que = new FTextRX(
fsq_monitor->x(), fsq_monitor->y() + fsq_monitor->h(),
fsq_monitor->w(), monitor_panel->h() - fsq_monitor->h());
fsq_que->color(
fl_rgb_color(
0.98*progdefaults.RxColor.R,
0.98*progdefaults.RxColor.G,
0.98*progdefaults.RxColor.B),
progdefaults.RxTxSelectcolor);
fsq_que->setFont(progdefaults.RxFontnbr);
fsq_que->setFontSize(progdefaults.RxFontsize);
fsq_que->setFontColor(progdefaults.RxFontcolor, FTextBase::RECV);
Fl_Box *minbox = new Fl_Box(
monitor_panel->x(), monitor_panel->y() + 66,
monitor_panel->w(), monitor_panel->h() - 132);
minbox->hide();
monitor_panel->resizable(minbox);
monitor_panel->end();
Fl_Group *g = new Fl_Group(
fsq_monitor->x(), monitor_panel->y() + monitor_panel->h() + 2,
fsq_monitor->w(), 22);
Fl_Group *g1 = new Fl_Group(
g->x(), g->y() + 2, g->w() - 80, g->h());
g1->box(FL_FLAT_BOX);
g1->end();
// close button
btnCloseMonitor = new Fl_Button(
g->x() + g->w() - 82, g->y(), 80, g->h(),
icons::make_icon_label(_("Close"), close_icon));
btnCloseMonitor->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
icons::set_icon_label(btnCloseMonitor);
btnCloseMonitor->callback((Fl_Callback*)cb_btnCloseMonitor);
g->resizable(g1);
g->end();
w->end();
w->callback((Fl_Callback*)cb_btnCloseMonitor);
w->resizable(monitor_panel);
w->size_range( 300, 200 );
w->xclass(PACKAGE_NAME);
w->hide();
return w;
}
void open_fsqMonitor()
{
if (!fsqMonitor)
fsqMonitor = create_fsqMonitor();
fsqMonitor->show();
fsqMonitor->redraw();
}
#if (FSQDEBUG == 1)
Fl_Double_Window *fsqDebug = 0;
FTextRX *fsq_debug = 0;
void close_fsqDebug()
{
if (fsqDebug) fsqDebug->hide();
}
static void cb_CloseDebug(Fl_Button*, void*) {
fsqDebug->hide();
}
Fl_Double_Window* create_fsqDebug(void)
{
Fl_Double_Window* w = new Fl_Double_Window( 50, 50, 500, 300, "FSQ debug");
fsq_debug = new FTextRX(
2, 2,
w->w() - 4, w->h() - 4);
fsq_debug->color( FL_WHITE);
fsq_debug->setFont(progdefaults.RxFontnbr);
fsq_debug->setFontSize(progdefaults.RxFontsize);
fsq_debug->setFontColor(progdefaults.RxFontcolor, FTextBase::RECV);
fsq_debug->setFontColor(progdefaults.XMITcolor, FTextBase::XMIT);
fsq_debug->setFontColor(progdefaults.CTRLcolor, FTextBase::CTRL);
fsq_debug->setFontColor(progdefaults.SKIPcolor, FTextBase::SKIP);
fsq_debug->setFontColor(progdefaults.ALTRcolor, FTextBase::ALTR);
w->end();
w->callback((Fl_Callback*)cb_CloseDebug);
w->resizable(fsq_debug);
w->size_range( 200, 200 );
w->xclass(PACKAGE_NAME);
w->hide();
return w;
}
void open_fsqDebug()
{
if (!fsqDebug)
fsqDebug = create_fsqDebug();
fsqDebug->show();
fsqDebug->redraw();
}
void write_fsqDebug(std::string s, int style)
{
if (!fsq_debug) return;
REQ(&FTextRX::addstr, fsq_debug, s, style);
}
#endif
void fsq_que_clear()
{
REQ(&FTextRX::clear, fsq_que);
}
void write_fsq_que(std::string s)
{
if (!fsq_que) return;
// REQ(&FTextRX::clear, fsq_que);
REQ(&FTextRX::addstr, fsq_que, s, FTextBase::ALTR);
}
| 5,572
|
C++
|
.cxx
| 179
| 28.72067
| 79
| 0.680641
|
w1hkj/fldigi
| 109
| 27
| 38
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
751,060
|
flarqenv.cxx
|
w1hkj_fldigi/src/flarq-src/flarqenv.cxx
|
// ----------------------------------------------------------------------------
// flarqenv.cxx
//
// Copyright (C) 2009
// Stelios Bounanos, M0GLD
// ----------------------------------------------------------------------------
// Copyright (C) 2014
// David Freese, W1HKJ
//
// This file is part of fldigi
//
// fldigi 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 3 of the License, or
// (at your option) any later version.
//
// fldigi 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, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include <config.h>
#include <iostream>
#include <string>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <cerrno>
#ifdef __MINGW32__
# include "compat.h"
#endif
#if HAVE_SYS_UTSNAME_H
# include <sys/utsname.h>
#endif
#include <signal.h>
#include <getopt.h>
#include <FL/Fl.H>
#include "stacktrace.h"
#include "flarq.h"
std::string option_help, version_text, build_text;
extern std::string arq_address, arq_port;
extern bool ioMPSK;
extern bool SHOWDEBUG;
void generate_option_help(void)
{
std::ostringstream help;
help << "Usage:\n"
<< " " << PACKAGE_NAME << " [option...]\n\n";
help << PACKAGE_NAME << " options:\n\n"
<< " --arq-protocol TYPE\n"
<< " Set the ARQ protocol\n"
<< " May be either ``fldigi'' or ``multipsk''\n"
<< " The default is: " << (ioMPSK ? "multipsk" : "fldigi") << "\n\n"
<< " --arq-server-address HOSTNAME\n"
<< " Set the ARQ TCP server address\n"
<< " The default is: " << arq_address << "\n\n"
<< " --arq-server-port PORT\n"
<< " Set the ARQ TCP server port\n"
<< " The default is: " << arq_port << "\n\n"
<< " --version\n"
<< " Print version information\n\n"
<< " --build-info\n"
<< " Print build information\n\n"
<< " --help\n"
<< " Print this option help\n\n";
// Fl::help looks ugly so we'll write our own
help << "Standard FLTK options:\n\n"
<< " -bg COLOR, -background COLOR\n"
<< " Set the background color\n"
<< " -bg2 COLOR, -background2 COLOR\n"
<< " Set the secondary (text) background color\n\n"
<< " -di DISPLAY, -display DISPLAY\n"
<< " Set the X display to use DISPLAY,\n"
<< " format is ``host:n.n''\n\n"
<< " -dn, -dnd or -nodn, -nodnd\n"
<< " Enable or disable drag and drop copy and paste in text fields\n\n"
<< " -fg COLOR, -foreground COLOR\n"
<< " Set the foreground color\n\n"
<< " -g GEOMETRY, -geometry GEOMETRY\n"
<< " Set the initial window size and position\n"
<< " GEOMETRY format is ``WxH+X+Y''\n"
<< " ** " << PACKAGE_NAME << " may override this setting **\n\n"
<< " -i, -iconic\n"
<< " Start " << PACKAGE_NAME << " in iconified state\n\n"
<< " -k, -kbd or -nok, -nokbd\n"
<< " Enable or disable visible keyboard focus in non-text widgets\n\n"
<< " -na CLASSNAME, -name CLASSNAME\n"
<< " Set the window class to CLASSNAME\n\n"
<< " -ti WINDOWTITLE, -title WINDOWTITLE\n"
<< " Set the window title\n\n";
help << "Additional UI options:\n\n"
<< " --font FONT[:SIZE]\n"
<< " Set the widget font and (optionally) size\n"
<< " The default is: " << Fl::get_font(FL_HELVETICA)
<< ':' << FL_NORMAL_SIZE << "\n\n";
option_help = help.str();
}
int parse_args(int argc, char** argv, int& idx)
{
// Only handle long options
if ( !(strlen(argv[idx]) >= 2 && strncmp(argv[idx], "--", 2) == 0) )
return 0;
enum { OPT_ZERO,
#ifndef __WOE32__
OPT_RX_IPC_KEY, OPT_TX_IPC_KEY,
#endif
OPT_ARQ_PROTOCOL, OPT_ARQ_ADDRESS, OPT_ARQ_PORT,
OPT_FONT,
OPT_DEBUG, OPT_DEPRECATED, OPT_HELP, OPT_VERSION, OPT_BUILD_INFO
};
const char shortopts[] = "+";
struct option longopts[] = {
#ifndef __WOE32__
{ "rx-ipc-key", 1, 0, OPT_RX_IPC_KEY },
{ "tx-ipc-key", 1, 0, OPT_TX_IPC_KEY },
#endif
{ "arq-protocol", 1, 0, OPT_ARQ_PROTOCOL },
{ "arq-server-address", 1, 0, OPT_ARQ_ADDRESS },
{ "arq-server-port", 1, 0, OPT_ARQ_PORT },
{ "font", 1, 0, OPT_FONT },
{ "help", 0, 0, OPT_HELP },
{ "version", 0, 0, OPT_VERSION },
{ "build-info", 0, 0, OPT_BUILD_INFO },
{ 0 }
};
int longindex;
optind = idx;
int c = getopt_long(argc, argv, shortopts, longopts, &longindex);
switch (c) {
case -1:
return 0;
case 0:
// handle options with non-0 flag here
return 0;
case OPT_ARQ_PROTOCOL:
if (!strcmp(optarg, "fldigi"))
ioMPSK = false;
else if (!strcmp(optarg, "multipsk"))
ioMPSK = true;
else {
std::cerr << "E: unknown protocol type\n";
exit(EXIT_FAILURE);
}
break;
case OPT_ARQ_ADDRESS:
arq_address = optarg;
break;
case OPT_ARQ_PORT:
arq_port = optarg;
break;
case OPT_FONT: {
char *p;
if ((p = strchr(optarg, ':'))) {
*p = '\0';
FL_NORMAL_SIZE = strtol(p + 1, 0, 10);
}
Fl::set_font(FL_HELVETICA, optarg);
break;
}
case OPT_DEBUG:
SHOWDEBUG = true;
break;
case OPT_DEPRECATED:
std::cerr << "W: the --" << longopts[longindex].name
<< " option has been deprecated and will be removed in a future version\n";
break;
case OPT_HELP:
std::cout << option_help;
exit(EXIT_SUCCESS);
case OPT_VERSION:
std::cout << version_text;
exit(EXIT_SUCCESS);
case OPT_BUILD_INFO:
std::cout << build_text;
exit(EXIT_SUCCESS);
case '?': default:
std::cerr << "Try `" << PACKAGE_NAME << " --help' for more information.\n";
exit(EXIT_FAILURE);
}
// Increment idx by the number of args we used and return that number.
// We must check whether the option argument is in the same argv element
// as the option name itself, i.e., --opt=arg.
c = longopts[longindex].has_arg ? 2 : 1;
if (c == 2) {
std::string arg = argv[idx];
std::string::size_type p;
if ((p = arg.rfind(optarg)) != std::string::npos && arg[p-1] == '=')
c = 1;
}
idx += c;
return c;
}
void set_platform_ui(void)
{
#if defined(__APPLE__)
FL_NORMAL_SIZE = 12;
#elif defined(__WOE32__)
Fl::set_font(FL_HELVETICA, "Tahoma");
FL_NORMAL_SIZE = 11;
#else
FL_NORMAL_SIZE = 12;
#endif
}
void generate_version_text(void)
{
version_text.assign(PACKAGE_STRING "\nCopyright (C) 2008, 2009 " PACKAGE_AUTHORS ".\n");
version_text.append("License GPLv3+: GNU GPL version 3 or later "
"<http://www.gnu.org/licenses/gpl.html>\n"
"This is free software: you are free to change and redistribute it.\n"
"There is NO WARRANTY, to the extent permitted by law.\n");
std::ostringstream s;
s << "Build information:\n";
s << " built : " << BUILD_DATE << " by " << BUILD_USER
<< '@' << BUILD_HOST << " on " << BUILD_BUILD_PLATFORM
<< " for " << BUILD_TARGET_PLATFORM << "\n\n"
<< " configure flags: " << BUILD_CONFIGURE_ARGS << "\n\n"
<< " compiler : " << BUILD_COMPILER << "\n\n"
<< " compiler flags : " << FLARQ_BUILD_CXXFLAGS << "\n\n"
<< " linker flags : " << FLARQ_BUILD_LDFLAGS << "\n\n"
<< " libraries : " "FLTK " FLTK_BUILD_VERSION "\n";
s << "\nRuntime information:\n";
struct utsname u;
if (uname(&u) != -1) {
s << " system : " << u.sysname << ' ' << u.nodename
<< ' ' << u.release << ' ' << u.version << ' ' << u.machine << "\n\n";
}
build_text = s.str();
}
void setup_signal_handlers(void)
{
#ifndef __WOE32__
struct sigaction action;
memset(&action, 0, sizeof(struct sigaction));
// no child stopped notifications, no zombies
action.sa_handler = SIG_DFL;
action.sa_flags = SA_NOCLDSTOP;
#ifdef SA_NOCLDWAIT
action.sa_flags |= SA_NOCLDWAIT;
#endif
sigaction(SIGCHLD, &action, NULL);
action.sa_flags = 0;
action.sa_handler = handle_signal;
sigaction(SIGSEGV, &action, NULL);
sigaction(SIGILL, &action, NULL);
sigaction(SIGABRT, &action, NULL);
sigaction(SIGUSR2, &action, NULL);
action.sa_handler = SIG_IGN;
sigaction(SIGPIPE, &action, NULL);
sigemptyset(&action.sa_mask);
sigaddset(&action.sa_mask, SIGUSR2);
pthread_sigmask(SIG_BLOCK, &action.sa_mask, NULL);
#else
signal(SIGSEGV, handle_signal);
signal(SIGILL, handle_signal);
signal(SIGABRT, handle_signal);
#endif
}
| 8,909
|
C++
|
.cxx
| 260
| 30.296154
| 89
| 0.586584
|
w1hkj/fldigi
| 109
| 27
| 38
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
751,061
|
xml_server.cxx
|
w1hkj_fldigi/src/flarq-src/xml_server.cxx
|
// ---------------------------------------------------------------------
//
// xml_server.cxx, a part of flarq
//
// Copyflarqht (C) 2016
// Dave Freese, W1HKJ
//
// This library 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 3 of the License, or
// (at your option) any later version.
//
// This library 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 the program; if not, write to the
//
// Free Software Foundation, Inc.
// 51 Franklin Street, Fifth Floor
// Boston, MA 02110-1301 USA.
//
// ---------------------------------------------------------------------
#include <config.h>
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <pthread.h>
#include <FL/Fl.H>
#include <FL/Fl_Box.H>
#include <FL/Enumerations.H>
#include "arq.h"
#include "flarq.h"
#include "xml_server.h"
#include "xmlrpcpp/XmlRpc.h"
using namespace XmlRpc;
// The server
XmlRpcServer flarq_server;
//----------------------------------------------------------------------
// get interface
//----------------------------------------------------------------------
bool xml_rx_text_ready = false;
//----------------------------------------------------------------------
// Request for flarq version
//----------------------------------------------------------------------
class flarq_get_version : public XmlRpcServerMethod {
public:
flarq_get_version(XmlRpcServer* s) : XmlRpcServerMethod("flarq.get_version", s) {}
void execute(XmlRpcValue& params, XmlRpcValue& result) {
result = VERSION;
}
std::string help() { return std::string("returns version number of flarq"); }
} flarq_get_version(&flarq_server);
//----------------------------------------------------------------------
// Request for ARQ state
//----------------------------------------------------------------------
class flarq_get_state : public XmlRpcServerMethod {
public:
flarq_get_state(XmlRpcServer* s) : XmlRpcServerMethod("flarq.get_state", s) {}
// x00 - unconnected
// x81 - connected
// x82 - sending
// x83 - receiving
// x84 - send completed
// x85 - recv completed
void execute(XmlRpcValue& params, XmlRpcValue& result) {
int state = 0;
if (arqstate != ARQ_CONNECTED)
state = 0;
else if (sendingfile)
state = 0x82;
else if (rxARQfile)
state = 0x83;
else if (xml_rx_text_ready)
state = 0x85;
else
state = 0x81;
result = state;
}
std::string help() { return std::string("returns state of connection"); }
} flarq_get_state(&flarq_server);
//----------------------------------------------------------------------
// Request for received text
//----------------------------------------------------------------------
class flarq_rcvd_text : public XmlRpcServerMethod {
public:
flarq_rcvd_text(XmlRpcServer* s) : XmlRpcServerMethod("flarq.rcvd_text", s) {}
void execute(XmlRpcValue& params, XmlRpcValue& result) {
std::string result_string = "none";
if (xml_rx_text_ready) result_string = txtarqload;
xml_rx_text_ready = false;
result = result_string;
txtarqload = "";
}
std::string help() { return std::string("returns received text"); }
} flarq_rcvd_text(&flarq_server);
//----------------------------------------------------------------------
// set interface
//----------------------------------------------------------------------
//------------------------------------------------------------------------------
// Send text
//------------------------------------------------------------------------------
class flarq_send_text : public XmlRpcServerMethod {
public:
flarq_send_text(XmlRpcServer* s) : XmlRpcServerMethod("flarq.send_text", s) {}
void execute(XmlRpcValue& params, XmlRpcValue &result) {
std::string txt_to_send = std::string(params[0]);
send_xml_text("FLMSG_XFR", txt_to_send);
}
std::string help() { return std::string("send_text"); }
} flarq_send_text(&flarq_server);
struct MLIST {
std::string name; std::string signature; std::string help;
} mlist[] = {
{ "flarq.rcvd_text", "s:n", "return MODE of current VFO" },
{ "flarq.get_state", "s:n", "return PTT state" },
{ "flarq.send_text", "i:i", "set MODE iaw MODE table" }
};
class flarq_list_methods : public XmlRpcServerMethod {
public:
flarq_list_methods(XmlRpcServer *s) : XmlRpcServerMethod("flarq.list_methods", s) {}
void execute(XmlRpcValue& params, XmlRpcValue& result) {
std::vector<XmlRpcValue> methods;
for (size_t n = 0; n < sizeof(mlist) / sizeof(*mlist); ++n) {
XmlRpcValue::ValueStruct item;
item["name"] = mlist[n].name;
item["signature"] = mlist[n].signature;
item["help"] = mlist[n].help;
methods.push_back(item);
}
result = methods;
}
std::string help() { return std::string("get flarq methods"); }
} flarq_list_methods(&flarq_server);
//------------------------------------------------------------------------------
// support thread xmlrpc clients
//------------------------------------------------------------------------------
pthread_t *xml_thread = 0;
void * xml_thread_loop(void *d)
{
for(;;) {
flarq_server.work(-1.0);
}
return NULL;
}
void start_xml_server(int port)
{
XmlRpc::setVerbosity(0);
// Create the server socket on the specified port
flarq_server.bindAndListen(port);
// Enable introspection
flarq_server.enableIntrospection(true);
xml_thread = new pthread_t;
if (pthread_create(xml_thread, NULL, xml_thread_loop, NULL)) {
perror("pthread_create");
exit(EXIT_FAILURE);
}
}
void exit_server()
{
flarq_server.exit();
}
| 5,987
|
C++
|
.cxx
| 170
| 33.329412
| 85
| 0.571181
|
w1hkj/fldigi
| 109
| 27
| 38
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
751,062
|
b64.cxx
|
w1hkj_fldigi/src/flarq-src/b64.cxx
|
// ----------------------------------------------------------------------------
// Copyright (C) 2014
// David Freese, W1HKJ
//
// This file is part of fldigi
//
// fldigi 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 3 of the License, or
// (at your option) any later version.
//
// fldigi 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, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
//=====================================================================
//
// base64 encoding / decoding class
//
// To create a standalone base64 encode/coder:
// g++ -DTEST b64.cxx -o base64
//
// To use in a calling program:
//
// base64 b64; // default no CRLF's in output file
// base 64 b64(true); // insert CRLF's in output file
// pass c++ string into encoder / decoder
// return value is encoded / decoded string
// original string is left unchanged
//
// string instr, outstr;
// outstr = b64.encoder(instr);
// outstr = b64.decoder(instr);
//=====================================================================
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "b64.h"
void base64::init()
{
iolen = 0;
iocp = 0;
ateof = false;
linelength = 0;
// create the etable for encoding
for (int i = 0; i < 9; i++) {
etable[i] = 'A' + i;
etable[i + 9] = 'J' + i;
etable[26 + i] = 'a' + i;
etable[26 + i + 9] = 'j' + i;
}
for (int i = 0; i < 8; i++) {
etable[i + 18] = 'S' + i;
etable[26 + i + 18] = 's' + i;
}
for (int i = 0; i < 10; i++)
etable[52 + i] = '0' + i;
etable[62] = '+';
etable[63] = '/';
// create the dtable for decoding
for (int i= 0; i < 255; i++)
dtable[i] = 0x80;
for (int i = 'A'; i <= 'I'; i++)
dtable[i] = 0 + (i - 'A');
for (int i = 'J'; i <= 'R'; i++)
dtable[i] = 9 + (i - 'J');
for (int i = 'S'; i <= 'Z'; i++)
dtable[i] = 18 + (i - 'S');
for (int i = 'a'; i <= 'i'; i++)
dtable[i] = 26 + (i - 'a');
for (int i = 'j'; i <= 'r'; i++)
dtable[i] = 35 + (i - 'j');
for (int i = 's'; i <= 'z'; i++)
dtable[i] = 44 + (i - 's');
for (int i = '0'; i <= '9'; i++)
dtable[i] = 52 + (i - '0');
dtable[(int)'+'] = 62;
dtable[(int)'/'] = 63;
dtable[(int)'='] = 0;
}
std::string base64::encode(std::string in)
{
int n;
byte igroup[3], ogroup[4];
output = "";
iocp = 0;
ateof = false;
if (crlf)
linelength = 0;
iolen = in.length();
while (!ateof) {
igroup[0] = igroup[1] = igroup[2] = 0;
for (n = 0; n < 3; n++) {
if (iocp == iolen) {
ateof = true;
break;
}
igroup[n] = (byte)in[iocp];
iocp++;
}
if (n > 0) {
ogroup[0] = etable[igroup[0] >> 2];
ogroup[1] = etable[((igroup[0] & 3) << 4) | (igroup[1] >> 4)];
ogroup[2] = etable[((igroup[1] & 0xF) << 2) | (igroup[2] >> 6)];
ogroup[3] = etable[igroup[2] & 0x3F];
if (n < 2) {
ogroup[2] = '=';
if (n < 1) {
ogroup[2] = '=';
}
}
for (int i = 0; i < 4; i++) {
if (crlf)
if (linelength >= LINELEN) {
// output += '\r';
output += '\n';
linelength = 0;
}
output += (byte)ogroup[i];
if (crlf)
linelength++;
}
}
}
if (crlf) {
// output += '\r';
output += '\n';
}
return output;
}
std::string base64::decode(std::string in)
{
int i;
output = "";
iocp = 0;
iolen = in.length();
byte c;
while (iocp < iolen) {
byte a[4], b[4], o[3];
for (i = 0; i < 4; i++) {
if (iocp == iolen) {
output = "b64 file length error.\n";
return output;
}
c = in[iocp++];
while (c <= ' ') {
if (iocp == iolen) {
return output;
}
c = in[iocp++];
}
if (dtable[c] & 0x80) {
output = "Illegal character in b64 file.\n";
return output;
}
a[i] = c;
b[i] = (byte)dtable[c];
}
o[0] = (b[0] << 2) | (b[1] >> 4);
o[1] = (b[1] << 4) | (b[2] >> 2);
o[2] = (b[2] << 6) | b[3];
output += o[0];
if (a[2] != '=') {
output += o[1];
if (a[3] != '=')
output += o[2];
}
}
return output;
}
#ifdef TEST
#include <iostream>
#include <fstream>
void usage(void)
{
printf("b64 -- Encode/decode file as base64. Call:\n");
printf(" b64 e/d < infile > outfile\n");
}
int main(int argc,char*argv[])
{
char opt;
bool decoding = false;
char * cp;
byte c;
std::string inputstring;
std::string infilename;
std::string outputstring;
std::string outfilename;
base64 b64;
if (argc < 2) {
usage();
return(0);
}
opt = *(argv[1]);
if (opt == 'd' || opt == 'D') {
while (!std::cin.eof()) {
c = std::cin.get();
if (!std::cin.eof())
inputstring += c;
}
outputstring = b64.decode( inputstring );
size_t len = outputstring.length();
for (size_t n = 0; n < len; n++)
std::cout << (unsigned char)outputstring[n];
} else if (opt == 'e' || opt == 'E') {
while (!std::cin.eof()) {
c = std::cin.get();
if (!std::cin.eof())
inputstring += c;
}
outputstring = b64.encode( inputstring );
size_t len = outputstring.length();
for (size_t n = 0; n < len; n++)
std::cout << (unsigned char)outputstring[n];
} else
usage();
return 0;
}
#endif
| 5,509
|
C++
|
.cxx
| 223
| 22.008969
| 79
| 0.52255
|
w1hkj/fldigi
| 109
| 27
| 38
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
751,063
|
arqdialogs.cxx
|
w1hkj_fldigi/src/flarq-src/arqdialogs.cxx
|
// generated by Fast Light User Interface Designer (fluid) version 1.0305
#include "arqdialogs.h"
#include <config.h>
#include <string>
#include "flarq.h"
static void cb_flarq(Fl_Double_Window*, void*) {
arqCLOSE();
}
Fl_Menu_Bar *mnu=(Fl_Menu_Bar *)0;
static void cb_mnu_nbems_files(Fl_Menu_*, void*) {
open_nbems_file_folder();
}
static void cb_mnuExit(Fl_Menu_*, void*) {
arqCLOSE();
}
static void cb_mnuSendEmail(Fl_Menu_*, void*) {
sendEmailFile();
}
static void cb_mnuSendText(Fl_Menu_*, void*) {
sendAsciiFile();
}
static void cb_mnuSendImage(Fl_Menu_*, void*) {
sendImageFile();
}
static void cb_mnuSendBinary(Fl_Menu_*, void*) {
sendBinaryFile();
}
static void cb_mnuCompose(Fl_Menu_*, void*) {
ComposeMail();
}
static void cb_mnuConfig(Fl_Menu_*, void*) {
cbMenuConfig();
}
static void cb_mnuHowTo(Fl_Menu_*, void*) {
help_cb();
}
static void cb_mnuAbout(Fl_Menu_*, void*) {
cbMenuAbout();
}
Fl_Menu_Item menu_mnu[] = {
{"&File", 0, 0, 0, 64, (uchar)FL_NORMAL_LABEL, 0, 14, 0},
{"NBEMS files", 0, (Fl_Callback*)cb_mnu_nbems_files, 0, 128, (uchar)FL_NORMAL_LABEL, 0, 14, 0},
{"E&xit", 0, (Fl_Callback*)cb_mnuExit, 0, 0, (uchar)FL_NORMAL_LABEL, 0, 14, 0},
{0,0,0,0,0,0,0,0,0},
{"&Send", 0, 0, 0, 64, (uchar)FL_NORMAL_LABEL, 0, 14, 0},
{"Email", 0, (Fl_Callback*)cb_mnuSendEmail, 0, 0, (uchar)FL_NORMAL_LABEL, 0, 14, 0},
{"Text File", 0, (Fl_Callback*)cb_mnuSendText, 0, 0, (uchar)FL_NORMAL_LABEL, 0, 14, 0},
{"Image File", 0, (Fl_Callback*)cb_mnuSendImage, 0, 0, (uchar)FL_NORMAL_LABEL, 0, 14, 0},
{"Binary File", 0, (Fl_Callback*)cb_mnuSendBinary, 0, 0, (uchar)FL_NORMAL_LABEL, 0, 14, 0},
{0,0,0,0,0,0,0,0,0},
{"Compose", 0, (Fl_Callback*)cb_mnuCompose, 0, 0, (uchar)FL_NORMAL_LABEL, 0, 14, 0},
{"&Config", 0, (Fl_Callback*)cb_mnuConfig, 0, 0, (uchar)FL_NORMAL_LABEL, 0, 14, 0},
{"&Help", 0, 0, 0, 64, (uchar)FL_NORMAL_LABEL, 0, 14, 0},
{"How To", 0, (Fl_Callback*)cb_mnuHowTo, 0, 0, (uchar)FL_NORMAL_LABEL, 0, 14, 0},
{"&About", 0, (Fl_Callback*)cb_mnuAbout, 0, 0, (uchar)FL_NORMAL_LABEL, 0, 14, 0},
{0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0}
};
Fl_Button *btnCONNECT=(Fl_Button *)0;
static void cb_btnCONNECT(Fl_Button*, void*) {
arqCONNECT();
}
Fl_Input2 *txtURCALL=(Fl_Input2 *)0;
Fl_Light_Button *btnBEACON=(Fl_Light_Button *)0;
static void cb_btnBEACON(Fl_Light_Button*, void*) {
arqBEACON();
}
Fl_Input2 *txtBeaconing=(Fl_Input2 *)0;
Fl_Box *indCONNECT=(Fl_Box *)0;
Fl_Input2 *txtState=(Fl_Input2 *)0;
FTextView *txtARQ=(FTextView *)0;
Fl_Input2 *txtStatus=(Fl_Input2 *)0;
Fl_Input2 *txtStatus2=(Fl_Input2 *)0;
Fl_Progress *prgStatus=(Fl_Progress *)0;
Fl_Button *btnClearText=(Fl_Button *)0;
static void cb_btnClearText(Fl_Button*, void*) {
cbClearText();
}
FTextView *txtRX=(FTextView *)0;
Fl_Input2 *txtTX=(Fl_Input2 *)0;
static void cb_txtTX(Fl_Input2*, void*) {
cbSendTalk();
}
Fl_Button *btnSendTalk=(Fl_Button *)0;
static void cb_btnSendTalk(Fl_Button*, void*) {
cbClearTalk();
}
Fl_Double_Window* arq_dialog() {
Fl_Double_Window* w;
{ Fl_Double_Window* o = new Fl_Double_Window(515, 415, "flarq");
w = o; if (w) {/* empty */}
o->color(FL_LIGHT1);
o->callback((Fl_Callback*)cb_flarq);
{ mnu = new Fl_Menu_Bar(0, 0, 516, 22);
mnu->menu(menu_mnu);
} // Fl_Menu_Bar* mnu
{ Fl_Group* o = new Fl_Group(0, 25, 515, 60);
{ Fl_Group* o = new Fl_Group(0, 25, 515, 31);
o->box(FL_ENGRAVED_FRAME);
{ btnCONNECT = new Fl_Button(5, 28, 90, 24, "Connnect");
btnCONNECT->tooltip("Connect to other station");
btnCONNECT->color(FL_LIGHT1);
btnCONNECT->callback((Fl_Callback*)cb_btnCONNECT);
} // Fl_Button* btnCONNECT
{ txtURCALL = new Fl_Input2(97, 28, 70, 24);
txtURCALL->tooltip("Connect-to callsign");
txtURCALL->box(FL_DOWN_BOX);
txtURCALL->color(FL_BACKGROUND2_COLOR);
txtURCALL->selection_color(FL_SELECTION_COLOR);
txtURCALL->labeltype(FL_NORMAL_LABEL);
txtURCALL->labelfont(0);
txtURCALL->labelsize(14);
txtURCALL->labelcolor(FL_FOREGROUND_COLOR);
txtURCALL->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE));
txtURCALL->when(FL_WHEN_RELEASE);
} // Fl_Input2* txtURCALL
{ btnBEACON = new Fl_Light_Button(168, 28, 79, 24, "Beacon");
btnBEACON->tooltip("Beacon ON / OFF");
btnBEACON->selection_color((Fl_Color)2);
btnBEACON->callback((Fl_Callback*)cb_btnBEACON);
} // Fl_Light_Button* btnBEACON
{ Fl_Input2* o = txtBeaconing = new Fl_Input2(249, 28, 261, 24, "output:");
txtBeaconing->box(FL_FLAT_BOX);
txtBeaconing->color(FL_LIGHT1);
txtBeaconing->selection_color(FL_SELECTION_COLOR);
txtBeaconing->labeltype(FL_NORMAL_LABEL);
txtBeaconing->labelfont(0);
txtBeaconing->labelsize(14);
txtBeaconing->labelcolor(FL_FOREGROUND_COLOR);
txtBeaconing->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE));
txtBeaconing->when(FL_WHEN_RELEASE);
Fl_Group::current()->resizable(txtBeaconing);
o->type(FL_NORMAL_OUTPUT);
} // Fl_Input2* txtBeaconing
o->end();
} // Fl_Group* o
{ Fl_Group* o = new Fl_Group(0, 54, 515, 31);
o->box(FL_ENGRAVED_FRAME);
{ indCONNECT = new Fl_Box(5, 60, 18, 18);
indCONNECT->tooltip("ARQ state");
indCONNECT->box(FL_DIAMOND_DOWN_BOX);
indCONNECT->color(FL_LIGHT1);
indCONNECT->labelfont(13);
indCONNECT->align(Fl_Align(FL_ALIGN_RIGHT|FL_ALIGN_INSIDE));
} // Fl_Box* indCONNECT
{ Fl_Input2* o = txtState = new Fl_Input2(27, 57, 483, 24, "Disconnecting");
txtState->box(FL_FLAT_BOX);
txtState->color(FL_LIGHT1);
txtState->selection_color(FL_SELECTION_COLOR);
txtState->labeltype(FL_NORMAL_LABEL);
txtState->labelfont(0);
txtState->labelsize(14);
txtState->labelcolor(FL_FOREGROUND_COLOR);
txtState->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE));
txtState->when(FL_WHEN_RELEASE);
Fl_Group::current()->resizable(txtState);
o->type(FL_NORMAL_OUTPUT);
} // Fl_Input2* txtState
o->end();
} // Fl_Group* o
o->end();
} // Fl_Group* o
{ txtARQ = new FTextView(0, 87, 515, 117);
txtARQ->box(FL_DOWN_BOX);
txtARQ->color(FL_BACKGROUND2_COLOR);
txtARQ->selection_color(FL_SELECTION_COLOR);
txtARQ->labeltype(FL_NORMAL_LABEL);
txtARQ->labelfont(0);
txtARQ->labelsize(14);
txtARQ->labelcolor(FL_FOREGROUND_COLOR);
txtARQ->textfont(4);
txtARQ->align(Fl_Align(FL_ALIGN_TOP));
txtARQ->when(FL_WHEN_RELEASE);
Fl_Group::current()->resizable(txtARQ);
} // FTextView* txtARQ
{ Fl_Group* o = new Fl_Group(0, 206, 516, 26);
o->box(FL_DOWN_BOX);
{ Fl_Input2* o = txtStatus = new Fl_Input2(5, 208, 220, 22);
txtStatus->tooltip("Status messages");
txtStatus->box(FL_DOWN_BOX);
txtStatus->color(FL_BACKGROUND2_COLOR);
txtStatus->selection_color(FL_SELECTION_COLOR);
txtStatus->labeltype(FL_NORMAL_LABEL);
txtStatus->labelfont(0);
txtStatus->labelsize(14);
txtStatus->labelcolor(FL_FOREGROUND_COLOR);
txtStatus->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE));
txtStatus->when(FL_WHEN_RELEASE);
Fl_Group::current()->resizable(txtStatus);
o->type(FL_NORMAL_OUTPUT);
} // Fl_Input2* txtStatus
{ Fl_Input2* o = txtStatus2 = new Fl_Input2(225, 208, 170, 22);
txtStatus2->box(FL_DOWN_BOX);
txtStatus2->color(FL_BACKGROUND2_COLOR);
txtStatus2->selection_color(FL_SELECTION_COLOR);
txtStatus2->labeltype(FL_NORMAL_LABEL);
txtStatus2->labelfont(0);
txtStatus2->labelsize(14);
txtStatus2->labelcolor(FL_FOREGROUND_COLOR);
txtStatus2->align(Fl_Align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE));
txtStatus2->when(FL_WHEN_RELEASE);
o->type(FL_NORMAL_OUTPUT);
} // Fl_Input2* txtStatus2
{ Fl_Progress* o = prgStatus = new Fl_Progress(395, 210, 70, 18);
prgStatus->tooltip("Tx/Rx ARQ file transfer progress");
prgStatus->selection_color((Fl_Color)70);
prgStatus->labelfont(1);
o->minimum(0.0);
o->maximum(1.0);
} // Fl_Progress* prgStatus
{ btnClearText = new Fl_Button(468, 210, 45, 20, "Clear");
btnClearText->callback((Fl_Callback*)cb_btnClearText);
} // Fl_Button* btnClearText
o->end();
} // Fl_Group* o
{ Fl_Group* o = new Fl_Group(0, 235, 515, 180, "Plain Talk");
o->box(FL_ENGRAVED_FRAME);
o->align(Fl_Align(FL_ALIGN_TOP_LEFT|FL_ALIGN_INSIDE));
{ txtRX = new FTextView(5, 255, 505, 130);
txtRX->box(FL_DOWN_BOX);
txtRX->color(FL_BACKGROUND2_COLOR);
txtRX->selection_color(FL_SELECTION_COLOR);
txtRX->labeltype(FL_NORMAL_LABEL);
txtRX->labelfont(0);
txtRX->labelsize(14);
txtRX->labelcolor(FL_FOREGROUND_COLOR);
txtRX->textfont(4);
txtRX->align(Fl_Align(FL_ALIGN_TOP));
txtRX->when(FL_WHEN_RELEASE);
Fl_Group::current()->resizable(txtRX);
} // FTextView* txtRX
{ Fl_Group* o = new Fl_Group(0, 387, 515, 28);
o->box(FL_ENGRAVED_FRAME);
{ txtTX = new Fl_Input2(5, 390, 450, 22, "input:");
txtTX->tooltip("Plain talk text - ENTER to send");
txtTX->box(FL_DOWN_BOX);
txtTX->color(FL_BACKGROUND2_COLOR);
txtTX->selection_color(FL_SELECTION_COLOR);
txtTX->labeltype(FL_NORMAL_LABEL);
txtTX->labelfont(0);
txtTX->labelsize(14);
txtTX->labelcolor(FL_FOREGROUND_COLOR);
txtTX->callback((Fl_Callback*)cb_txtTX);
txtTX->align(Fl_Align(FL_ALIGN_CENTER));
txtTX->when(FL_WHEN_ENTER_KEY);
Fl_Group::current()->resizable(txtTX);
txtTX->value("");
txtTX->maximum_size(80);
} // Fl_Input2* txtTX
{ btnSendTalk = new Fl_Button(460, 390, 49, 22, "Clear");
btnSendTalk->callback((Fl_Callback*)cb_btnSendTalk);
} // Fl_Button* btnSendTalk
o->end();
} // Fl_Group* o
o->end();
} // Fl_Group* o
o->end();
} // Fl_Double_Window* o
return w;
}
Fl_Input2 *txtMyCall=(Fl_Input2 *)0;
static void cb_txtMyCall(Fl_Input2* o, void*) {
changeMyCall(o->value());
}
Fl_Input2 *txtBEACONTXT=(Fl_Input2 *)0;
static void cb_txtBEACONTXT(Fl_Input2* o, void*) {
changeBeaconText(o->value());
}
Fl_Spinner2 *spnRetries=(Fl_Spinner2 *)0;
static void cb_spnRetries(Fl_Spinner2* o, void*) {
iretries = (int)o->value();
cbSetConfig();
}
Fl_Spinner2 *spnWaitTime=(Fl_Spinner2 *)0;
static void cb_spnWaitTime(Fl_Spinner2* o, void*) {
iwaittime = (int)(1000 * o->value());
cbSetConfig();
}
Fl_Spinner2 *spnTimeout=(Fl_Spinner2 *)0;
static void cb_spnTimeout(Fl_Spinner2* o, void*) {
itimeout = (int)(o->value() * 1000.0);
cbSetConfig();
}
Fl_Spinner2 *spnTxDelay=(Fl_Spinner2 *)0;
static void cb_spnTxDelay(Fl_Spinner2* o, void*) {
txdelay = (int)o->value();
cbSetConfig();
}
Fl_Spinner2 *spnBcnInterval=(Fl_Spinner2 *)0;
static void cb_spnBcnInterval(Fl_Spinner2* o, void*) {
bcnInterval = (int)o->value();
cbSetConfig();
}
Fl_Spinner2 *spnIDtimer=(Fl_Spinner2 *)0;
static void cb_spnIDtimer(Fl_Spinner2* o, void*) {
idtimer = (int)(o->value());
cb_idtimer();
}
Fl_ComboBox *choiceBlockSize=(Fl_ComboBox *)0;
static void cb_choiceBlockSize(Fl_ComboBox* o, void*) {
exponent = (int)o->index() + 4;
cbSetConfig();
}
Fl_Button *btnOK=(Fl_Button *)0;
static void cb_btnOK(Fl_Button*, void*) {
closeConfig();
}
Fl_Check_Button *btn_restart_beacon=(Fl_Check_Button *)0;
static void cb_btn_restart_beacon(Fl_Check_Button* o, void*) {
restart_beacon = (int)(o->value());
cbSetConfig();
}
Fl_Double_Window* arq_configure() {
Fl_Double_Window* w;
{ Fl_Double_Window* o = new Fl_Double_Window(480, 190, "Configure flarq");
w = o; if (w) {/* empty */}
{ Fl_Input2* o = txtMyCall = new Fl_Input2(98, 13, 150, 22, "My Call:");
txtMyCall->box(FL_DOWN_BOX);
txtMyCall->color(FL_BACKGROUND2_COLOR);
txtMyCall->selection_color(FL_SELECTION_COLOR);
txtMyCall->labeltype(FL_NORMAL_LABEL);
txtMyCall->labelfont(0);
txtMyCall->labelsize(14);
txtMyCall->labelcolor(FL_FOREGROUND_COLOR);
txtMyCall->callback((Fl_Callback*)cb_txtMyCall);
txtMyCall->align(Fl_Align(FL_ALIGN_LEFT));
txtMyCall->when(FL_WHEN_RELEASE);
o->value(MyCall.c_str());
} // Fl_Input2* txtMyCall
{ Fl_Input2* o = txtBEACONTXT = new Fl_Input2(98, 42, 370, 22, "Beacon Text");
txtBEACONTXT->tooltip("Text for the beacon 64 chars max");
txtBEACONTXT->box(FL_DOWN_BOX);
txtBEACONTXT->color(FL_BACKGROUND2_COLOR);
txtBEACONTXT->selection_color(FL_SELECTION_COLOR);
txtBEACONTXT->labeltype(FL_NORMAL_LABEL);
txtBEACONTXT->labelfont(0);
txtBEACONTXT->labelsize(14);
txtBEACONTXT->labelcolor(FL_FOREGROUND_COLOR);
txtBEACONTXT->callback((Fl_Callback*)cb_txtBEACONTXT);
txtBEACONTXT->align(Fl_Align(FL_ALIGN_LEFT));
txtBEACONTXT->when(FL_WHEN_RELEASE);
Fl_Group::current()->resizable(txtBEACONTXT);
o->value(beacontext.c_str());
} // Fl_Input2* txtBEACONTXT
{ Fl_Spinner2* o = spnRetries = new Fl_Spinner2(146, 71, 45, 22, "Retries:");
spnRetries->tooltip("# retries before connection declared down");
spnRetries->box(FL_NO_BOX);
spnRetries->color(FL_BACKGROUND_COLOR);
spnRetries->selection_color(FL_BACKGROUND_COLOR);
spnRetries->labeltype(FL_NORMAL_LABEL);
spnRetries->labelfont(0);
spnRetries->labelsize(14);
spnRetries->labelcolor(FL_FOREGROUND_COLOR);
spnRetries->callback((Fl_Callback*)cb_spnRetries);
spnRetries->align(Fl_Align(FL_ALIGN_LEFT));
spnRetries->when(FL_WHEN_RELEASE);
o->minimum(2);
o->maximum(20);
o->step(1);
o->value(iretries);
} // Fl_Spinner2* spnRetries
{ Fl_Spinner2* o = spnWaitTime = new Fl_Spinner2(121, 98, 70, 22, "Wait time (sec):");
spnWaitTime->tooltip("Time between retries");
spnWaitTime->box(FL_NO_BOX);
spnWaitTime->color(FL_BACKGROUND_COLOR);
spnWaitTime->selection_color(FL_BACKGROUND_COLOR);
spnWaitTime->labeltype(FL_NORMAL_LABEL);
spnWaitTime->labelfont(0);
spnWaitTime->labelsize(14);
spnWaitTime->labelcolor(FL_FOREGROUND_COLOR);
spnWaitTime->callback((Fl_Callback*)cb_spnWaitTime);
spnWaitTime->align(Fl_Align(FL_ALIGN_LEFT));
spnWaitTime->when(FL_WHEN_RELEASE);
o->minimum(10);
o->maximum(30);
o->step(5);
o->value(iwaittime/1000);
} // Fl_Spinner2* spnWaitTime
{ Fl_Spinner2* o = spnTimeout = new Fl_Spinner2(121, 126, 70, 22, "Timeout (sec):");
spnTimeout->tooltip("Time out for dead connection");
spnTimeout->box(FL_NO_BOX);
spnTimeout->color(FL_BACKGROUND_COLOR);
spnTimeout->selection_color(FL_BACKGROUND_COLOR);
spnTimeout->labeltype(FL_NORMAL_LABEL);
spnTimeout->labelfont(0);
spnTimeout->labelsize(14);
spnTimeout->labelcolor(FL_FOREGROUND_COLOR);
spnTimeout->callback((Fl_Callback*)cb_spnTimeout);
spnTimeout->align(Fl_Align(FL_ALIGN_LEFT));
spnTimeout->when(FL_WHEN_RELEASE);
o->minimum(30);
o->maximum(300);
o->step(15);
o->value(itimeout / 1000);
} // Fl_Spinner2* spnTimeout
{ Fl_Spinner2* o = spnTxDelay = new Fl_Spinner2(317, 126, 70, 22, "Tx delay (msec):");
spnTxDelay->tooltip("delay from Rx to Tx");
spnTxDelay->box(FL_NO_BOX);
spnTxDelay->color(FL_BACKGROUND_COLOR);
spnTxDelay->selection_color(FL_BACKGROUND_COLOR);
spnTxDelay->labeltype(FL_NORMAL_LABEL);
spnTxDelay->labelfont(0);
spnTxDelay->labelsize(14);
spnTxDelay->labelcolor(FL_FOREGROUND_COLOR);
spnTxDelay->callback((Fl_Callback*)cb_spnTxDelay);
spnTxDelay->align(Fl_Align(FL_ALIGN_LEFT));
spnTxDelay->when(FL_WHEN_RELEASE);
o->minimum(200);
o->maximum(2000);
o->step(100);
o->value(txdelay);
} // Fl_Spinner2* spnTxDelay
{ Fl_Spinner2* o = spnBcnInterval = new Fl_Spinner2(398, 71, 70, 22, "Beacon interval (sec)");
spnBcnInterval->tooltip("Time between beacon transmissions");
spnBcnInterval->box(FL_NO_BOX);
spnBcnInterval->color(FL_BACKGROUND_COLOR);
spnBcnInterval->selection_color(FL_BACKGROUND_COLOR);
spnBcnInterval->labeltype(FL_NORMAL_LABEL);
spnBcnInterval->labelfont(0);
spnBcnInterval->labelsize(14);
spnBcnInterval->labelcolor(FL_FOREGROUND_COLOR);
spnBcnInterval->value(120);
spnBcnInterval->callback((Fl_Callback*)cb_spnBcnInterval);
spnBcnInterval->align(Fl_Align(FL_ALIGN_LEFT));
spnBcnInterval->when(FL_WHEN_RELEASE);
o->minimum(60); o->maximum(3600);
o->step(30);
o->value(bcnInterval);
} // Fl_Spinner2* spnBcnInterval
{ Fl_Spinner2* o = spnIDtimer = new Fl_Spinner2(121, 155, 70, 22, "ID timer (min):");
spnIDtimer->tooltip("ID timer\\n0 = disable");
spnIDtimer->box(FL_NO_BOX);
spnIDtimer->color(FL_BACKGROUND_COLOR);
spnIDtimer->selection_color(FL_BACKGROUND_COLOR);
spnIDtimer->labeltype(FL_NORMAL_LABEL);
spnIDtimer->labelfont(0);
spnIDtimer->labelsize(14);
spnIDtimer->labelcolor(FL_FOREGROUND_COLOR);
spnIDtimer->minimum(0);
spnIDtimer->maximum(10);
spnIDtimer->value(10);
spnIDtimer->callback((Fl_Callback*)cb_spnIDtimer);
spnIDtimer->align(Fl_Align(FL_ALIGN_LEFT));
spnIDtimer->when(FL_WHEN_RELEASE);
o->minimum(0);
o->maximum(10);
o->step(1);
o->value(idtimer);
} // Fl_Spinner2* spnIDtimer
{ choiceBlockSize = new Fl_ComboBox(314, 155, 72, 22, "Block Size:");
choiceBlockSize->box(FL_DOWN_BOX);
choiceBlockSize->color(FL_BACKGROUND2_COLOR);
choiceBlockSize->selection_color(FL_BACKGROUND_COLOR);
choiceBlockSize->labeltype(FL_NORMAL_LABEL);
choiceBlockSize->labelfont(0);
choiceBlockSize->labelsize(14);
choiceBlockSize->labelcolor(FL_FOREGROUND_COLOR);
choiceBlockSize->callback((Fl_Callback*)cb_choiceBlockSize);
choiceBlockSize->align(Fl_Align(FL_ALIGN_LEFT));
choiceBlockSize->when(FL_WHEN_RELEASE);
choiceBlockSize->end();
} // Fl_ComboBox* choiceBlockSize
{ btnOK = new Fl_Button(406, 154, 62, 24, "Ok");
btnOK->callback((Fl_Callback*)cb_btnOK);
} // Fl_Button* btnOK
{ Fl_Check_Button* o = btn_restart_beacon = new Fl_Check_Button(448, 101, 20, 20, "Restart Beacon");
btn_restart_beacon->tooltip("Restart beacon after disconnect");
btn_restart_beacon->down_box(FL_DOWN_BOX);
btn_restart_beacon->callback((Fl_Callback*)cb_btn_restart_beacon);
btn_restart_beacon->align(Fl_Align(FL_ALIGN_LEFT));
o->value(restart_beacon);
} // Fl_Check_Button* btn_restart_beacon
o->end();
} // Fl_Double_Window* o
return w;
}
Table *tblOutgoing=(Table *)0;
Fl_Button *send_Cancel=(Fl_Button *)0;
static void cb_send_Cancel(Fl_Button*, void*) {
sendCancel();
}
Fl_Return_Button *send_OK=(Fl_Return_Button *)0;
static void cb_send_OK(Fl_Return_Button*, void*) {
sendOK();
}
Fl_Double_Window* arq_SendSelect() {
Fl_Double_Window* w;
{ Fl_Double_Window* o = new Fl_Double_Window(500, 170, "Select Email");
w = o; if (w) {/* empty */}
{ tblOutgoing = new Table(0, 3, 500, 140);
tblOutgoing->box(FL_DOWN_BOX);
tblOutgoing->color(FL_BACKGROUND2_COLOR);
tblOutgoing->selection_color((Fl_Color)246);
tblOutgoing->labeltype(FL_NORMAL_LABEL);
tblOutgoing->labelfont(0);
tblOutgoing->labelsize(14);
tblOutgoing->labelcolor(FL_FOREGROUND_COLOR);
tblOutgoing->align(Fl_Align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE));
tblOutgoing->when(FL_WHEN_RELEASE);
} // Table* tblOutgoing
{ send_Cancel = new Fl_Button(335, 145, 70, 20, "Cancel");
send_Cancel->callback((Fl_Callback*)cb_send_Cancel);
} // Fl_Button* send_Cancel
{ send_OK = new Fl_Return_Button(420, 145, 72, 20, "OK");
send_OK->callback((Fl_Callback*)cb_send_OK);
} // Fl_Return_Button* send_OK
o->set_modal();
o->end();
o->resizable(o);
} // Fl_Double_Window* o
return w;
}
Fl_Input2 *inpMailFrom=(Fl_Input2 *)0;
Fl_Input2 *inpMailTo=(Fl_Input2 *)0;
Fl_Input2 *inpMailSubj=(Fl_Input2 *)0;
F_Edit *txtMailText=(F_Edit *)0;
Fl_Button *btnOpenComposedMail=(Fl_Button *)0;
static void cb_btnOpenComposedMail(Fl_Button*, void*) {
cb_OpenComposeMail();
}
Fl_Button *btnClearComposer=(Fl_Button *)0;
static void cb_btnClearComposer(Fl_Button*, void*) {
cb_ClearComposer();
}
Fl_Button *btnUseTemplate=(Fl_Button *)0;
static void cb_btnUseTemplate(Fl_Button*, void*) {
cb_UseTemplate();
}
Fl_Button *btnCancelComposedMail=(Fl_Button *)0;
static void cb_btnCancelComposedMail(Fl_Button*, void*) {
cb_CancelComposeMail();
}
Fl_Button *btnSaveComposedMail=(Fl_Button *)0;
static void cb_btnSaveComposedMail(Fl_Button*, void*) {
cb_SaveComposeMail();
}
Fl_Double_Window* arq_composer() {
Fl_Double_Window* w;
{ Fl_Double_Window* o = new Fl_Double_Window(515, 300, "Flarq Mail Composer");
w = o; if (w) {/* empty */}
{ inpMailFrom = new Fl_Input2(47, 5, 460, 24, "From");
inpMailFrom->box(FL_DOWN_BOX);
inpMailFrom->color(FL_BACKGROUND2_COLOR);
inpMailFrom->selection_color(FL_SELECTION_COLOR);
inpMailFrom->labeltype(FL_NORMAL_LABEL);
inpMailFrom->labelfont(0);
inpMailFrom->labelsize(14);
inpMailFrom->labelcolor(FL_FOREGROUND_COLOR);
inpMailFrom->align(Fl_Align(FL_ALIGN_LEFT));
inpMailFrom->when(FL_WHEN_RELEASE);
} // Fl_Input2* inpMailFrom
{ inpMailTo = new Fl_Input2(48, 32, 460, 24, "To");
inpMailTo->box(FL_DOWN_BOX);
inpMailTo->color(FL_BACKGROUND2_COLOR);
inpMailTo->selection_color(FL_SELECTION_COLOR);
inpMailTo->labeltype(FL_NORMAL_LABEL);
inpMailTo->labelfont(0);
inpMailTo->labelsize(14);
inpMailTo->labelcolor(FL_FOREGROUND_COLOR);
inpMailTo->align(Fl_Align(FL_ALIGN_LEFT));
inpMailTo->when(FL_WHEN_RELEASE);
} // Fl_Input2* inpMailTo
{ inpMailSubj = new Fl_Input2(48, 59, 460, 24, "Subj");
inpMailSubj->box(FL_DOWN_BOX);
inpMailSubj->color(FL_BACKGROUND2_COLOR);
inpMailSubj->selection_color(FL_SELECTION_COLOR);
inpMailSubj->labeltype(FL_NORMAL_LABEL);
inpMailSubj->labelfont(0);
inpMailSubj->labelsize(14);
inpMailSubj->labelcolor(FL_FOREGROUND_COLOR);
inpMailSubj->align(Fl_Align(FL_ALIGN_LEFT));
inpMailSubj->when(FL_WHEN_RELEASE);
} // Fl_Input2* inpMailSubj
{ txtMailText = new F_Edit(0, 85, 510, 188);
txtMailText->box(FL_DOWN_FRAME);
txtMailText->color(FL_BACKGROUND2_COLOR);
txtMailText->selection_color(FL_SELECTION_COLOR);
txtMailText->labeltype(FL_NORMAL_LABEL);
txtMailText->labelfont(0);
txtMailText->labelsize(14);
txtMailText->labelcolor(FL_FOREGROUND_COLOR);
txtMailText->textfont(4);
txtMailText->align(Fl_Align(FL_ALIGN_TOP));
txtMailText->when(FL_WHEN_RELEASE);
Fl_Group::current()->resizable(txtMailText);
} // F_Edit* txtMailText
{ Fl_Group* o = new Fl_Group(0, 274, 515, 28);
{ btnOpenComposedMail = new Fl_Button(4, 278, 70, 20, "Open");
btnOpenComposedMail->tooltip("Open existing Composed email");
btnOpenComposedMail->callback((Fl_Callback*)cb_btnOpenComposedMail);
} // Fl_Button* btnOpenComposedMail
{ new Fl_Box(75, 278, 5, 20);
} // Fl_Box* o
{ btnClearComposer = new Fl_Button(81, 278, 70, 20, "Clear");
btnClearComposer->tooltip("Clear all fields");
btnClearComposer->callback((Fl_Callback*)cb_btnClearComposer);
} // Fl_Button* btnClearComposer
{ new Fl_Box(152, 278, 5, 20);
} // Fl_Box* o
{ btnUseTemplate = new Fl_Button(159, 278, 70, 20, "Template");
btnUseTemplate->tooltip("Use template file");
btnUseTemplate->callback((Fl_Callback*)cb_btnUseTemplate);
} // Fl_Button* btnUseTemplate
{ Fl_Box* o = new Fl_Box(230, 278, 127, 20);
Fl_Group::current()->resizable(o);
} // Fl_Box* o
{ btnCancelComposedMail = new Fl_Button(358, 278, 70, 20, "Cancel");
btnCancelComposedMail->tooltip("Close Dialog");
btnCancelComposedMail->callback((Fl_Callback*)cb_btnCancelComposedMail);
} // Fl_Button* btnCancelComposedMail
{ new Fl_Box(429, 278, 5, 20);
} // Fl_Box* o
{ btnSaveComposedMail = new Fl_Button(436, 278, 70, 20, "Save");
btnSaveComposedMail->tooltip("Save this message (shift click Save Template)");
btnSaveComposedMail->callback((Fl_Callback*)cb_btnSaveComposedMail);
} // Fl_Button* btnSaveComposedMail
o->end();
} // Fl_Group* o
o->end();
} // Fl_Double_Window* o
return w;
}
| 25,188
|
C++
|
.cxx
| 622
| 34.660772
| 104
| 0.648808
|
w1hkj/fldigi
| 109
| 27
| 38
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
751,064
|
arq.cxx
|
w1hkj_fldigi/src/flarq-src/arq.cxx
|
// ----------------------------------------------------------------------------
// Copyright (C) 2014
// David Freese, W1HKJ
//
// This file is part of fldigi
//
// fldigi 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 3 of the License, or
// (at your option) any later version.
//
// fldigi 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, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include <config.h>
#include <sys/time.h>
#include <iostream>
#include "arq.h"
//=============================================================================
// status messages
//=============================================================================
std::string TXPOLL = "TX: Send Blocks Report";
std::string STIMEDOUT = "Timed out";
std::string ABORTXFR = "ABORT transfer";
std::string RXIDENT = "RX: Link Still Active";
std::string RXCONREQ = "RX: Connect Request";
std::string RXCONACK = "RX: Connect OK";
std::string RXDISCONN = "RX: Disconnect Request";
std::string RXDISCONACK = "RX: Disconnect OK";
std::string RXSTATUS = "RX: Status Report";
std::string RXPOLL = "RX: Send Blocks Report";
std::string TXSTATUS = "TX: Blocks Received OK";
std::string TXDISCONN = "TX: Disconnect Request";
std::string TXDISACK = "TX: Disconnect OK";
std::string TXBEACON = "TX: Beacon";
std::string TXCONNECT = "TX: Connect";
std::string TXCONNACK = "TX: Connect OK";
std::string TXIDENT = "TX: Watchdog %d";
//bool bPoll = false;
std::string arq::upcase(std::string s)
{
for (size_t i = 0; i < s.length(); i++)
s[i] = toupper(s[i]);
return s;
}
arq::arq()
{
sendfnc = NULL;
rcvfnc = NULL;
printRX = NULL;
abortfnc = NULL;
disconnectfnc = NULL;
qualityfnc = NULL;
printRX_DEBUG = NULL;
printTX_DEBUG = NULL;
rxUrCall = NULL;
Header.erase();
MyStreamID = '0';
UrStreamID = '0';
UrCall.erase();
MyCall.erase();
logfile = "server.log";
// queues //
TxTextQueue.clear();//erase(); // Text out to mail engine
RxTextQueue.clear();//erase(); // Text in from mail engine
TxPlainTextQueue.clear();//erase();
RxFrameQueue.clear();//erase();
lastRxChar = 0;
TXflag = false;
SessionNumber = 0;
exponent = EXPONENT;
maxheaders = MAXHEADERS;
RetryTime = RETRYTIME;
Retries = RETRIES;
Timeout = TIMEOUT;
TxDelay = TXDELAY;
immediate = false;
primary = false;
setBufferlength();
// status variables //
// totalRx = 0;
// nbrbadRx = 0;
totalTx = 0;
nbrbadTx = 0;
payloadlength = 32; // Average length of payload received
// static status
Firstsent = MAXCOUNT - 1; // First Header I sent last turn
LastHeader = MAXCOUNT - 1; // Last Header I sent last turn
Lastqueued = MAXCOUNT - 1; // Last Header in static send queue
EndHeader = MAXCOUNT - 1; // Last I received o.k.
GoodHeader = MAXCOUNT - 1; // Last Header received consecutive
// Ur status
UrGoodHeader = MAXCOUNT - 1; // Other station's Good Header
UrLastHeader = MAXCOUNT - 1; // Other station's Header last sent
UrEndHeader = MAXCOUNT - 1; // Other station's last received Header
blkcount = -1;
TXflag = false; // TX on
LinkState = DOWN; // ARQ link is initially down
Sending = 0;
PollOK = false;
// bABORT = false;
MyMissing.clear();
MissingRxBlocks = "";
TxBlocks.clear();
TxMissing.clear();
TxPending.clear();
RxPending.clear();
arqstop = false;
retries = baseRetries = Retries;
baseRetryTime = RetryTime;
baseTimeout = Timeout;
retrytime = RetryTime / ARQLOOPTIME;
timeout = Timeout / ARQLOOPTIME;
loopcount = 0;
set_idtimer();
tx2txdelay = 0;//TxDelay / ARQLOOPTIME;
// srand(time(NULL));
}
void arq::setBufferlength()
{
Bufferlength = 1;
for (int i = 0; i < exponent; i++) Bufferlength *= 2;
MyBlockLengthChar = '0' + exponent;
}
void arq::resetTx()
{
Firstsent = MAXCOUNT - 1; // First Header I sent last turn
LastHeader = MAXCOUNT - 1; // Last Header I sent last turn
Lastqueued = MAXCOUNT - 1; // Last Header in static send queue
TxMissing.clear();
TxBlocks.clear();
TxPending.clear();
TxTextQueue.clear();
// UrMissing.clear();
}
void arq::resetRx()
{
RxTextQueue.clear();//erase(); // Text in from mail engine
RxFrameQueue.clear();//erase();
lastRxChar = 0;
EndHeader = MAXCOUNT - 1; // Last I received o.k.
GoodHeader = MAXCOUNT - 1; // Last Header I received conseq. o.k, 1st in send queue
RxPending.clear();
MissingRxBlocks = "";
}
void arq::reset()
{
resetTx();
resetRx();
immediate = false;
primary = false;
blkcount = -1;
// bABORT = false;
}
// new session number
// unknown stream id = 0
// known id's from 1 to 63
void arq::newsession()
{
if (++SessionNumber == 64) SessionNumber = 1;
MyStreamID = SessionNumber + '0';
}
// get new blocknumber
void arq::newblocknumber()
{
Lastqueued++;
Lastqueued %= MAXCOUNT;
}
// Checksum of header + Header
std::string arq::checksum(std::string &s)
{
framecrc.reset();
return framecrc.scrc16(s);
}
// Start header when MyStreamID has been assigned
void arq::newHeader()
{
Header.erase();
Header += SOH;
Header += '0'; // protocol version;
}
void arq::IdHeader()
{
newHeader();
Header += UrStreamID;
}
void arq::UnkHeader()
{
newHeader();
Header += '0';
}
char crlf[3] = " ";
void arq::addToTxQue(std::string s)
{
// TxTextQueue += "\r\n";
crlf[0] = 0x0D;
crlf[1] = 0x0A;
TxTextQueue.append(s);
TxTextQueue.append(crlf);
totalTx++;
}
// Connect (client:port, server:port)
// c Header = Client:port Server:port <streamnr. (0)> <max. Headerlen>
// e.g.: '00cW1HKJ:1025 KH6TY:24 4'
//
void arq::connectFrame()
{
char szGlobals[24];
reset();
UnkHeader();
Header += CONREQ;
Payload.erase();
Payload.append(MyCall);
Payload.append(":1025");
Payload += ' ';
Payload.append(UrCall);
Payload.append(":24");
Payload += ' ';
Payload += MyStreamID;
Payload += ' ';
Payload += MyBlockLengthChar;
snprintf(szGlobals, 23, " T%dR%dW%d", Timeout/1000, Retries, RetryTime/1000);
Payload.append(szGlobals);
Frame = Header + Payload;
Frame = Frame + checksum(Frame);
Frame += EOT;
addToTxQue(Frame);
LinkState = ARQ_CONNECTING;
printSTATUS(TXCONNECT, 5.0);
set_idtimer();
}
// Connect acknowledge (server:port, client:port)
// k Header = Server:port Client:port <streamnr.> <max. Headerlen>
// e.g: '00kKH6TY:24 W1HKJ:1024 8 6'
//
void arq::ackFrame ()
{
reset();
IdHeader();
Header += CONACK;
Payload.erase();
Payload.append(MyCall);
Payload.append(":24");
Payload += ' ';
Payload.append(UrCall);
Payload += ' ';
Payload += MyStreamID;
Payload += ' ';
Payload += MyBlockLengthChar;
Frame = Header + Payload;
Frame = Frame + checksum(Frame);
Frame += EOT;
addToTxQue(Frame);
printSTATUS(TXCONNACK, 5.0);
set_idtimer();
}
// Connect (caller:port, static:port)
// c Header = Caller:port static:port <streamnr. (0)> <max. Headerlen>
// e.g.: '00cW1HKJ:87 KH6TY:87 4'
//
void arq::ttyconnectFrame()
{
UnkHeader();
Header += CONREQ;
Payload.erase();
Payload.append(MyCall);
Payload.append(":87");
Payload += ' ';
Payload.append(UrCall);
Payload.append(":87");
Payload += ' ';
Payload += MyStreamID;
Payload += ' ';
Payload += MyBlockLengthChar;
Frame = Header + Payload;
Frame = Frame + checksum(Frame);
Frame += EOT;
addToTxQue(Frame);
set_idtimer();
}
// Connect acknowledge (server:port, client:port)
// k Header = Server:port Client:port <streamnr.> <max. Headerlen>
// e.g: '00kKH6TY:87 W1HKJ 4'
// Service id # 87 is keyboard-to-keyboard
//
void arq::ttyackFrame()
{
IdHeader();
Header += CONACK;
Payload.erase();
Payload.append(MyCall);
Payload.append(":87");
Payload += ' ';
Payload.append(UrCall);
Payload += ' ';
Payload += MyBlockLengthChar;
Frame = Header + Payload;
Frame = Frame + checksum(Frame);
Frame += EOT;
addToTxQue(Frame);
set_idtimer();
}
// Identify
//i frame = '00iKH6TY de W1HKJ'
void arq::identFrame()
{
IdHeader();
Header += IDENT;
Payload.erase();
Payload.append(UrCall);
Payload.append(" de ");
Payload.append(MyCall);
Frame = Header + Payload;
Frame = Frame + checksum(Frame);
Frame += EOT;
addToTxQue(Frame);
char szIDENT[80];
snprintf(szIDENT,sizeof(szIDENT), TXIDENT.c_str(), retries);
printSTATUS(szIDENT, 5.0);
set_idtimer();
}
// e.g. Ping frame
// u Header = From:port
// e.g: '00uKH6TY:7 '
void arq::pingFrame()
{
IdHeader();
Header += _UNPROTO;
Payload.erase();
Payload.append(MyCall);
Payload.append(":7");
Payload += ' ';
Frame = Header + Payload;
Frame = Frame + checksum(Frame);
Frame += EOT;
addToTxQue(Frame);
set_idtimer();
}
// talk frame
// similar to UNPROTO frame
// but only sent if ARQ_CONNECTED
void arq::talkFrame(std::string txt)
{
IdHeader();
Header += _TALK;
Payload.erase();
Payload.append(MyCall);
Payload.append(":73");
Payload += ' ';
if (txt.length() > (size_t)Bufferlength)
Payload.append(txt.substr(0, Bufferlength));
else
Payload.append(txt);
Frame = Header + Payload;
Frame = Frame + checksum(Frame);
Frame += EOT;
addToTxQue(Frame);
set_idtimer();
}
void arq::ackAbortFrame()
{
IdHeader();
Header += _ACKABORT;
Payload.erase();
Payload += (LastHeader + 0x20);
Payload += (GoodHeader + 0x20);
Payload += (EndHeader + 0x20);
Payload.append(MissingRxBlocks);
Frame = Header + Payload;
Frame = Frame + checksum(Frame);
Frame += EOT;
addToTxQue(Frame);
printSTATUS(TXSTATUS, 5.0);
}
// Status report (End, Good, Lastrx, Missing)
//p frame = <last Header tx><last Header rx ok><last Header rx> <missing Headers>
//e.g.: '00sXHCAB'
//
void arq::statFrame()
{
if (idtimer && _idtimer <= 0) talkFrame("auto ID");
IdHeader();
Header += STATUS;
Payload.erase();
Payload += (LastHeader + 0x20);
Payload += (GoodHeader + 0x20);
Payload += (EndHeader + 0x20);
Payload.append(MissingRxBlocks);
Frame = Header + Payload;
Frame = Frame + checksum(Frame);
Frame += EOT;
addToTxQue(Frame);
printSTATUS(TXSTATUS, 5.0);
}
// Disconnect session
//d frame = ""
//e.g.: '00d'
void arq::disconnectFrame()
{
IdHeader();
Header += DISREQ;
Payload.erase();
Payload.append(MyCall);
Payload.append(":90");
Frame = Header + Payload;
Frame = Frame + checksum(Frame);
Frame += EOT;
addToTxQue(Frame);
printSTATUS(TXDISCONN, 5.0);
set_idtimer();
}
void arq::disackFrame()
{
IdHeader();
Header += _DISACK;
Payload.erase();
Payload.append(MyCall);
Payload.append(":91");
Frame = Header + Payload;
Frame = Frame + checksum(Frame);
Frame += EOT;
addToTxQue(Frame);
printSTATUS(TXDISACK, 5.0);
set_idtimer();
}
// ABORT session
//a frame = ""
//e.g.: '00a'
void arq::abortFrame()
{
IdHeader();
Header += _ABORT;
Payload.erase();
Payload.append(MyCall);
Payload.append(":92");
Frame = Header + Payload;
Frame = Frame + checksum(Frame);
Frame += EOT;
addToTxQue(Frame);
set_idtimer();
}
// Beacon frame
// u Header = From:port data
// e.g: '00uKH6TY:72 Beacon text '
//
void arq::beaconFrame(std::string txt)
{
UnkHeader();
Header += _UNPROTO;
Payload.erase();
Payload.append(MyCall);
Payload.append(":72");
Payload += ' ';
if (txt.length() > (size_t)Bufferlength)
Payload.append(txt.substr(0, Bufferlength));
else
Payload.append(txt);
Frame = Header + Payload;
Frame = Frame + checksum(Frame);
Frame += EOT;
addToTxQue(Frame);
printSTATUS(TXBEACON, 5.0);
set_idtimer();
}
// poll
//p frame = <last Header tx><last Header rx ok><last Header rx> <missing Headers>
//e.g.: '00pXHCAB'
void arq::pollFrame()
{
IdHeader();
Frame = Header;
Frame += POLL;
Frame.append(MyCall);
Frame += SUB;
Frame += (LastHeader + 0x20);
Frame += (GoodHeader + 0x20);
Frame += (EndHeader + 0x20);
Frame.append(MissingRxBlocks);
Frame.append(checksum(Frame));
Frame += EOT;
addToTxQue(Frame);
printSTATUS(TXPOLL, 5.0);
set_idtimer();
}
// Text frame
void arq::textFrame(cTxtBlk block)
{
IdHeader();
Frame = Header;
Frame += (block.nbr() + 0x20);
Frame.append(block.text());
Frame.append(checksum(Frame));
Frame += SOH;
addToTxQue(Frame);
}
//=====================================================================
void arq::parseIDENT()
{
timeout = Timeout / ARQLOOPTIME;
statFrame();
immediate = true;
printSTATUS(RXIDENT, 5.0);
}
void arq::parseCONREQ()
{
size_t p1 = 0, p2 = rcvPayload.find(':');
if (p2 == std::string::npos)
return;
// if (LinkState == ARQ_CONNECTED || LinkState == WAITFORACK) return; // disallow multiple connects
// requesting stations callsign
UrCall = upcase(rcvPayload.substr(p1, p2 - p1));
p1 = rcvPayload.find(' ', p2+1);
if (p1 == std::string::npos) {
UrCall.erase();
return;
}
p1++;
p2 = rcvPayload.find(":", p1);
std::string testcall = upcase(rcvPayload.substr(p1, p2 - p1));
if (testcall != MyCall) {
UrCall.erase();
return;
}
p1 = rcvPayload.find(' ', p2 +1);
if (p1 == std::string::npos) {
UrCall.erase();
return;
}
p1++; // *p1 ==> StreamID for requesting station
UrStreamID = rcvPayload[p1];
p1++; // *p1 ==> requested block size
UrBlockLengthChar = rcvPayload[p1];
p1 += 3; // *p1 ==>" TnnnRnnnWnnn"
if (p1 < rcvPayload.length()) {
char num[7];
if (rcvPayload[p1] == 'T') {
int n = 0;
while (rcvPayload[++p1] != 'R' && n < 6) num[n++] = rcvPayload[p1];
num[n] = 0;
sscanf(num, "%d", &Timeout);
Timeout *= 1000;
if (p1 < rcvPayload.length() && rcvPayload[p1] == 'R') {
int n = 0;
while (rcvPayload[++p1] != 'W' && n < 6) num[n++] = rcvPayload[p1];
num[n] = 0;
sscanf(num, "%d", &Retries);
if (p1 < rcvPayload.length() && rcvPayload[p1] == 'W') {
int n = 0;
while (++p1 < rcvPayload.length() && n < 6) num[n++] = rcvPayload[p1];
num[n] = 0;
sscanf(num, "%d", &RetryTime);
RetryTime *= 1000;
Timeout += Retries * RetryTime;
}
}
/*
char line[80];
std::string NewValues = "Temporary control parameters set to\n";
snprintf(line, 79, " Retries = %d\n", Retries);
NewValues.append(line);
snprintf(line, 79, " Wait time = %d secs\n", RetryTime / 1000);
NewValues.append(line);
snprintf(line, 79, " Timeout = %d secs\n", Timeout / 1000);
NewValues.append(line);
printRX(NewValues);
*/
}
}
reset();
LinkState = WAITFORACK;
newsession();
if (rxUrCall) rxUrCall(UrCall);
TxTextQueue.clear();
ackFrame();
immediate = true;
printSTATUS(RXCONREQ, 5.0);
}
void arq::parseCONACK()
{
if (LinkState < ARQ_CONNECTING ) { //!= ARQ_CONNECTING) {
return; // Connect Acknowledge only valid during a connect
}
size_t p1 = 0, p2 = rcvPayload.find(':');
// LinkState = DOWN;
if (p2 == std::string::npos)
return;
// requesting stations callsign
UrCall = upcase(rcvPayload.substr(p1, p2 - p1));
p1 = rcvPayload.find(' ', p2+1);
if (p1 == std::string::npos) {
UrCall.erase();
return;
}
p1++;
p2 = rcvPayload.find(" ", p1);
std::string testcall = upcase(rcvPayload.substr(p1, p2 - p1));
if (testcall != MyCall) {
UrCall.erase();
return;
}
p1++; // *p1 ==> StreamID for requesting station
UrStreamID = rcvPayload[p1];
p1++; // *p1 ==> requested block size
UrBlockLengthChar = rcvPayload[p1];
RxTextQueue.clear();//erase();
LinkState = ARQ_CONNECTED;
timeout = Timeout / ARQLOOPTIME;
statFrame();
immediate = true;
primary = true;
printSTATUS(RXCONACK, 5.0);
}
void arq::parseDISREQ()
{
if (LinkState == DOWN) return;
TxTextQueue.clear();//erase();
TxMissing.clear();
TxBlocks.clear();
TxPlainTextQueue.clear();
disackFrame();
immediate = true;
LinkState = DOWN;
if (rxUrCall) rxUrCall("");
if (disconnectfnc) disconnectfnc();
printSTATUS(RXDISCONN, 5.0);
}
void arq::parseDISACK()
{
if (rxUrCall) rxUrCall("");
LinkState = DOWN;
printSTATUS(RXDISCONACK, 5.0);
}
void arq::parseABORT()
{
reset();
if (abortfnc) abortfnc();
ackAbortFrame();
immediate = true;
LinkState = ARQ_CONNECTED;
}
void arq::parseACKABORT()
{
reset();
if (abortfnc) abortfnc();
LinkState = ARQ_CONNECTED;
}
void arq::parseUNPROTO()
{
size_t p1 = 0, p2 = rcvPayload.find(':');
if (p2 == std::string::npos)
return;
// requesting stations callsign
UrCall = upcase(rcvPayload.substr(p1, p2 - p1));
if (rxUrCall) rxUrCall(UrCall);
if (printRX) printRX(rcvPayload + "\n");
}
void arq::parseTALK()
{
size_t p1 = rcvPayload.find(":73");
if (p1 == std::string::npos)
return;
std::string talktext = rcvPayload.substr(p1 + 4);
if (printTALK) printTALK(talktext);
}
void arq::parseSTATUS()
{
// create the missing list
// all reported missing blocks
if (LinkState >= ARQ_CONNECTED) {
UrLastHeader = rcvPayload[0] - 0x20; // Other station's Header last sent
UrGoodHeader = rcvPayload[1] - 0x20; // Other station's Good Header
UrEndHeader = rcvPayload[2] - 0x20; // Other station's last received Header
size_t nummissing = rcvPayload.length() - 3;
std::vector<int> missing;
// append those reported missing
if (nummissing > 0)
for (size_t i = 0; i < nummissing; i++)
missing.push_back(rcvPayload[i+3] - 0x20);
// append those not reported missing from UrEndHeader to LastHeader
if (UrEndHeader != LastHeader) {
int m = UrEndHeader + 1;
if (m > MAXCOUNT) m -= MAXCOUNT;
while (m != LastHeader) {
missing.push_back(m);
m++;
if (m > MAXCOUNT) m -= MAXCOUNT;
}
missing.push_back(LastHeader);
}
if (missing.empty())
TxMissing.clear();
if (TxMissing.empty() == false) {
std::list<cTxtBlk> keep;
std::list<cTxtBlk>::iterator p = TxMissing.begin();
while (p != TxMissing.end()) {
for (size_t n = 0; n < missing.size(); n++) {
if (p->nbr() == missing[n]) {
keep.push_back(*p);
break;
}
}
p++;
}
TxMissing = keep;
}
}
// print any txpending blocks up to and including UrGoodHeader
std::list<cTxtBlk>::iterator p1 = TxPending.begin();
p1 = TxPending.begin();
while (p1 != TxPending.end()) {
if(p1->nbr() == UrGoodHeader) {
if (printTX) printTX(p1->text());
TxPending.erase(p1);
break;
} else
if (printTX) printTX(p1->text());
TxPending.erase(p1);
p1 = TxPending.begin();
}
switch (LinkState) {
case WAITFORACK :
LinkState = ARQ_CONNECTED;
break;
case DISCONNECTING :
if (rxUrCall) rxUrCall("");
LinkState = DOWN;
break;
case WAITING :
LinkState = ARQ_CONNECTED;
break;
// case ABORTING :
// reset();
// if (abortfnc) abortfnc();
// LinkState = ARQ_CONNECTED;
// break;
// case ABORT :
// break;
default: break;
}
printSTATUS(RXSTATUS, 5.0);
}
void arq::parsePOLL()
{
if (LinkState == DISCONNECTING || LinkState == DOWN ||
LinkState == TIMEDOUT || LinkState == ABORT )
return;
statFrame();
immediate = true;
LinkState = ARQ_CONNECTED;
printSTATUS(RXPOLL, 5.0);
}
void arq::parseDATA()
{
std::vector<cTxtBlk>::iterator p1, p2;
int n1, n2;
if (LinkState < ARQ_CONNECTED) return; // do not respond if DOWN or TIMEDOUT
for (p1 = RxPending.begin(); p1 < RxPending.end(); p1++)
if (blknbr == p1->nbr()) {
return;
}
char szStatus[80];
snprintf(szStatus, sizeof(szStatus),"RX: data block %d", blknbr);
printSTATUS(szStatus, 5.0);
cTxtBlk tempblk(blknbr, rcvPayload);
RxPending.push_back (tempblk);
for (p1 = RxPending.begin(); p1 < RxPending.end() - 1; p1++) {
n1 = p1->nbr();
if (n1 < GoodHeader) n1 += MAXCOUNT;
for (p2 = p1 + 1; p2 < RxPending.end(); p2++) {
n2 = p2->nbr();
if (n2 < GoodHeader) n2 += MAXCOUNT;
if (n2 < n1) {
tempblk = *p1;
*p1 = *p2;
*p2 = tempblk;
}
}
}
// compute new EndHeader
EndHeader = GoodHeader;
if (!RxPending.empty()) {
p1 = RxPending.end() - 1;
EndHeader = p1->nbr();
}
// add RxPending blocks that are consecutive to GoodHeader
p1 = RxPending.begin();
while (!RxPending.empty()) {
if ((p1->nbr() != (GoodHeader +1) % MAXCOUNT))
break;
RxTextQueue.append(p1->text());
GoodHeader = p1->nbr();
if (printRX) printRX(p1->text());
RxPending.erase(p1);
p1 = RxPending.begin();
}
MissingRxBlocks = "";
if (RxPending.empty())
return;
int start = (GoodHeader + 1)%MAXCOUNT;
int end = (EndHeader + 1)%MAXCOUNT;
int test;
bool ok;
if (end < start) end += MAXCOUNT;
for (int i = start; i < end; i++) {
test = (i % MAXCOUNT);
ok = false;
for (p1 = RxPending.begin(); p1 < RxPending.end(); p1++) {
if (test == p1->nbr()) {
ok = true;
break;
}
}
if (!ok)
MissingRxBlocks += test + 0x20;
}
}
bool arq::isUrcall()
{
if (UrCall.empty())
return false;
if (rcvPayload.find(UrCall) != std::string::npos)
return true;
return false;
}
// expects to receive a full frame
// txt[0] == SOH
// txt[len - 3] ... txt[len] == CRC
// returns
// -1 invalid frame
// -n failed CRC for text type n
// n valid frame
// rcvPayload will contain the valid payload
//
int arq::parseFrame(std::string txt)
{
if ( txt.length() < 8 ) {
return -1; // not a valid frame
}
Ccrc16 testcrc;
size_t len = txt.length();
rcvPayload = txt.substr(4, len - 8);
fID = txt[3];
// treat unproto TALK as a special case
// no effort made to confirm the data by the CRC value
if (fID == _TALK) {
if (LinkState >= ARQ_CONNECTED) {
timeout = Timeout / ARQLOOPTIME;
parseTALK();
retries = Retries;
}
return -1;
}
std::string sRcvdCRC = testcrc.scrc16( txt.substr(0, len - 4));
if (sRcvdCRC != txt.substr(len - 4) ) {
if (printRX_DEBUG)
printRX_DEBUG("CRC failed\n");
return -1; // failed CRC test
}
retries = Retries;
switch (fID) {
case IDENT :
if (!isUrcall())
break;
blknbr = fID - 0x20;
parseIDENT();
if (printRX_DEBUG) {
printRX_DEBUG("IDENT:");
}
break;
case CONREQ :
if (LinkState > TIMEDOUT)
break; // disallow multiple connects
blknbr = fID - 0x20;
parseCONREQ();
if (printRX_DEBUG) {
printRX_DEBUG("CONREQ:");
}
break;
case CONACK :
if (!isUrcall())
break;
blknbr = fID - 0x20;
parseCONACK();
if (printRX_DEBUG) {
printRX_DEBUG("CONACK:");
}
break;
case DISREQ :
if (!isUrcall())
break;
blknbr = fID - 0x20;
parseDISREQ();
if (printRX_DEBUG) {
printRX_DEBUG("DISREQ:");
}
break;
case _DISACK :
if (!isUrcall())
break;
blknbr = fID - 0x20;
parseDISACK();
if (printRX_DEBUG) {
printRX_DEBUG("DISACK: ");
}
break;
case STATUS :
if (LinkState == DOWN || LinkState == TIMEOUT)
break;
blknbr = fID - 0x20;
parseSTATUS();
if (printRX_DEBUG) {
printRX_DEBUG("STATUS:");
}
break;
case POLL :
if (!isUrcall()) {
break;
}
blknbr = fID - 0x20;
parsePOLL();
if (printRX_DEBUG) {
printRX_DEBUG("POLL:");
}
break;
case _ABORT :
if (!isUrcall())
break;
blknbr = fID - 0x20;
parseABORT();
if (printRX_DEBUG) {
printRX_DEBUG("RCVD ABORT:");
}
break;
case _ACKABORT :
blknbr = fID - 0x20;
parseACKABORT();
if (printRX_DEBUG) {
printRX_DEBUG("RCVD ACK_ABORT:");
}
break;
case _UNPROTO :
if (LinkState >TIMEDOUT && !isUrcall())
break; // disallow interruption
blknbr = fID - 0x20;
parseUNPROTO();
if (printRX_DEBUG) {
printRX_DEBUG("UNPROTO:");
}
break;
default :
blknbr = fID - 0x20;
parseDATA();
if (printRX_DEBUG) {
printRX_DEBUG("DATA:");
}
}
if (printRX_DEBUG) {
printRX_DEBUG(txt); printRX_DEBUG("\n");
}
if (LinkState == ARQ_CONNECTED)
timeout = Timeout / ARQLOOPTIME;
return fID;
}
void arq::rcvChar( char c )
{
if ( c == 0x06 ) {
Sending = 0;
retrytime = rtry();
timeout = Timeout / ARQLOOPTIME;
tx2txdelay = TxDelay / ARQLOOPTIME;
return;
}
if (lastRxChar == SOH && c == SOH) // consecutive <SOH> characters
return;
if (lastRxChar == EOT && c == EOT) // consecutive <EOT> characters
return;
if (RxFrameQueue.empty()) {
if (c == SOH)
RxFrameQueue += c;
} else {
if (c == SOH || c == EOT) {
parseFrame(RxFrameQueue);
RxFrameQueue.clear();//erase();
if (c == SOH) RxFrameQueue += c;
} else
RxFrameQueue += c;
}
lastRxChar = c;
}
//=====================================================================
void arq::sendText (std::string txt)
{
size_t offset = 0;
cTxtBlk tempblk;
if (LinkState < ARQ_CONNECTED) return;
Blocks2Send = 0;
while (offset < txt.length()) {
newblocknumber();
tempblk.nbr(Lastqueued);
tempblk.text(txt.substr(offset, Bufferlength));
offset += Bufferlength;
TxBlocks.push_back(tempblk);
Blocks2Send++;
}
}
void arq::sendblocks()
{
char szStatus[80];
int missedblks = 0, newblks = 0;
int framecount = 0;
cTxtBlk tempblk;
if (TxMissing.empty() == false) {
std::list<cTxtBlk>::iterator p = TxMissing.begin();
while (p != TxMissing.end()) {
textFrame(*p);
p++;
framecount++;
}
}
missedblks = framecount;
if (!TxBlocks.empty()) {
while (TxBlocks.empty() == false && framecount < maxheaders) {
tempblk = TxBlocks.front();
if ((tempblk.nbr() + 2)%MAXCOUNT == UrGoodHeader)
break;
TxBlocks.pop_front();
TxMissing.push_back(tempblk);
TxPending.push_back(tempblk);
textFrame(tempblk);
LastHeader = tempblk.nbr();
framecount++;
}
}
newblks = framecount - missedblks;
snprintf(szStatus, sizeof(szStatus),"TX: repeat %d new %d",
missedblks, newblks);
printSTATUS(szStatus, 0.0);
if (!TxMissing.empty() || !TxBlocks.empty())
pollFrame();
if (LinkState != ABORT && LinkState != ABORTING)
LinkState = WAITING;
}
void arq::connect(std::string callsign)
{
UrCall = callsign;
for (size_t i = 0; i < UrCall.length(); i++)
UrCall[i] = toupper(UrCall[i]);
if (rxUrCall) rxUrCall(UrCall);
TxTextQueue.clear();
connectFrame();
LinkState = ARQ_CONNECTING;
immediate = true;
}
void arq::disconnect()
{
Retries = baseRetries;
Timeout = baseTimeout;
RetryTime = baseRetryTime;
totalTx = 0;
nbrbadTx = 0;
LinkState = DISCONNECT;
}
void arq::abort()
{
// bABORT = true;
LinkState = ABORT;
}
void arq::sendBeacon (std::string txt)
{
std::string deText = "<<< FLARQ Beacon >>> de ";
deText.append(MyCall);
TxTextQueue.clear();//erase();
addToTxQue(deText);
beaconFrame(txt);
immediate = true;
LinkState = DOWN;
}
void arq::sendPlainText( std::string txt )
{
size_t p = 0;
while (p < txt.length()) {
talkFrame(txt.substr(p, Bufferlength));
p += Bufferlength;
}
}
void arq::transmitdata()
{
if (TxTextQueue.empty() == false) {
sendfnc(TxTextQueue);
Sending = 0x80;
if (printTX_DEBUG)
printTX_DEBUG(TxTextQueue);
TxTextQueue.clear();
tx2txdelay = TxDelay / ARQLOOPTIME;
return;
}
if (TxPlainTextQueue.empty() == false) {
sendfnc(TxPlainTextQueue);
Sending = 0x80;
if (printTX_DEBUG)
printTX_DEBUG(TxPlainTextQueue);
TxPlainTextQueue.clear();
tx2txdelay = TxDelay / ARQLOOPTIME;
}
}
int arq::rtry()
{
return RetryTime / ARQLOOPTIME;
// return (RetryTime + rand() * 5000 / RAND_MAX) / ARQLOOPTIME;
}
//---------------------------------------------------------------------
void arqloop(void *who)
{
arq *me = (arq *)who;
char c;
if (idtimer) me->_idtimer--;
// check for received chars including 0x06 for Sending = 0
if (me->getc1(c) == true) {
me->rcvChar(c);
while (me->getc1(c) == true)
me->rcvChar(c);
if (me->tx2txdelay < me->TxDelay / ARQLOOPTIME)
me->tx2txdelay = me->TxDelay / ARQLOOPTIME;
}
if (me->Sending == 0) { // not transmitting
// wait period between transmits
if (me->tx2txdelay > 0) {
me->tx2txdelay--;
} else {
if (me->immediate == true) {
me->transmitdata();
me->retrytime = me->rtry();
me->retries = me->Retries;
me->immediate = false;
} else {
switch (me->LinkState) {
case ARQ_CONNECTING :
break;
case DISCONNECT :
me->LinkState = DISCONNECTING;
me->TxTextQueue.clear();
me->TxMissing.clear();
me->TxBlocks.clear();
me->TxPlainTextQueue.clear();
me->disconnectFrame();
me->immediate = true;
break;
case DISCONNECTING :
if (me->retrytime-- == 0) {
me->retrytime = me->rtry();
if (--me->retries) {
me->TxTextQueue.clear();
me->TxMissing.clear();
me->TxBlocks.clear();
me->TxPlainTextQueue.clear();
me->disconnectFrame();
me->transmitdata();
me->timeout = me->Timeout / ARQLOOPTIME;
}
}
break;
case ABORT :
me->LinkState = ABORTING;
me->TxTextQueue.clear();
me->TxMissing.clear();
me->TxBlocks.clear();
me->TxPlainTextQueue.clear();
me->tx2txdelay = 5000/ ARQLOOPTIME; // 5 sec delay for abort
me->abortFrame();
me->immediate = true;
break;
case ABORTING :
if (--me->retrytime == 0) {
me->retrytime = me->rtry();
if (me->retries--) {
me->TxTextQueue.clear();
me->TxMissing.clear();
me->TxBlocks.clear();
me->TxPlainTextQueue.clear();
me->abortFrame();
me->transmitdata();
me->timeout = me->Timeout / ARQLOOPTIME;
}
}
break;
case WAITING :
if (me->retrytime-- == 0) {
me->retrytime = me->rtry();
if (--me->retries) {
me->TxTextQueue.clear();
me->pollFrame();
me->transmitdata();
me->nbrbadTx++;
me->timeout = me->Timeout / ARQLOOPTIME;
}
}
break;
case WAITFORACK :
if (me->retrytime-- == 0) {
me->retrytime = me->rtry();
if (--me->retries) {
me->TxTextQueue.clear();
me->ackFrame();
me->transmitdata();
me->nbrbadTx++;
me->timeout = me->Timeout / ARQLOOPTIME;
}
}
break;
case ARQ_CONNECTED :
default:
if (me->TxTextQueue.empty() == false) {
me->transmitdata();
} else if ( (me->TxMissing.empty() == false) || (me->TxBlocks.empty() == false)) {
me->nbrbadTx += me->TxMissing.size();
me->sendblocks();
me->transmitdata();
} else if ( me->TxPlainTextQueue.empty() == false ) {
me->transmitdata();
}
break;
}
me->timeout--;
if (me->timeout == 0 // 10000 / ARQLOOPTIME // 10 seconds remaining
&& me->LinkState == ARQ_CONNECTED // link is connected
&& me->primary == true ) { // this is the connecting station
if (--me->retries) { // repeat Retries and then allow timeout
me->TxTextQueue.clear();
me->identFrame(); // send an identity frame to try to keep
me->transmitdata(); // the link up
me->timeout = me->rtry(); //10000 / ARQLOOPTIME + 1;
}
}
if (me->timeout == 0) {
if (me->LinkState == ARQ_CONNECTED)
me->LinkState = TIMEDOUT;
else
me->LinkState = DOWN;
me->Retries = me->baseRetries;
me->Timeout = me->baseTimeout;
me->RetryTime = me->baseRetryTime;
me->retries = me->Retries;
me->retrytime = me->rtry();
me->TxMissing.clear();
me->TxBlocks.clear();
me->TxTextQueue.clear();
me->TxPlainTextQueue.clear();
me->timeout = me->Timeout / ARQLOOPTIME;
if (me->rxUrCall) me->rxUrCall("");
}
if (me->retries == 0) {
me->LinkState = DOWN;
me->Retries = me->baseRetries;
me->Timeout = me->baseTimeout;
me->RetryTime = me->baseRetryTime;
me->retries = me->Retries;
me->retrytime = me->rtry();
me->TxMissing.clear();
me->TxBlocks.clear();
me->TxTextQueue.clear();
me->TxPlainTextQueue.clear();
me->timeout = me->Timeout / ARQLOOPTIME;
if (me->rxUrCall) me->rxUrCall("");
me->printSTATUS(STIMEDOUT, 10.0);
}
}
}
}
if (me->arqstop) {
me->LinkState = STOPPED;
me->arqstop = false;
me->LinkState = DOWN;
me->Retries = me->baseRetries;
me->Timeout = me->baseTimeout;
me->RetryTime = me->baseRetryTime;
me->retries = me->Retries;
me->retrytime = me->rtry();
me->TxMissing.clear();
me->TxBlocks.clear();
me->TxTextQueue.clear();
me->TxPlainTextQueue.clear();
me->timeout = me->Timeout / ARQLOOPTIME;
if (me->rxUrCall) me->rxUrCall("");
me->printSTATUS(STIMEDOUT, 10.0);
Fl::repeat_timeout( 1.0, arqloop, me);
return;
}
Fl::repeat_timeout( ARQLOOPTIME/1000.0, arqloop, me);
}
void arq::start_arq()
{
Fl::add_timeout(1.0, arqloop, this);
}
void arq::restart_arq() {
arqstop = true;
}
//---------------------------------------------------------------------
| 32,480
|
C++
|
.cxx
| 1,302
| 22.112135
| 99
| 0.642746
|
w1hkj/fldigi
| 109
| 27
| 38
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
751,065
|
arqhelp.cxx
|
w1hkj_fldigi/src/flarq-src/arqhelp.cxx
|
// ----------------------------------------------------------------------------
// Copyright (C) 2014
// David Freese, W1HKJ
//
// This file is part of fldigi
//
// fldigi 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 3 of the License, or
// (at your option) any later version.
//
// fldigi 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, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include <config.h>
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <ctime>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <FL/Fl.H>
#include <FL/Enumerations.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Group.H>
#include <FL/Fl_Sys_Menu_Bar.H>
#include <FL/x.H>
#include <FL/Fl_Help_Dialog.H>
#ifndef __WOE32__
#include <sys/ipc.h>
#include <sys/msg.h>
#include <dirent.h>
#endif
// this tests depends on a modified FL/filename.H in the Fltk-1.3.0
// change
//# if defined(WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__)
// to
//# if defined(WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__) && !defined(__WOE32__)
#include <dirent.h>
#include "flarq.h"
#include "arq.h"
#include "arqdialogs.h"
#include "b64.h"
Fl_Help_Dialog *help_dialog = (Fl_Help_Dialog *)0;
void help_cb() {
if (!help_dialog) {
help_dialog = new Fl_Help_Dialog();
help_dialog->value(
"<HTML>\n"
"<HEAD>\n"
"<TITLE>Flarq Help</TITLE>\n"
"</HEAD>\n"
"<BODY BGCOLOR='#ffffff'>\n"
"<H2>Initiating an ARQ connect session</H2>\n"
"<P>Start by sending a 'CQ NBEMS' or some similar unique way of indicating\n"
"that you are seeking to send ARQ traffic. Do this from the digital modem\n"
"program and not from flarq. The potential station for receiving your ARQ\n"
"traffic will answer in the clear. Negotiate what digital mode you will use\n"
"for the ARQ connection; ie: PSK-63, PSK-125, PSK-250, MFKS-16 etc. Then\n"
"try that mode without ARQ to be sure that QRN and QSB will not seriously\n"
"disrupt the connection. Ask the responding station to send an ARQ beacon\n"
"using flarq. You will then see his ARQ callsign appear in the callsign\n"
"window.</P>"
"<P>Click the CONNECT button to connect with that station. The text next to\n"
"the diamond will change to CONNECTING and remain that way during the connect\n"
"time out period. During the connection process the CONNECT button will be\n"
"disabled (greyed out).</P>\n"
"<P>After a connection has been established the button label changes to\n"
"'Disconnect' and the text next to the diamond indicator will read CONNECTED.\n"
"Pressing this button will then execute an orderly disconnect from the other\n"
"station and return the program to the CONNECTED state.</P>\n"
"<P>During a file transfer the button's label changes to Abort. When the\n"
"button says Abort, pressing it will abort the file transfer and the program\n"
"will return to the CONNECTED state. During the abort text next to the\n"
"diamond indicator will read ABORTING XFR and return to CONNECTED after the\n"
"abort has been fully recognized by both ends of the connection.</P>\n"
"<H2>Beaconing</H2>\n"
"<P>Click the Beacon button to transmit a beacon signal requesting\n"
"assistance with ARQ message forwarding. The small rectangle on the Beacon\n"
"button will turn green when a beacon signal is being sent. The beacon will\n"
"repeat at the repeat interval (default is 60 seconds). You should not reduce\n"
"the repeat interval so short as to make it impossible to receive an ARQ\n"
"connection. This is particularly true on PSK-31.</P>\n"
"<H2>Diamond Indicator</H2>\n"
"<P>The diamond-shaped indicator will be green when ready to transfer messages.\n"
"The ""Not Connected"" label next to the diamond indicator will change to Sending\n"
"when sending, or Connected when connected.</P>\n"
"<H2>Send Menu</H2>\n"
"<P>The Send menu will not be enabled unless a CONNECTION has been established\n"
"with another flarq station.</P>\n"
"<P>This menu accesses four types of files. When selecting any type, the Show: field\n"
"allows you to use the dropdown arrow to choose which type of file to display.</P>\n"
"<P>The area with the question mark is where file content is displayed, if the Preview\n"
"box is checked.</P>\n"
"<P>The Filename field has a row of buttons above it which can be used to quickly\n"
"navigate through the hierarchy of folders shown. Just click the button over the\n"
"folder you want to access.</P>\n"
"<P>When Email is selected, a list of emails waiting to be transferred will be\n"
"displayed. Select an email and click the Send button to start transferring the\n"
"email.</P>\n"
"<P>When Image File is selected, Flarq can send a color, passport photo sized\n"
"picture, in about 10 minutes using PSK250.</P>\n"
"<H2>Config Menu</H2>\n"
"<P>This menu provides a place where you should enter your callsign that Flarq\n"
"will use for transmitting. Various folders are shown and can be changed, but\n"
"it is recommended that the default folders be used except in special\n"
"circumstances.</P>\n"
"<P>If you are using the Sylpheed mail client you need to check that box.\n"
"Sylpheed uses a different naming convention for storing messages inside of\n"
"it's mail folders.</P>\n"
"<P>The beacon interval is probably the most often changed setting. Use it to\n"
"control how often Flarq sends the beacon text.</P>\n"
"<P>You can enter additional beacon text which will be sent with the each time\n"
"the ARQ beacon is transmited.</P>\n"
"<P>At the bottom left of the Flarq window there is a space on the left side that\n"
"displays messages showing the Flarq status at any given time.</P>\n"
"<P>At the bottom right, there is a space for a progress indicator, which will show\n"
"a moving green bar as a message is transferred. When a transfer is completed, the\n"
"green color will disappear after filling the space, indicating that transfer has\n"
"been completed.</P>\n"
"<H2>Status Bar</H2>\n"
"<P>A notification area in the bar just above the Plain Talk label will show the name\n"
"and size of the file being transferred and how long it took to transfer when the\n"
"transfer is completed. The left and right arrows are for adjusting the number of\n"
"SOH characters preceding each block. Leave it at the default of 10 unless you\n"
"have trouble connecting at high speed, or have too many repeat blocks. Then try\n"
"higher values to reduce the number of repeated blocks.</P>\n"
"<P>Next to the right hand arrow is an area where the quality level of the transfer\n"
"is shown. A transfer without any retries will be shown as 1.00.</P>\n"
"<P>The area next to the Clear button will display a progress indicator, which will\n"
"show the progress of the transfer. When you are sending a message, it will show\n"
"the amount of the message confirmed as being received correctly. When you are on\n"
"the receiving end, it will advance as each message frame is received.</P>\n"
"<P>The Clear button can be used to clear the flarq screen.</P>\n"
"<H2>Plain Talk</H2>\n"
"<P>You can also communicate during, before, or after a file transfer, as long as\n"
"the Connected diamond is green (showing that you are connected to the other\n"
"station), by typing in the box next to the Clear button at the very bottom of\n"
"the flarq window, and pressing Enter. The text you are sending will be shown\n"
"in red in the Plain Talk window and incoming text from the other station will\n"
"be shown in black. Text you type will be sent out at the first opportunity,\n"
"but only after a block completes being sent, so there will be a delay until\n"
"your text appears on the other station's Plain Talk window, and the other\n"
"station responds. As with most edit controls it is necessary to first put\n"
"the keyboard focus in that box by clicking in it with the mouse.</P>\n"
"<P>The maximum number of characters you can type on the Plain Talk line before\n"
"pressing Enter can be no more than 80 characters. In order to make the speed\n"
"of Plain Talk text exchanges as rapid as possible, Plain Talk uses the current\n"
"mode without any ARQ error checking, so there may be some errors at the\n"
"receiving end that would not occur if ARQ were used.</P>\n"
"<P>The Clear button next to the Plain Talk line can be used to clear the Plain\n"
"Talk display area."
"</BODY>\n"
);
}
help_dialog->show();
}
| 8,921
|
C++
|
.cxx
| 166
| 52.307229
| 94
| 0.737628
|
w1hkj/fldigi
| 109
| 27
| 38
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
751,066
|
flarq.cxx
|
w1hkj_fldigi/src/flarq-src/flarq.cxx
|
// ----------------------------------------------------------------------------
// flarq.cxx - Fast Light ARQ Application
//
// ----------------------------------------------------------------------------
// Copyright (C) 2014
// David Freese, W1HKJ
//
// This file is part of fldigi
//
// fldigi 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 3 of the License, or
// (at your option) any later version.
//
// fldigi 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, see <http://www.gnu.org/licenses/>.
// ----------------------------------------------------------------------------
#include <config.h>
#include <unistd.h>
#include <stdlib.h>
#include <iostream>
#include <string>
#include <fstream>
#include <cstring>
#include <ctime>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <FL/Fl.H>
#include <FL/Fl_Widget.H>
#include <FL/Enumerations.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Group.H>
#include <FL/Fl_Sys_Menu_Bar.H>
#include <FL/x.H>
#include <FL/Fl_Help_Dialog.H>
#include <FL/Fl_Menu_Item.H>
// this tests depends on a modified FL/filename.H in the Fltk-1.3.0
// change
//# if defined(WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__)
// to
//# if defined(WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__) && !defined(__WOE32__)
#include <FL/filename.H>
#ifdef __MINGW32__
# include "compat.h"
#endif
#include <dirent.h>
#include "fileselect.h"
#include "socket.h"
#include "debug.h"
#include "threads.h"
#include "flarq.h"
#include "flarqenv.h"
#include "flmisc.h"
#include "stacktrace.h"
#include "icons.h"
#include "arq.h"
#include "arqdialogs.h"
#include "b64.h"
#include "gettext.h"
#include "xml_server.h"
#include "FTextView.h"
debug::level_e debug::level = debug::INFO_LEVEL;
unsigned int debug::mask;
void debug::log(debug::level_e, const char*, const char*, int line, const char* ...) {}
#define FLDIGI_port "7322"
#define MPSK_port "3122"
#define FLARQ_XML_PORT 7422
#define MPSK_TX "TX"
#define MPSK_RX "RX"
#define MPSK_TX2RX "RX_AFTER_TX"
#define MPSK_BYTE 25
#define MPSK_CMD 26
#define MPSK_END 27
#define MPSK_ISTX 28
#define MPSK_ISRX 29
#define MPSK_ISCMD 30
#define MPSK_CMDEND 31
// directory structures for all NBEMS applications
static void checkdirectories(void);
std::string HomeDir;
std::string NBEMS_dir;
std::string ARQ_dir;
std::string ARQ_files_dir;
std::string ARQ_recv_dir;
std::string ARQ_send_dir;
std::string ARQ_mail_dir;
std::string ARQ_mail_in_dir;
std::string ARQ_mail_out_dir;
std::string ARQ_mail_sent_dir;
std::string WRAP_dir;
std::string WRAP_recv_dir;
std::string WRAP_send_dir;
std::string WRAP_auto_dir;
std::string ICS_dir;
std::string ICS_msg_dir;
std::string ICS_tmp_dir;
std::string MailFileName = "";
std::string MailSaveFileName = "";
std::string Logfile;
struct dirent *entry;
DIR *dp;
bool SendingEmail = false;
bool SHOWDEBUG = false;
extern void STATUSprint(std::string s);
Fl_Text_Buffer_mod *txtbuffARQ;
Fl_Text_Buffer_mod *txtbuffRX;
Fl_Text_Buffer_mod *txtbuffComposer;
Fl_Double_Window *arqwin = 0;
Fl_Double_Window *dlgconfig = 0;
Fl_Double_Window *outdialog = 0;
Fl_Double_Window *composer = 0;
arq *digi_arq;
bool traffic = false;
bool sendingfile = false;
int arqstate = 0;
bool configured = false;
bool ioMPSK = false;
std::string arq_address = "127.0.0.1";
std::string arq_port = FLDIGI_port;
std::string RX;
std::string TX;
std::string teststring;
std::string statusmsg;
std::string MyCall;
std::string beacontext;
#if !defined(__APPLE__) && !defined(__WOE32__) && USE_X
Pixmap flarq_icon_pixmap;
#endif
Socket *tcpip = 0;
std::string txbuffer;
std::string cmdbuffer;
std::string rxbuffer;
size_t bufsize = 0;
size_t bufptr = 0;
bool isRxChar = false;
bool isCmdChar = false;
bool isTxChar = false;
bool inLoop = false;
int exponent = 5;
int txdelay = 500;
int iretries = 5;
long iwaittime = 10000;
long itimeout = 60000;
int idtimer = 10;
int bcnInterval = 30;
enum {OFF, ON, WAIT};
int autobeacon = OFF;
bool beaconrcvd = false;
bool restart_beacon = false;
int blocksSent = 0;
int mainX = 0, mainY = 0, mainW = 600, mainH = 500;
float vers = 0;
float version;
const char *ASCII[32] = {
"<NUL>", "<SOH>", "<STX>", "<ETX>", // 0x00 - 0x03
"<EOT>", "<ENQ>", "<ACK>", "<BEL>", // 0x04 - 0x07
"<BX>", "<TAB>", "<LF>", "<VT>", // 0x08 - 0x0B
"<FF>", "<CR>", "<SO>", "<SI>", // 0x0C - 0x0F
"<DLE>", "<DC1>", "<DC2>", "<DC3>", // 0x10 - 0x13
"<DC4>", "<NAK>", "<SYN>", "<ETB>", // 0x14 - 0x17
"<CAN>", "<EM>", "<SUB>", "<ESC>", // 0x18 - 0x1B
"<FS>", "<GS>", "<RS>", "<US>" // 0x1C - 0x1F
};
std::string AsciiChars;
std::string incomingText = "";
std::string txtarqload = "";
std::string rxfname = "";
std::string arqstart = "ARQ::STX\n";
std::string arqend = "ARQ::ETX\n";
std::string arqfile = "ARQ:FILE::";
std::string arqemail = "ARQ:EMAIL::\n";
std::string arqascii = "ARQ:ENCODING::ASCII\n";
std::string arqbase64 = "ARQ:ENCODING::BASE64\n";
std::string arqsizespec = "ARQ:SIZE::";
size_t startpos = std::string::npos;
size_t endpos = std::string::npos;
size_t fnamepos = std::string::npos;
size_t indx = std::string::npos;
size_t sizepos = std::string::npos;
size_t lfpos = std::string::npos;
size_t arqPayloadSize = 0;
bool haveemail = false;
bool rxARQfile = false;
bool rxARQhavesize = false;
bool rxTextReady = false;
time_t StartTime_t;
time_t EndTime_t;
time_t TransferTime_t;
double TransferTime;
//=============================================================================
// email selector
//=============================================================================
int datedir = 1;
int todir = 1;
int subdir = 1;
std::string sendfilename = "";
void cb_SortByDate()
{
if (datedir == 0) {
tblOutgoing->sort(1, false);
datedir = 1;
} else {
tblOutgoing->sort(1, true);
datedir = 0;
}
tblOutgoing->redraw();
}
void cb_SortByTo()
{
if (todir == 0) {
tblOutgoing->sort(2, false);
todir = 1;
} else {
tblOutgoing->sort(2, true);
todir = 0;
}
tblOutgoing->redraw();
}
void cb_SortBySubj()
{
if (subdir == 0) {
tblOutgoing->sort(3, false);
subdir = 1;
} else {
tblOutgoing->sort(3, true);
subdir = 0;
}
tblOutgoing->redraw();
}
void sendOK()
{
outdialog->hide();
int sel = tblOutgoing->value();
if (sel >= 0)
sendfilename = tblOutgoing->valueAt(sel,0);
else
sendfilename.clear();
}
void sendCancel()
{
outdialog->hide();
sendfilename.clear();
}
void selectTrafficOut(bool ComposerOnly)
{
if (outdialog == 0) {
outdialog = arq_SendSelect();
outdialog->xclass(PACKAGE_TARNAME);
tblOutgoing->addHiddenColumn ("fnbr"); // column #0
tblOutgoing->addColumn ("Date", 180); // column #1
tblOutgoing->addColumn ("To", 120); // column #2
tblOutgoing->addColumn ("Subj", 196); // column #3
tblOutgoing->colcallback (1, cb_SortByDate);
tblOutgoing->columnAlign(1, FL_ALIGN_LEFT);
tblOutgoing->colcallback (2, cb_SortByTo);
tblOutgoing->columnAlign(2, FL_ALIGN_LEFT);
tblOutgoing->colcallback (3, cb_SortBySubj);
tblOutgoing->columnAlign(3, FL_ALIGN_LEFT);
tblOutgoing->allowSort(true);
tblOutgoing->rowSize (14);
tblOutgoing->headerSize (14);
tblOutgoing->allowResize (true);
tblOutgoing->gridEnabled (true);
}
tblOutgoing->clear();
std::string fline, fname, fdate, fto, fsubj;
char szline[10000];
size_t p;
std::string folder = ARQ_mail_out_dir;
dp = 0;
dp = opendir(folder.c_str());
if (dp == 0) {
std::string nfound = folder;
nfound += " not found";
fl_message("%s", nfound.c_str());
return;
}
int nummails = 0;
while ((entry = readdir(dp)) != 0) {
if (entry->d_name[0] == '.')
continue;
fname = folder; fname.append(entry->d_name);
if (fname.find(".eml") == std::string::npos)
continue;
int validlines = 0;
std::ifstream emailtxt(fname.c_str());
while (!emailtxt.eof()) {
memset(szline, 0, 10000);
emailtxt.getline(szline,10000);
fline = szline;
if ((p = fline.find("Date: ")) != std::string::npos) {
fdate = fline.substr(p + 6);
validlines++;
continue;
}
if ((p = fline.find("To: ")) != std::string::npos) {
fto = fline.substr(p + 4);
p = fto.find('@');
if (p != std::string::npos) fto.replace(p,1,"@@");
p = fto.find("<");
if (p != std::string::npos) fto.erase(p,1);
p = fto.find(">");
if (p != std::string::npos) fto.erase(p,1);
validlines++;
continue;
}
if ((p = fline.find("Subject: ")) != std::string::npos) {
fsubj = fline.substr(p + 9);
validlines++;
continue;
}
if ((p = fline.find("//FLARQ COMPOSER")) != std::string::npos)
validlines++;
}
emailtxt.close();
if ((!ComposerOnly && validlines >= 3) || (ComposerOnly && validlines == 4)) {
tblOutgoing->addRow (4, fname.c_str(), fdate.c_str(), fto.c_str(), fsubj.c_str());
nummails++;
}
}
if (nummails) {
tblOutgoing->FirstRow();
outdialog->show();
while (outdialog->shown())
Fl::wait();
} else
fl_message2("No emails for delivery");
}
//======================================================================================
// simple email composer
//======================================================================================
extern bool fileExists(std::string fname);
void cb_CancelComposeMail()
{
composer->hide();
}
void readComposedFile(std::string filename)
{
std::ifstream textfile;
textfile.open(filename.c_str());
if (textfile) {
char szline[10000];
std::string fline, tempstr;
size_t p;
txtMailText->clear();
inpMailFrom->value("");
inpMailTo->value("");
inpMailSubj->value("");
while (!textfile.eof()) {
memset(szline,0, 10000);
textfile.getline(szline,10000);
fline = szline;
if ((p = fline.find("//FLARQ COMPOSER")) != std::string::npos)
continue;
if ((p = fline.find("Date: ")) != std::string::npos)
continue;
if ((p = fline.find("Content-Type:")) != std::string::npos)
continue;
if ((p = fline.find("From: ")) != std::string::npos) {
tempstr = fline.substr(p + 6);
inpMailFrom->value(tempstr.c_str());
continue;
}
if ((p = fline.find("To: ")) != std::string::npos) {
tempstr = fline.substr(p + 4);
p = tempstr.find("<");
if (p != std::string::npos) tempstr.erase(p,1);
p = tempstr.find(">");
if (p != std::string::npos) tempstr.erase(p,1);
inpMailTo->value(tempstr.c_str());
continue;
}
if ((p = fline.find("Subject: ")) != std::string::npos) {
inpMailSubj->value(fline.substr(p + 9).c_str());
continue;
}
if (strlen(szline) == 0 && txtbuffComposer->length() == 0) continue;
txtMailText->add(szline);
txtMailText->add("\n");
}
textfile.close();
}
}
void cb_UseTemplate()
{
std::string templatename = ARQ_mail_out_dir;
const char *p = FSEL::select("Load Template file", "*.tpl", templatename.c_str());
if (!p) return;
if (!*p) return;
readComposedFile(p);
}
void cb_ClearComposer()
{
sendfilename.clear();
txtMailText->clear();
inpMailFrom->value("");
inpMailTo->value("");
inpMailSubj->value("");
}
std::string nextEmailFile(std::string fname)
{
int nbr = 0;
char szNbr[20];
std::string name;
std::string ext;
std::string nuname;
size_t p;
p = fname.find_last_of('.');
if (p != std::string::npos) {
ext = fname.substr(p);
name = fname.substr(0,p);
} else {
ext = "";
name = fname;
}
do {
nbr++;
nuname = name;
#ifdef __WOE32__
snprintf(szNbr, sizeof(szNbr), "-%-d", nbr);
#else
snprintf(szNbr, sizeof(szNbr), "%-d", nbr);
#endif
nuname.append(szNbr);
nuname.append(ext);
} while (fileExists(nuname));
return nuname;
}
void saveComposedText(std::string filename)
{
std::ofstream textfile;
textfile.open(filename.c_str());
textfile << "//FLARQ COMPOSER" << std::endl;
char szmaildt[100];
time_t maildt = time(NULL);
struct tm *gmt = gmtime(&maildt);
strftime(szmaildt, sizeof(szmaildt), "%x %X", gmt);
textfile << "Date: " << szmaildt << std::endl;
textfile << "From: " << inpMailFrom->value() << std::endl;
textfile << "To: " << inpMailTo->value() << std::endl;
textfile << "Subject: " << inpMailSubj->value() << std::endl;
textfile << "Content-Type: text/plain; charset=\"UTF-8\"" << std::endl;
textfile << std::endl;
textfile << txtbuffComposer->text() << std::endl;
textfile.close();
cb_ClearComposer();
}
void SaveComposeMail()
{
if (strlen(inpMailTo->value()) == 0 ||
strlen(inpMailSubj->value()) == 0)
return;
if (sendfilename.empty()) {
sendfilename = ARQ_mail_out_dir;
sendfilename += "flarqmail.eml";
sendfilename = nextEmailFile(sendfilename);
}
saveComposedText(sendfilename);
}
void SaveComposeTemplate()
{
std::string templatename = ARQ_mail_out_dir;
const char *p = FSEL::saveas("Save Template file", "*.tpl", templatename.c_str());
if (!p) return;
if (!*p) return;
saveComposedText(p);
}
void cb_SaveComposeMail()
{
if (Fl::event_state(FL_SHIFT))
SaveComposeTemplate();
else
SaveComposeMail();
}
void cb_OpenComposeMail()
{
sendfilename.clear();
selectTrafficOut(true);
if (sendfilename.empty())
return;
readComposedFile(sendfilename);
}
void ComposeMail()
{
if (composer == 0) {
composer = arq_composer();
composer->xclass(PACKAGE_TARNAME);
txtbuffComposer = txtMailText->buffer();
txtMailText->wrap_mode(1,80);
}
txtbuffComposer->text("");
inpMailFrom->value("");
inpMailTo->value("");
inpMailSubj->value("");
composer->show();
}
//======================================================================================
std::string noCR(std::string s)
{
std::string text = s;
size_t p;
while ((p = text.find('\r')) != std::string::npos)
text.erase(p,1);
return text;
}
void createAsciiChars()
{
AsciiChars = "";
AsciiChars += 0x09; // tab
AsciiChars += 0x0A; // lf
AsciiChars += 0x0D; // cr
for (int n = 20; n < 256; n++) AsciiChars += n;
}
void initVals()
{
MyCall = "NOCALL";
exponent = digi_arq->getExponent();
iretries = digi_arq->getRetries();
itimeout = digi_arq->getTimeout();
txdelay = digi_arq->getTxDelay();
iwaittime = digi_arq->getWaitTime();
bcnInterval = 30;
beacontext = "";
cbMenuConfig();
digi_arq->myCall(MyCall.c_str());
}
void testDirectory(std::string dir)
{
std::string tstdir = ARQ_dir;
tstdir += '/';
tstdir.append(dir);
std::ifstream test(tstdir.c_str());
if (!test)
mkdir(tstdir.c_str(), 0777);
else
test.close();
}
void readConfig()
{
extern void cbMenuConfig();
std::string configfname = ARQ_dir;
configfname.append("flarq.config");
std::ifstream configfile(configfname.c_str());
if (configfile) {
char tempstr[200];
configfile.getline(tempstr,200);
sscanf(tempstr,"%f", &vers);
if (int(vers*10) != int(version*10))
initVals();
else {
configfile >> MyCall;
configfile >> exponent;
configfile >> txdelay;
configfile >> iretries;
configfile >> iwaittime;
configfile >> itimeout;
configfile >> bcnInterval;
configfile >> mainX;
configfile >> mainY;
configfile >> mainW;
configfile >> mainH;
configfile.ignore();
configfile.getline(tempstr, 200);
beacontext = tempstr;
configfile >> restart_beacon;
digi_arq->myCall(MyCall.c_str());
digi_arq->setExponent(exponent);
digi_arq->setRetries(iretries);
digi_arq->setTimeout(itimeout);
digi_arq->setTxDelay(txdelay);
digi_arq->setWaitTime(iwaittime);
}
configfile.close();
} else
initVals();
}
void saveConfig()
{
std::string configfname = ARQ_dir;
configfname.append("flarq.config");
std::ofstream configfile(configfname.c_str());
if (configfile) {
int mainX = arqwin->x();
int mainY = arqwin->y();
int mainW = arqwin->w();
int mainH = arqwin->h();
configfile << VERSION << std::endl;
configfile << MyCall << std::endl;
configfile << exponent << std::endl;
configfile << txdelay << std::endl;
configfile << iretries << std::endl;
configfile << iwaittime << std::endl;
configfile << itimeout << std::endl;
configfile << bcnInterval << std::endl;
configfile << mainX << std::endl;
configfile << mainY << std::endl;
configfile << mainW << std::endl;
configfile << mainH << std::endl;
configfile << beacontext.c_str() << std::endl;
configfile << restart_beacon << std::endl;
configfile.close();
}
}
void cbSetConfig()
{
digi_arq->setExponent(exponent);
digi_arq->setRetries(iretries);
digi_arq->setTimeout(itimeout);
digi_arq->setTxDelay(txdelay);
digi_arq->setWaitTime(iwaittime);
}
void closeConfig()
{
if (dlgconfig)
dlgconfig->hide();
cbSetConfig();
}
void cb_idtimer()
{
digi_arq->set_idtimer();
}
void cbMenuConfig()
{
if (!dlgconfig) {
dlgconfig = arq_configure();
dlgconfig->xclass(PACKAGE_TARNAME);
choiceBlockSize->add("16");
choiceBlockSize->add("32");
choiceBlockSize->add("64");
choiceBlockSize->add("128");
choiceBlockSize->add("256");
}
choiceBlockSize->index(exponent - 4);
choiceBlockSize->redraw();
dlgconfig->show();
}
void cbMenuAbout()
{
fl_message2("flarq - ARQ client\nversion: %s\nw1hkj@@w1hkj.com", VERSION);
}
std::string txhold = "";
//=============================================================================
void mpsk_on()
{
std::string s;
s.append(1, MPSK_CMD).append(MPSK_TX).append(1, MPSK_END);
try {
tcpip->send(s);
}
catch (const SocketException& e) {
std::cerr << e.what() << '\n';
}
}
void mpsk_off_after_buffer_sent()
{
std::string s;
s.append(1, MPSK_CMD).append(MPSK_TX2RX).append(1, MPSK_END);
try {
tcpip->send(s);
}
catch (const SocketException& e) {
std::cerr << e.what() << '\n';
}
}
void mpsk_off()
{
std::string s;
s.append(1, MPSK_CMD).append(MPSK_RX).append(1, MPSK_END);
try {
tcpip->send(s);
}
catch (const SocketException& e) {
std::cerr << e.what() << '\n';
}
}
void MPSK_client_transmit(const std::string& s)
{
if (s.empty())
return;
std::string tosend;
tosend.reserve(s.length() * 2);
for (size_t i = 0; i < s.length(); i++)
tosend.append(1, MPSK_BYTE).append(1, s[i]);
try {
mpsk_on();
tcpip->send(tosend);
mpsk_off_after_buffer_sent();
}
catch (const SocketException& e) {
std::cerr << e.what() << '\n';
}
}
void MPSK_Socket_rcv_loop(void *)
{
if (inLoop) Fl::wait(0.1);
inLoop = true;
char cs;
try {
while (tcpip->wait(0)) {
tcpip->recv(&cs, 1);
if (isRxChar) {
rxbuffer += cs;
isRxChar = false;
continue;
}
if (isTxChar) {
if (cs < 28 || cs > 31)
txbuffer += cs;
isTxChar = false;
continue;
}
if (isCmdChar) {
if (cs == MPSK_CMDEND) {
isCmdChar = false;
if (cmdbuffer.find("RX_AFTER_TX OK") != std::string::npos) {
rxbuffer += 0x06;
cmdbuffer.clear();
txbuffer.clear();
}
continue;
}
cmdbuffer += cs;
continue;
}
if (cs == MPSK_ISRX) {
isRxChar = true;
continue;
}
if (cs == MPSK_ISCMD) {
isCmdChar = true;
continue;
}
if (cs == MPSK_ISTX) {
isTxChar = true;
continue;
}
}
}
catch (const SocketException& e) {
std::cerr << e.what() << '\n';
}
inLoop = false;
Fl::add_timeout(0.01, MPSK_Socket_rcv_loop);
}
//=============================================================================
void client_transmit(const std::string& s )
{
try {
if (!s.empty())
tcpip->send(s);
}
catch (const SocketException& e) {
std::cerr << e.what() << '\n';
}
}
void Socket_rcv_loop(void *)
{
if (inLoop)
Fl::wait(0.1);
inLoop = true;
try {
tcpip->set_nonblocking(true);
tcpip->recv(rxbuffer);
tcpip->set_nonblocking(false);
}
catch (const SocketException& e) {
std::cerr << e.what() << '\n';
}
inLoop = false;
Fl::add_timeout(0.01, Socket_rcv_loop);
}
bool client_receive(char &c)
{
if (inLoop) Fl::wait(0.1);
inLoop = true;
bufsize = rxbuffer.length();
if (bufsize) {
if (bufptr < bufsize) {
c = rxbuffer[bufptr++];
inLoop = false;
return true;
}
}
rxbuffer.clear();
bufsize = 0;
bufptr = 0;
inLoop = false;
return false;
}
int autobeaconcounter = 0;
char bcnMsg[40];
void arqAutoBeacon(void *)
{
if (autobeacon == ON) {
int currstate = digi_arq->state();
btnCONNECT->deactivate();
btnCONNECT->redraw();
if (currstate > 0x7F) {
txtBeaconing->value("Beaconing");
btnBEACON->deactivate();
btnBEACON->redraw();
Fl::repeat_timeout(1.0, arqAutoBeacon);
return;
} else if (currstate == DOWN || currstate == TIMEDOUT) {
if (autobeaconcounter == 0) {
digi_arq->sendBeacon( beacontext );
autobeaconcounter = bcnInterval;
Fl::repeat_timeout(1.0 + txdelay / 1000.0, arqAutoBeacon);
} else {
snprintf(bcnMsg, sizeof(bcnMsg), "Bcn in: %d sec", autobeaconcounter);
txtBeaconing->value(bcnMsg);
btnBEACON->label("STOP");
btnBEACON->redraw_label();
btnBEACON->activate();
btnBEACON->redraw();
autobeaconcounter--;
Fl::repeat_timeout(1.0, arqAutoBeacon);
}
return;
} else {
autobeaconcounter = 0;
btnBEACON->value(0);
btnBEACON->label("Beacon");
btnBEACON->redraw_label();
btnBEACON->activate();
btnBEACON->redraw();
txtBeaconing->value("Beacon Off");
}
} else if (autobeacon == OFF) {
autobeaconcounter = 0;
btnCONNECT->activate();
btnCONNECT->redraw();
btnBEACON->value(0);
btnBEACON->label("Beacon");
btnBEACON->redraw_label();
btnBEACON->activate();
btnBEACON->redraw();
txtBeaconing->value("Beacon Off");
} else { // autobeacon == WAIT
btnBEACON->deactivate();
btnBEACON->redraw();
Fl::repeat_timeout(1.0, arqAutoBeacon);
}
}
void arqBEACON()
{
if (autobeacon != ON) {
autobeacon = ON;
btnBEACON->value(1);
Fl::add_timeout(0.01, arqAutoBeacon);
} else {
autobeacon = OFF;
btnBEACON->value(0);
}
}
void printstring(std::string s)
{
for (size_t n = 0; n < s.length(); n++)
if (s[n] < ' ') printf("<%02d>",(int)s[n]);
else printf("%c", s[n]);
printf("\n");
}
void arqCLOSE()
{
tcpip->close();
saveConfig();
exit_server();
exit(0);
}
void clearText()
{
txtarqload = "";
txtbuffARQ->text("");
txtStatus->value("");
txtStatus2->value("");
}
void restart()
{
TX.clear();
rxfname = "";
rxTextReady = false;
prgStatus->value(0.0);
prgStatus->label("");
prgStatus->redraw();
prgStatus->redraw_label();
rxARQfile = false;
sendingfile = false;
incomingText.clear();
clearText();
}
void arqCONNECT()
{
int state = Fl::event_state();
if ((state & FL_CTRL) == FL_CTRL) {
digi_arq->restart_arq();
txtURCALL->value("");
restart();
return;
}
if (digi_arq->state() < ARQ_CONNECTED) {
if (strlen(txtURCALL->value()) > 0)
digi_arq->connect(txtURCALL->value());
} else {
if (rxARQfile || sendingfile)
abortTransfer();
else {
restart();
digi_arq->disconnect();
txtURCALL->value("");
}
}
}
bool fileExists(std::string fname)
{
std::ifstream test(fname.c_str());
if (test) {
test.close();
return true;
}
return false;
}
std::string nextFileName(std::string fname)
{
int nbr = 0;
char szNbr[20];
std::string name;
std::string ext;
std::string nuname;
size_t p;
p = fname.find_last_of('.');
if (p != std::string::npos) {
ext = fname.substr(p);
name = fname.substr(0,p);
} else {
ext = "";
name = fname;
}
do {
nbr++;
nuname = name;
snprintf(szNbr, sizeof(szNbr), ".dup%-d", nbr);
nuname.append(szNbr);
nuname.append(ext);
} while (fileExists(nuname));
return nuname;
}
void saveEmailFile()
{
static char xfrmsg[80];
std::string tempname;
time(&EndTime_t);
TransferTime = difftime(EndTime_t, StartTime_t);
snprintf(xfrmsg, sizeof(xfrmsg), "Transfer Completed in %4.0f sec's", TransferTime);
std::string savetoname = ARQ_mail_in_dir;
if (rxfname.find(".eml") == std::string::npos)
rxfname.append(".eml");
savetoname.append(rxfname);
while (fileExists(savetoname))
savetoname = nextFileName(savetoname);
std::ofstream tfile(savetoname.c_str(), std::ios::binary);
if (tfile) {
tfile << txtarqload;
tfile.close();
}
txtStatus->value(xfrmsg);
rxfname = "";
txtarqload = "";
rxTextReady = false;
}
void saveRxFile()
{
static char xfrmsg[80];
time(&EndTime_t);
TransferTime = difftime(EndTime_t, StartTime_t);
snprintf(xfrmsg, sizeof(xfrmsg), "Transfer Completed in %4.0f sec's", TransferTime);
std::string savetoname = ARQ_recv_dir;
savetoname.append(rxfname);
if (fileExists(savetoname))
savetoname = nextFileName(savetoname);
std::ofstream tfile(savetoname.c_str(), std::ios::binary);
if (tfile) {
tfile << txtarqload;
tfile.close();
}
txtStatus->value(xfrmsg);
rxfname = "";
txtarqload = "";
rxTextReady = false;
}
void payloadText(std::string s)
{
static char szPercent[10];
std::string text = noCR(s);
txtARQ->insert(text.c_str());
txtARQ->show_insert_position();
txtARQ->redraw();
incomingText.append (s);
if (!rxARQfile)
if ((startpos = incomingText.find(arqstart)) != std::string::npos) {
rxARQfile = true;
startpos += arqstart.length();
time(&StartTime_t);
}
if (rxARQfile) {
if (!rxARQhavesize) {
if ( (sizepos = incomingText.find(arqsizespec)) != std::string::npos) {
sizepos += arqsizespec.length();
if ((lfpos = incomingText.find('\n', sizepos)) != std::string::npos) {
std::string sizechars = incomingText.substr(sizepos, lfpos - sizepos);
unsigned int tempnbr;
sscanf(sizechars.c_str(), "%u", &tempnbr);
arqPayloadSize = tempnbr;
rxARQhavesize = true;
char statusmsg[40];
snprintf(statusmsg, sizeof(statusmsg), "Rcvg: %d",
static_cast<int>(arqPayloadSize));
txtStatus->value(statusmsg);
}
}
} else {
if (startpos != std::string::npos) {
float partial = incomingText.length() - startpos;
snprintf(szPercent, sizeof(szPercent), "%3.0f %%", 100.0 * partial / arqPayloadSize);
prgStatus->value( partial / arqPayloadSize );
prgStatus->label(szPercent);
} else {
prgStatus->value(0.0);
prgStatus->label("");
}
prgStatus->redraw();
prgStatus->redraw_label();
}
if ((endpos = incomingText.find(arqend)) != std::string::npos) {
haveemail = false;
fnamepos = incomingText.find(arqfile);
fnamepos += arqfile.length();
indx = incomingText.find('\n', fnamepos);
rxfname = incomingText.substr(fnamepos, indx - fnamepos);
txtarqload = incomingText.substr(startpos, endpos - startpos);
if (incomingText.find(arqbase64) != std::string::npos) {
base64 b64;
txtarqload = b64.decode(txtarqload);
}
if (incomingText.find(arqemail) != std::string::npos)
haveemail = true;
startpos = std::string::npos;
endpos = std::string::npos;
fnamepos = std::string::npos;
indx = std::string::npos;
sizepos = std::string::npos;
lfpos = std::string::npos;
arqPayloadSize = 0;
rxARQfile = false;
rxARQhavesize = false;
rxTextReady = true;
if (incomingText.find("FLMSG_XFR") != std::string::npos)
xml_rx_text_ready = true;
incomingText = "";
txtStatus->value("");
prgStatus->value(0.0);
prgStatus->label("");
prgStatus->redraw();
prgStatus->redraw_label();
}
}
}
void cbClearText()
{
txtbuffARQ->text("");
}
void abortedTransfer()
{
restart();
txtARQ->insert("transfer aborted\n");
btnCONNECT->activate();
}
void abortTransfer()
{
sendingfile = false;
SendingEmail = false;
rxARQfile = false;
btnCONNECT->label("ABORTING");
btnCONNECT->redraw_label();
btnCONNECT->deactivate();
digi_arq->abort();
}
void rxBeaconCallsign(std::string s)
{
txtURCALL->value(s.c_str());
beaconrcvd = true;
}
void moveEmailFile()
{
if (MailFileName.empty()) return;
if (MailSaveFileName.empty()) return;
std::ifstream infile(MailFileName.c_str(), std::ios::in | std::ios::binary);
if (MailSaveFileName.find(".eml") == std::string::npos)
MailSaveFileName.append(".eml");
while (fileExists(MailSaveFileName))
MailSaveFileName = nextFileName(MailSaveFileName);
std::ofstream outfile(MailSaveFileName.c_str(), std::ios::out | std::ios::binary);
char c;
if (infile && outfile) {
while (!infile.eof()) {
infile.get(c);
outfile.put(c);
}
infile.close();
outfile.close();
unlink(MailFileName.c_str());
}
MailFileName.clear();
MailSaveFileName.clear();
}
void sendEmailFile()
{
if (arqstate < ARQ_CONNECTED) {
fl_alert2("Not connected");
return;
}
sendfilename.clear();
selectTrafficOut(false);
if (sendfilename.empty())
return;
char cin;
size_t txtsize;
std::string textin = "";
char sizemsg[40];
size_t p;
std::ifstream textfile;
textfile.open(sendfilename.c_str(), std::ios::binary);
if (textfile) {
for (size_t i = 0; i < sendfilename.length(); i++)
if (sendfilename[i] == '\\') sendfilename[i] = '/';
MailFileName = sendfilename;
TX.erase();
TX.append(arqfile);
MailSaveFileName = ARQ_mail_sent_dir;
p = sendfilename.find_last_of('/');
if (p != std::string::npos) p++;
MailSaveFileName.append(sendfilename.substr(p));
TX.append(sendfilename.substr(p));
TX.append("\n");
TX.append(arqemail);
// only allow ASCII printable characters
while (textfile.get(cin)) textin += (cin & 0xFF);
textfile.close();
if ( textin.find_first_not_of(AsciiChars) != std::string::npos) {
fl_alert2("File contains non-ASCII bytes and must be sent as binary.");
return;
}
textfile.close();
txtsize = textin.length();
arqPayloadSize = txtsize;
blocksSent = 0;
snprintf(sizemsg, sizeof(sizemsg), "ARQ:SIZE::%d\n",
static_cast<int>(txtsize));
TX.append(sizemsg);
TX.append(arqstart);
TX.append(textin);
TX.append(arqend);
traffic = true;
statusmsg = "Sending email: ";
statusmsg.append(sendfilename.substr(p));
txtStatus->value(statusmsg.c_str());
SendingEmail = true;
sendingfile = true;
cbClearText();
return;
}
traffic = false;
sendingfile = false;
SendingEmail = false;
}
void sendAsciiFile()
{
if (arqstate < ARQ_CONNECTED) {
fl_alert2("Not connected");
return;
}
std::string readfromname = ARQ_send_dir;
readfromname.append(rxfname);
const char *p = FSEL::select("ARQ text file", "*.txt\t*", readfromname.c_str());
char cin;
size_t txtsize;
std::string textin = "";
char sizemsg[40];
if (p && *p) {
std::ifstream textfile;
textfile.open(p);
if (textfile) {
TX.erase();
TX.append(arqfile);
p = fl_filename_name(p);
TX.append(p);
TX.append("\n");
TX.append(arqascii);
while (textfile.get(cin)) textin += (cin & 0xFF);
textfile.close();
if ( textin.find_first_not_of(AsciiChars) != std::string::npos) {
fl_alert2("File contains non-ASCII bytes and must be sent as binary.");
return;
}
txtsize = textin.length();
arqPayloadSize = txtsize;
blocksSent = 0;
snprintf(sizemsg, sizeof(sizemsg), "ARQ:SIZE::%d\n",
static_cast<int>(txtsize));
TX.append(sizemsg);
TX.append(arqstart);
TX.append(textin);
TX.append(arqend);
traffic = true;
sendingfile = true;
statusmsg = "Sending ASCII file: ";
statusmsg.append(p);
txtStatus->value(statusmsg.c_str());
cbClearText();
return;
}
}
traffic = false;
sendingfile = false;
}
void sendImageFile()
{
if (arqstate < ARQ_CONNECTED) {
fl_alert2("Not connected");
return;
}
const char *p = FSEL::select(_("ARQ image file"), "Images\t*.{png,jpg,bmp}", "");
char cin;
size_t b64size;
std::string textin = "";
std::string b64text;
base64 b64(true);
char sizemsg[40];
if (p && *p) {
std::ifstream textfile;
textfile.open(p, std::ios::binary);
if (textfile) {
TX.erase();
TX.append(arqfile);
p = fl_filename_name(p);
TX.append(p);
TX.append("\n");
TX.append(arqbase64);
while (textfile.get(cin))
textin += cin;
textfile.close();
b64text = b64.encode(textin);
b64size = b64text.length();
snprintf(sizemsg, sizeof(sizemsg), "ARQ:SIZE::%d\n",
static_cast<int>(b64size));
arqPayloadSize = b64size;
blocksSent = 0;
TX.append(sizemsg);
TX.append(arqstart);
TX.append(b64text);
TX.append(arqend);
traffic = true;
sendingfile = true;
statusmsg = "Sending image: ";
statusmsg.append(p);
txtStatus->value(statusmsg.c_str());
cbClearText();
return;
}
}
traffic = false;
sendingfile = false;
}
void sendBinaryFile()
{
if (arqstate < ARQ_CONNECTED) {
fl_alert2("Not connected");
return;
}
const char *p = FSEL::select("ARQ file", "*", "");
char cin;
size_t b64size;
std::string textin = "";
std::string b64text;
base64 b64(true);
char sizemsg[40];
if (p && *p) {
std::ifstream textfile;
textfile.open(p, std::ios::binary);
if (textfile) {
TX.erase();
TX.append(arqfile);
p = fl_filename_name(p);
TX.append(p);
TX.append("\n");
TX.append(arqbase64);
while (textfile.get(cin))
textin += cin;
textfile.close();
b64text = b64.encode(textin);
b64size = b64text.length();
snprintf(sizemsg, sizeof(sizemsg), "ARQ:SIZE::%d\n",
static_cast<int>(b64size));
arqPayloadSize = b64size;
blocksSent = 0;
TX.append(sizemsg);
TX.append(arqstart);
TX.append(b64text);
TX.append(arqend);
traffic = true;
sendingfile = true;
statusmsg = "Sending binary: ";
statusmsg.append(p);
txtStatus->value(statusmsg.c_str());
cbClearText();
return;
}
}
traffic = false;
sendingfile = false;
}
void send_xml_text(std::string fname, std::string txt)
{
if (arqstate < ARQ_CONNECTED) {
fl_alert2("Not connected");
return;
}
size_t txtsize;
char sizemsg[40];
if (!txt.empty()) {
TX.erase();
TX.append(arqfile);
TX.append(fname);
TX.append("\n");
TX.append(arqascii);
txtsize = txt.length();
arqPayloadSize = txtsize;
blocksSent = 0;
snprintf(sizemsg, sizeof(sizemsg), "ARQ:SIZE::%d\n",
static_cast<int>(txtsize));
TX.append(sizemsg);
TX.append(arqstart);
TX.append(txt);
TX.append(arqend);
traffic = true;
sendingfile = true;
statusmsg = "Sending XML payload: ";
statusmsg.append(fname);
txtStatus->value(statusmsg.c_str());
cbClearText();
return;
}
traffic = false;
sendingfile = false;
}
static char statemsg[80];
void dispState()
{
static int last_state = DOWN;
int currstate = digi_arq->state();
static char xfrmsg[80];
static char szPercent[10];
arqstate = currstate & 0x7F;
if (last_state != currstate) {
last_state = currstate;
if (arqstate == DOWN || arqstate == TIMEDOUT) {
if (btnCONNECT->active()) {
btnCONNECT->label("Connect");
}
btnBEACON->activate();
mnu->redraw();
}
else if (arqstate == ARQ_CONNECTED || arqstate == WAITING) {
if (btnCONNECT->active())
btnCONNECT->label("Disconnect");
if (!autobeacon)
btnBEACON->deactivate();
mnuSend->activate();
mnu->redraw();
}
if (rxARQfile || sendingfile) {
if (btnCONNECT->active())
btnCONNECT->label("Abort");
}
if (btnCONNECT->active())
btnCONNECT->redraw_label();
if (currstate <= 0x7F) { // receiving
switch (currstate) {
case ARQ_CONNECTING :
snprintf(statemsg, sizeof(statemsg), "CONNECTING: %d", digi_arq->getTimeLeft());
txtState->value(statemsg);
txtState->redraw();
autobeacon = WAIT;
break;
case WAITFORACK :
snprintf(statemsg, sizeof(statemsg), "WAITING FOR ACK ");
txtState->value(statemsg);
txtState->redraw();
autobeacon = WAIT;
break;
case ABORT:
case ABORTING :
txtState->value("ABORTING XFR");
txtState->redraw();
autobeacon = WAIT;
break;
case WAITING :
case ARQ_CONNECTED :
char szState[80];
snprintf(szState, sizeof(szState),"CONNECTED - Quality = %4.2f",
digi_arq->quality());
indCONNECT->color(FL_GREEN);
indCONNECT->redraw();
txtBeaconing->value("");
txtState->value(szState);
txtURCALL->value( digi_arq->urCall().c_str() );
autobeacon = WAIT;
break;
case TIMEDOUT :
indCONNECT->color(FL_WHITE);
indCONNECT->redraw();
txtState->value("TIMED OUT");
txtStatus->value("");
if (restart_beacon && autobeacon != ON) {
autobeacon = ON;
Fl::remove_timeout(arqAutoBeacon);
Fl::add_timeout(1.0 + txdelay / 1000.0, arqAutoBeacon);
}
beaconrcvd = false;
break;
case DISCONNECT:
case DISCONNECTING:
txtState->value("DISCONNECTING");
break;
case DOWN :
default :
if (autobeacon != ON && restart_beacon) {
btnBEACON->activate();
Fl::remove_timeout(arqAutoBeacon);
Fl::add_timeout(1.0 + txdelay / 1000.0, arqAutoBeacon);
}
indCONNECT->color(FL_WHITE);
indCONNECT->redraw();
autobeacon = ON;
txtState->value("NOT CONNECTED");
txtStatus->value("");
}
}
}
if (sendingfile == true) {
if (digi_arq->transferComplete()) {
time(&EndTime_t);
TransferTime = difftime(EndTime_t,StartTime_t);
snprintf(xfrmsg, sizeof(xfrmsg), "Transfer Completed in %4.0f sec's", TransferTime);
txtStatus->value(xfrmsg);
blocksSent = 0;
prgStatus->value(0.0);
prgStatus->label("");
prgStatus->redraw();
prgStatus->redraw_label();
sendingfile = false;
}
else {
prgStatus->value( digi_arq->percentSent());
snprintf(szPercent, sizeof(szPercent), "%3.0f %%", 100.0 * digi_arq->percentSent());
prgStatus->label(szPercent);
prgStatus->redraw();
prgStatus->redraw_label();
}
}
if (SendingEmail == true) {
if (digi_arq->transferComplete()) {
time(&EndTime_t);
TransferTime = difftime(EndTime_t,StartTime_t);
snprintf(xfrmsg, sizeof(xfrmsg), "Transfer Completed in %4.0f sec's", TransferTime);
txtStatus->value(xfrmsg);
moveEmailFile();
blocksSent = 0;
prgStatus->value(0.0);
prgStatus->label("");
prgStatus->redraw();
prgStatus->redraw_label();
SendingEmail = false;
}
else {
prgStatus->value( digi_arq->percentSent());
snprintf(szPercent, sizeof(szPercent), "%3.0f %%", 100.0 * digi_arq->percentSent());
prgStatus->label(szPercent);
prgStatus->redraw();
prgStatus->redraw_label();
}
}
}
void mainloop(void *)
{
if (traffic) {
digi_arq->sendText(TX);
traffic = false;
time(&StartTime_t);
}
dispState();
if (rxTextReady) {
if (haveemail)
saveEmailFile();
else if (!xml_rx_text_ready)
saveRxFile();
}
Fl::repeat_timeout(0.1, mainloop);
}
void changeMyCall(const char *nucall)
{
int currstate = digi_arq->state();
if (currstate != DOWN)
return;
MyCall = nucall;
for (size_t i = 0; i < MyCall.length(); i++)
MyCall[i] = toupper(MyCall[i]);
txtMyCall->value(MyCall.c_str());
digi_arq->myCall(MyCall.c_str());
std::string title = "flarq ";
title.append(VERSION);
title.append(" - ");
title.append(MyCall);
arqwin->label(title.c_str());
}
void changeBeaconText(const char *txt)
{
beacontext = txt;
}
void TALKprint(std::string s)
{
txtRX->insert(s.c_str());
txtRX->show_insert_position();
txtRX->redraw();
}
void clear_STATUS(void* arg)
{
txtStatus2->value("");
}
void STATUSprint(std::string s, double disptime)
{
txtStatus2->value(s.c_str());
if (disptime > 0.0) {
Fl::remove_timeout( clear_STATUS );
Fl::add_timeout( disptime, clear_STATUS );
}
}
void cbSendTalk()
{
std::string tosend;
tosend = txtTX->value();
if (tosend.empty()) return;
tosend += '\n';
digi_arq->sendPlainText(tosend);
txtTX->value("");
txtRX->insert(tosend.c_str());
txtRX->show_insert_position();
txtRX->redraw();
}
void arqlog(std::string nom,std::string s)
{
static char szGMT[80];
tm *now;
time_t tm;
std::string strdebug;
time(&tm);
now = localtime( &tm );
strftime(szGMT, sizeof(szGMT), "[%X] ", now);
for (unsigned int i = 0; i < s.length(); i++)
if (s[i] < 32)
strdebug += ASCII[(int)s[i]];
else
strdebug += s[i];
std::ofstream logfile(Logfile.c_str(), std::ios::app);
if (logfile)
logfile << nom << szGMT << strdebug << std::endl;
}
void DEBUGrxprint(std::string s)
{
std::string text = noCR(s);
txtRX->insert(text.c_str());
txtRX->show_insert_position();
txtRX->redraw();
arqlog("<RX>",s);
}
void DEBUGtxprint(std::string s)
{
std::string text = noCR(s);
txtRX->insert(text.c_str());
txtRX->show_insert_position();
txtRX->redraw();
arqlog("<TX>",s);
}
void TXecho(std::string s)
{
blocksSent += s.length();
std::string text = noCR(s);
txtARQ->insert(text.c_str());
txtARQ->show_insert_position();
txtARQ->redraw();
}
void style_unfinished_cb(int, void*) {
}
void cbClearTalk()
{
txtbuffRX->text("");
}
void cb_arqwin(Fl_Widget *, void*)
{
arqCLOSE();
}
std::string pname;
int main (int argc, char *argv[] )
{
sscanf(VERSION, "%f", &version);
std::set_unexpected(handle_unexpected);
std::set_terminate(diediedie);
setup_signal_handlers();
NBEMS_dir.clear();
{
std::string appname = pname = argv[0];
std::string appdir = argv[0];
#ifdef __WIN32__
size_t p = appdir.find("FL_APPS\\");
if (p == std::string::npos) p = appdir.find("FL_APPS/");
if (p == std::string::npos) {
char dirbuf[FL_PATH_MAX + 1];
fl_filename_expand(dirbuf, sizeof(dirbuf) -1, "$USERPROFILE/");
NBEMS_dir.assign(dirbuf);
} else
NBEMS_dir.assign(appdir.substr(0, p + 8));
NBEMS_dir.append("NBEMS.files/");
#else
char dirbuf[FL_PATH_MAX + 1];
fl_filename_absolute(dirbuf, sizeof(dirbuf), argv[0]);
appdir.assign(dirbuf);
size_t p = appdir.rfind("flarq");
if (p != std::string::npos)
appdir.erase(p);
p = appdir.find("FL_APPS/");
if (p != std::string::npos)
NBEMS_dir.assign(appdir.substr(0, p + 8));
else {
fl_filename_expand(dirbuf, FL_PATH_MAX, "$HOME/");
NBEMS_dir = dirbuf;
}
DIR *isdir = 0;
std::string test_dir;
test_dir.assign(NBEMS_dir).append("NBEMS.files/");
isdir = opendir(test_dir.c_str());
if (isdir) {
NBEMS_dir = test_dir;
closedir(isdir);
} else {
NBEMS_dir.append(".nbems/");
}
#endif
HomeDir = NBEMS_dir;
}
checkdirectories();
Logfile = ARQ_dir;
Logfile.append("/").append("arqlog.txt");
set_platform_ui();
generate_option_help();
generate_version_text();
int arg_idx;
if (Fl::args(argc, argv, arg_idx, parse_args) != argc) {
std::cerr << PACKAGE_NAME << ": bad option `" << argv[arg_idx]
<< "'\nTry `" << PACKAGE_NAME
<< " --help' for more information.\n";
exit(EXIT_FAILURE);
}
createAsciiChars(); // allowable ASCII text chars for ".txt" type of files
FSEL::create();
arqwin = arq_dialog();
arqwin->callback(cb_arqwin);
arqwin->xclass(PACKAGE_TARNAME);
// FL_NORMAL_SIZE may have changed; update the menu items
for (int i = 0; i < menu_mnu->size() - 1; i++)
if (menu_mnu[i].text)
menu_mnu[i].labelsize(FL_NORMAL_SIZE);
txtbuffRX = txtRX->buffer();
txtRX->wrap_mode(1,80);
txtbuffARQ = txtARQ->buffer();
txtARQ->wrap_mode(1,80);
digi_arq = new arq();
try {
tcpip = new Socket(Address(arq_address.c_str(), arq_port.c_str()));
tcpip->set_timeout(0.01);
tcpip->connect();
}
catch (const SocketException& e) {
std::string errmsg;
errmsg.append("Could not connect to modem program.\nPlease start ");
if (ioMPSK)
errmsg.append("MultiPSK");
else
errmsg.append("fldigi");
errmsg.append(" before flarq.");
fl_alert2("%s", errmsg.c_str());
exit(EXIT_FAILURE);
}
if (ioMPSK)
Fl::add_timeout(0.1, MPSK_Socket_rcv_loop);
else
Fl::add_timeout(0.1, Socket_rcv_loop);
// the following sequence of assigning callback functions is mandatory
// for the arq class to function
if (ioMPSK)
digi_arq->setSendFunc (MPSK_client_transmit);
else
digi_arq->setSendFunc (client_transmit);
digi_arq->setGetCFunc (client_receive);
digi_arq->setAbortedTransfer(abortedTransfer);
digi_arq->setDisconnected(restart);
digi_arq->setrxUrCall (rxBeaconCallsign);
digi_arq->setPrintRX (payloadText);
digi_arq->setPrintTX (TXecho);
digi_arq->setPrintTALK (TALKprint);
digi_arq->setPrintSTATUS (STATUSprint);
if (SHOWDEBUG) {
digi_arq->setPrintRX_DEBUG (DEBUGrxprint);
digi_arq->setPrintTX_DEBUG (DEBUGtxprint);
}
digi_arq->start_arq();
readConfig();
std::string title = "flarq ";
title.append(VERSION);
title.append(" - ");
title.append(MyCall);
arqwin->label(title.c_str());
arqwin->resize(mainX, mainY, mainW, mainH);
txtBeaconing->value("Beacon Off");
Fl::add_timeout(0.1, mainloop);
#ifdef __WOE32__
# ifndef IDI_ICON
# define IDI_ICON 101
# endif
arqwin->icon((char*)LoadIcon(fl_display, MAKEINTRESOURCE(IDI_ICON)));
#elif !defined(__APPLE__) && USE_X
make_pixmap(&flarq_icon_pixmap, flarq_icon, argc, argv);
arqwin->icon((char *)flarq_icon_pixmap);
#endif
start_xml_server(FLARQ_XML_PORT);
arqwin->show(argc, argv);
return Fl::run();
}
static void checkdirectories(void)
{
struct DIRS {
std::string& dir;
const char* suffix;
void (*new_dir_func)(void);
};
DIRS NBEMS_dirs[] = {
{ NBEMS_dir, 0, 0 },
{ ARQ_dir, "ARQ", 0 },
{ ARQ_files_dir, "ARQ/files", 0 },
{ ARQ_recv_dir, "ARQ/recv", 0 },
{ ARQ_send_dir, "ARQ/send", 0 },
{ ARQ_mail_dir, "ARQ/mail", 0 },
{ ARQ_mail_in_dir, "ARQ/mail/in", 0 },
{ ARQ_mail_out_dir, "ARQ/mail/out", 0 },
{ ARQ_mail_sent_dir, "ARQ/mail/sent", 0 },
{ WRAP_dir, "WRAP", 0 },
{ WRAP_recv_dir, "WRAP/recv", 0 },
{ WRAP_send_dir, "WRAP/send", 0 },
{ WRAP_auto_dir, "WRAP/auto", 0 },
{ ICS_dir, "ICS", 0 },
{ ICS_msg_dir, "ICS/messages", 0 },
{ ICS_tmp_dir, "ICS/templates", 0 },
};
int r;
for (size_t i = 0; i < sizeof(NBEMS_dirs)/sizeof(*NBEMS_dirs); i++) {
if (NBEMS_dirs[i].suffix)
NBEMS_dirs[i].dir.assign(NBEMS_dir).append(NBEMS_dirs[i].suffix).append("/");
if ((r = mkdir(NBEMS_dirs[i].dir.c_str(), 0777)) == -1 && errno != EEXIST) {
std::cerr << _("Could not make directory") << ' ' << NBEMS_dirs[i].dir
<< ": " << strerror(errno) << '\n';
exit(EXIT_FAILURE);
}
else if (r == 0 && NBEMS_dirs[i].new_dir_func)
NBEMS_dirs[i].new_dir_func();
}
}
// This function may be called by the QRZ thread
void cb_mnuVisitURL(Fl_Widget*, void* arg)
{
const char* url = reinterpret_cast<const char *>(arg);
#ifndef __WOE32__
const char* browsers[] = {
# ifdef __APPLE__
getenv("FLDIGI_BROWSER"), // valid for any OS - set by user
"open" // OS X
# else
"fl-xdg-open", // Puppy Linux
"xdg-open", // other Unix-Linux distros
getenv("FLDIGI_BROWSER"), // force use of spec'd browser
getenv("BROWSER"), // most Linux distributions
"sensible-browser",
"firefox",
"mozilla" // must be something out there!
# endif
};
switch (fork()) {
case 0:
# ifndef NDEBUG
unsetenv("MALLOC_CHECK_");
unsetenv("MALLOC_PERTURB_");
# endif
for (size_t i = 0; i < sizeof(browsers)/sizeof(browsers[0]); i++)
if (browsers[i])
execlp(browsers[i], browsers[i], url, (char*)0);
exit(EXIT_FAILURE);
case -1:
fl_alert2(_("Could not run a web browser:\n%s\n\n"
"Open this URL manually:\n%s"),
strerror(errno), url);
}
#else
// gurgle... gurgle... HOWL
// "The return value is cast as an HINSTANCE for backward
// compatibility with 16-bit Windows applications. It is
// not a true HINSTANCE, however. The only thing that can
// be done with the returned HINSTANCE is to cast it to an
// int and compare it with the value 32 or one of the error
// codes below." (Error codes omitted to preserve sanity).
if ((INT_PTR)ShellExecute(NULL, "open", url, NULL, NULL, SW_SHOWNORMAL) <= 32)
fl_alert2(_("Could not open url:\n%s\n"), url);
#endif
}
void open_nbems_file_folder()
{
cb_mnuVisitURL(0, (void*)NBEMS_dir.c_str());
}
| 47,719
|
C++
|
.cxx
| 1,844
| 23.183297
| 94
| 0.651977
|
w1hkj/fldigi
| 109
| 27
| 38
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
751,067
|
hid_lin.cxx
|
w1hkj_fldigi/src/cmedia/hid_lin.cxx
|
/***********************************************************************
HIDAPI - Multi-Platform library for communication with HID devices.
hid_lin.cxx
Alan Ott
Signal 11 Software
Copyright 2009, All Rights Reserved.
C++ implementation
* Copyright 2021
* David Freese, W1HKJ
* for use in fldigi
This software is licensed under the terms of the GNU General Public
License v3.
***********************************************************************/
#include <iostream>
/* C */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <locale.h>
#include <errno.h>
/* Unix */
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/utsname.h>
#include <fcntl.h>
#include <poll.h>
/* Linux */
#include <linux/hidraw.h>
#include <linux/version.h>
#include <linux/input.h>
#include <libudev.h>
#include "hidapi.h"
/* Definitions from linux/hidraw.h. Since these are new, some distros
may not have header files which contain them. */
#ifndef HIDIOCSFEATURE
#define HIDIOCSFEATURE(len) _IOC(_IOC_WRITE|_IOC_READ, 'H', 0x06, len)
#endif
#ifndef HIDIOCGFEATURE
#define HIDIOCGFEATURE(len) _IOC(_IOC_WRITE|_IOC_READ, 'H', 0x07, len)
#endif
/* uses_numbered_reports() returns 1 if report_descriptor describes a device
which contains numbered reports. */
static int uses_numbered_reports(__u8 *report_descriptor, __u32 size) {
unsigned int i = 0;
int size_code;
int data_len, key_size;
while (i < size) {
int key = report_descriptor[i];
/* Check for the Report ID key */
if (key == 0x85/*Report ID*/) {
/* This device has a Report ID, which means it uses
numbered reports. */
return 1;
}
//printf("key: %02hhx\n", key);
if ((key & 0xf0) == 0xf0) {
/* This is a Long Item. The next byte contains the
length of the data section (value) for this key.
See the HID specification, version 1.11, section
6.2.2.3, titled "Long Items." */
if (i+1 < size)
data_len = report_descriptor[i+1];
else
data_len = 0; /* malformed report */
key_size = 3;
}
else {
/* This is a Short Item. The bottom two bits of the
key contain the size code for the data section
(value) for this key. Refer to the HID
specification, version 1.11, section 6.2.2.2,
titled "Short Items." */
size_code = key & 0x3;
switch (size_code) {
case 0:
case 1:
case 2:
data_len = size_code;
break;
case 3:
data_len = 4;
break;
default:
/* Can't ever happen since size_code is & 0x3 */
data_len = 0;
break;
};
key_size = 1;
}
/* Skip over this key and it's associated data */
i += data_len + key_size;
}
/* Didn't find a Report ID key. Device doesn't use numbered reports. */
return 0;
}
/*
* The caller is responsible for free()ing the (newly-allocated) character
* strings pointed to by serial_number_utf8 and product_name_utf8 after use.
*/
static int
parse_uevent_info(const char *uevent, int *bus_type,
unsigned short *vendor_id, unsigned short *product_id,
char **serial_number_utf8, char **product_name_utf8)
{
char *tmp = strdup(uevent);
char *saveptr = NULL;
char *line;
char *key;
char *value;
int found_id = 0;
int found_serial = 0;
int found_name = 0;
line = strtok_r(tmp, "\n", &saveptr);
while (line != NULL) {
/* line: "KEY=value" */
key = line;
value = strchr(line, '=');
if (!value) {
goto next_line;
}
*value = '\0';
value++;
if (strcmp(key, "HID_ID") == 0) {
/**
* type vendor product
* HID_ID=0003:000005AC:00008242
**/
int ret = sscanf(value, "%x:%hx:%hx", bus_type, vendor_id, product_id);
if (ret == 3) {
found_id = 1;
}
} else if (strcmp(key, "HID_NAME") == 0) {
/* The caller has to free the product name */
*product_name_utf8 = strdup(value);
found_name = 1;
} else if (strcmp(key, "HID_UNIQ") == 0) {
/* The caller has to free the serial number */
*serial_number_utf8 = strdup(value);
found_serial = 1;
}
next_line:
line = strtok_r(NULL, "\n", &saveptr);
}
free(tmp);
return (found_id && found_name && found_serial);
}
int hid_init(void)
{
const char *locale;
/* Set the locale if it's not set. */
locale = setlocale(LC_CTYPE, NULL);
if (!locale)
setlocale(LC_CTYPE, "");
return 0;
}
int hid_exit(void)
{
/* Nothing to do for this in the Linux/hidraw implementation. */
return 0;
}
hid_device_info *hid_enumerate(unsigned short vendor_id, unsigned short product_id)
{
struct udev *udev;
struct udev_enumerate *enumerate;
struct udev_list_entry *devices, *dev_list_entry;
hid_device_info *root = NULL; /* return object */
hid_device_info *cur_dev = NULL;
hid_device_info *prev_dev = NULL; /* previous device */
hid_init();
/* Create the udev object */
udev = udev_new();
if (!udev) {
printf("Can't create udev\n");
return NULL;
}
/* Create a list of the devices in the 'hidraw' subsystem. */
enumerate = udev_enumerate_new(udev);
udev_enumerate_add_match_subsystem(enumerate, "hidraw");
udev_enumerate_scan_devices(enumerate);
devices = udev_enumerate_get_list_entry(enumerate);
/* For each item, see if it matches the vid/pid, and if so
create a udev_device record for it */
udev_list_entry_foreach(dev_list_entry, devices) {
const char *sysfs_path;
const char *dev_path;
const char *str;
struct udev_device *raw_dev; /* The device's hidraw udev node. */
struct udev_device *hid_dev; /* The device's HID udev node. */
struct udev_device *usb_dev; /* The device's USB udev node. */
struct udev_device *intf_dev; /* The device's interface (in the USB sense). */
unsigned short dev_vid;
unsigned short dev_pid;
char *serial_number_utf8 = NULL;
char *product_name_utf8 = NULL;
int bus_type;
int result;
/* Get the filename of the /sys entry for the device
and create a udev_device object (dev) representing it */
sysfs_path = udev_list_entry_get_name(dev_list_entry);
raw_dev = udev_device_new_from_syspath(udev, sysfs_path);
dev_path = udev_device_get_devnode(raw_dev);
hid_dev = udev_device_get_parent_with_subsystem_devtype(
raw_dev,
"hid",
NULL);
if (!hid_dev) {
/* Unable to find parent hid device. */
goto next;
}
result = parse_uevent_info(
udev_device_get_sysattr_value(hid_dev, "uevent"),
&bus_type,
&dev_vid,
&dev_pid,
&serial_number_utf8,
&product_name_utf8);
if (!result) {
/* parse_uevent_info() failed for at least one field. */
goto next;
}
if (bus_type != BUS_USB && bus_type != BUS_BLUETOOTH) {
/* We only know how to handle USB and BT devices. */
goto next;
}
/* Check the VID/PID against the arguments */
if ((vendor_id == 0x0 || vendor_id == dev_vid) &&
(product_id == 0x0 || product_id == dev_pid)) {
hid_device_info *tmp = new hid_device_info;
if (cur_dev) {
cur_dev->next = tmp;
}
else {
root = tmp;
}
prev_dev = cur_dev;
cur_dev = tmp;
/* Fill out the record */
cur_dev->next = NULL;
cur_dev->path.assign(dev_path ? dev_path : "");
/* VID/PID */
cur_dev->vendor_id = dev_vid;
cur_dev->product_id = dev_pid;
/* Serial Number */
cur_dev->str_serial_number.assign(serial_number_utf8);
/* Release Number */
cur_dev->release_number = 0x0;
/* Interface Number */
cur_dev->interface_number = -1;
switch (bus_type) {
case BUS_USB:
/* The device pointed to by raw_dev contains information about
the hidraw device. In order to get information about the
USB device, get the parent device with the
subsystem/devtype pair of "usb"/"usb_device". This will
be several levels up the tree, but the function will find
it. */
usb_dev = udev_device_get_parent_with_subsystem_devtype(
raw_dev,
"usb",
"usb_device");
if (!usb_dev) {
delete cur_dev;
/* Take it off the device list. */
if (prev_dev) {
prev_dev->next = NULL;
cur_dev = prev_dev;
}
else {
cur_dev = root = NULL;
}
goto next;
}
/* Manufacturer and Product strings */
str = udev_device_get_sysattr_value(usb_dev, "manufacturer");
if (str) cur_dev->str_manufacturer_string.assign(str);
str = udev_device_get_sysattr_value(usb_dev, "product");
if (str) cur_dev->str_product_string.assign(str);
/* Release Number */
str = udev_device_get_sysattr_value(usb_dev, "bcdDevice");
if (str) cur_dev->release_number = strtol(str, NULL, 16);
else cur_dev = 0x0;
/* Get a handle to the interface's udev node. */
intf_dev = udev_device_get_parent_with_subsystem_devtype(
raw_dev,
"usb",
"usb_interface");
if (intf_dev) {
str = udev_device_get_sysattr_value(intf_dev, "bInterfaceNumber");
cur_dev->interface_number = (str)? strtol(str, NULL, 16): -1;
}
break;
case BUS_BLUETOOTH:
/* Manufacturer and Product strings */
cur_dev->str_product_string.assign(product_name_utf8);
break;
default:
/* Unknown device type - this should never happen, as we
* check for USB and Bluetooth devices above */
break;
}
}
next:
free(serial_number_utf8);
free(product_name_utf8);
udev_device_unref(raw_dev);
/* hid_dev, usb_dev and intf_dev don't need to be (and can't be)
unref()d. It will cause a double-free() error. I'm not
sure why. */
}
/* Free the enumerator and udev objects. */
udev_enumerate_unref(enumerate);
udev_unref(udev);
return root;
}
void hid_free_enumeration(hid_device_info *devs)
{
hid_device_info *d = devs;
while (d) {
hid_device_info *next = d->next;
delete d;
d = next;
}
}
hid_device * hid_open(unsigned short vendor_id, unsigned short product_id, std::string serial_number)
{
hid_device_info *devs, *cur_dev;
hid_device *device = NULL;
std::string path_to_open;
devs = hid_enumerate(vendor_id, product_id);
cur_dev = devs;
while (cur_dev) {
if (cur_dev->vendor_id == vendor_id &&
cur_dev->product_id == product_id) {
if (!serial_number.empty() &&
(cur_dev->str_serial_number == serial_number) ) {
path_to_open = cur_dev->path;
break;
}
else {
path_to_open = cur_dev->path;
break;
}
}
cur_dev = cur_dev->next;
}
if (!path_to_open.empty()) {
/* Open the device */
device = hid_open_path(path_to_open);
}
hid_free_enumeration(devs);
return device;
}
hid_device * hid_open_path(std::string path)
{
hid_device *dev = new hid_device;
hid_init();
/* OPEN HERE */
dev->device_handle = open(path.c_str(), O_RDWR);
/* If we have a good handle, return it. */
if (dev->device_handle > 0) {
/* Get the report descriptor */
int res, desc_size = 0;
struct hidraw_report_descriptor rpt_desc;
memset(&rpt_desc, 0x0, sizeof(rpt_desc));
/* Get Report Descriptor Size */
res = ioctl(dev->device_handle, HIDIOCGRDESCSIZE, &desc_size);
if (res < 0)
perror("HIDIOCGRDESCSIZE");
/* Get Report Descriptor */
rpt_desc.size = desc_size;
res = ioctl(dev->device_handle, HIDIOCGRDESC, &rpt_desc);
if (res < 0) {
perror("HIDIOCGRDESC");
} else {
/* Determine if this device uses numbered reports. */
dev->uses_numbered_reports =
uses_numbered_reports(rpt_desc.value,
rpt_desc.size);
}
return dev;
}
else {
/* Unable to open any devices. */
delete dev;
return (hid_device *)0;
}
}
int hid_device::hid_write(const unsigned char *data, size_t length)
{
int bytes_written;
bytes_written = write(device_handle, data, length);
return bytes_written;
}
int hid_device::hid_read_timeout(unsigned char *data, size_t length, int milliseconds)
{
int bytes_read;
if (milliseconds >= 0) {
/* Milliseconds is either 0 (non-blocking) or > 0 (contains
a valid timeout). In both cases we want to call poll()
and wait for data to arrive. Don't rely on non-blocking
operation (O_NONBLOCK) since some kernels don't seem to
properly report device disconnection through read() when
in non-blocking mode. */
int ret;
struct pollfd fds;
fds.fd = device_handle;
fds.events = POLLIN;
fds.revents = 0;
ret = poll(&fds, 1, milliseconds);
if (ret == -1 || ret == 0) {
/* Error or timeout */
return ret;
}
else {
/* Check for errors on the file descriptor. This will
indicate a device disconnection. */
if (fds.revents & (POLLERR | POLLHUP | POLLNVAL))
return -1;
}
}
bytes_read = read(device_handle, data, length);
if (bytes_read < 0 && (errno == EAGAIN || errno == EINPROGRESS))
bytes_read = 0;
return bytes_read;
}
int hid_device::hid_read(unsigned char *data, size_t length)
{
return hid_read_timeout(data, length, (blocking)? -1: 0);
}
int hid_device::hid_set_nonblocking(int nonblock)
{
/* Do all non-blocking in userspace using poll(), since it looks
like there's a bug in the kernel in some versions where
read() will not return -1 on disconnection of the USB device */
blocking = !nonblock;
return 0; /* Success */
}
int hid_device::hid_send_feature_report(const unsigned char *data, size_t length)
{
int res;
res = ioctl(device_handle, HIDIOCSFEATURE(length), data);
if (res < 0)
perror("ioctl (SFEATURE)");
return res;
}
int hid_device::hid_get_feature_report(unsigned char *data, size_t length)
{
int res;
res = ioctl(device_handle, HIDIOCGFEATURE(length), data);
if (res < 0)
perror("ioctl (GFEATURE)");
return res;
}
void hid_device::hid_close()
{
close(device_handle);
}
const char *hid_device::hid_error()
{
return "HID error string not implemented";
}
| 13,683
|
C++
|
.cxx
| 463
| 26.045356
| 101
| 0.654649
|
w1hkj/fldigi
| 109
| 27
| 38
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
751,068
|
cmedia.cxx
|
w1hkj_fldigi/src/cmedia/cmedia.cxx
|
// ----------------------------------------------------------------------------
// Copyright (C) 2021
// David Freese, W1HKJ
//
// This file is part of fldigi.
//
// fldigi 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 3 of the License, or
// (at your option) any later version.
//
// fldigi 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, see <http://www.gnu.org/licenses/>.
//
// This interface is based on the CM108 HID support code found in hamlib
//
// CM108 Audio chips found on many USB audio interfaces have controllable
// General Purpose Input/Output pins.
// ----------------------------------------------------------------------------
#include <iostream>
#include <fstream>
#include <string>
#include <map>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#ifndef __WIN32__
#include <termios.h>
#include <glob.h>
# ifndef __APPLE__
# include <error.h>
# endif
#endif
#include "config.h"
#include "threads.h"
#include "debug.h"
#include "util.h"
#include "confdialog.h"
#include "hidapi.h"
#include "cmedia.h"
static int ptt_state_cmedia = 0;
static std::map<std::string, std::string> paths;
static hid_device *ptt_dev = (hid_device *)0;
void test_hid_ptt()
{
hid_device *test_dev = (hid_device *)0;
if (ptt_dev) test_dev = ptt_dev;
else if (progdefaults.cmedia_device == "NONE")
return;
else
test_dev = hid_open_path(paths[progdefaults.cmedia_device]);
if (test_dev == (hid_device *)0) {
LOG_ERROR("Could not open %s", progdefaults.cmedia_device.c_str());
return;
}
if (test_dev == ptt_dev)
LOG_INFO("Testing using ptt device: %s", progdefaults.cmedia_device.c_str());
else
LOG_INFO("Testing using test_dev: %s", progdefaults.cmedia_device.c_str());
int bitnbr = 2; // GPIO-3
unsigned char out_rep[5];
for (int i = 0; i < 5; out_rep[i++] = 0x00);
out_rep[3] = 0x01 << bitnbr;
for (int j = 0; j < 20; j++) {
out_rep[2] = 0x01 << bitnbr;
test_dev->hid_write(out_rep, 5);
MilliSleep(50);
out_rep[2] = 0x00;
test_dev->hid_write(out_rep, 5);
MilliSleep(50);
}
if (test_dev != ptt_dev) delete test_dev;
return;
}
int open_cmedia(std::string str_device)
{
if (str_device == "NONE")
return -1;
std::string dev_path = paths[str_device];
if (ptt_dev) close_cmedia();
LOG_DEBUG("Device path: %s", dev_path.c_str());
ptt_dev = hid_open_path(dev_path);
if (!ptt_dev) {
LOG_ERROR( "unable to open device");
return -1;
}
LOG_INFO("C-Media device %s opened for GPIO i/o", str_device.c_str());
return 0;
}
void close_cmedia()
{
delete ptt_dev;
ptt_dev = (hid_device *)0;
}
//
// Set or unset the Push To Talk bit on a CM108 GPIO.
//
// param ptt 1 - Set PTT, 0 - unset PTT.
//
// return true on success, false otherwise
// For a CM108 USB audio device PTT is wired up to one of the GPIO
// pins. Usually this is GPIO3 (bit 2 of the GPIO register) because it
// is on the corner of the chip package (pin 13) so it's easily accessible.
// Some CM108 chips are epoxy-blobbed onto the PCB, so no GPIO
// pins are accessible. The SSS1623 chips have a different pinout, so
// we make the GPIO bit number configurable.
bool set_cmedia(int bitnbr, int ptt)
{
if (!ptt_dev) return false;
// Build a packet for CM108 HID to turn GPIO bit on or off.
// Packet is 4 bytes, preceded by a 'report number' byte
// 0x00 report number
// Write data packet (from CM108 documentation)
// byte 0: 00xx xxxx Write GPIO
// byte 1: xxxx dcba GPIO3-0 output values (1=high)
// byte 2: xxxx dcba GPIO3-0 data-direction register (1=output)
// byte 3: xxxx xxxx SPDIF
unsigned char out_rep[5];
out_rep[0] = 0x00;
out_rep[1] = 0x00;
out_rep[2] = ptt ? (0x01 << bitnbr) : 0x00;
out_rep[3] = 0x01 << bitnbr;
out_rep[4] = 0x00;
LOG_DEBUG("bit %d : %d; %s", bitnbr, ptt ? 1 : 0, str2hex(out_rep, 5));
// Send the HID packet
int nw = ptt_dev->hid_write(out_rep, 5);
if (nw < 0) return false;
ptt_state_cmedia = ptt;
return true;
}
// Get the state of Push To Talk from a CM108 GPIO.
// return 1 if ON, 0 if OFF
int get_cmedia()
{
return ptt_state_cmedia;
}
void init_hids()
{
std::string hidstr = "NONE";
hid_device_info *devs = 0;
inp_cmedia_dev->clear();
paths.clear();
if (hid_init()) {
inp_cmedia_dev->add(hidstr.c_str());
return;
}
devs = hid_enumerate(0x0d8c, 0x0); // find all C-Media devices
std::string dev_name = "C-Media-A";
while (devs) {
LOG_INFO("\n\
HID : %s\n\
vendor id : %04hx\n\
product id : %04hx\n\
Manufacturer : %s\n\
Product : %s\n\
Release : %hx",
dev_name.c_str(),
devs->vendor_id,
devs->product_id,
devs->str_manufacturer_string.c_str(),
devs->str_product_string.c_str(),
devs->release_number);
hidstr.append("|").append(dev_name);
paths[dev_name] = devs->path;
++dev_name[8]; // increment A->B->C...
devs = devs->next;
}
inp_cmedia_dev->add(hidstr.c_str());
}
| 5,396
|
C++
|
.cxx
| 178
| 28.398876
| 79
| 0.661128
|
w1hkj/fldigi
| 109
| 27
| 38
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
751,069
|
hid.cxx
|
w1hkj_fldigi/src/cmedia/hid.cxx
|
/***********************************************************************
HIDAPI - Multi-Platform library for communication with HID devices.
Alan Ott
Signal 11 Software
8/22/2009
Linux Version - 6/2/2009
Copyright 2009, All Rights Reserved.
This software is licensed under the terms of the GNU General Public
License v3.
***********************************************************************/
#ifdef __WIN32__
# include "hid_win.cxx"
#else
# ifdef __APPLE__
# include "hid_mac.cxx"
# else
# include "hid_lin.cxx"
# endif
#endif
| 549
|
C++
|
.cxx
| 19
| 27.052632
| 72
| 0.544933
|
w1hkj/fldigi
| 109
| 27
| 38
|
GPL-3.0
|
9/20/2024, 9:41:57 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.