From 68f9343a65fc6ddaac1cb5c763be1990c7a78e38 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Tue, 26 Feb 2008 08:36:09 -0500 Subject: [PATCH] After much work, we can now link to libssh2.a --- PrintDrop.xcodeproj/project.pbxproj | 24 +++++++++++++ Source/AppController.m | 50 ++++++++++++++++++++++++++++ libssh2/lib/libssh2.a | Bin 452112 -> 452112 bytes 3 files changed, 74 insertions(+) diff --git a/PrintDrop.xcodeproj/project.pbxproj b/PrintDrop.xcodeproj/project.pbxproj index e447f66..1eb4901 100644 --- a/PrintDrop.xcodeproj/project.pbxproj +++ b/PrintDrop.xcodeproj/project.pbxproj @@ -10,6 +10,7 @@ 1E1624F30D736C500067F3B4 /* GradientBackView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1E1624F20D736C500067F3B4 /* GradientBackView.m */; }; 1E1625410D736EF20067F3B4 /* DraggableImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1E1625400D736EF20067F3B4 /* DraggableImageView.m */; }; 1E1626560D7388110067F3B4 /* AppController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1E1626550D7388110067F3B4 /* AppController.m */; }; + 1EE1E1D90D744BB8002999AD /* libssh2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1EE1E1D80D744BB8002999AD /* libssh2.a */; }; 8D11072A0486CEB800E47090 /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = 29B97318FDCFA39411CA2CEA /* MainMenu.nib */; }; 8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; }; 8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; }; @@ -26,6 +27,7 @@ 1E1625400D736EF20067F3B4 /* DraggableImageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DraggableImageView.m; path = Source/DraggableImageView.m; sourceTree = ""; }; 1E1626540D7388110067F3B4 /* AppController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppController.h; path = Source/AppController.h; sourceTree = ""; }; 1E1626550D7388110067F3B4 /* AppController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AppController.m; path = Source/AppController.m; sourceTree = ""; }; + 1EE1E1D80D744BB8002999AD /* libssh2.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libssh2.a; path = libssh2/lib/libssh2.a; sourceTree = ""; }; 29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 29B97319FDCFA39411CA2CEA /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/MainMenu.nib; sourceTree = ""; }; 29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = ""; }; @@ -41,6 +43,7 @@ buildActionMask = 2147483647; files = ( 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */, + 1EE1E1D90D744BB8002999AD /* libssh2.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -63,6 +66,7 @@ 1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */ = { isa = PBXGroup; children = ( + 1EE1E1D80D744BB8002999AD /* libssh2.a */, 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */, ); name = "Linked Frameworks"; @@ -220,8 +224,18 @@ GCC_OPTIMIZATION_LEVEL = 0; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = PrintDrop_Prefix.pch; + HEADER_SEARCH_PATHS = "\"$(SRCROOT)/libssh2/include\""; INFOPLIST_FILE = Info.plist; INSTALL_PATH = "$(HOME)/Applications"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "\"$(SRCROOT)/libssh2/lib\"", + ); + OTHER_LDFLAGS = ( + "-undefined", + suppress, + "-force_flat_namespace", + ); PRODUCT_NAME = PrintDrop; WRAPPER_EXTENSION = app; ZERO_LINK = YES; @@ -235,8 +249,18 @@ GCC_MODEL_TUNING = G5; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = PrintDrop_Prefix.pch; + HEADER_SEARCH_PATHS = "\"$(SRCROOT)/libssh2/include\""; INFOPLIST_FILE = Info.plist; INSTALL_PATH = "$(HOME)/Applications"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "\"$(SRCROOT)/libssh2/lib\"", + ); + OTHER_LDFLAGS = ( + "-undefined", + suppress, + "-force_flat_namespace", + ); PRODUCT_NAME = PrintDrop; WRAPPER_EXTENSION = app; }; diff --git a/Source/AppController.m b/Source/AppController.m index 564dc04..a6f9940 100644 --- a/Source/AppController.m +++ b/Source/AppController.m @@ -15,6 +15,17 @@ */ #import "AppController.h" +#import +#import +#import +#import + +@interface AppController (Private) + +//- (BOOL)uploadFile; +- (void)setStatus:(NSString *)msg isError:(BOOL)error; + +@end @implementation AppController @@ -44,14 +55,53 @@ return self; } +/** + * Sets the status text + */ +- (void)setStatus:(NSString *)msg isError:(BOOL)error +{ + [status setStringValue:msg]; + if (error) + { + [status setTextColor:[NSColor redColor]]; + [progress stopAnimation:self]; + } + else + { + [status setTextColor:[NSColor blackColor]]; + } +} + /** * Sends an item to the printer */ - (IBAction)print:(id)sender { + [progress startAnimation:self]; + [progress setHidden:NO]; + [status setHidden:NO]; + NSString *printer = [[printersController selection] valueForKey:@"unixName"]; NSLog(@"printer = %@", printer); + LIBSSH2_SESSION *ssh = libssh2_session_init(); + if (ssh == NULL) + { + return [self setStatus:@"Failed to initialize SSH context" isError:YES]; + } + + struct sockaddr_in sin; + int sock = socket(AF_INET, SOCK_STREAM, 0); + sin.sin_port = htons(22); + in_addr_t t = inet_addr("acs.bu.edu"); + sin.sin_addr.s_addr = inet_addr("acs.bu.edu"); + sin.sin_family = AF_INET; + if (connect(sock, (struct sockaddr *)(&sin), sizeof(struct sockaddr_in)) != 0) + { + return [self setStatus:@"Could not connect to acs.bu.edu" isError:YES]; + } + + close(sock); } @end diff --git a/libssh2/lib/libssh2.a b/libssh2/lib/libssh2.a index b2be511ffae6be00eccf0cf843e308f89078d079..1235448aeeb4a281bb588f5b4dd8d4280d15b426 100644 GIT binary patch delta 581 zcmbPmMtTAed9#`r7#o>RfAES`a%1KtJ~lAdVDiHA5}PCW7u6y7;+rMJ&VNlgFcLl1YjbHB|wqJSjJ1-NFw6f3o;p*J&;5s zwoly1xF{SZlDL~$e0u;V(`6SF5eGje=K#1!9jo~E1@o8=FGLY(a9|eBLlN1qj(If? zM8t6V!&g9E6}y>#%cF=)xXm0ag%mauGv&7{d}H1W4Irb5f#Tagu&_*ygXjYD7bLS( zL;Yz43_$Vi79}jsP;Wv6X4JF%7KG{mtJpA+ML8Z4az}RtUhl_v$`o}dk34Q=1(6y-m delta 574 zcmbPmMtTAed9xc^T3Q&JnoNK7mDy}#$7VjTfT4xSW+(ogb#M+--%D{g=hIR~UN(?E zLyO6d{NkGhHh0S)_!66Uo_|#X;f|+v5r-IyMrH-a{!9Sf_Y4b7s5myz5=Rga9|eBLlTkL zzHuG%Djp;e@$D76nSaZph)lT694rM3n(e@#dC3QsH#VLOa_k2dmdSBYf$3nUEJ$Xl zhWOCf7$Ra(!r~0^AxvaOJZJL%z>l^ z=xsLEWOKO4H8%0>2W(kqJD`YE)Uh5mMG=YE!rE-c3XbiG0g~H)zGD4V4&zE}7f5C+ g4uN>s#Bh7pcDA4F2;P3SKuF{p1LYoFW7FdY00uF