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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
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
123
124
125
126
127
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
|
#ifndef NCUR_CXX
#define NCUR_CXX
#include "ncur.h"
#include "s_mman.h"
#include "s_sman.h"
#include "s_sock.h"
using namespace std;
ncur::ncur( )
{
p_messagelist = new list<char*>;
pthread_mutex_init( &mut_messages, NULL );
i_message_length = 41;
b_is_ready = false;
}
ncur::~ncur()
{
pthread_mutex_destroy( &mut_messages );
}
void*
ncur::start( void *v_pointer )
{
pthread_mutex_lock ( &s_mutx::get().mut_stdout );
ncur* admin_interface = static_cast<ncur*>(v_pointer);
initscr();
start_color();
clear();
noecho();
cbreak(); // Line buffering disabled. pass on everything
init_pair(1, COLOR_WHITE, COLOR_BLUE);
mvprintw(0, 2, DESCRIP );
mvprintw(1, 2, CONTACT );
refresh();
char *choices[] = {
"Chat manager NI",
"Config manager NI",
"HTML-template manager NI",
"Language manager NI",
"Module-loader manager NI",
"MySQL connection manag. NI",
"Session manager NI",
"Socket manager NI",
"Shut down server",
};
admin_interface->p_serveroutput = newwin( 17, 45, 3, 34 );
wbkgd(admin_interface->p_serveroutput, COLOR_PAIR(1));
box ( admin_interface->p_serveroutput, 0, 0 );
mvwprintw( admin_interface->p_serveroutput, 2, 2, "SERVER SYSTEM MESSAGES" );
wrefresh ( admin_interface->p_serveroutput );
admin_interface->print( VERSION );
pthread_mutex_unlock( &s_mutx::get().mut_stdout );
#ifdef NCURSES
s_mman::get().print_init_ncurses();
s_sman::get().print_init_ncurses();
#endif
admin_interface->is_ready( true );
admin_interface->p_menu = new menu( 1, 3, 32, 17, "ADMINISTRATOR's MAIN MENU", choices, 9, COLOR_PAIR(1));
admin_interface->p_menu->start( &switch_main_menu_ );
admin_interface->shutdown();
}
void
ncur::shutdown()
{
endwin();
}
void
ncur::print( string *p_msg )
{
print( (char*)p_msg->c_str() );
}
void
ncur::print( string s_msg )
{
print( (char*)s_msg.c_str() );
}
void
ncur::print( char* c_print )
{
if ( strlen( c_print ) > i_message_length )
{
string s_tmp( c_print );
print( s_tmp.substr( 0, i_message_length ) );
print( s_tmp.substr( i_message_length, s_tmp.length() ) );
return;
}
char* c_temp = new char[i_message_length];
int i;
for ( i = 0; i < i_message_length; i++ )
c_temp[i] = ' ';
c_temp[i] = '\0';
memcpy( c_temp, c_print, strlen(c_print) );
pthread_mutex_lock( &mut_messages );
if ( p_messagelist->size() > 10 )
p_messagelist->pop_front();
p_messagelist->push_back( c_temp );
list<char*>::iterator iter;
iter = p_messagelist->begin();
for ( i=4; i<16 && iter != p_messagelist->end(); i++, iter++ )
mvwprintw( p_serveroutput, i, 2, *iter );
wrefresh ( p_serveroutput );
pthread_mutex_unlock( &mut_messages );
}
void
ncur::switch_main_menu_( int i_choice )
{
if( i_choice != 0 )
switch ( i_choice )
{
case 9: // Shut down server
s_mman::get().~mman();
mvprintw( 21,2, "Good bye !");
refresh();
clrtoeol();
refresh();
endwin();
exit(0);
break;
default:
pthread_mutex_lock ( &s_mutx::get().mut_stdout );
mvprintw( 20,2, "Selection # %d not yet implemented!", i_choice-1);
refresh();
pthread_mutex_lock ( &s_mutx::get().mut_stdout );
break;
}
}
#endif
|