++void
++gui_eaid_response(blt_dev_t * dev, char * cmd)
++{
++ ast_log(LOG_NOTICE, "Submenu displayed.\n");
++}
++
++static int
++atcmd_eami_execute(blt_dev_t * dev, const char * data)
++{
++ char * number = NULL;
++
++ number = strndup(data, strlen(data));
++ int menuitem = atoi(number);
++
++ ast_log(LOG_NOTICE, "Menu Item '%d'.\n", menuitem);
++
++ dev->cb = gui_eaid_response;
++
++ if (menuitem == 1) {
++ char command[1024] = "";
++ const char* c1 = "AT*EAID=8,1,\"Make a SIP call\",\"Number\",\"";
++ const char* c2 = "\"";
++
++ (void)strncat(command, c1, sizeof(command) - strlen(command) - 1);
++ (void)strncat(command, gui_default_sip_number, sizeof(command) - strlen(command) - 1);
++ (void)strncat(command, c2, sizeof(command) - strlen(command) - 1);
++
++ //strcat(command, "AT*EAID=8,1,\"Make a SIP call\",\"Number\",\"");
++ //strcat(command, gui_default_sip_number);
++ //strcat(command, "\"");
++ send_atcmd(dev, command);
++ } else if (menuitem == 2) {
++ char command[1024] = "";
++ const char* c1 = "AT*EAID=11,1,\"Make a SIP call\",\"SIP Address\",100,\"";
++ const char* c2 = "\"";
++
++ (void)strncat(command, c1, sizeof(command) - strlen(command) - 1);
++ (void)strncat(command, gui_default_sip_address, sizeof(command) - strlen(command) - 1);
++ (void)strncat(command, c2, sizeof(command) - strlen(command) - 1);
++
++ //strcat(command, "AT*EAID=11,1,\"Make a SIP call\",\"SIP Address\",100,\"");
++ //strcat(command, gui_default_sip_address);
++ //strcat(command, "\"");
++ send_atcmd(dev, command);
++ } else if (menuitem == 0) {
++ dev->cb = gui_easm_response;
++// send_atcmd(dev,"AT*EASM=\"SIP Menu\",1,1,3,\"Call Number\",\"Call Address\",\"More Options\",1");
++ send_atcmd(dev,"AT*EASM=\"SIP Menu\",1,1,2,\"Call Number\",\"Call Address\",1");
++ } else {
++ ast_log(LOG_ERROR, "Menu item not implementented.\n");
++ }
++ return 0;
++}
++
++static int
++atcmd_eaii_execute(blt_dev_t * dev, const char * data)
++{
++ int pos = 1, len = 0;
++ char type[128];
++ char val[128];
++ const char * start = data;
++ struct sockaddr_in addr;
++
++ while (*data) {
++ if (*data == ',') {
++ memset(type, 0, 128);
++ strncpy(type, start, len);
++
++ ast_log(LOG_NOTICE, "Number(8)/Address(11): '%s'.\n", type);
++
++ pos++;
++ len = 0;
++ data++;
++ start = data;
++ continue;
++ }
++ len++;
++ data++;
++ }
++
++ memset(val, 0, 128);
++ strncpy(val, start, len);
++
++ char del[]= "\"";
++ char* address;
++ address = strtok(val, del);
++ int type_int = atoi(type);
++
++ if (strcmp(address, " 0") == 0) {
++ ast_log(LOG_NOTICE, "Spurious EAII:\n");
++ ast_log(LOG_NOTICE, data);
++ return 0;
++ }
++
++ if (type_int == 8) {
++ (void)strncat(address, "@sipgate.de", sizeof(address) - strlen(address) - 1);
++ }
++
++ ast_log(LOG_NOTICE, "SIP number/address: '%i','%s'.\n", type_int, address);
++
++ if (type_int == 8 || type_int == 11) {
++
++ char messagebox[1024] = "";
++ const char* mb1 = "AT*EAID=1,1,\"Setting up SIP call to ";
++ const char* mb2 = "\",30";
++
++ (void)strncat(messagebox, mb1, sizeof(messagebox) - strlen(messagebox) - 1);
++ (void)strncat(messagebox, address, sizeof(messagebox) - strlen(messagebox) - 1);
++ (void)strncat(messagebox, mb2, sizeof(messagebox) - strlen(messagebox) - 1);
++
++ //strcat(messagebox, "AT*EAID=1,1,\"Setting up SIP call to ");
++ //strcat(messagebox, address);
++ //strcat(messagebox, "\",30");
++ send_atcmd(dev, messagebox);
++
++ send_atcmd(dev, "AT*ESKS=2");
++ send_atcmd(dev, "AT*EKSP");
++ send_atcmd(dev, "AT*ESKS=0");
++
++ //Create manager connection to create call
++ int s = socket(AF_INET,SOCK_STREAM,0);
++ if (s < 0) {
++ ast_log(LOG_ERROR, "Manager connection failed.");
++
++ dev->cb = ag_cgmi_response;
++ send_atcmd(dev, "AT*EAID=1,1,\"Call failed\"");
++ return -1;
++ }
++ addr.sin_family = AF_INET;
++ addr.sin_port = htons(5038);
++ addr.sin_addr.s_addr = inet_addr("127.0.0.1");
++ memset(&(addr.sin_zero), '\0', 8);
++
++ if (connect(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
++ ast_log(LOG_ERROR, "Manager connection failed. (2)");
++ dev->cb = ag_cgmi_response;
++ send_atcmd(dev, "AT*EAID=1,1,\"Call failed\"");
++ return -1;
++ }
++ char* command = "Action: login\r\nUsername: markus\r\nSecret: supAEr\r\n\r\n";
++ if (write(s,command,strlen(command)) < 0) {
++ ast_log(LOG_ERROR, "Manager connection failed. (3)");
++ dev->cb = ag_cgmi_response;
++ send_atcmd(dev, "AT*EAID=1,1,\"Call failed\"");
++ return -1;
++ }
++
++ char command3[1024] = "";
++ const char* action = "Action: Originate\r\nChannel: SIP/";
++ const char* action2 = "\r\nExten: 1235\r\nPriority: 1\r\nContext: sipgate.de\r\n\r\nAction: logoff\r\n\r\n";
++
++ (void)strncat(command3, action, sizeof(command3) - strlen(command3) - 1);
++ (void)strncat(command3, address, sizeof(command3) - strlen(command3) - 1);
++ (void)strncat(command3, action2, sizeof(command3) - strlen(command3) - 1);
++
++ //strcat(command3, "Action: Originate\r\nChannel: SIP/");
++ //strcat(command3, address);
++ //strcat(command3, "\r\nExten: 1235\r\nPriority: 1\r\nContext: sipgate.de\r\n\r\n");
++ ast_log(LOG_NOTICE, command3);
++
++ if (write(s,command3,strlen(command3)) < 0) {
++ ast_log(LOG_ERROR, "Manager connection failed. (5)");
++ return -1;
++ }
++ }
++ //dev->cb = ag_cgmi_response;
++ return 0;
++}
++