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
|
//
// MAServerInformation.m
// MySQL Administrator
//
// Created by Alfredo Kojima on Thu Jun 24 2004.
// Copyright (c) 2004 MySQL AB. All rights reserved.
//
#import "MAServerInformation.h"
#import <MySQLToolsCommon/MConnectionInfo.h>
#import "MAdministrator.h"
#import <MySQLToolsCommon/MControlForm.h>
@implementation MAServerInformation
+ (NSImage*)icon
{
return [NSImage imageNamed:@"OSX-Icons_33.png"];
}
+ (NSString*)label
{
return @"Information";
}
+ (NSString*)toolTip
{
return @"Information about the connected MySQL server instance.";
}
+ (BOOL)needsConnection
{
return NO;
}
- (id)initWithOwner: (MAdministrator*)owner
{
self= [super initWithNibFile: @"ServerInformation" panelOwner: owner];
_defaultFrame= [[self topView] frame];
#if 0
#if 0
NSMatrix *matrix= [[NSMatrix alloc] initWithFrame:NSMakeRect(10,10,500,500)];
NSPopUpButtonCell *cell= [[NSPopUpButtonCell alloc] initTextCell:@"X" pullsDown:NO];
// [cell setEditable:YES];
[matrix addRow];
[matrix putCell:cell atRow:0 column:0];
[topBox addSubview:matrix];
#else
MControlForm *form= [[MControlForm alloc] initWithFrame:NSMakeRect(10, 10, 400, 400)];
[topBox addSubview:form];
[form addTextFieldWithTitle:@"Name" description:@"Name of the something eqwhle hejqeh qeqeqeqewqeqjrjwqerqw."];
[form addTextFieldWithTitle:@"Address" description:@"Write down the address info for the name."];
[form addPopUpWithTitle:@"Engine"
items:[NSArray arrayWithObjects:@"MyISAM", @"InnoDB", @"Falcon", @"CSV", @"Blackhole", nil]
description:@"Begin qrqweryewquir weqruwe qrywuer qrh fdjhfg sdahjf afdaf a end."];
#endif
#endif
return self;
}
- (void)didShow
{
[self updateStatus];
}
- (void)updateStatus
{
NSImage *image;
NSString *status;
MYSQL *mysql;
MConnectionInfo *conn;
MYX_MACHINE_INFO *info;
switch ([_owner serverStatus])
{
case 0:
image= [NSImage imageNamed:@"service_status_stopped.png"];
status= @"Server is Stopped";
break;
case 1:
image= [NSImage imageNamed: @"service_status_running.png"];
status= @"Server is Running";
break;
default:
image= [NSImage imageNamed: @"service_status_unknown.png"];
status= @"Cannot determine server status";
break;
}
[statusImage setImage: image];
[statusLabel setStringValue: status];
conn= [_owner serverInfo];
if ((mysql= [_owner mysql]))
{
MYX_USER_CONNECTION *uconn= [conn createUserConnection];
info= myx_get_server_info(uconn, mysql);
if (info)
{
[serverInfoLabel setStringValue:
[NSString stringWithFormat:@"%s\r%s\r%s",
info->version?:"", info->network_name?:"", info->IP?:""]];
myx_free_pc_info(info);
}
if (mysql->unix_socket)
{
[instanceInfoCaption setStringValue: @"User:\rHost:\rSocket:"];
[instanceInfoLabel setStringValue:
[NSString stringWithFormat:@"%@\r%@\r%s",
[conn username], [conn hostname], mysql->unix_socket]];
}
else
{
[instanceInfoCaption setStringValue: @"User:\rHost:\rPort:"];
[instanceInfoLabel setStringValue:
[NSString stringWithFormat:@"%@\r%@\r%i",
[conn username], [conn hostname], [conn port]]];
}
myx_free_user_connection_content(uconn);
g_free(uconn);
}
else
{
[instanceInfoLabel setStringValue: @"\nNot Connected"];
[serverInfoLabel setStringValue:@"\nNot Connected"];
}
info= myx_get_client_info(mysql);
if (info)
{
[clientInfoLabel setStringValue:
[NSString stringWithFormat:@"%s\r%s\r%s\r%s\r%s",
info->version?:"", info->network_name?:"",
info->IP?:"", info->OS?:"", info->hardware?:""]];
//XXX check how to retrieve hw info
myx_free_pc_info(info);
}
else
[clientInfoLabel setStringValue:@""];
}
@end
|