Paste number 42197: string with file ... shoul be easy but....

Index of paste annotations: 1

Paste number 42197: string with file ... shoul be easy but....
Pasted by: armahg
When:2 years, 1 month ago
Share:Tweet this! | http://paste.lisp.org/+WK5
Channel:#adium
Paste contents:
Raw Source | XML | Display As
/
//  SMSSendWindowController.m
//  GAdiumSendEmailPlugin
//
//  Created by George  Armah on 05/19/20007
//  Copyright 2007 armahg. All rights reserved.
//
//  This source code is subject to the license included in the LICENSE.txt file included with ths project.







#import "SMSSendWindowController.h"

@implementation SMSSendWindowController

- (id)initWithWindowNibName:(NSString *)windowNibName
{
	//Initializing window ... with the name of the .nib file
	if(self = [super initWithWindowNibName:windowNibName]){
		
		//Having to do this twice seems kind of wasteful .. perhaps there's a better alternative
		//Initializing NSMatrix of service providers
		firstRow = [NSArray arrayWithObjects:cingularButton, nextelButton, verizonButton, metrocallButton,nil];
		secondRow = [NSArray arrayWithObjects:tmobileButton, sprintButton, virginButton, otherButton, nil];
		[serviceMatrix addRowWithCells:firstRow];
		[serviceMatrix addRowWithCells:secondRow];

		
		//Initializing email script from file
		NSError *error;
		NSLog(@"arrrggghh");
		NSString * path = [[NSBundle bundleForClass:[self class]] pathForResource:@"sendSMS" ofType:@"sh"];
	
		NSLog(path);
		
		if ([smsScript initWithContentsOfFile:@"sendSMS.sh" encoding:NSUTF8StringEncoding error:&error] != nil) {
			NSLog(smsScript);
		}
		else {
			NSLog(@"whats going on?");
			NSLog([[NSFileManager defaultManager] currentDirectoryPath]);
			//NSLog(@"Error reading file at %@\n%@", @"sendSMS.sh", [error localizedDescription]);
		}
		
		
		}
    return self;
}







- (IBAction)cancelClicked:(id)sender
{

	[self close];

}




- (IBAction)sendClicked:(id)sender
{
	
	
	
	if([[smsView string] writeToFile:smsFile atomically:NO]) {
		
		//Design decision ... for now i compare what the user has previously saved
		//with what is being displayed just before he clicks send. If it is different I 
		//assume that he has done that intentionally for a reason ... if not I use the 
		//information from his preferences
		int row, col;
		
		[serviceMatrix getRow:&row column:&col ofCell:[serviceMatrix selectedCell]];
		
		[sms initWithString:[selectedBuddy preferenceForKey:KEY_SMS
													  group:PREF_GROUP_SMS]];
		
		row = ((4 * row) + (col + 1));
		
		if ([[NSNumber numberWithInt:row] isEqualToNumber:[selectedBuddy preferenceForKey:KEY_PHONESERVICEPROVIDER 
											 group:PREF_GROUP_PHONESERVICEPROVIDER]]) {
			
			if ([[phoneField stringValue] isEqualToString:[[sms componentsSeparatedByString:AT] 
																			  objectAtIndex:0]]) {
				
				
				NSLog( [[(AIListContact*)selectedBuddy account] explicitFormattedUID]);
				
	
			}
		}
		

		
		
		
	}


}



- (void)showWindowForContact:(AIListObject *)lo
{	
	
	selectedBuddy = lo;
	[self reloadData];
	
	//Opening window with buddy's current phone number in textField
	//getting everything before @phoneservice.com 
	[phoneField setStringValue:[[[selectedBuddy preferenceForKey:KEY_SMS
														   group:PREF_GROUP_SMS] 
									 componentsSeparatedByString:@"@"] 
												   objectAtIndex:0]];
	
	
	int row , col, sProviderInt;
	
	
	//Getting  and selecting service Provider
	NSNumber * serviceProvider = [selectedBuddy preferenceForKey:KEY_PHONESERVICEPROVIDER
														   group:PREF_GROUP_PHONESERVICEPROVIDER];
	
	sProviderInt = [serviceProvider intValue];
	
	if (sProviderInt <= 4) {
		row = 0;
		col = sProviderInt - 1;
	}
	else {
		row = 1;
		col = (sProviderInt % 4) - 1;	
	}
	

	[serviceMatrix selectCellAtRow:row column:col];
	
	NSLog(@"Row and column of selected cell are");
	NSLog([NSString stringWithFormat:@"%d", row]);
	NSLog([NSString stringWithFormat:@"%d", col]);
	
	[self showWindow:nil];
	[[self window] makeKeyAndOrderFront:nil];
}




//Customizing window for newly selected buddy
- (void)reloadData
{
	
	NSString *title = @"Send SMS to ";
	NSString *name = [selectedBuddy displayName];
	name ? name : [selectedBuddy description];
	name ? name : @"Unknown Contact";
	[[self window] setTitle:[title stringByAppendingString:name]];
	
}


@end

Annotations for this paste:

Annotation number 1: log file stuff
Pasted by: armahg
When:2 years, 1 month ago
Share:Tweet this! | http://paste.lisp.org/+WK5#1
Paste contents:
Raw Source | Display As
2007-06-03 18:13:01.275 Adium[4076] arrrggghh
2007-06-03 18:13:01.276 Adium[4076] /Users/Armahg/Library/Application Support/Adium 2.0/PlugIns/GAdiumSendEmailPlugin.AdiumPlugin/Contents/Resources/sendSMS.sh
2007-06-03 18:13:01.276 Adium[4076] whats going on?
2007-06-03 18:13:01.276 Adium[4076] /
2007-06-03 18:13:01.280 Adium[4076] GAdiumSendEmailPlugin Loaded!

Colorize as:
Show Line Numbers
Index of paste annotations: 1

Lisppaste pastes can be made by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively.