00001
00002
00003
00004
00005
00006
00007
00008
00009 #include <windows.h>
00010 #include <shellapi.h>
00011 #define _INC_SHELLAPI
00012
00013 #ifndef RC_INVOKED
00014
00015 #include <windowsx.h>
00016 #include <winsock.h>
00017 #include <mmsystem.h>
00018
00019 #include <stdarg.h>
00020 #include <stdio.h>
00021 #include <stdlib.h>
00022 #include <string.h>
00023 #include <ctype.h>
00024 #include <memory.h>
00025 #include <time.h>
00026 #include <float.h>
00027 #include <io.h>
00028 #include <commdlg.h>
00029 #include <math.h>
00030 #include <wchar.h>
00031 #include <fcntl.h>
00032 #include <sys/types.h>
00033 #include <sys/stat.h>
00034 #include <share.h>
00035 #include <commctrl.h>
00036
00037 #define WM_COMMAND_ID(x) (LOWORD(x))
00038 #define WM_COMMAND_NOTIFY (HIWORD(wParam))
00039
00040
00041
00042 #include "md5.h"
00043 #include "aes.h"
00044 #define AES_BLOCK_SIZE BLOCK_SIZE
00045 #include "blowfish.h"
00046 #include "des.h"
00047 #include "ndes.h"
00048 #include "idea.h"
00049 #include "ulaw.h"
00050 #include "gsm.h"
00051 #include "adpcm_u.h"
00052 #include "celp.h"
00053 #include "rtp.h"
00054 #include "rtpacket.h"
00055 #include "lpc.h"
00056 #include "vox.h"
00057
00058 #endif
00059
00060 #include "resource.h"
00061
00062 #define HTML_HELP
00063 #ifdef HTML_HELP
00064 #include "HtmlHelp.h"
00065 #endif
00066
00067 #ifdef NDEBUG
00068
00069
00070
00071 #ifdef OutputDebugString
00072 #undef OutputDebugString
00073 #endif
00074 #define OutputDebugString { extern void OutputDebugString_in_release_build(void); \
00075 OutputDebugString_in_release_build(1); }
00076 #define Assert(x)
00077 #else
00078
00079
00080 #define HEXDUMP
00081
00082
00083 #define Assert(x) { if (!(x)) { char erm[128]; wsprintf((LPSTR) erm, \
00084 (LPSTR) "Assertion %s failed at line %d of file %s.", (LPCSTR) #x, __LINE__,(LPSTR) __FILE__); \
00085 FatalAppExit(0, (LPCSTR) erm); }}
00086 #endif
00087 #define Gag(text) OutputDebugString("Gag me with a " #text "!\r\n");
00088
00089
00090
00091 #define NETFONE_COMMAND_PORT 2074
00092
00093
00094
00095 #define RANT_ON_ERROR
00096
00097
00098
00099 #define MAX_HOST 256
00100
00101
00102
00103 #define GWL_CLIENT 0 // Client-side data
00104
00105
00106
00107 #define WINDOW_TYPE_CLIENT 1
00108
00109
00110
00111 #define FRAME_TIMER_ID 1
00112
00113 #define TIMEOUT_CONNECTION 30 // Remote connection timeout
00114 #define TIMEOUT_AUDIO_OUTPUT 4 // Release audio output timeout
00115 #define TIMEOUT_RESEND_LWL (119) // Resend Look Who's Listening listing
00116 #define TIMEOUT_RESEND_SDES 10 // Reset VAT/RTP ID interval
00117 #define BroadcastUnsubscribe 10 // Broadcast mike blip length (seconds)
00118
00119
00120
00121 #define MAX_PRINTF_OUTPUT 1024
00122
00123
00124
00125 #define LPC_FRAME_SIZE 160
00126
00127
00128
00129 #define REMEMBER_CONNECTIONS 5
00130
00131
00132
00133 #ifndef IN_MULTICAST
00134 #define IN_MULTICAST(i) ((ntohl((long)(i)) & 0xF0000000) == 0xE0000000)
00135 #endif
00136
00137
00138
00139 #define WM_SOCKET_SELECT (WM_USER + 100) // Data socket notifications
00140 #define WM_SOCKET_ASYNC (WM_USER + 101) // Asynchronous request completions
00141 #define WM_SOCKET_LWL (WM_USER + 102) // LWL socket notifications
00142 #define WM_SOCKET_CONTROL (WM_USER + 103) // Control socket notifications
00143 #define WM_CLEAN_UP_YOUR_ACT (WM_USER + 104) // Too depressing to explain--see FRAME.C
00144
00145
00146
00147 #define WM_NEW_COMMANDLINE (WM_USER + 200) // Second instance launched with new site
00148
00149 #define HANDLE_WM_SOCKET_SELECT(hwnd, wParam, lParam, fn) \
00150 ((fn)((hwnd), (SOCKET)(wParam), (SOCKERR)WSAGETSELECTERROR(lParam), \
00151 (SOCKEVENT)WSAGETSELECTEVENT(lParam)), 0L)
00152 #define FORWARD_WM_SOCKET_SELECT(hwnd, socket, serr, sevent, fn) \
00153 (void)(fn)((hwnd), WM_SOCKET_SELECT, (WPARAM)(socket), \
00154 (LPARAM)WSAMAKESELECTREPLY(sevent, serr))
00155
00156 #define HANDLE_WM_SOCKET_ASYNC(hwnd, wParam, lParam, fn) \
00157 ((fn)((hwnd), (HANDLE)(wParam), (SOCKERR)WSAGETASYNCERROR(lParam), \
00158 (WORD)WSAGETASYNCBUFLEN(lParam)), 0L)
00159 #define FORWARD_WM_GETXBYX(hwnd, hAsync, serr, cbBuffer, fn) \
00160 (void)(fn)((hwnd), WM_SOCKET_ASYNC, (WPARAM)(hAsync), \
00161 (LPARAM)WSAMAKEASYNCREPLY(cbBuffer, serr))
00162
00163
00164
00165 #define ELEMENTS(array) (sizeof(array)/sizeof((array)[0]))
00166
00167
00168
00169 #define Format(n) rstring(IDS_FORMATS + (n))
00170
00171
00172
00173
00174 #define Lrstring(n) ((LPSTR) rstring(n))
00175
00176
00177
00178 #ifdef RC_INVOKED
00179 #define ID(x) x
00180 #else
00181 #define ID(x) MAKEINTRESOURCE(x)
00182 #endif
00183
00185
00186 #define IDI_BASE 1000
00187 #define IDM_BASE 2000
00188 #define IDD_BASE 3000
00189 #define IDA_BASE 4000
00190
00191
00192
00193 #define IDI_FRAME ID(1000) // IDI_BASE + 0
00194 #define IDI_CLIENT ID(1001) // IDI_BASE + 1
00195 #define IDI_SERVER ID(1002) // IDI_BASE + 2
00196
00197
00198
00199 #define IDM_FRAME_BASE 2000 // IDM_BASE + 0
00200 #define IDM_FRAME ID(IDM_FRAME_BASE)
00201 #define IDM_CONNECTION_BASE (IDM_FRAME_BASE + 0)
00202 #define IDM_CONNECTION_EXIT (IDM_CONNECTION_BASE + 3)
00203
00204 #define IDM_WINDOW_BASE (IDM_FRAME_BASE + 100)
00205 #define IDM_WINDOW_CASCADE (IDM_WINDOW_BASE + 0)
00206 #define IDM_WINDOW_TILE_VERTICALLY (IDM_WINDOW_BASE + 1)
00207 #define IDM_WINDOW_TILE_HORIZONTALLY (IDM_WINDOW_BASE + 2)
00208 #define IDM_WINDOW_ARRANGE_ICONS (IDM_WINDOW_BASE + 3)
00209 #define IDM_WINDOW_FIRST_CHILD (IDM_WINDOW_BASE + 4)
00210
00211 #define IDM_HELP_BASE (IDM_FRAME_BASE + 200)
00212 #define IDM_HELP_ABOUT (IDM_HELP_BASE + 0)
00213
00214 #define IDM_CUSTOM 9000 // Custom (remembered file) menu items
00215
00216
00217
00218 #define IDD_ABOUT ID(3000) // IDD_BASE + 0
00219
00220 #define IDD_NEW ID(3100) // IDD_BASE + 100
00221 #define IDD_NEW_HOST 3101
00222 #define IDD_NEW_HOST_LABEL 3102
00223
00224
00225
00226 #define IDA_FRAME ID(4000) // IDA_BASE + 0
00227
00228 #define BUFL 8000 // Sound buffer maximum length (actually less)
00229
00230 #define LONG long
00231
00232 #define SPEAK_FREE_FRAME_CLASS "SpeakFreeFrameClass"
00233
00234 #define EXCHANGE_SAMPLE_RATE 8000 // Samples per second in data exchanged over the network
00235
00236 struct soundbuf {
00237 LONG compression;
00238 char sendinghost[16];
00239 struct {
00240 LONG buffer_len;
00241 char buffer_val[BUFL];
00242 } buffer;
00243 };
00244 typedef struct soundbuf soundbuf;
00245
00246
00247
00248 #define fComp2X 1 // Simple 2 to 1 compression
00249 #define fDebug 2 // Debug mode
00250 #define fSetDest 4 // Set sound output destination
00251 #define fDestSpkr 0 // Destination: speaker
00252 #define fDestJack 8 // Destination: audio output jack
00253 #define fLoopBack 16 // Loopback packets for testing
00254 #define fCompGSM 32 // GSM compression
00255 #define fEncDES 64 // DES encrypted
00256 #define fEncOTP 128 // One-time pad encrypted
00257 #define fEncIDEA 256 // IDEA encrypted
00258 #define fCompADPCM 512 // ADPCM compressed
00259 #define fEncPGP 1024 // PGP-protected session key encrypted
00260 #define fKeyPGP 2048 // Packet contains PGP-encrypted session key
00261 #define fCompLPC 4096 // LPC compressed
00262 #define fFaceData 8192 // Request/reply for face data
00263 #define fFaceOffer 16384 // Offer face image to remote host
00264 #define fNewProto 0x8000 // Version 7.1 Protocol Enhancements
00265 #define fCompVOX 0x10000 // VOX compressed
00266 #define fCompLPC10 0x20000 // LPC-10 compressed
00267 #define fCompRobust 0x40000 // Robust duplicate packet mode
00268 #define fEncBF 0x80000 // Blowfish encrypted
00269 #define fCompCELP 0x100000 // CELP compressed
00270 #define fEncAES 0x200000 // AES encrypted
00271 #define fProtocol 0x40000000 // Speak Freely protocol flag
00272
00273
00274
00275 #define faceRequest 1 // Face data request
00276 #define faceReply 2 // Face data reply
00277 #define faceLess 4 // No face available
00278
00279
00280
00281 #define fCompressionModes (fComp2X | fCompGSM | fCompADPCM | fCompLPC | fCompVOX | fCompLPC10 | fCompCELP)
00282
00283
00284
00285
00286
00287
00288 #define fFromModem 0x8000 // From the modem
00289 #define fPlayback 0x02000000 // Answering machine playback packet
00290 #define fAnsNewMsg 0x01000000 // Start of new message on answering machine
00291
00292
00293
00294 #define isSoundPacket(c) (((c) & (fFaceData | fKeyPGP)) == 0)
00295
00296
00297
00298 #define PROTOCOL_SPEAKFREE 0 // Speak Freely protocol
00299 #define PROTOCOL_VAT 1 // VAT protocol
00300 #define PROTOCOL_RTP 2 // RTP protocol
00301 #define PROTOCOL_VATRTP_CRYPT 3 // Probably encrypted VAT or RTP message
00302 #define PROTOCOL_UNKNOWN 4 // No evidence as to protocol yet
00303
00304
00305
00306 struct respHeader {
00307 struct in_addr hostIPnumber;
00308 time_t itemTime;
00309 short hostNameLength;
00310 short soundBufLength;
00311
00312
00313
00314
00315
00316
00317 };
00318
00319
00320
00321 struct localLoop {
00322 struct localLoop *llnext;
00323 int lllen;
00324 int llsamples;
00325 SOCKADDR_IN lladdr;
00326 char llpacket[0];
00327 };
00328
00329 #define IS_LOCALHOST(i) (ntohl((long)(i)) == 0x7F000001)
00330 #define LOOPBACK_ENABLED 1 // Enabled flag in localLoopback
00331 #define LOOPBACK_PLAYING 2 // Flag in localLoopback for play active
00332
00333
00334
00335 struct auxSocket {
00336 struct auxSocket *asnext;
00337 short asrefc;
00338 unsigned short asport;
00339 SOCKET asdata;
00340 SOCKET asctrl;
00341 };
00342
00343
00344
00345 typedef struct ratestuff {
00346 unsigned long opos_frac;
00347 unsigned long opos;
00348
00349 unsigned long opos_inc_frac;
00350 unsigned long opos_inc;
00351
00352 unsigned long ipos;
00353
00354 long ilast;
00355 } rate_t;
00356
00357
00358
00359 typedef INT SOCKERR;
00360 typedef WORD PORT;
00361 typedef WORD SOCKEVENT;
00362
00363
00364
00365 typedef enum _CLIENT_STATE
00366 {
00367 Embryonic,
00368 Idle,
00369 SendingLiveAudio,
00370 Transferring,
00371 PlayingReceivedAudio
00372
00373 } CLIENT_STATE;
00374
00375 typedef enum {
00376 Unspecified,
00377 PGP,
00378 GPG
00379 } public_key_package;
00380
00381
00382
00383
00384 typedef struct _CLIENT_DATA {
00385 DWORD dwType;
00386 CLIENT_STATE state;
00387 SOCKET sReply;
00388 SOCKET sControl;
00389 int timeout;
00390 SOCKADDR_IN inetSock;
00391 unsigned short port;
00392 struct auxSocket *auxSock;
00393 CHAR szHost[MAX_HOST];
00394 HFILE hFile;
00395 DWORD cbSent;
00396 DWORD cbReceived;
00397 CHAR szFile[MAX_PATH];
00398 HANDLE getNameTask;
00399 BYTE hostBuffer[MAXGETHOSTSTRUCT];
00400
00401 int modemConnection;
00402 HMMIO mmioHandle;
00403 LPWAVEFORMAT mmioFormat;
00404 DWORD mmioDataLeft;
00405 int quitSoundFile;
00406 int wantsInput;
00407 int outputSocketBusy;
00408 DWORD broadcastBeginTime;
00409 int broadcastEnd;
00410 struct sockaddr_in name;
00411 struct sockaddr_in ctrl;
00412 char desKeyString[256];
00413 char deskey[9];
00414 char rtpdeskey[9];
00415 char vatdeskey[9];
00416 char ideaKeyString[256];
00417 char ideakey[17];
00418 char blowfishKeyString[256];
00419 char blowfish_spec;
00420 BF_KEY blowfishkey;
00421 char aesKeyString[256];
00422 int aesKeyHex;
00423 char aes_spec;
00424 aes_ctx aesEkey;
00425 aes_ctx aesDkey;
00426 char pgpkeymd5[16];
00427 char pgpkey[17];
00428 char pgpFileName[MAX_PATH];
00429 char opgpUserList[256];
00430 char opgpkey[17];
00431 char opgpFileName[MAX_PATH];
00432 char otpFileName[MAX_PATH];
00433 char otp[BUFL];
00434 int multicast_scope;
00435 int squelch;
00436 int ring;
00437 int debugging;
00438 int debugReq;
00439 int loopback;
00440 int saveKeys;
00441 char connectionFileName[MAX_PATH];
00442 gsm gsmh;
00443 lpcstate_t lpc_state;
00444 rate_t rateconv;
00445 struct celp_context *d_celp_ctx;
00446 int rseq;
00447
00448 short protocol;
00449
00450 short localLoopback;
00451 struct localLoop *llhead,
00452 *lltail;
00453
00454 char session_id[4];
00455 int sendSDEStimer;
00456 int buttonUpTimer;
00457 LPSTR uname;
00458 char email[256];
00459 char szRemoteProgram[256];
00460
00461 int face_stat;
00462 long face_address;
00463 int face_retry;
00464 int face_timeout;
00465 LPSTR face_bmp;
00466 int face_is_gif;
00467 long face_file_length;
00468 int face_shown;
00469 int bSentOutgoingMessage;
00470 } CLIENT_DATA, *LPCLIENT_DATA;
00471
00472 #define CLIENTPTR(w) ((LPCLIENT_DATA)GetWindowLong((w), GWL_CLIENT))
00473 #define IS_CLIENT_WINDOW(w) (CLIENTPTR(w)->dwType == WINDOW_TYPE_CLIENT)
00474
00475
00476
00477 #define FSinit 0 // Nothing requested yet
00478 #define FSrequest 1 // Request sent, awaiting reply
00479 #define FSreply 2 // Reply received, ready for next request
00480 #define FScomplete 3 // Face file reception complete
00481 #define FSabandoned 4 // Face file retrieval abandoned
00482
00483
00484
00485 #define FaceFetchInterval 250 // Interval between block requests, msec
00486 #define FaceTimeout 20 // Resend block request after this number of intervals
00487 #define FaceMaxRetries 10 // Maximum retries to obtain face data
00488
00489
00490
00491 #define AORA_MINIMUM_DELAY 500 // Minimum delay (ms) at which to act, regardless of jitter
00492 #define AORA_ACTION_DELAY 500 // Begin adjusting rate when queue delay > this value in ms
00493 #define AORA_MAXIMUM_RATE_PERCENT 10 // Maximum output rate speed-up in percent
00494 #define AORA_MAXIMUM_RATE_DELAY 3000 // Apply maximum rate when delay greater than this number of ms
00495
00496
00497
00498 #define TRAY // Enable system tray minimisation
00499 #ifdef TRAY
00500 #define WM_TRAY_NOTIFY (WM_USER + 300) // System tray notification message
00501 extern HWND trayIconWindow;
00502 extern HWND createTrayIcon(void);
00503 extern void updateTrayToolTipText(void);
00504 extern void blinkTrayIcon(BOOL blink);
00505 #define TRAY_TIMER_ID 7 // Tray timer ID
00506 #endif
00507
00508
00509
00510 typedef enum {
00511 AE_PCMU, AE_PCMA, AE_G721, AE_IDVI, AE_G723, AE_GSM,
00512 AE_1016, AE_LPC,
00513 AE_L8, AE_L16, AE_L24, AE_L32,
00514 AE_G728, AE_TRUE,
00515 AE_MAX
00516 } audio_encoding_t;
00517
00518
00519
00520 typedef struct {
00521 audio_encoding_t encoding;
00522 unsigned sample_rate;
00523 unsigned channels;
00524 } audio_descr_t;
00525
00526
00527
00528 extern SOCKET sCommand;
00529 extern struct auxSocket *asList;
00530
00531
00532
00533 extern HINSTANCE hInst;
00534 extern HACCEL hAccel;
00535 extern HWND hwndMDIFrame;
00536 extern HWND hwndMDIClient;
00537 extern HWND hDlgPropeller;
00538 extern HWND hDlgAnswer;
00539 extern HWND hDlgChat;
00540 extern HWND hDlgConsole;
00541 extern HWND hDlgSpectral;
00542
00543
00544
00545 extern LPSTR pszFrameClass;
00546 extern LPSTR pszMDIClientClass;
00547 extern LPSTR pszClientClass;
00548
00549
00550
00551 extern LPSTR pszAppName;
00552 extern INT tmAveCharWidth;
00553 extern INT tmHeight;
00554 extern LPSTR commandLine;
00555 extern int holped;
00556 #ifdef HTML_HELP
00557 extern DWORD HtmlHelpContext;
00558 #endif
00559 extern UINT fileOpenHelpButton;
00560 extern char *fileHelpKey;
00561 extern UINT jitterBuf;
00562 extern BOOL jitterPause;
00563
00564 extern HWAVEOUT hWaveOut;
00565 extern HWAVEIN hWaveIn;
00566
00567 extern soundbuf ebuf;
00568
00569 extern int audioChannels, samplesPerSecond, bytesPerSecond, sampleAlignment, bitsPerSample;
00570 extern int currentOutputRate;
00571
00572
00573
00574 extern int openOnAnswerMessage;
00575
00576
00577
00578 extern int voxmode;
00579 extern int breakinput;
00580 extern int compression;
00581 extern int gsmcompress;
00582 extern int adpcmcompress;
00583 extern int lpccompress;
00584 extern int lpc10compress;
00585 extern int celpcompress;
00586 extern int robust;
00587 extern int voxcompress;
00588 extern int protocolXmit;
00589 extern int protocolSent;
00590 extern int protocolAuto;
00591 extern gsm gsmh;
00592 #ifdef CELP_USE_CONTEXT
00593 struct celp_context *celp_xp;
00594 #endif
00595 extern rate_t xrate;
00596 extern int currentInputSamples;
00597
00598
00599
00600 extern int broadcasting;
00601 extern int listeners;
00602 extern int bConferencing;
00603
00604
00605
00606 extern int isWaveSound;
00607 extern int inputActive, outputActive;
00608 extern int inputPaused;
00609 extern int halfDuplex;
00610 extern int aboutInSamples;
00611 extern int aboutInBits;
00612 extern int aboutOutSamples;
00613 extern int aboutOutBits;
00614
00615
00616
00617 extern public_key_package pk_package;
00618
00619
00620
00621 extern long packetsReceived, packetsSent;
00622 extern long inputPacketsLost, outputPacketsLost;
00623 extern int openConnections;
00624 extern int halfDuplexTransition;
00625 extern int outputInShutdown;
00626 extern long outputPending;
00627 extern long microsecondsPending;
00628 double smoothedMicrosecondsPending;
00629 extern int messageQueueSize;
00630 extern long messageChecks;
00631
00632
00633
00634 extern int aboutUDPmax;
00635 extern int netMaxSamples;
00636
00637
00638
00639 extern int alwaysBindSocket;
00640
00641 extern int useSendNotSendto;
00642
00643
00644
00645 extern int waNetNoConnect;
00646 extern int waNetUseSend;
00647 extern int waNetMultiTTLisChar;
00648 extern int waNetNoOutOverflow;
00649 extern int waNetNoMsgLoopIns;
00650 extern int waNetSynchronousGetHostname;
00651 extern int waNetSynchronousGetHostnameAction;
00652
00653 extern int waProtNoHeartbeat;
00654 extern int waProtUseLargerRTCPackets;
00655 extern int waProtNoVAT;
00656 extern int waProtNoRTP;
00657 extern int waProtNoRTCPCrypt;
00658
00659 extern int waAudioHalf;
00660 extern int waAudio11025;
00661 extern int waAudioRingMaxVolume;
00662 extern int waAudioNoOutputRateAdjustment;
00663 extern int waAudioBeepOnTransmit;
00664
00665
00666
00667 #define modemInputQueue 10240
00668 #define modemOutputQueue 10240
00669
00670 extern int modemEnable;
00671 extern char modemInitString[128];
00672 extern char baudrate[12];
00673 extern char commport[12];
00674 extern int modemHandle;
00675 extern int modemSessions;
00676 extern int modemShowRant;
00677
00678
00679
00680 extern int rememberedConnections;
00681 extern LPSTR rememberedConnection[REMEMBER_CONNECTIONS];
00682
00683
00684
00685 extern int multiMemberships;
00686 #ifdef IP_MAX_MEMBERSHIPS
00687 extern struct in_addr multiAddr[IP_MAX_MEMBERSHIPS];
00688 extern LPSTR multiName[IP_MAX_MEMBERSHIPS];
00689 #endif
00690 extern int multiLoop;
00691 extern int multiBrainDead;
00692
00693
00694
00695 extern char answerFileName[MAX_PATH];
00696 extern char answerOutFileName[MAX_PATH];
00697 extern int answerRecord;
00698
00699
00700
00701 extern char faceFileName[MAX_PATH];
00702 extern HFILE faceFile;
00703 extern int faceShow;
00704
00705
00706
00707 extern char lwl_s_server[MAX_PATH];
00708 extern char lwl_s_email[80];
00709 extern char lwl_s_fullname[80];
00710 extern char lwl_s_phone[80];
00711 extern char lwl_s_location[80];
00712 extern int lwl_s_publish;
00713 extern int lwl_s_exact;
00714
00715 extern char lwl_a_server[MAX_PATH];
00716 extern int lwl_a_exact;
00717
00718 extern int lwl_t_published;
00719 extern int lwl_t_resend;
00720 extern int lwl_t_pending;
00721 extern struct sockaddr_in lookhost;
00722 extern void lwl_ask_set_target(const char *target);
00723
00724
00725
00726 extern unsigned long ssrc;
00727 extern unsigned long timestamp;
00728 extern unsigned short seq;
00729 extern unsigned long rtpdesrand;
00730 extern char *sdes;
00731 extern int sdesl;
00732 extern int spurt;
00733 extern char *vatid;
00734 extern int vatidl;
00735 extern char *rtpsdes;
00736 extern int rtpsdesl;
00737
00738 extern HCURSOR phoneCursor, earCursor, boltCursor;
00739
00740
00741
00742 extern u_long Lazarus;
00743 extern int LazarusLong;
00744 #define LazarusLength 15 // Lazarus timeout in seconds
00745
00746 extern char blankit[];
00747
00748 #define V (void)
00749
00750 #ifdef RANT_ON_ERROR
00751 #define errorRant(hwnd) {if (modemShowRant) { modemRant(hwnd); } }
00752 #else
00753 #define errorRant(hwnd)
00754 #endif
00755
00756
00757
00758 extern void revlong(long *l);
00759 extern void revshort(short *s);
00760
00761
00762
00763 extern LRESULT CALLBACK connectWndProc(HWND hwnd, UINT nMessage,
00764 WPARAM wParam, LPARAM lParam);
00765 extern HWND createNewConnection(LPCLIENT_DATA pClientData);
00766 extern void connFetchFace(HWND hwndClient, LPCLIENT_DATA pClientData);
00767
00768
00769
00770 extern VOID aboutDialogue(HWND hwndParent);
00771 extern VOID propellerHeadDialogue(HWND hwndParent);
00772 extern BOOL CALLBACK propellerHeadDlgProc(HWND hwnd,
00773 UINT nMessage, WPARAM wParam, LPARAM lParam);
00774 extern void propUpdateAudio(void);
00775 extern VOID benchDialogue(HWND hwndParent);
00776 extern BOOL newHostDialogue(HWND hwndParent, LPSTR pszHostName, LPIN_ADDR paddr,
00777 unsigned short *port);
00778 extern VOID genKeyDialogue(HWND hwnd);
00779 extern VOID connectionProperties(HWND hwnd, LPCLIENT_DATA d);
00780 extern VOID modemSetupDialogue(HWND hwnd);
00781 extern void modemRant(HWND hwnd);
00782 extern VOID multicastGroupsDialogue(HWND hwnd);
00783 extern VOID answerDialogue(HWND hwndParent);
00784 extern BOOL CALLBACK answerDlgProc(HWND hwnd, UINT nMessage,
00785 WPARAM wParam, LPARAM lParam);
00786 extern int faceDialogue(HWND hWndParent);
00787 extern BOOL CALLBACK faceDlgProc(HWND hwnd, UINT nMessage,
00788 WPARAM wParam, LPARAM lParam);
00789 extern VOID lwl_ask(HWND hwnd);
00790 extern VOID lwl_tell_settings(HWND hwnd);
00791 extern BOOL voxMonitorDialog(HWND hwndParent);
00792 extern BOOL IsVoxMonitorMessage(MSG *pmsg);
00793 extern void voxMonitorUpdate(long nAudio, long nVox);
00794 extern BOOL IsVoxMonitorOn();
00795
00796
00797
00798 extern LRESULT CALLBACK Frame_WndProc(HWND hwnd, UINT nMessage, WPARAM wParam, LPARAM lParam);
00799 extern void ParseCommandLine(HWND hwnd, LPSTR pszCmdLine);
00800
00801
00802
00803 extern BOOL InitApplication(HINSTANCE hInstance);
00804 extern BOOL InitInstance(HINSTANCE hInstance, LPSTR pszCmdLine, INT nCmdShow);
00805 void SetupICQ(void);
00806 void SetICQData(HKEY hSpeakFreelyKey, char *szSpeakFreelyPath);
00807
00808
00809
00810 extern void DefaultMessageLoop();
00811
00812
00813
00814 extern int readWaveInit(HWND hwndApp, LPCLIENT_DATA d, LPSTR szFileName);
00815 extern int readWaveNext(HWND hwnd, LPCLIENT_DATA d);
00816 extern void readWaveTerm(LPCLIENT_DATA d);
00817
00818 #ifdef MODEM
00819
00820
00821
00822 extern unsigned short crc(unsigned char *buff, int bufflen);
00823
00824
00825
00826 extern int openModem(HWND hwnd);
00827 extern int closeModem(HWND hwnd);
00828 #endif
00829
00830
00831
00832 extern void AES_cbc_encrypt(unsigned char *in,
00833 unsigned char *out,
00834 int len, aes_ctx *ctx);
00835 extern void AES_cbc_decrypt(unsigned char *in,
00836 unsigned char *out,
00837 int len, aes_ctx *ctx);
00838
00839
00840
00841 extern int answerOpen(void);
00842 extern void answerSave(struct in_addr IPaddr, LPSTR hostName, soundbuf *sb);
00843 extern void answerSync(void);
00844 extern void answerClose(void);
00845 extern int answerEnabled(void);
00846
00847
00848
00849 extern void loop_flush(LPCLIENT_DATA d);
00850 extern int loop_sendto(LPCLIENT_DATA d, const char *buf, int len,
00851 const struct sockaddr *to, int tolen);
00852 extern int loop_recvfrom(LPCLIENT_DATA d, char *buf, int len,
00853 struct sockaddr *from, int *fromlen);
00854 extern int loop_samples(LPCLIENT_DATA d);
00855 extern BOOL loop_control_port(LPCLIENT_DATA d);
00856
00857
00858
00859 extern void closeFaceFile(void);
00860 extern int openFaceFile(HWND hwnd);
00861 extern void processFaceRequest(soundbuf *d);
00862 extern void processFaceData(HWND hwnd, LPCLIENT_DATA c, soundbuf *d);
00863
00864
00865
00866 extern int sendLwlMessage(HWND hDlg, int dobye);
00867 extern int lwl_reconnect(HWND hDlg);
00868
00869
00870
00871 extern int rtp_make_sdes(char **pkt, unsigned long ssrc_i, int port, int exact, int strict);
00872 extern int rtp_make_bye(unsigned char *p, unsigned long ssrc_i, char *raison, int strict);
00873 extern int rtp_make_app(unsigned char *p, unsigned long ssrc_i,
00874 int strict, char *type, char *content);
00875 extern LONG rtpout(soundbuf *sb, unsigned long ssrc_i,
00876 unsigned long timestamp_i, unsigned short seq_i,
00877 int spurt);
00878 extern int isValidRTCPpacket(unsigned char *p, int len);
00879 extern int isRTCPByepacket(unsigned char *p, int len);
00880 extern int isRTCPAPPpacket(unsigned char *p, int len, char *name, unsigned char **app_ptr);
00881 extern int isrtp(unsigned char *pkt, int len);
00882 extern int parseSDES(unsigned char *packet, struct rtcp_sdes_request *r);
00883 extern void copySDESitem(char *s, char *d);
00884 extern void string_DES_key(LPSTR key, LPBYTE des_key, char algorithm[16]);
00885
00886
00887
00888 #define RTCP_APP_TEXT_CHAT "SFtc" // APP packet name for text chat
00889 #define WM_CHAT_TEXT_SEND (WM_USER + 1004) // Message sent to frame to transmit text chat
00890 extern VOID chatDialogue(HWND hwndParent);
00891 extern BOOL CALLBACK chatDlgProc(HWND hwnd, UINT nMessage, WPARAM wParam, LPARAM lParam);
00892 extern void chatLog(HWND hwnd, char *ident, char *text);
00893
00894
00895
00896 extern VOID consoleDialogue(HWND hwndParent);
00897 extern BOOL CALLBACK consoleDlgProc(HWND hwnd, UINT nMessage, WPARAM wParam, LPARAM lParam);
00898 extern void consoleLog(char *text);
00899 extern void vcPrintf(LPCSTR lpFormat, va_list arglist);
00900 extern void cPrintf(LPCSTR lpFormat, ...);
00901
00902
00903
00904 extern int isvat(unsigned char *pkt, int len);
00905 extern LONG vatout(soundbuf *sb, unsigned long ssrc_i, unsigned long timestamp_i, int spurt);
00906 extern int makeVATid(char **vp, unsigned long ssrc_i);
00907 extern int makevatdone(unsigned char *v, unsigned long ssrc_i);
00908
00909
00910
00911 extern void lpc10init(void);
00912 extern int lpc10encode(unsigned char *in, unsigned char *out, int inlen);
00913 extern int lpc10decode(unsigned char *in, unsigned char *out, int inlen);
00914
00915
00916
00917 extern BOOL spectrumBarGraph;
00918 extern BOOL spectrumVoicePrint;
00919 extern BOOL spectrumTransmitOnly;
00920 extern BOOL spectrumReceiveOnly;
00921 extern BOOL spectrumMaxEnergy;
00922 extern double spectrum(short *samples, int nsamples, double *ps, int nfreqs, double maxpwr);
00923 extern void spectrumEnd(void);
00924 extern VOID spectralDialogue(HWND hwndParent);
00925 extern BOOL CALLBACK spectralDlgProc(HWND hwnd, UINT nMessage, WPARAM wParam, LPARAM lParam);
00926 extern void spectrumUpdate(LPSTR buffer, WORD buflen, DWORD channels,
00927 DWORD rate, DWORD bytesec, WORD align, BOOL isInput);
00928
00929
00930
00931 extern char *rstring(int resid);
00932 extern char *rfilter(int resid);
00933 extern INT MsgBox(HWND hwndParent, UINT fuType, LPSTR pszFormat, ...);
00934 extern VOID WinPrintf(HDC hdc, INT row, INT col, LPSTR pszFormat, ...);
00935 extern VOID displayHelpTopicString(LPCSTR topicStr);
00936 extern VOID displayHelpTopic(int topicResID);
00937 extern LPSTR SockerrToString(SOCKERR serr);
00938 extern SOCKERR ResetSocket(SOCKET sock);
00939 extern SOCKERR CreateSocket(SOCKET *psock, INT type, ULONG address, PORT port);
00940 extern void playSound(HWND hWnd, LPCLIENT_DATA pClientData, soundbuf *d,
00941 int bitsPerSample, int samplesPerSecond);
00942 extern void decodeAnswerPacket(soundbuf *d,
00943 int bitsPerSample, int samplesPerSecond,
00944 LPSTR *pcmData, DWORD *pcmLength);
00945 extern VOID newConnection(HWND hwnd, LPSTR connectionFile, LPSTR knownHost);
00946 extern void adpcmdecomp( struct soundbuf *sb);
00947 extern int startWaveInput(HWND hwnd);
00948 extern int inputSampleCount(void);
00949 extern void terminateWaveInput(void);
00950 extern void compress2X(soundbuf *asb);
00951 extern void createSoundBuffer(LPSTR buffer, WORD buflen, DWORD channels,
00952 DWORD rate, DWORD bytesec, WORD align);
00953 extern void shipSoundBuffer(HWND hwnd, LPCLIENT_DATA pClientData);
00954 extern VOID startSoundFile(HWND hwnd, LPSTR pszFile);
00955 extern LPBYTE GIFtoBMP(LPBYTE gif, int imageNumber);
00956 extern void sessionKeyGenerate(LPSTR key, BOOL binary);
00957 extern int makeInternalEncryptionKeys(HWND hwnd, LPCLIENT_DATA d);
00958 extern void multicastJoin(HWND hwnd, int join);
00959 extern void propeller(int control, DWORD value);
00960 extern int obtainOutput(HWND hwnd);
00961 extern unsigned char alaw2ulaw(unsigned char aval);
00962 extern void rate_start(rate_t *rate, int inrate, int outrate);
00963 extern void rate_flow(rate_t *rate, unsigned char *ibuf, unsigned char *obuf,
00964 int *isamp, int *osamp);
00965 #ifdef HEXDUMP
00966 extern void xd(void *buf, int bufl, int dochar);
00967 #endif