commit c3c2c93cc91d94560457c8364841703befb13527 Author: Ray Slakinski Date: Fri Jul 27 10:06:22 2012 -0400 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..61475ef --- /dev/null +++ b/.gitignore @@ -0,0 +1,58 @@ +# python +*.py[co] +ipython_autoexec.py + + +# system +.DS_Store +*.pid +*.log +*.sw[ponm] +*~ + +# xcode +build/* +*.perspective +*.perspectivev3 +*.pbxuser +*.xcworkspace +*.mode1 +*.mode2v3 +*.mode1v3 +xcuserdata +Snapshots + +# java/andriod +*.apk +*.ap_ +*.dex +*.class +bin/ +gen/ + +# Eclipse/Idea/Dev Env +env/ +.idea +.cache +tags +temp +.coverage +*.packed +*.pydevproject +.project +.metadata +bin/** +tmp/** +tmp/**/* +*.tmp +*.bak +*.swp +*~.nib +local.properties +.classpath +.settings/ +.loadpath +.externalToolBuilders/ +*.launch +.cproject +.buildpath diff --git a/OSX/English.lproj/InfoPlist.strings b/OSX/English.lproj/InfoPlist.strings new file mode 100644 index 0000000..4e1c51c Binary files /dev/null and b/OSX/English.lproj/InfoPlist.strings differ diff --git a/OSX/English.lproj/MainMenu.nib/classes.nib b/OSX/English.lproj/MainMenu.nib/classes.nib new file mode 100644 index 0000000..74b287c --- /dev/null +++ b/OSX/English.lproj/MainMenu.nib/classes.nib @@ -0,0 +1,28 @@ +{ + IBClasses = ( + {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, + { + ACTIONS = { + goDEVSDF1 = id; + goDonate = id; + goiMoodURL = id; + iMoodUpdater = id; + setMoodPrefs = id; + }; + CLASS = iMoodUpdater; + LANGUAGE = ObjC; + OUTLETS = { + adv = id; + face = id; + mood = id; + moodList = id; + moodTextList = id; + pMood = id; + pass = id; + userID = id; + }; + SUPERCLASS = NSObject; + } + ); + IBVersion = 1; +} \ No newline at end of file diff --git a/OSX/English.lproj/MainMenu.nib/info.nib b/OSX/English.lproj/MainMenu.nib/info.nib new file mode 100644 index 0000000..9a8a125 --- /dev/null +++ b/OSX/English.lproj/MainMenu.nib/info.nib @@ -0,0 +1,25 @@ + + + + + IBDocumentLocation + 410 325 364 391 0 0 1024 746 + IBEditorPositions + + 29 + 480 252 165 44 0 0 1024 746 + 292 + 377 338 270 342 0 0 1024 746 + + IBFramework Version + 326.0 + IBOpenObjects + + 29 + 295 + 394 + + IBSystem Version + 7A202 + + diff --git a/OSX/English.lproj/MainMenu.nib/keyedobjects.nib b/OSX/English.lproj/MainMenu.nib/keyedobjects.nib new file mode 100644 index 0000000..88aba65 Binary files /dev/null and b/OSX/English.lproj/MainMenu.nib/keyedobjects.nib differ diff --git a/OSX/README b/OSX/README new file mode 100644 index 0000000..85fe182 --- /dev/null +++ b/OSX/README @@ -0,0 +1,38 @@ +iMood Updater 1.52 - Updates your internet mood (imood.com). +Copyright (C) 2003 RiSC, and SDF1 Networks +-------------------------------------------------------------------------- +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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +GNU License @ http://www.gnu.org/copyleft/gpl.htm + +iMood Updater version 1.52, Copyright (C) 2003 RiSC, and SDF1 Networks +iMood Updater comes with ABSOLUTELY NO WARRANTY +-------------------------------------------------------------------------- +Requirements: + Mac OS X 10.2 or higher +-------------------------------------------------------------------------- + +New in 1.52: + +- DES encryption of passwords being sent to iMood.com + +Known issues: + +- Must have a connection to the internet before running + +To-do list: + +- Keychain support +- Better error handling diff --git a/OSX/Resources/images/00.gif b/OSX/Resources/images/00.gif new file mode 100644 index 0000000..e144212 Binary files /dev/null and b/OSX/Resources/images/00.gif differ diff --git a/OSX/Resources/images/01.gif b/OSX/Resources/images/01.gif new file mode 100644 index 0000000..5310235 Binary files /dev/null and b/OSX/Resources/images/01.gif differ diff --git a/OSX/Resources/images/02.gif b/OSX/Resources/images/02.gif new file mode 100644 index 0000000..5d1a8c0 Binary files /dev/null and b/OSX/Resources/images/02.gif differ diff --git a/OSX/Resources/images/03.gif b/OSX/Resources/images/03.gif new file mode 100644 index 0000000..a81417e Binary files /dev/null and b/OSX/Resources/images/03.gif differ diff --git a/OSX/Resources/images/04.gif b/OSX/Resources/images/04.gif new file mode 100644 index 0000000..499624f Binary files /dev/null and b/OSX/Resources/images/04.gif differ diff --git a/OSX/Resources/images/05.gif b/OSX/Resources/images/05.gif new file mode 100644 index 0000000..3088f58 Binary files /dev/null and b/OSX/Resources/images/05.gif differ diff --git a/OSX/Resources/images/06.gif b/OSX/Resources/images/06.gif new file mode 100644 index 0000000..a488de2 Binary files /dev/null and b/OSX/Resources/images/06.gif differ diff --git a/OSX/Resources/images/07.gif b/OSX/Resources/images/07.gif new file mode 100644 index 0000000..3d09c0b Binary files /dev/null and b/OSX/Resources/images/07.gif differ diff --git a/OSX/Resources/images/08.gif b/OSX/Resources/images/08.gif new file mode 100644 index 0000000..884e50f Binary files /dev/null and b/OSX/Resources/images/08.gif differ diff --git a/OSX/Resources/images/09.gif b/OSX/Resources/images/09.gif new file mode 100644 index 0000000..2aa9c91 Binary files /dev/null and b/OSX/Resources/images/09.gif differ diff --git a/OSX/Resources/images/10.gif b/OSX/Resources/images/10.gif new file mode 100644 index 0000000..a241df0 Binary files /dev/null and b/OSX/Resources/images/10.gif differ diff --git a/OSX/Resources/images/11.gif b/OSX/Resources/images/11.gif new file mode 100644 index 0000000..73ac2ce Binary files /dev/null and b/OSX/Resources/images/11.gif differ diff --git a/OSX/Resources/images/12.gif b/OSX/Resources/images/12.gif new file mode 100644 index 0000000..5cf3bc5 Binary files /dev/null and b/OSX/Resources/images/12.gif differ diff --git a/OSX/Resources/images/13.gif b/OSX/Resources/images/13.gif new file mode 100644 index 0000000..10b5d22 Binary files /dev/null and b/OSX/Resources/images/13.gif differ diff --git a/OSX/Resources/images/14.gif b/OSX/Resources/images/14.gif new file mode 100644 index 0000000..64ef094 Binary files /dev/null and b/OSX/Resources/images/14.gif differ diff --git a/OSX/Resources/images/15.gif b/OSX/Resources/images/15.gif new file mode 100644 index 0000000..3a790f9 Binary files /dev/null and b/OSX/Resources/images/15.gif differ diff --git a/OSX/Resources/images/16.gif b/OSX/Resources/images/16.gif new file mode 100644 index 0000000..414a0a1 Binary files /dev/null and b/OSX/Resources/images/16.gif differ diff --git a/OSX/Resources/images/17.gif b/OSX/Resources/images/17.gif new file mode 100644 index 0000000..cdbe8b1 Binary files /dev/null and b/OSX/Resources/images/17.gif differ diff --git a/OSX/Resources/images/18.gif b/OSX/Resources/images/18.gif new file mode 100644 index 0000000..d813f3a Binary files /dev/null and b/OSX/Resources/images/18.gif differ diff --git a/OSX/Resources/images/19.gif b/OSX/Resources/images/19.gif new file mode 100644 index 0000000..39ceab2 Binary files /dev/null and b/OSX/Resources/images/19.gif differ diff --git a/OSX/Resources/images/20.gif b/OSX/Resources/images/20.gif new file mode 100644 index 0000000..e704d6d Binary files /dev/null and b/OSX/Resources/images/20.gif differ diff --git a/OSX/Resources/images/21.gif b/OSX/Resources/images/21.gif new file mode 100644 index 0000000..12e934e Binary files /dev/null and b/OSX/Resources/images/21.gif differ diff --git a/OSX/Resources/images/22.gif b/OSX/Resources/images/22.gif new file mode 100644 index 0000000..0454431 Binary files /dev/null and b/OSX/Resources/images/22.gif differ diff --git a/OSX/Resources/images/23.gif b/OSX/Resources/images/23.gif new file mode 100644 index 0000000..f1bfcfc Binary files /dev/null and b/OSX/Resources/images/23.gif differ diff --git a/OSX/Resources/images/24.gif b/OSX/Resources/images/24.gif new file mode 100644 index 0000000..ca41554 Binary files /dev/null and b/OSX/Resources/images/24.gif differ diff --git a/OSX/Resources/images/25.gif b/OSX/Resources/images/25.gif new file mode 100644 index 0000000..bdc40d0 Binary files /dev/null and b/OSX/Resources/images/25.gif differ diff --git a/OSX/Resources/images/26.gif b/OSX/Resources/images/26.gif new file mode 100644 index 0000000..de91555 Binary files /dev/null and b/OSX/Resources/images/26.gif differ diff --git a/OSX/Resources/images/27.gif b/OSX/Resources/images/27.gif new file mode 100644 index 0000000..b84c824 Binary files /dev/null and b/OSX/Resources/images/27.gif differ diff --git a/OSX/Resources/images/28.gif b/OSX/Resources/images/28.gif new file mode 100644 index 0000000..a97364a Binary files /dev/null and b/OSX/Resources/images/28.gif differ diff --git a/OSX/Resources/images/29.gif b/OSX/Resources/images/29.gif new file mode 100644 index 0000000..9019951 Binary files /dev/null and b/OSX/Resources/images/29.gif differ diff --git a/OSX/Resources/images/30.gif b/OSX/Resources/images/30.gif new file mode 100644 index 0000000..27e4aa0 Binary files /dev/null and b/OSX/Resources/images/30.gif differ diff --git a/OSX/Resources/images/31.gif b/OSX/Resources/images/31.gif new file mode 100644 index 0000000..24b568c Binary files /dev/null and b/OSX/Resources/images/31.gif differ diff --git a/OSX/Resources/images/32.gif b/OSX/Resources/images/32.gif new file mode 100644 index 0000000..275bedf Binary files /dev/null and b/OSX/Resources/images/32.gif differ diff --git a/OSX/Resources/imood.icns b/OSX/Resources/imood.icns new file mode 100644 index 0000000..e44bc60 Binary files /dev/null and b/OSX/Resources/imood.icns differ diff --git a/OSX/XMLTree.h b/OSX/XMLTree.h new file mode 100644 index 0000000..74c7364 --- /dev/null +++ b/OSX/XMLTree.h @@ -0,0 +1,325 @@ +#import + +/*! + @header XMLTree + XMLTree provides an Objective-C wrapper for Apple's built-in C-language + XML parser and manipulation functions. + */ + + +/*! + @class XMLTree + @abstract Wraps some C-level functions from Apple for XML manipulation. + @discussion +

+ XMLTree provides an Objective-C wrapper for Apple's built-in C-language + XML parser and manipulation functions. + At the moment it only supports basic element and attribute information. + However Apple's XML parser supports processing instructions, CDATA, + and some other things I've never seen, so I'll add support for these + as I go along. +

+

+ I'm releasing this code into the Public Domain, so you can include it + with your software regardless of the license you use. If you make any + useful additions or bug fixes (especially with retain/release), we + would all appreciate it if you would let me know so we can give the + changes to everyone else too. +

+

Author: Robert Harder, rob -at- iharder.net

+

version: 0.1

+ */ +@interface XMLTree : NSObject +{ + CFXMLTreeRef _tree; + CFXMLNodeRef _node; + + NSString *_lastUnknownSelector; +} + + +/*! + @method dealloc + @abstract Be a good citizen and clean up after ourselves. + */ +-(void)dealloc; + + +/*! + @method treeWithURL: + @abstract Creates an autoreleased XMLTree with the contents of url. + @discussion +

This method does not return a properly-autoreleased object. + Do not use it until we figure out what's wrong (or let me know if you found out.

+ Creates an autoreleased XMLTree with the contents of url or + nil if there was an error. + Of course the URL can be pointing to a file or a URL on the internet + such as a GET command to a SOAP application. + @param url The NSURL pointing to your XML data. + @result An autoreleased XMLTree with the contents + of url or nil if there was a problem. + */ ++(XMLTree *)treeWithURL:(NSURL *)url; + + +/*! + @method init + @abstract Initializes and returns an XMLTree. + @discussion + Initializes and returns an XMLTree (with a retain count of 1). + There isn't much point to creating an XMLTree this way until + I add methods for manuallying adding XML nodes to the tree. + @result An XMLTree (with a retain count of 1). + */ +-(XMLTree *)init; + + +/*! + @method initWithURL: + @abstract Initializes and returns an XMLTree + with the contents of url. + @discussion + Initializes and returns an XMLTree (with a retain count of 1) + with the XML contents of url or nil if there is an error. + @param url The NSURL pointing to your XML data. + @result An XMLTree with a retain count of 1. + */ +-(XMLTree *)initWithURL:(NSURL *)url; + + +/*! + @method initWithCFXMLTreeRef: + @abstract Initializes and returns an XMLTree + with the internal data represented by ref. + @discussion + Initializes and returns an XMLTree (with a retain count of 1) + with the internal CFXMLTreeRef data represented by ref. + You probably won't ever need to call this yourself, but I call it internally + and may move it to a Private API in the XMLTree.m file later. + @param ref The CFXMLTreeRef containing the XML data. + @result An XMLTree with a retain count of 1. + */ +-(XMLTree *)initWithCFXMLTreeRef:(CFXMLTreeRef)ref; + + + +/* ******** A B O U T S E L F ******** */ +/*! + @method name + @abstract Returns the name of the root node in the tree. + @discussion + Returns the name of the root node in the tree or nil + if a name is not appropriate in the current context such as + if the "tree" is actually a single XML Processing Instruction node. + @result The name of the root node in the tree.. + */ +-(NSString *)name; + + +/*! + @method xml + @abstract Returns the XMLTree in an XML-looking form. + @discussion + Returns the XMLTree in an XML-looking form as performed + by Apple's own CFXMLTreeCreateXMLData(...) method. + @result The XMLTree in an XML-looking form. + */ +-(NSString *)xml; + + +/*! + @method description + @abstract Returns a textual representation of the XMLTree. + @discussion +

+ Returns a textual representation of the XMLTree. + The way the tree is interpreted depends on what kind of root + node is represented by the receiver. +

+

+ Listed below are the actions this method takes depending + on the type of node this is. +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Node TypeCFXMLNodeTypeCodeAction
DocumentkCFXMLNodeTypeDocument + Recursively descends XML document piecing together + the Text and CDATA nodes that are encountered. + You can think of this as returning the plaintext + version of the XML data, that is, with all tags removed. +
ElementkCFXMLNodeTypeElement
AttributekCFXMLNodeTypeAttribute + Default action: Whatever is returned by Apple's + CFXMLNodeGetString(...) method. +
Processing InstructionkCFXMLNodeTypeProcessingInstruction
CommentkCFXMLNodeTypeComment
TextkCFXMLNodeTypeText
CDATA SectionkCFXMLNodeTypeCDATASection
Document FragmentkCFXMLNodeTypeDocumentFragment
EntitykCFXMLNodeTypeEntity
Entity ReferencekCFXMLNodeTypeEntityReference
Document TypekCFXMLNodeTypeDocumentType
WhitespacekCFXMLNodeTypeWhitespace
Notation ElementkCFXMLNodeTypeNotation
Element Type DeclarationkCFXMLNodeTypeElementTypeDeclaration
Attribute List DeclarationkCFXMLNodeTypeAttributeListDeclaration
+ + @result A textual representation of the XMLTree. + */ +-(NSString *)description; + + +/*! + @method attributeNamed: + @abstract Returns the attribute named name. + @discussion + Returns the attribute named name or + nil if no such attribute is found or + the node is not an Element node. + @param name The name of the attribute to return. + @result The attribute named name. + */ +-(NSString *)attributeNamed:(NSString *)name; + + + +/*! + @method attributes + @abstract Returns a dictionary of all the attributes. + @discussion + Returns a dictionary of all the attributes in the node + or nil if the node is not an Element node. + @result A dictionary of all the attributes. + */ +-(NSDictionary *)attributes; + + +/*! + @method type + @abstract Returns the type of node this is. + @discussion + Returns the type of node this is as defined by Apple's + enum: +
+ enum CFXMLNodeTypeCode {
+     kCFXMLNodeTypeDocument = 1,
+     kCFXMLNodeTypeElement = 2,
+     kCFXMLNodeTypeAttribute = 3,
+     kCFXMLNodeTypeProcessingInstruction = 4,
+     kCFXMLNodeTypeComment = 5,
+     kCFXMLNodeTypeText = 6,
+     kCFXMLNodeTypeCDATASection = 7,
+     kCFXMLNodeTypeDocumentFragment = 8,
+     kCFXMLNodeTypeEntity = 9,
+     kCFXMLNodeTypeEntityReference = 10,
+     kCFXMLNodeTypeDocumentType = 11,
+     kCFXMLNodeTypeWhitespace = 12,
+     kCFXMLNodeTypeNotation = 13,
+     kCFXMLNodeTypeElementTypeDeclaration = 14,
+     kCFXMLNodeTypeAttributeListDeclaration = 15
+ };
+ 
+ @result The type of node this is. + */ +-(CFXMLNodeTypeCode)type; + + + +/* ******** A B O U T C H I L D R E N ******** */ + + +/*! + @method childAtIndex: + @abstract Returns the child at the given index. + @discussion + Returns the child at the given index or nil + if no such child exists or it doesn't make sense + to have children (such as a Processing Instruction node). + @param index The index of the child to get. + @result The child at index. + */ +-(XMLTree *)childAtIndex:(int)index; + + + + +/*! + @method childNamed: + @abstract Returns the first child named name. + @discussion + Returns the first child named name or nil + if no such child exists or it doesn't make sense + to have children (such as a Processing Instruction node). + @param name The name of the child. + @result The child named name. +*/ +-(XMLTree *)childNamed:(NSString *)name; + + +/*! + @method descendentNamed: + @abstract Returns the first descendent named name. + @discussion + Returns the descendent named name or nil + if no such descendent exists or it doesn't make sense + to have descendents (such as a Processing Instruction node). + This is a depth-first search. + @param name The name of the child. + @result The child named name. +*/ +-(XMLTree *)descendentNamed:(NSString *)name; + + +/*! + @method count + @abstract Returns the number of children in the tree. + @discussion + Returns the number of children in the tree or -1 + if there is no valid tree contained within (like if you + tried to create an XMLTree with init). + @result The number of children in the tree. + */ +-(int)count; + + +@end + +/*! + @function XMLTreeDescription + @abstract Used internally to recursively generate tree descriptions. + @param descr The mutable string that will have descriptions appended to it. + @param tree The tree from which to make a description. + @result A description of tree. + */ +CFStringRef XMLTreeDescription( CFMutableStringRef descr, CFXMLTreeRef tree ); + + + +/*! +@function XMLTreeDescendentNamed + @abstract Used internally to recursively search for a descendent. + @param name The name of the descendent to search for. + @param tree The tree in which to recursively search. + @result The matching descendent or nil if no descendent is found. + */ +CFXMLTreeRef XMLTreeDescendentNamed( CFStringRef name, CFXMLTreeRef tree ); + + + diff --git a/OSX/XMLTree.m b/OSX/XMLTree.m new file mode 100644 index 0000000..8e47e97 --- /dev/null +++ b/OSX/XMLTree.m @@ -0,0 +1,383 @@ +#import "XMLTree.h" + +@interface XMLTree (PrivateAPI) + + +@end // End Private API + + + +@implementation XMLTree + + +-(void)dealloc +{ + //NSLog( @"dealloc %@", self ); + + if( _tree != NULL ) + CFRelease( _tree ); + + if( _node != NULL ) + CFRelease( _node ); + + _tree = NULL; + _node = NULL; + +} // end dealloc + + + ++(XMLTree *)treeWithURL:(NSURL *)url +{ + return [[[XMLTree alloc] initWithURL:url] autorelease]; +} // end treeWithURL + + + +-(XMLTree *)init +{ + if( [super init] == nil ) + return nil; + + _tree = NULL; + _node = NULL; + + return self; +} // end init + + + +-(XMLTree *)initWithCFXMLTreeRef:(CFXMLTreeRef)ref +{ + if( [self init] == nil ) + return nil; + + // Clean up? + if( _tree != NULL ) + CFRelease( _tree ); + if( _node != NULL ) + CFRelease( _node ); + + _tree = ref; + _node = CFXMLTreeGetNode( _tree ); + + CFRetain( _tree ); + CFRetain( _node ); + + return self; +} // end initWithCFXMLTreeRef: + + +-(XMLTree *)initWithURL:(NSURL *)url +{ + CFDataRef xmlData; + if( (xmlData = (CFDataRef)malloc( sizeof( CFDataRef ) ) ) == NULL){ + NSLog(@"Couldn't allocate any memory."); + return nil; + } // end if: malloc fail + + + _tree = CFXMLTreeCreateWithDataFromURL( + kCFAllocatorDefault, + (CFURLRef)url, + kCFXMLParserSkipWhitespace, + NULL ); //CFIndex + + _node = CFXMLTreeGetNode( _tree ); + + // _tree is implicitly retained + CFRetain( _node ); + + return self; +} // end initWithURL + + + + + +/* ******** A B O U T C H I L D R E N ******** */ + + +-(int)count +{ + if( _tree == NULL ) + return -1; + + return CFTreeGetChildCount( _tree ); +} // end count + + + +-(XMLTree *)childAtIndex:(int)index +{ + CFXMLTreeRef child; + + if( _tree == NULL ) + return nil; + + if( index >= CFTreeGetChildCount( _tree ) ) + return nil; + + child = CFTreeGetChildAtIndex(_tree, index); + + return [[XMLTree alloc] initWithCFXMLTreeRef:child]; +} // end childAtIndex: + + + +-(XMLTree *)childNamed:(NSString *)name +{ + CFXMLTreeRef childTree; + CFXMLNodeRef childNode; + CFStringRef childName; + int childCount; + int i; + + if( _tree == NULL ) + return nil; + + childCount = CFTreeGetChildCount( _tree ); + + for( i = 0; i < childCount; i++ ){ + childTree = CFTreeGetChildAtIndex(_tree, i ); + childNode = CFXMLTreeGetNode( childTree ); + childName = CFXMLNodeGetString( childNode ); + + if( CFStringCompare( (CFStringRef)name, childName, NULL ) == kCFCompareEqualTo ) + return [[XMLTree alloc] initWithCFXMLTreeRef:childTree]; + + } // end for: each child + + return nil; +} // end childNamed: + + +-(XMLTree *)descendentNamed:(NSString *)name +{ + CFXMLTreeRef descTree; + + if( _tree == NULL ) + return nil; + + descTree = XMLTreeDescendentNamed( (CFStringRef)name, _tree ); + + if( descTree == NULL ) + return nil; + + return [[XMLTree alloc] initWithCFXMLTreeRef:descTree]; +} // end descendentNamed: + + + +/* ******** A B O U T S E L F ******** */ + + + + +-(NSString *)name +{ + NSString *name; + + if( _node == NULL ) + return nil; + + name = [[NSString alloc] initWithString:(NSString *)CFXMLNodeGetString(_node)]; + + return name; +} // end name + + +/*! + @discussion + Returns the node type, as defined by Apple's XML parser. + The values will be one of the following constants: +
+ enum CFXMLNodeTypeCode {
+     kCFXMLNodeTypeDocument = 1,
+     kCFXMLNodeTypeElement = 2,
+     kCFXMLNodeTypeAttribute = 3,
+     kCFXMLNodeTypeProcessingInstruction = 4,
+     kCFXMLNodeTypeComment = 5,
+     kCFXMLNodeTypeText = 6,
+     kCFXMLNodeTypeCDATASection = 7,
+     kCFXMLNodeTypeDocumentFragment = 8,
+     kCFXMLNodeTypeEntity = 9,
+     kCFXMLNodeTypeEntityReference = 10,
+     kCFXMLNodeTypeDocumentType = 11,
+     kCFXMLNodeTypeWhitespace = 12,
+     kCFXMLNodeTypeNotation = 13,
+     kCFXMLNodeTypeElementTypeDeclaration = 14,
+     kCFXMLNodeTypeAttributeListDeclaration = 15
+ };
+ 
+ */ +-(CFXMLNodeTypeCode)type +{ + return CFXMLNodeGetTypeCode(_node); +} // end type + + + +-(NSDictionary *)attributes +{ + CFXMLElementInfo eInfo; + + if( CFXMLNodeGetTypeCode( _node ) != kCFXMLNodeTypeElement ) + return nil; + + eInfo = *(CFXMLElementInfo *)CFXMLNodeGetInfoPtr(_node); + + return (NSDictionary *)eInfo.attributes; +} // end attributes + + + + + + + +-(NSString *)attributeNamed:(NSString *)name +{ + if( _tree == NULL ) + return nil; + + return [[[self attributes] objectForKey:name] description]; +} // end attributeNamed: + + + + + +-(NSString *)description +{ + NSMutableString *descr; + + descr = [[NSMutableString alloc] init]; + + //NSLog( @"Description for type %d", CFXMLNodeGetTypeCode(_node) ); + + switch( CFXMLNodeGetTypeCode(_node) ){ + + case kCFXMLNodeTypeDocument: + case kCFXMLNodeTypeElement: + XMLTreeDescription( (CFMutableStringRef)descr, _tree ); + break; + + case kCFXMLNodeTypeProcessingInstruction: + case kCFXMLNodeTypeAttribute: + case kCFXMLNodeTypeComment: + case kCFXMLNodeTypeText: + case kCFXMLNodeTypeCDATASection: + case kCFXMLNodeTypeDocumentFragment: + case kCFXMLNodeTypeEntity: + case kCFXMLNodeTypeEntityReference: + case kCFXMLNodeTypeDocumentType: + case kCFXMLNodeTypeWhitespace: + case kCFXMLNodeTypeNotation: + case kCFXMLNodeTypeElementTypeDeclaration: + case kCFXMLNodeTypeAttributeListDeclaration: + default: + [descr appendString:(NSString *)CFXMLNodeGetString(_node)]; + } // end switch + + return descr; +} // end description + + + + +-(NSString *)xml +{ + CFDataRef xmlData; + + if( _tree == NULL ) + return nil; + + xmlData = CFXMLTreeCreateXMLData( + kCFAllocatorDefault, + _tree ); + if( xmlData == NULL ) + return nil; + + return [[NSString alloc] initWithData:(NSData *)xmlData encoding:NSASCIIStringEncoding]; + +} // end xml + + + + +@end // End implementation + + + +CFStringRef XMLTreeDescription( CFMutableStringRef descr, CFXMLTreeRef tree ) +{ + CFXMLTreeRef childTree; + CFXMLNodeRef childNode; + int childCount; + int i; + + childCount = CFTreeGetChildCount( tree ); + + for( i = 0; i < childCount; i++ ){ + + childTree = CFTreeGetChildAtIndex( tree, i ); + childNode = CFXMLTreeGetNode( childTree ); + + switch( CFXMLNodeGetTypeCode( childNode ) ){ + + case kCFXMLNodeTypeText: + CFStringAppend( descr, CFXMLNodeGetString( childNode ) ); + break; + + case kCFXMLNodeTypeElement: + XMLTreeDescription( descr, childTree ); + break; + + default: + break; + } // end switch: node type + } // end for + + return descr; +} // end XMLTreeDescription + + + +CFXMLTreeRef XMLTreeDescendentNamed( CFStringRef name, CFXMLTreeRef tree ) +{ + CFXMLTreeRef childTree; + CFXMLTreeRef descTree; + CFXMLNodeRef childNode; + CFStringRef childName; + int childCount; + int i; + + childCount = CFTreeGetChildCount( tree ); + + for( i = 0; i < childCount; i++ ){ + + childTree = CFTreeGetChildAtIndex( tree, i ); + childNode = CFXMLTreeGetNode( childTree ); + childName = CFXMLNodeGetString( childNode ); + + // Is this it? + if( CFStringCompare( name, childName, NULL ) == kCFCompareEqualTo ) + return childTree; + + // If child is an element, search recursively + if( CFXMLNodeGetTypeCode( childNode ) == kCFXMLNodeTypeElement ){ + + descTree = XMLTreeDescendentNamed( name, childTree ); + + // Got a match? + if( descTree != NULL ) + return descTree; + + } // end if: element node type + + } // end for + + return NULL; +} // end XMLTreeDescendentNamed: + diff --git a/OSX/iMoodUpdater.h b/OSX/iMoodUpdater.h new file mode 100644 index 0000000..92f6087 --- /dev/null +++ b/OSX/iMoodUpdater.h @@ -0,0 +1,18 @@ +/* iMoodUpdater */ + +#import + +@interface iMoodUpdater : NSObject +{ + IBOutlet id face; + IBOutlet id mood; + IBOutlet id pMood; + IBOutlet id pass; + IBOutlet id adv; + IBOutlet id userID; + IBOutlet id moodList; + IBOutlet id moodTextList; +} + +- (IBAction)iMoodUpdater:(id)sender; +@end diff --git a/OSX/iMoodUpdater.m b/OSX/iMoodUpdater.m new file mode 100644 index 0000000..748a319 --- /dev/null +++ b/OSX/iMoodUpdater.m @@ -0,0 +1,127 @@ +#import "iMoodUpdater.h" +#import "XMLTree.h" +#include + +#define preferences [NSUserDefaults standardUserDefaults] + +@implementation iMoodUpdater + +- (IBAction)iMoodUpdater:(id)sender +{ + // Put data from app into usable variables + int iFace = [face selectedTag]; + NSString *lMood = @"happy"; + char *crypt(); + char passwd[256]; + char salt[3]; + char rndChar[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789./"; + + // Setup the salt for crypt() + srandom(time(0)); + salt[0] = rndChar[random() %64]; + salt[1] = rndChar[random() &64]; + salt[3] = 0; + + if ([[preferences stringForKey:@"Advanced"] compare:@"1"]) + { + lMood = [moodList titleOfSelectedItem]; + } + else + { + lMood = [moodTextList stringValue]; + } + + // Setup the URL to goto to update the mood for given user. + NSString *tempURL = @"http://xml.imood.org/update.cgi?email="; + tempURL = [tempURL stringByAppendingString:[preferences stringForKey:@"UserID"]]; + tempURL = [tempURL stringByAppendingString:@"&crypt=1"]; + tempURL = [tempURL stringByAppendingString:@"&password="]; + // Crypt the password + [[preferences stringForKey:@"Password"] getCString:passwd]; + tempURL = [tempURL stringByAppendingString:[NSString stringWithFormat:@"%s",crypt(passwd, salt)]]; + tempURL = [tempURL stringByAppendingString:@"&base="]; + tempURL = [tempURL stringByAppendingString:lMood]; + tempURL = [tempURL stringByAppendingString:@"&face="]; + tempURL = [tempURL stringByAppendingFormat:@"%d",iFace]; + tempURL = [tempURL stringByAppendingString:@"&personal="]; + tempURL = [tempURL stringByAppendingString:[pMood stringValue]]; + tempURL = (NSString *) CFURLCreateStringByAddingPercentEscapes(NULL,(CFStringRef)tempURL,NULL, NULL,kCFStringEncodingUTF8); + [tempURL retain]; + //NSLog(tempURL); + + XMLTree *errorXML = [[[XMLTree alloc] initWithURL:[NSURL URLWithString:tempURL]] retain]; + NSString *errorMsg = [NSString stringWithFormat: @"%@", [errorXML descendentNamed:@"error"]]; + NSRunAlertPanel(@"iMood Updater",errorMsg,@"OK",NULL,NULL); +} + + +- (void)awakeFromNib +{ + if ([preferences stringForKey:@"UserID"] == nil) + { + [preferences setObject:@"" forKey:@"UserID"]; + [preferences setObject:@"" forKey:@"Password"]; + NSRunAlertPanel(@"No Account Info Found",@"Please go into preferences and set your account info.",@"OK", NULL, NULL); + } + else + { + [userID setStringValue:[preferences stringForKey:@"UserID"]]; + [pass setStringValue:[preferences stringForKey:@"Password"]]; + + + if ([preferences stringForKey:@"Advanced"] == nil) + { + [preferences setObject:[adv stringValue] forKey:@"Advanced"]; + } + else + { + [adv setStringValue:[preferences stringForKey:@"Advanced"]]; + } + } + + if ([[preferences stringForKey:@"Advanced"] compare:@"1"]) + { + NSDictionary *moodsDict = [NSDictionary dictionaryWithContentsOfURL: + [NSURL URLWithString:@"http://dev.sdf1.net/moods.xml"]]; + NSArray *moods = [moodsDict valueForKey:@"Moods"]; + NSLog(@"Number of moods found in XML: %d",[moods count]); + + [moodTextList removeFromSuperview]; + [moodList addItemsWithTitles:moods]; + [moodList removeItemAtIndex:0]; + [moodList selectItemAtIndex:0]; + } + else + { + [moodList removeFromSuperview]; + } + + [[mood window] makeKeyAndOrderFront:self]; + [moodTextList selectText:self]; + [userID selectText:self]; +} + +- (void)setMoodPrefs:(id)sender; +{ + [preferences setObject:[userID stringValue] forKey:@"UserID"]; + [preferences setObject:[pass stringValue] forKey:@"Password"]; + [preferences setObject:[adv stringValue] forKey:@"Advanced"]; + [[userID window] performClose:self]; +} + +- (void)goiMoodURL:(id)sender; +{ + [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://my.imood.com"]]; +} + +- (void)goDEVSDF1:(id)sender; +{ + [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://dev.sdf1.net"]]; +} + +- (void)goDonate:(id)sender; +{ + [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://dev.sdf1.net/donate.html"]]; +} + +@end \ No newline at end of file diff --git a/OSX/iMoodUpdater.pbproj/project.pbxproj b/OSX/iMoodUpdater.pbproj/project.pbxproj new file mode 100644 index 0000000..abb97d2 --- /dev/null +++ b/OSX/iMoodUpdater.pbproj/project.pbxproj @@ -0,0 +1,1018 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 39; + objects = { + 080E96DCFE201CFB7F000001 = { + fileRef = 29B97318FDCFA39411CA2CEA; + isa = PBXBuildFile; + settings = { + }; + }; + 080E96DDFE201D6D7F000001 = { + children = ( + CC12CA75044734C2002CDE91, + CC12CA6C04473407002CDE91, + 29B97316FDCFA39411CA2CEA, + CCFB7AA8043E231D005CDF0D, + CC95CD6C04F79E8A002032FD, + CCFB7AA9043E231D005CDF0D, + ); + isa = PBXGroup; + name = Classes; + refType = 4; + sourceTree = ""; + }; + 089C165CFE840E0CC02AAC07 = { + children = ( + 089C165DFE840E0CC02AAC07, + ); + isa = PBXVariantGroup; + name = InfoPlist.strings; + refType = 4; + sourceTree = ""; + }; + 089C165DFE840E0CC02AAC07 = { + expectedFileType = text.plist.strings; + fileEncoding = 10; + isa = PBXFileReference; + name = English; + path = English.lproj/InfoPlist.strings; + refType = 4; + sourceTree = ""; + }; + 089C165EFE840E0CC02AAC07 = { + fileRef = 089C165CFE840E0CC02AAC07; + isa = PBXBuildFile; + settings = { + }; + }; +//080 +//081 +//082 +//083 +//084 +//100 +//101 +//102 +//103 +//104 + 1058C7A0FEA54F0111CA2CBB = { + children = ( + 1058C7A1FEA54F0111CA2CBB, + ); + isa = PBXGroup; + name = "Linked Frameworks"; + refType = 4; + sourceTree = ""; + }; + 1058C7A1FEA54F0111CA2CBB = { + expectedFileType = wrapper.framework; + fallbackIsa = PBXFileReference; + isa = PBXFrameworkReference; + name = Cocoa.framework; + path = /System/Library/Frameworks/Cocoa.framework; + refType = 0; + sourceTree = ""; + }; + 1058C7A2FEA54F0111CA2CBB = { + children = ( + 29B97325FDCFA39411CA2CEA, + 29B97324FDCFA39411CA2CEA, + ); + isa = PBXGroup; + name = "Other Frameworks"; + refType = 4; + sourceTree = ""; + }; + 1058C7A3FEA54F0111CA2CBB = { + fileRef = 1058C7A1FEA54F0111CA2CBB; + isa = PBXBuildFile; + settings = { + }; + }; +//100 +//101 +//102 +//103 +//104 +//170 +//171 +//172 +//173 +//174 + 17587328FF379C6511CA2CBB = { + expectedFileType = wrapper.application; + fallbackIsa = PBXFileReference; + isa = PBXApplicationReference; + path = "iMood Updater.app"; + refType = 3; + sourceTree = BUILT_PRODUCTS_DIR; + }; +//170 +//171 +//172 +//173 +//174 +//190 +//191 +//192 +//193 +//194 + 19C28FACFE9D520D11CA2CBB = { + children = ( + 17587328FF379C6511CA2CBB, + ); + isa = PBXGroup; + name = Products; + refType = 4; + sourceTree = ""; + }; +//190 +//191 +//192 +//193 +//194 +//290 +//291 +//292 +//293 +//294 + 29B97313FDCFA39411CA2CEA = { + buildStyles = ( + 4A9504CCFFE6A4B311CA0CBA, + 4A9504CDFFE6A4B311CA0CBA, + ); + hasScannedForEncodings = 1; + isa = PBXProject; + mainGroup = 29B97314FDCFA39411CA2CEA; + projectDirPath = ""; + targets = ( + 29B97326FDCFA39411CA2CEA, + ); + }; + 29B97314FDCFA39411CA2CEA = { + children = ( + 080E96DDFE201D6D7F000001, + 29B97317FDCFA39411CA2CEA, + 29B97323FDCFA39411CA2CEA, + 19C28FACFE9D520D11CA2CBB, + ); + isa = PBXGroup; + name = iMoodUpdater; + path = ""; + refType = 4; + sourceTree = ""; + }; + 29B97316FDCFA39411CA2CEA = { + expectedFileType = sourcecode.c.objc; + fileEncoding = 30; + isa = PBXFileReference; + path = main.m; + refType = 4; + sourceTree = ""; + }; + 29B97317FDCFA39411CA2CEA = { + children = ( + CC4C73FA04FFA54D00A1B3B3, + F5A7328C04422F8C0134A0D8, + 29B97318FDCFA39411CA2CEA, + 089C165CFE840E0CC02AAC07, + ); + isa = PBXGroup; + name = Resources; + path = ""; + refType = 4; + sourceTree = ""; + }; + 29B97318FDCFA39411CA2CEA = { + children = ( + 29B97319FDCFA39411CA2CEA, + ); + isa = PBXVariantGroup; + name = MainMenu.nib; + path = ""; + refType = 4; + sourceTree = ""; + }; + 29B97319FDCFA39411CA2CEA = { + expectedFileType = wrapper.nib; + isa = PBXFileReference; + name = English; + path = English.lproj/MainMenu.nib; + refType = 4; + sourceTree = ""; + }; + 29B97323FDCFA39411CA2CEA = { + children = ( + 1058C7A0FEA54F0111CA2CBB, + 1058C7A2FEA54F0111CA2CBB, + ); + isa = PBXGroup; + name = Frameworks; + path = ""; + refType = 4; + sourceTree = ""; + }; + 29B97324FDCFA39411CA2CEA = { + expectedFileType = wrapper.framework; + fallbackIsa = PBXFileReference; + isa = PBXFrameworkReference; + name = AppKit.framework; + path = /System/Library/Frameworks/AppKit.framework; + refType = 0; + sourceTree = ""; + }; + 29B97325FDCFA39411CA2CEA = { + expectedFileType = wrapper.framework; + fallbackIsa = PBXFileReference; + isa = PBXFrameworkReference; + name = Foundation.framework; + path = /System/Library/Frameworks/Foundation.framework; + refType = 0; + sourceTree = ""; + }; + 29B97326FDCFA39411CA2CEA = { + buildPhases = ( + 29B97327FDCFA39411CA2CEA, + 29B97328FDCFA39411CA2CEA, + 29B9732BFDCFA39411CA2CEA, + 29B9732DFDCFA39411CA2CEA, + ); + buildSettings = { + DEBUGGING_SYMBOLS = NO; + FRAMEWORK_SEARCH_PATHS = ""; + HEADER_SEARCH_PATHS = ""; + INSTALL_PATH = "$(HOME)/Applications"; + LIBRARY_SEARCH_PATHS = ""; + OPTIMIZATION_CFLAGS = "-O3"; + OTHER_CFLAGS = ""; + OTHER_LDFLAGS = ""; + PRECOMPILE_PREFIX_HEADER = YES; + PREFIX_HEADER = iMoodUpdater_Prefix.h; + PRODUCT_NAME = "iMood Updater"; + PROFILING_CODE = YES; + SECTORDER_FLAGS = ""; + WARNING_CFLAGS = "-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"; + WRAPPER_EXTENSION = app; + }; + dependencies = ( + ); + isa = PBXApplicationTarget; + name = iMoodUpdater; + productInstallPath = "$(HOME)/Applications"; + productName = iMoodUpdater; + productReference = 17587328FF379C6511CA2CBB; + productSettingsXML = " + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + iMood Updater + CFBundleGetInfoString + 1.52 + CFBundleIconFile + imood + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + iMood Updater + CFBundlePackageType + APPL + CFBundleShortVersionString + iMood Updater v1.52 + CFBundleSignature + ???? + CFBundleVersion + 1.52 + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + +"; + }; + 29B97327FDCFA39411CA2CEA = { + buildActionMask = 2147483647; + files = ( + CCFB7AAA043E231D005CDF0D, + CC12CA6D04473407002CDE91, + ); + isa = PBXHeadersBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 29B97328FDCFA39411CA2CEA = { + buildActionMask = 2147483647; + files = ( + 080E96DCFE201CFB7F000001, + 089C165EFE840E0CC02AAC07, + CC4C73D704FFA53400A1B3B3, + CC4C73D804FFA53400A1B3B3, + CC4C73D904FFA53400A1B3B3, + CC4C73DA04FFA53400A1B3B3, + CC4C73DB04FFA53400A1B3B3, + CC4C73DC04FFA53400A1B3B3, + CC4C73DD04FFA53400A1B3B3, + CC4C73DE04FFA53400A1B3B3, + CC4C73DF04FFA53400A1B3B3, + CC4C73E004FFA53400A1B3B3, + CC4C73E104FFA53400A1B3B3, + CC4C73E204FFA53400A1B3B3, + CC4C73E304FFA53400A1B3B3, + CC4C73E404FFA53400A1B3B3, + CC4C73E504FFA53400A1B3B3, + CC4C73E604FFA53400A1B3B3, + CC4C73E704FFA53400A1B3B3, + CC4C73E804FFA53400A1B3B3, + CC4C73E904FFA53400A1B3B3, + CC4C73EA04FFA53400A1B3B3, + CC4C73EB04FFA53400A1B3B3, + CC4C73EC04FFA53400A1B3B3, + CC4C73ED04FFA53400A1B3B3, + CC4C73EE04FFA53400A1B3B3, + CC4C73EF04FFA53400A1B3B3, + CC4C73F004FFA53400A1B3B3, + CC4C73F104FFA53400A1B3B3, + CC4C73F204FFA53400A1B3B3, + CC4C73F304FFA53400A1B3B3, + CC4C73F404FFA53400A1B3B3, + CC4C73F504FFA53400A1B3B3, + CC4C73F604FFA53400A1B3B3, + CC4C73F704FFA53400A1B3B3, + CC4C73FB04FFA54D00A1B3B3, + ); + isa = PBXResourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 29B9732BFDCFA39411CA2CEA = { + buildActionMask = 2147483647; + files = ( + 29B9732CFDCFA39411CA2CEA, + CC12CA76044734C2002CDE91, + CC95CD6D04F79E8A002032FD, + ); + isa = PBXSourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 29B9732CFDCFA39411CA2CEA = { + fileRef = 29B97316FDCFA39411CA2CEA; + isa = PBXBuildFile; + settings = { + ATTRIBUTES = ( + ); + }; + }; + 29B9732DFDCFA39411CA2CEA = { + buildActionMask = 2147483647; + files = ( + 1058C7A3FEA54F0111CA2CBB, + ); + isa = PBXFrameworksBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; +//290 +//291 +//292 +//293 +//294 +//4A0 +//4A1 +//4A2 +//4A3 +//4A4 + 4A9504CCFFE6A4B311CA0CBA = { + buildRules = ( + ); + buildSettings = { + COPY_PHASE_STRIP = NO; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_FIX_AND_CONTINUE = YES; + GCC_GENERATE_DEBUGGING_SYMBOLS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + OPTIMIZATION_CFLAGS = "-O0"; + ZERO_LINK = YES; + }; + isa = PBXBuildStyle; + name = Development; + }; + 4A9504CDFFE6A4B311CA0CBA = { + buildRules = ( + ); + buildSettings = { + COPY_PHASE_STRIP = YES; + GCC_ENABLE_FIX_AND_CONTINUE = NO; + ZERO_LINK = NO; + }; + isa = PBXBuildStyle; + name = Deployment; + }; +//4A0 +//4A1 +//4A2 +//4A3 +//4A4 +//CC0 +//CC1 +//CC2 +//CC3 +//CC4 + CC12CA6C04473407002CDE91 = { + expectedFileType = sourcecode.c.h; + fileEncoding = 30; + isa = PBXFileReference; + path = XMLTree.h; + refType = 4; + sourceTree = ""; + }; + CC12CA6D04473407002CDE91 = { + fileRef = CC12CA6C04473407002CDE91; + isa = PBXBuildFile; + settings = { + }; + }; + CC12CA75044734C2002CDE91 = { + expectedFileType = sourcecode.c.objc; + fileEncoding = 30; + isa = PBXFileReference; + path = XMLTree.m; + refType = 4; + sourceTree = ""; + }; + CC12CA76044734C2002CDE91 = { + fileRef = CC12CA75044734C2002CDE91; + isa = PBXBuildFile; + settings = { + }; + }; + CC4C73B604FFA53400A1B3B3 = { + expectedFileType = image.gif; + isa = PBXFileReference; + name = 31.gif; + path = Resources/images/31.gif; + refType = 4; + sourceTree = ""; + }; + CC4C73B704FFA53400A1B3B3 = { + expectedFileType = image.gif; + isa = PBXFileReference; + name = 15.gif; + path = Resources/images/15.gif; + refType = 4; + sourceTree = ""; + }; + CC4C73B804FFA53400A1B3B3 = { + expectedFileType = image.gif; + isa = PBXFileReference; + name = 04.gif; + path = Resources/images/04.gif; + refType = 4; + sourceTree = ""; + }; + CC4C73B904FFA53400A1B3B3 = { + expectedFileType = image.gif; + isa = PBXFileReference; + name = 20.gif; + path = Resources/images/20.gif; + refType = 4; + sourceTree = ""; + }; + CC4C73BA04FFA53400A1B3B3 = { + expectedFileType = image.gif; + isa = PBXFileReference; + name = 18.gif; + path = Resources/images/18.gif; + refType = 4; + sourceTree = ""; + }; + CC4C73BB04FFA53400A1B3B3 = { + expectedFileType = image.gif; + isa = PBXFileReference; + name = 07.gif; + path = Resources/images/07.gif; + refType = 4; + sourceTree = ""; + }; + CC4C73BC04FFA53400A1B3B3 = { + expectedFileType = image.gif; + isa = PBXFileReference; + name = 28.gif; + path = Resources/images/28.gif; + refType = 4; + sourceTree = ""; + }; + CC4C73BD04FFA53400A1B3B3 = { + expectedFileType = image.gif; + isa = PBXFileReference; + name = 12.gif; + path = Resources/images/12.gif; + refType = 4; + sourceTree = ""; + }; + CC4C73BE04FFA53400A1B3B3 = { + expectedFileType = image.gif; + isa = PBXFileReference; + name = 03.gif; + path = Resources/images/03.gif; + refType = 4; + sourceTree = ""; + }; + CC4C73BF04FFA53400A1B3B3 = { + expectedFileType = image.gif; + isa = PBXFileReference; + name = 24.gif; + path = Resources/images/24.gif; + refType = 4; + sourceTree = ""; + }; + CC4C73C004FFA53400A1B3B3 = { + expectedFileType = image.gif; + isa = PBXFileReference; + name = 10.gif; + path = Resources/images/10.gif; + refType = 4; + sourceTree = ""; + }; + CC4C73C104FFA53400A1B3B3 = { + expectedFileType = image.gif; + isa = PBXFileReference; + name = 22.gif; + path = Resources/images/22.gif; + refType = 4; + sourceTree = ""; + }; + CC4C73C204FFA53400A1B3B3 = { + expectedFileType = image.gif; + isa = PBXFileReference; + name = 01.gif; + path = Resources/images/01.gif; + refType = 4; + sourceTree = ""; + }; + CC4C73C304FFA53400A1B3B3 = { + expectedFileType = image.gif; + isa = PBXFileReference; + name = 30.gif; + path = Resources/images/30.gif; + refType = 4; + sourceTree = ""; + }; + CC4C73C404FFA53400A1B3B3 = { + expectedFileType = image.gif; + isa = PBXFileReference; + name = 14.gif; + path = Resources/images/14.gif; + refType = 4; + sourceTree = ""; + }; + CC4C73C504FFA53400A1B3B3 = { + expectedFileType = image.gif; + isa = PBXFileReference; + name = 26.gif; + path = Resources/images/26.gif; + refType = 4; + sourceTree = ""; + }; + CC4C73C604FFA53400A1B3B3 = { + expectedFileType = image.gif; + isa = PBXFileReference; + name = 06.gif; + path = Resources/images/06.gif; + refType = 4; + sourceTree = ""; + }; + CC4C73C704FFA53400A1B3B3 = { + expectedFileType = image.gif; + isa = PBXFileReference; + name = 17.gif; + path = Resources/images/17.gif; + refType = 4; + sourceTree = ""; + }; + CC4C73C804FFA53400A1B3B3 = { + expectedFileType = image.gif; + isa = PBXFileReference; + name = 27.gif; + path = Resources/images/27.gif; + refType = 4; + sourceTree = ""; + }; + CC4C73C904FFA53400A1B3B3 = { + expectedFileType = image.gif; + isa = PBXFileReference; + name = 11.gif; + path = Resources/images/11.gif; + refType = 4; + sourceTree = ""; + }; + CC4C73CA04FFA53400A1B3B3 = { + expectedFileType = image.gif; + isa = PBXFileReference; + name = 23.gif; + path = Resources/images/23.gif; + refType = 4; + sourceTree = ""; + }; + CC4C73CB04FFA53400A1B3B3 = { + expectedFileType = image.gif; + isa = PBXFileReference; + name = 09.gif; + path = Resources/images/09.gif; + refType = 4; + sourceTree = ""; + }; + CC4C73CC04FFA53400A1B3B3 = { + expectedFileType = image.gif; + isa = PBXFileReference; + name = 32.gif; + path = Resources/images/32.gif; + refType = 4; + sourceTree = ""; + }; + CC4C73CD04FFA53400A1B3B3 = { + expectedFileType = image.gif; + isa = PBXFileReference; + name = 00.gif; + path = Resources/images/00.gif; + refType = 4; + sourceTree = ""; + }; + CC4C73CE04FFA53400A1B3B3 = { + expectedFileType = image.gif; + isa = PBXFileReference; + name = 21.gif; + path = Resources/images/21.gif; + refType = 4; + sourceTree = ""; + }; + CC4C73CF04FFA53400A1B3B3 = { + expectedFileType = image.gif; + isa = PBXFileReference; + name = 05.gif; + path = Resources/images/05.gif; + refType = 4; + sourceTree = ""; + }; + CC4C73D004FFA53400A1B3B3 = { + expectedFileType = image.gif; + isa = PBXFileReference; + name = 02.gif; + path = Resources/images/02.gif; + refType = 4; + sourceTree = ""; + }; + CC4C73D104FFA53400A1B3B3 = { + expectedFileType = image.gif; + isa = PBXFileReference; + name = 19.gif; + path = Resources/images/19.gif; + refType = 4; + sourceTree = ""; + }; + CC4C73D204FFA53400A1B3B3 = { + expectedFileType = image.gif; + isa = PBXFileReference; + name = 13.gif; + path = Resources/images/13.gif; + refType = 4; + sourceTree = ""; + }; + CC4C73D304FFA53400A1B3B3 = { + expectedFileType = image.gif; + isa = PBXFileReference; + name = 08.gif; + path = Resources/images/08.gif; + refType = 4; + sourceTree = ""; + }; + CC4C73D404FFA53400A1B3B3 = { + expectedFileType = image.gif; + isa = PBXFileReference; + name = 25.gif; + path = Resources/images/25.gif; + refType = 4; + sourceTree = ""; + }; + CC4C73D504FFA53400A1B3B3 = { + expectedFileType = image.gif; + isa = PBXFileReference; + name = 29.gif; + path = Resources/images/29.gif; + refType = 4; + sourceTree = ""; + }; + CC4C73D604FFA53400A1B3B3 = { + expectedFileType = image.gif; + isa = PBXFileReference; + name = 16.gif; + path = Resources/images/16.gif; + refType = 4; + sourceTree = ""; + }; + CC4C73D704FFA53400A1B3B3 = { + fileRef = CC4C73B604FFA53400A1B3B3; + isa = PBXBuildFile; + settings = { + }; + }; + CC4C73D804FFA53400A1B3B3 = { + fileRef = CC4C73B704FFA53400A1B3B3; + isa = PBXBuildFile; + settings = { + }; + }; + CC4C73D904FFA53400A1B3B3 = { + fileRef = CC4C73B804FFA53400A1B3B3; + isa = PBXBuildFile; + settings = { + }; + }; + CC4C73DA04FFA53400A1B3B3 = { + fileRef = CC4C73B904FFA53400A1B3B3; + isa = PBXBuildFile; + settings = { + }; + }; + CC4C73DB04FFA53400A1B3B3 = { + fileRef = CC4C73BA04FFA53400A1B3B3; + isa = PBXBuildFile; + settings = { + }; + }; + CC4C73DC04FFA53400A1B3B3 = { + fileRef = CC4C73BB04FFA53400A1B3B3; + isa = PBXBuildFile; + settings = { + }; + }; + CC4C73DD04FFA53400A1B3B3 = { + fileRef = CC4C73BC04FFA53400A1B3B3; + isa = PBXBuildFile; + settings = { + }; + }; + CC4C73DE04FFA53400A1B3B3 = { + fileRef = CC4C73BD04FFA53400A1B3B3; + isa = PBXBuildFile; + settings = { + }; + }; + CC4C73DF04FFA53400A1B3B3 = { + fileRef = CC4C73BE04FFA53400A1B3B3; + isa = PBXBuildFile; + settings = { + }; + }; + CC4C73E004FFA53400A1B3B3 = { + fileRef = CC4C73BF04FFA53400A1B3B3; + isa = PBXBuildFile; + settings = { + }; + }; + CC4C73E104FFA53400A1B3B3 = { + fileRef = CC4C73C004FFA53400A1B3B3; + isa = PBXBuildFile; + settings = { + }; + }; + CC4C73E204FFA53400A1B3B3 = { + fileRef = CC4C73C104FFA53400A1B3B3; + isa = PBXBuildFile; + settings = { + }; + }; + CC4C73E304FFA53400A1B3B3 = { + fileRef = CC4C73C204FFA53400A1B3B3; + isa = PBXBuildFile; + settings = { + }; + }; + CC4C73E404FFA53400A1B3B3 = { + fileRef = CC4C73C304FFA53400A1B3B3; + isa = PBXBuildFile; + settings = { + }; + }; + CC4C73E504FFA53400A1B3B3 = { + fileRef = CC4C73C404FFA53400A1B3B3; + isa = PBXBuildFile; + settings = { + }; + }; + CC4C73E604FFA53400A1B3B3 = { + fileRef = CC4C73C504FFA53400A1B3B3; + isa = PBXBuildFile; + settings = { + }; + }; + CC4C73E704FFA53400A1B3B3 = { + fileRef = CC4C73C604FFA53400A1B3B3; + isa = PBXBuildFile; + settings = { + }; + }; + CC4C73E804FFA53400A1B3B3 = { + fileRef = CC4C73C704FFA53400A1B3B3; + isa = PBXBuildFile; + settings = { + }; + }; + CC4C73E904FFA53400A1B3B3 = { + fileRef = CC4C73C804FFA53400A1B3B3; + isa = PBXBuildFile; + settings = { + }; + }; + CC4C73EA04FFA53400A1B3B3 = { + fileRef = CC4C73C904FFA53400A1B3B3; + isa = PBXBuildFile; + settings = { + }; + }; + CC4C73EB04FFA53400A1B3B3 = { + fileRef = CC4C73CA04FFA53400A1B3B3; + isa = PBXBuildFile; + settings = { + }; + }; + CC4C73EC04FFA53400A1B3B3 = { + fileRef = CC4C73CB04FFA53400A1B3B3; + isa = PBXBuildFile; + settings = { + }; + }; + CC4C73ED04FFA53400A1B3B3 = { + fileRef = CC4C73CC04FFA53400A1B3B3; + isa = PBXBuildFile; + settings = { + }; + }; + CC4C73EE04FFA53400A1B3B3 = { + fileRef = CC4C73CD04FFA53400A1B3B3; + isa = PBXBuildFile; + settings = { + }; + }; + CC4C73EF04FFA53400A1B3B3 = { + fileRef = CC4C73CE04FFA53400A1B3B3; + isa = PBXBuildFile; + settings = { + }; + }; + CC4C73F004FFA53400A1B3B3 = { + fileRef = CC4C73CF04FFA53400A1B3B3; + isa = PBXBuildFile; + settings = { + }; + }; + CC4C73F104FFA53400A1B3B3 = { + fileRef = CC4C73D004FFA53400A1B3B3; + isa = PBXBuildFile; + settings = { + }; + }; + CC4C73F204FFA53400A1B3B3 = { + fileRef = CC4C73D104FFA53400A1B3B3; + isa = PBXBuildFile; + settings = { + }; + }; + CC4C73F304FFA53400A1B3B3 = { + fileRef = CC4C73D204FFA53400A1B3B3; + isa = PBXBuildFile; + settings = { + }; + }; + CC4C73F404FFA53400A1B3B3 = { + fileRef = CC4C73D304FFA53400A1B3B3; + isa = PBXBuildFile; + settings = { + }; + }; + CC4C73F504FFA53400A1B3B3 = { + fileRef = CC4C73D404FFA53400A1B3B3; + isa = PBXBuildFile; + settings = { + }; + }; + CC4C73F604FFA53400A1B3B3 = { + fileRef = CC4C73D504FFA53400A1B3B3; + isa = PBXBuildFile; + settings = { + }; + }; + CC4C73F704FFA53400A1B3B3 = { + fileRef = CC4C73D604FFA53400A1B3B3; + isa = PBXBuildFile; + settings = { + }; + }; + CC4C73FA04FFA54D00A1B3B3 = { + expectedFileType = image.icns; + isa = PBXFileReference; + name = imood.icns; + path = Resources/imood.icns; + refType = 4; + sourceTree = ""; + }; + CC4C73FB04FFA54D00A1B3B3 = { + fileRef = CC4C73FA04FFA54D00A1B3B3; + isa = PBXBuildFile; + settings = { + }; + }; + CC95CD6C04F79E8A002032FD = { + expectedFileType = sourcecode.c.objc; + fileEncoding = 30; + isa = PBXFileReference; + path = iMoodUpdater.m; + refType = 4; + sourceTree = ""; + }; + CC95CD6D04F79E8A002032FD = { + fileRef = CC95CD6C04F79E8A002032FD; + isa = PBXBuildFile; + settings = { + }; + }; + CCFB7AA8043E231D005CDF0D = { + expectedFileType = sourcecode.c.h; + fileEncoding = 30; + isa = PBXFileReference; + path = iMoodUpdater.h; + refType = 4; + sourceTree = ""; + }; + CCFB7AA9043E231D005CDF0D = { + expectedFileType = sourcecode.c.objc; + fileEncoding = 30; + isa = PBXFileReference; + name = iMoodUpdater.m; + path = /Users/thrawn/Sandbox/dev/iMoodUpdater.m; + refType = 0; + sourceTree = ""; + }; + CCFB7AAA043E231D005CDF0D = { + fileRef = CCFB7AA8043E231D005CDF0D; + isa = PBXBuildFile; + settings = { + }; + }; +//CC0 +//CC1 +//CC2 +//CC3 +//CC4 +//F50 +//F51 +//F52 +//F53 +//F54 + F5A7328C04422F8C0134A0D8 = { + children = ( + CC4C73B604FFA53400A1B3B3, + CC4C73B704FFA53400A1B3B3, + CC4C73B804FFA53400A1B3B3, + CC4C73B904FFA53400A1B3B3, + CC4C73BA04FFA53400A1B3B3, + CC4C73BB04FFA53400A1B3B3, + CC4C73BC04FFA53400A1B3B3, + CC4C73BD04FFA53400A1B3B3, + CC4C73BE04FFA53400A1B3B3, + CC4C73BF04FFA53400A1B3B3, + CC4C73C004FFA53400A1B3B3, + CC4C73C104FFA53400A1B3B3, + CC4C73C204FFA53400A1B3B3, + CC4C73C304FFA53400A1B3B3, + CC4C73C404FFA53400A1B3B3, + CC4C73C504FFA53400A1B3B3, + CC4C73C604FFA53400A1B3B3, + CC4C73C704FFA53400A1B3B3, + CC4C73C804FFA53400A1B3B3, + CC4C73C904FFA53400A1B3B3, + CC4C73CA04FFA53400A1B3B3, + CC4C73CB04FFA53400A1B3B3, + CC4C73CC04FFA53400A1B3B3, + CC4C73CD04FFA53400A1B3B3, + CC4C73CE04FFA53400A1B3B3, + CC4C73CF04FFA53400A1B3B3, + CC4C73D004FFA53400A1B3B3, + CC4C73D104FFA53400A1B3B3, + CC4C73D204FFA53400A1B3B3, + CC4C73D304FFA53400A1B3B3, + CC4C73D404FFA53400A1B3B3, + CC4C73D504FFA53400A1B3B3, + CC4C73D604FFA53400A1B3B3, + ); + isa = PBXGroup; + name = images; + refType = 4; + sourceTree = ""; + }; + }; + rootObject = 29B97313FDCFA39411CA2CEA; +} diff --git a/OSX/iMoodUpdater_Prefix.h b/OSX/iMoodUpdater_Prefix.h new file mode 100644 index 0000000..ae671b7 --- /dev/null +++ b/OSX/iMoodUpdater_Prefix.h @@ -0,0 +1,7 @@ +// +// Prefix header for all source files of the 'iMoodUpdater' target in the 'iMoodUpdater' project +// + +#ifdef __OBJC__ + #import +#endif diff --git a/OSX/main.m b/OSX/main.m new file mode 100644 index 0000000..a42e30d --- /dev/null +++ b/OSX/main.m @@ -0,0 +1,35 @@ +/* +iMood Updater - Updates your internet mood (imood.com). +Copyright (C) 2003 RiSC, and SDF1 Networks +-------------------------------------------------------------------------- +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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +GNU License @ http://www.gnu.org/copyleft/gpl.htm + +iMood Updater version .9 build 14, Copyright (C) 2003 RiSC, and SDF1 Networks +iMood Updater comes with ABSOLUTELY NO WARRANTY +-------------------------------------------------------------------------- +Requirements: + Mac OS X 10.2 +-------------------------------------------------------------------------- +*/ + +#import + +int main(int argc, const char *argv[]) +{ + return NSApplicationMain(argc, argv); +} + diff --git a/cmdline/README b/cmdline/README new file mode 100644 index 0000000..13b656d --- /dev/null +++ b/cmdline/README @@ -0,0 +1,36 @@ +iMood Updater 0.9 - Updates your internet mood (imood.com). +Copyright (C) 2003 RiSC, and SDF1 Networks +-------------------------------------------------------------------------- +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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +GNU License @ http://www.gnu.org/copyleft/gpl.htm + +iMood Updater version 0.9, Copyright (C) 2003 RiSC, and SDF1 Networks +iMood Updater comes with ABSOLUTELY NO WARRANTY + +-------------------------------------------------------------------------- +Requirements: + - None +-------------------------------------------------------------------------- + +Known issues: + +- Must have a connection to the internet before running + +To-do list: + +- DES encryption of password being sent to iMood.com +- Better error handling +- Add personal mood diff --git a/cmdline/imoodupdater.c b/cmdline/imoodupdater.c new file mode 100644 index 0000000..35661cd --- /dev/null +++ b/cmdline/imoodupdater.c @@ -0,0 +1,93 @@ +/* +-------------------------------------------------------------------------- +iMood - Using www.imood.com's API we can change our web mood +Copyright (C) 2003 Rise In Superior Code & SDF1 Networks +-------------------------------------------------------------------------- +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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +GNU License @ http://www.gnu.org/copyleft/gpl.htm + +iMood version 1.0, Copyright (C) 2003 Rise In Superior Code & SDF1 Networks +iMood comes with ABSOLUTELY NO WARRANTY +*/ + +#include +#include +#include +#include +#include +#include +#include + +void iMoodSend(char **argv) +{ + char buffy[2048]; + int dstPort, sock, result; + struct sockaddr_in name; + struct hostent *hostinfo; + + dstPort = 80; + + hostinfo=gethostbyname("my.imood.com"); + if (!hostinfo){ + herror("Error"); exit(-1); + } + + name.sin_family=AF_INET; + name.sin_port=htons(dstPort); + name.sin_addr=*(struct in_addr *)hostinfo->h_addr; + sock=socket(AF_INET, SOCK_STREAM, 0); + result=connect(sock, (struct sockaddr *)&name, sizeof(struct sockaddr_in)); + if (result != 0) { + herror("Error"); + exit(-1); + } + + sock=socket(AF_INET, SOCK_STREAM, 0); + result=connect(sock, (struct sockaddr *)&name, sizeof(struct sockaddr_in)); + if (result != 0) { + herror("Error"); + exit(-1); + } + + strcpy(buffy, "GET /updater.cgi?action=update&new_mood="); + strncat(buffy,argv[3],256); + strcat(buffy,"&face="); + strncat(buffy,argv[4],2); + strcat(buffy," HTTP/1.1\r\n"); + strcat(buffy,"Host: www2.imood.com\r\n"); + strcat(buffy, "Cookie: imood_pass="); + strncat(buffy,argv[2],256); + strcat(buffy,"; imood_user="); + strncat(buffy,argv[1],256); + strcat(buffy,"\r\n\r\n"); + + send(sock, buffy, sizeof(buffy), 0); + + return; +} + +int main(int argc, char **argv) +{ + if (argc < 4 || argc > 5){ + printf ("\r\nUsage:\r\n%s UID PW Mood FaceID\r\n", argv[0]); + printf ("FaceID:\t0-32\r\nie: imood bob@bob.com myPass happy 0\r\n\r\n"); + exit(0); + } + + iMoodSend(argv); + printf ("\r\niMood Updated\r\n"); + return 0; +} \ No newline at end of file diff --git a/python/README b/python/README new file mode 100644 index 0000000..b710e15 --- /dev/null +++ b/python/README @@ -0,0 +1,44 @@ +iMood Updater 1.52-python - Updates your internet mood (imood.com). +Copyright (C) 2003 RiSC, and SDF1 Networks +-------------------------------------------------------------------------- +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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +GNU License @ http://www.gnu.org/copyleft/gpl.htm + +iMood Updater version 1.52-python, Copyright (C) 2003 RiSC, and SDF1 Networks +iMood Updater comes with ABSOLUTELY NO WARRANTY +-------------------------------------------------------------------------- +Requirements: + Python 2.2+ (python.org) + PyXML (PyXML.sf.net) + - Only if using source version +-------------------------------------------------------------------------- + +New in 1.52: + +- Added MD5 password encryption before sending to imood.com + +New in 1.51: + +- Ported over C code from the command line version +- Added error handling + +Known issues: + +- password is sent in plain text + +To-do list: + +- Add GUI diff --git a/python/imoodupdater.py b/python/imoodupdater.py new file mode 100644 index 0000000..920279d --- /dev/null +++ b/python/imoodupdater.py @@ -0,0 +1,95 @@ +""" +iMood Updater 1.52-python - Updates your internet mood (imood.com). +Copyright (C) 2003 RiSC, and SDF1 Networks +-------------------------------------------------------------------------- +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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +GNU License @ http://www.gnu.org/copyleft/gpl.htm + +iMood Updater version 1.52-python, Copyright (C) 2003 RiSC, and SDF1 Networks +iMood Updater comes with ABSOLUTELY NO WARRANTY +-------------------------------------------------------------------------- +Requirements: + Python 2.2+ (python.org) + PyXML (PyXML.sf.net) + - Only if using source version +-------------------------------------------------------------------------- +""" + +from xml.dom.ext.reader import Sax2 +from whrandom import choice +import httplib, urllib, sys, getopt, crypt, random, re, string + +def GenRandStr(length=8, chars=string.uppercase + string.lowercase + string.digits + "./"): + return ''.join([choice(chars) for i in range(length)]) + +def updateMood(userID, passwd, mood, face, pMood): + params = "email=" + userID + "&crypt=1" + "&password=" + passwd + "&base=" + mood + "&face=" + face + "&personal=" + pMood + + print params + try: + tempURL = "/update.cgi" + "?" + params + h = httplib.HTTP("xml.imood.org") + h.putrequest('GET', tempURL) + h.putheader('User-Agent', 'iMood Updater(python)') + h.putheader('Connection', 'close') + h.putheader('Host', 'xml.imood.org') + h.endheaders() + except Exception, reason: + print "Error: Could not contact imood.com" + sys.exit(2) + + try: + reply, msg, hdrs = h.getreply() + data = h.getfile().read() + + reader = Sax2.Reader() + doc_node = reader.fromString(data) + result = doc_node.documentElement.getElementsByTagName("error")[ 0] + print result.firstChild.data + except Exception, reason: + print "Warning: Bad data from imood.com, mood may not have been updated" + sys.exit(2) + +usage = "Usage: %s <\"mood\"> [\"personal mood\"]\n<> are required params, [] are optional" % sys.argv[0] + +try: + opts, args = getopt.getopt(sys.argv[1:], "h", ["help"]) +except getopt.error, msg: + print msg + print "for help use --help" + sys.exit(2) +for o, a in opts: + if o in ("-h", "--help"): + print usage; + sys.exit(0) + +try: + userID = sys.argv[1] + salt = GenRandStr() + passwd= crypt.crypt(sys.argv[2], salt) + mood = sys.argv[3] + face = sys.argv[4] +except IndexError: + print usage; + sys.exit(0) + +try: + pMood = sys.argv[5] +except IndexError: + pMood = "" + +print "Updateing your iMood..." +updateMood(userID, passwd, mood, face, pMood)