Initial import of CVS-v2_8_branch

This commit is contained in:
Fred Gleason
2014-08-12 15:13:02 -04:00
commit afd67c7af8
1508 changed files with 405304 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
## automake.am
##
## Automake.am for rivendell/ios/rmlsend/Classes
##
## (C) Copyright 2011 Fred Gleason <fredg@paravelsystems.com>
##
## $Id: Makefile.am,v 1.1 2011/05/27 16:53:00 cvs Exp $
##
## 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.
##
## 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; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
##
## Use automake to process this into a Makefile.in
EXTRA_DIST = RMLSendAppDelegate.h\
RMLSendAppDelegate.m\
RMLSendViewController.h\
RMLSendViewController.m\
TextFieldDelegate.h\
TextFieldDelegate.m
CLEANFILES = *~ moc_* *.qm *.obj *.idb *.pdb *ilk
MAINTAINERCLEANFILES = *~ Makefile.in configure aclocal.m4 *.tar.gz moc_*

View File

@@ -0,0 +1,35 @@
//
// RMLSendAppDelegate.h
// RMLSend
//
// (C) Copyright 2010 Fred Gleason <fredg@paravelsystems.com>
//
// $Id: RMLSendAppDelegate.h,v 1.2 2011/05/27 17:20:14 cvs Exp $
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// 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; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#import <UIKit/UIKit.h>
@class RMLSendViewController;
@interface RMLSendAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
RMLSendViewController *viewController;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet RMLSendViewController *viewController;
@end

View File

@@ -0,0 +1,104 @@
//
// RMLSendAppDelegate.m
// RMLSend
//
// (C) Copyright 2010 Fred Gleason <fredg@paravelsystems.com>
//
// $Id: RMLSendAppDelegate.m,v 1.3 2011/05/31 22:47:33 cvs Exp $
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// 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; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#import "RMLSendAppDelegate.h"
#import "RMLSendViewController.h"
@implementation RMLSendAppDelegate
@synthesize window;
@synthesize viewController;
#pragma mark -
#pragma mark Application lifecycle
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// Add the view controller's view to the window and display.
[window addSubview:viewController.view];
[window makeKeyAndVisible];
[viewController RestoreFields];
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application {
/*
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
*/
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
/*
Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
If your application supports background execution, called instead of applicationWillTerminate: when the user quits.
*/
[viewController SaveFields];
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
/*
Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background.
*/
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
/*
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
*/
}
- (void)applicationWillTerminate:(UIApplication *)application {
/*
Called when the application is about to terminate.
See also applicationDidEnterBackground:.
*/
}
#pragma mark -
#pragma mark Memory management
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
/*
Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.
*/
}
- (void)dealloc {
[viewController release];
[window release];
[super dealloc];
}
@end

View File

@@ -0,0 +1,68 @@
//
// RMLSendViewController.h
// RMLSend
//
// (C) Copyright 2010 Fred Gleason <fredg@paravelsystems.com>
//
// $Id: RMLSendViewController.h,v 1.3 2011/05/31 22:47:33 cvs Exp $
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// 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; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include <netdb.h>
#include <netinet/ip.h>
#include <netinet/in.h>
#import <UIKit/UIKit.h>
#define RMLSEND_TAG_IPADDR 0
#define RMLSEND_TAG_UDPPORT 1
#define RMLSEND_TAG_CMDLINE 2
#define RMLSEND_TAG_BUTTON 3
@interface RMLSendViewController : UIViewController <UITextFieldDelegate> {
UITextField *ipaddr;
UITextField *udpport;
UITextField *cmdline;
UIButton *button;
int sock;
struct sockaddr_in sa;
NSString *conf_filename;
}
@property(nonatomic,retain) IBOutlet UITextField *ipaddr;
@property(nonatomic,retain) IBOutlet UITextField *udpport;
@property(nonatomic,retain) IBOutlet UITextField *cmdline;
@property(nonatomic,retain) IBOutlet UIButton *button;
-(IBAction) processSend: (id) sender;
-(BOOL) ValidateFields;
-(BOOL) SaveFields;
-(BOOL) RestoreFields;
//
// UITextFieldDelegate methods
//
-(BOOL) textFieldShouldBeginEditing:(UITextField *)textField;
-(void) textFieldDidBeginEditing:(UITextField *)textField;
-(BOOL) textFieldShouldEndEditing:(UITextField *)textField;
-(void) textFieldDidEndEditing:(UITextField *)textField;
-(BOOL) textField:(UITextField *)textField shouldChangeCharactersInRange: (NSRange) range
replacementString: (NSString *) string;
-(BOOL) textFieldShouldClear:(UITextField *)textField;
-(BOOL) textFieldShouldReturn: (UITextField *) textField;
@end

View File

@@ -0,0 +1,262 @@
//
// RMLSendViewController.m
// RMLSend
//
// (C) Copyright 2010 Fred Gleason <fredg@paravelsystems.com>
//
// $Id: RMLSendViewController.m,v 1.3 2011/05/31 22:47:33 cvs Exp $
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// 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; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA
//
#include <unistd.h>
#include <sys/socket.h>
#import "RMLSendViewController.h"
#import "TextFieldDelegate.h"
@implementation RMLSendViewController
@synthesize ipaddr,udpport,cmdline,button;
-(IBAction) processSend: (id) sender
{
sendto(sock,[cmdline.text UTF8String],cmdline.text.length,0,(struct sockaddr *)(&sa),sizeof(sa));
}
-(BOOL) ValidateFields
{
struct hostent *host=NULL;
//
// IP Address
//
if([ipaddr.text length]<1) {
return NO;
}
if((host=gethostbyname([ipaddr.text UTF8String]))==NULL) {
NSString *err=[[NSString alloc] initWithUTF8String: hstrerror(h_errno)];
UIAlertView *alert=[[UIAlertView alloc]
initWithTitle: @"RMLSend"
message: err
delegate:nil
cancelButtonTitle:nil
otherButtonTitles:@"OK",nil];
[alert show];
[alert release];
[err release];
return NO;
}
sa.sin_addr.s_addr=*((uint32_t *)host->h_addr_list[0]);
//
// Command-line
//
if([cmdline.text length]<1) {
return NO;
}
if([cmdline.text characterAtIndex:[cmdline.text length]-1]!='!') {
return NO;
}
//
// UDP Port
//
if((udpport.text.intValue<1)||(udpport.text.intValue>0xFFFF)) {
UIAlertView *alert=[[UIAlertView alloc]
initWithTitle: @"RMLSend"
message: @"Invalid Port Number"
delegate:nil
cancelButtonTitle:nil
otherButtonTitles:@"OK",nil];
[alert show];
[alert release];
return NO;
}
sa.sin_port=htons(udpport.text.intValue);
return YES;
}
-(BOOL) SaveFields
{
NSMutableString *str=[[NSMutableString alloc] init];
[str appendString: ipaddr.text];
[str appendString: @"\n"];
[str appendString: udpport.text];
[str appendString: @"\n"];
[str appendString: cmdline.text];
[str writeToFile: conf_filename atomically: NO encoding: NSASCIIStringEncoding error: nil];
return YES;
}
-(BOOL) RestoreFields
{
NSString *str=[NSString stringWithContentsOfFile: conf_filename encoding: NSASCIIStringEncoding error: nil];
NSArray *fields=[NSArray arrayWithArray: [str componentsSeparatedByString: @"\n"]];
if(fields.count==3) {
[ipaddr setText: [fields objectAtIndex: 0]];
[udpport setText: [fields objectAtIndex: 1]];
[cmdline setText: [fields objectAtIndex: 2]];
}
return YES;
}
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
NSLog(@"Started up!");
// Custom initialization
}
return self;
}
/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
ipaddr.delegate=self;
udpport.delegate=self;
cmdline.delegate=self;
//
// Configure the UDP Socket
//
if((sock=socket(PF_INET,SOCK_DGRAM,0))<0) {
NSLog(@"socket: %s",strerror(errno));
}
memset(&sa,0,sizeof(sa));
sa.sin_family=AF_INET;
//
// Initialize the configuration file
//
NSString *dir=[NSHomeDirectory() stringByAppendingPathComponent: @"Documents/.rivendell"];
NSFileManager *fm=[[NSFileManager alloc] init];
if([fm contentsOfDirectoryAtPath: dir error: nil]==nil) {
[fm createDirectoryAtPath: dir withIntermediateDirectories: YES attributes: nil error: nil];
}
conf_filename=[[NSString alloc] initWithString: [dir stringByAppendingPathComponent: @"rmlsend"]];
if(![fm fileExistsAtPath: conf_filename]) {
[fm createFileAtPath: conf_filename contents: [[NSData alloc] init] attributes: nil];
}
/*
UIAlertView *alert=[[UIAlertView alloc]
initWithTitle: @"RMLSend"
message: conf_filename
delegate:nil
cancelButtonTitle:nil
otherButtonTitles:@"OK",nil];
[alert show];
[alert release];
*/
}
/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
//
// UITextFieldDelegate methods
//
-(BOOL) textFieldShouldBeginEditing:(UITextField *)textField
{
return YES;
}
-(void) textFieldDidBeginEditing:(UITextField *)textField
{
}
-(BOOL) textFieldShouldEndEditing:(UITextField *)textField
{
return YES;
}
-(void) textFieldDidEndEditing:(UITextField *)textField
{
}
-(BOOL) textField: (UITextField *) textField shouldChangeCharactersInRange: (NSRange) range
replacementString: (NSString *) string
{
return YES;
}
-(BOOL) textFieldShouldClear:(UITextField *)textField
{
return YES;
}
-(BOOL) textFieldShouldReturn: (UITextField *) textField
{
switch(textField.tag) {
case RMLSEND_TAG_IPADDR:
break;
case RMLSEND_TAG_UDPPORT:
break;
case RMLSEND_TAG_CMDLINE:
break;
}
button.enabled=[self ValidateFields];
[textField resignFirstResponder];
return YES;
}
- (void)dealloc {
if(sock>=0) {
close(sock);
}
[super dealloc];
}
@end

View File

@@ -0,0 +1,32 @@
//
// TextFieldDelegate.h
// RMLSend
//
// (C) Copyright 2010 Fred Gleason <fredg@paravelsystems.com>
//
// $Id: TextFieldDelegate.h,v 1.2 2011/05/27 17:20:14 cvs Exp $
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// 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; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface TextFieldDelegate : NSObject {
}
-(BOOL) textFieldShouldReturn: (UITextField *) textField;
@end

View File

@@ -0,0 +1,35 @@
//
// TextFieldDelegate.m
// RMLSend
//
// (C) Copyright 2010 Fred Gleason <fredg@paravelsystems.com>
//
// $Id: TextFieldDelegate.m,v 1.2 2011/05/27 17:20:14 cvs Exp $
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// 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; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA
//
#import "TextFieldDelegate.h"
@implementation TextFieldDelegate
-(BOOL) textFieldShouldReturn: (UITextField *) textField
{
[textField resignFirstResponder];
return YES;
}
@end