Skip to content

Commit

Permalink
Merge pull request #56 from olab-io/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
bakercp committed Jun 16, 2014
2 parents 5151483 + 3e321a7 commit ddc2bb9
Show file tree
Hide file tree
Showing 11 changed files with 152 additions and 51 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
- 0.1.5 (06-16-2014)
+ Server now sends available addons to client.
+ Updated default number of processors to match target machine cores on a make build.
+ Rewrote build scripts. Now works on all osx / linux.

- 0.1.4 (06-13-2014)
+ Added linux64 build.
+ Updated build script for linux64.
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ For ofSketch to work properly, the "Projects" folder __must__ be located in the

### Running Examples

Double-click ofSketch to open the editor. From there you can create, load, save, and run ofSketch projects. The projects folder comes with a few example projects to get a feel for the editor. Click the open folder icon to select a project. Press the play button to run a project.
Double-click ofSketch to open the editor.

_Note: If OSX does not allow you to open the program due to security restrictions, right click on the ofSketch.app bundle and click "open". See [this link](http://support.apple.com/kb/ht5290) for more information about Apple's security system._

From there you can create, load, save, and run ofSketch projects. The projects folder comes with a few example projects to get a feel for the editor. Click the open folder icon to select a project. Press the play button to run a project.

### Coding

Expand Down
4 changes: 4 additions & 0 deletions ofSketchApp/bin/data/DocumentRoot/js/ofSketch/ofSketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ $(document).ready( function()

checkVersion();
}
else if (evt.method == "addons")
{
console.log(evt.params);
}
else if (evt.method == "updateEditorSettings")
{

Expand Down
24 changes: 24 additions & 0 deletions ofSketchApp/src/Addon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,28 @@ namespace of {
namespace Sketch {


Addon::Addon(const std::string& name, const std::string& path):
_name(name),
_path(path)
{
}


Addon::~Addon()
{
}


const std::string& Addon::getName() const
{
return _name;
}


const std::string& Addon::getPath() const
{
return _path;
}


} } // namespace of::Sketch
15 changes: 9 additions & 6 deletions ofSketchApp/src/Addon.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,16 @@ class Addon
public:
typedef std::shared_ptr<Addon> SharedPtr;

Addon()
{
}
Addon(const std::string& name, const std::string& path);

virtual ~Addon()
{
}
virtual ~Addon();

const std::string& getName() const;
const std::string& getPath() const;

private:
std::string _name;
std::string _path;

};

Expand Down
93 changes: 66 additions & 27 deletions ofSketchApp/src/AddonManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,76 +36,115 @@ const std::string AddonManager::DEFAULT_ADDON_PATH = "addons/";
AddonManager::AddonManager(const std::string& path):
_path(path)
{
_addonWatcher.addPath(ofToDataPath(_path));
Poco::Path fullPath(ofToDataPath(_path, true));

std::vector<std::string> files;
Poco::File file(fullPath);

ofx::IO::DirectoryFilter filter;
if(!file.exists())
{
Poco::FileNotFoundException exc(fullPath.toString());
throw exc;
}

ofx::IO::DirectoryUtils::list(ofToDataPath(_path),
files,
true,
&filter);
std::vector<Poco::File> files;

std::vector<std::string>::iterator iter = files.begin();
ofx::IO::DirectoryUtils::list(file, files, true, &_directoryFilter);

// while(iter != files.end())
// {
// cout << *iter << endl;
// ++iter;
// }

}
std::vector<Poco::File>::iterator iter = files.begin();

while(iter != files.end())
{
std::string addonPath = (*iter).path();
std::string addonName = Poco::Path(addonPath).getBaseName();

AddonManager::~AddonManager()
{
}
_addons[addonName] = Addon::SharedPtr(new Addon(addonName, addonPath));

++iter;
}

void AddonManager::setup()
{
_addonWatcher.registerAllEvents(this);
_addonWatcher.addPath(fullPath.toString(),
false,
true,
&_directoryFilter);
}


void AddonManager::updateAddon(const Poco::URI& uri)
AddonManager::~AddonManager()
{
_addonWatcher.unregisterAllEvents(this);
}


void AddonManager::onDirectoryWatcherItemAdded(const Poco::DirectoryWatcher::DirectoryEvent& evt)
{
// ofSendMessage("Added: " + evt.item.path());
ofLogNotice("AddonManager::onDirectoryWatcherItemAdded") << evt.event << " " << evt.item.path();

std::string path = evt.item.path();
std::string name = Poco::Path(path).getBaseName();

_addons[name] = Addon::SharedPtr(new Addon(name, path));

}


void AddonManager::onDirectoryWatcherItemRemoved(const Poco::DirectoryWatcher::DirectoryEvent& evt)
{
// ofSendMessage("Removed: " + evt.item.path());
ofLogNotice("AddonManager::onDirectoryWatcherItemRemoved") << evt.event << " " << evt.item.path();

std::string path = evt.item.path();
std::string name = Poco::Path(path).getBaseName();

std::map<std::string, Addon::SharedPtr>::iterator iter = _addons.find(name);

if (iter != _addons.end())
{
_addons.erase(iter);
}
else
{
ofLogError("AddonManager::onDirectoryWatcherItemRemoved") << "Unable to find " << path;
}
}


void AddonManager::onDirectoryWatcherItemModified(const Poco::DirectoryWatcher::DirectoryEvent& evt)
{
// ofSendMessage("Modified: " + evt.item.path());
ofLogNotice("AddonManager::onDirectoryWatcherItemModified") << evt.event << " " << evt.item.path();
}


void AddonManager::onDirectoryWatcherItemMovedFrom(const Poco::DirectoryWatcher::DirectoryEvent& evt)
{
// ofLogNotice("ofApp::onDirectoryWatcherItemMovedFrom") << "Moved From: " << evt.item.path();
ofLogNotice("AddonManager::onDirectoryWatcherItemMovedFrom") << evt.event << " " << evt.item.path();
}


void AddonManager::onDirectoryWatcherItemMovedTo(const Poco::DirectoryWatcher::DirectoryEvent& evt)
{
// ofLogNotice("ofApp::onDirectoryWatcherItemMovedTo") << "Moved To: " << evt.item.path();
ofLogNotice("AddonManager::onDirectoryWatcherItemMovedTo") << evt.event << " " << evt.item.path();
}


void AddonManager::onDirectoryWatcherError(const Poco::Exception& exc)
{
// ofLogError("ofApp::onDirectoryWatcherError") << "Error: " << exc.displayText();
ofLogError("AddonManager::onDirectoryWatcherError") << exc.displayText();
}


std::vector<Addon::SharedPtr> AddonManager::getAddons() const
{
std::vector<Addon::SharedPtr> addons;

std::map<std::string, Addon::SharedPtr>::const_iterator iter = _addons.begin();

while (iter != _addons.end())
{
addons.push_back(iter->second);
++iter;
}

return addons;
}


Expand Down
15 changes: 4 additions & 11 deletions ofSketchApp/src/AddonManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,34 +44,27 @@ namespace Sketch {
class AddonManager
{
public:
typedef std::shared_ptr<AddonManager> SharedPtr;

AddonManager(const std::string& addonsPath);
virtual ~AddonManager();

void setup();

void updateAddon(const Poco::URI& uri);

void onDirectoryWatcherItemAdded(const Poco::DirectoryWatcher::DirectoryEvent& evt);
void onDirectoryWatcherItemRemoved(const Poco::DirectoryWatcher::DirectoryEvent& evt);
void onDirectoryWatcherItemModified(const Poco::DirectoryWatcher::DirectoryEvent& evt);
void onDirectoryWatcherItemMovedFrom(const Poco::DirectoryWatcher::DirectoryEvent& evt);
void onDirectoryWatcherItemMovedTo(const Poco::DirectoryWatcher::DirectoryEvent& evt);
void onDirectoryWatcherError(const Poco::Exception& exc);

static SharedPtr makeShared(const std::string& addonsPath)
{
return SharedPtr(new AddonManager(addonsPath));
}
std::vector<Addon::SharedPtr> getAddons() const;

static const std::string DEFAULT_ADDON_PATH;

private:
std::string _path;
std::set<Addon::SharedPtr> _addons;
std::map<std::string, Addon::SharedPtr> _addons;
ofx::IO::DirectoryWatcherManager _addonWatcher;

ofx::IO::DirectoryFilter _directoryFilter;

};


Expand Down
29 changes: 27 additions & 2 deletions ofSketchApp/src/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,8 @@ bool App::onWebSocketOpenEvent(HTTP::WebSocketOpenEventArgs& args)
// Send the update to the client that just connected.
args.getConnectionRef().sendFrame(frame);


// Send version info.
params.clear();
params["version"] = getVersion();
params["major"] = getVersionMajor();
params["minor"] = getVersionMinor();
Expand All @@ -385,7 +385,32 @@ bool App::onWebSocketOpenEvent(HTTP::WebSocketOpenEventArgs& args)
frame = ofx::HTTP::WebSocketFrame(App::toJSONString(json));

args.getConnectionRef().sendFrame(frame);


params.clear();

Json::Value addonsJSON;

std::vector<Addon::SharedPtr> addons = _addonManager.getAddons();

std::vector<Addon::SharedPtr>::const_iterator iter = addons.begin();

while (iter != addons.end())
{
Json::Value addon;
addon["name"] = (*iter)->getName();
addon["path"] = (*iter)->getPath();
addonsJSON.append(addon);
++iter;
}

params["addons"] = addonsJSON;

json = App::toJSONMethod("Server", "addons", params);
frame = ofx::HTTP::WebSocketFrame(App::toJSONString(json));

args.getConnectionRef().sendFrame(frame);


// Send editor ettings
// params.clear();
//
Expand Down
2 changes: 1 addition & 1 deletion ofSketchApp/src/App.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class App: public ofBaseApp
{
VERSION_MAJOR = 0,
VERSION_MINOR = 1,
VERSION_PATCH = 4
VERSION_PATCH = 5
};

static const std::string VERSION_PRE_RELEASE;
Expand Down
5 changes: 3 additions & 2 deletions ofSketchApp/src/MakeTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#include "MakeTask.h"
#include "Poco/TaskNotification.h"
#include "Poco/Environment.h"


namespace of {
Expand All @@ -33,8 +34,8 @@ namespace Sketch {

MakeTask::Settings::Settings():
ofRoot(ofToDataPath("openFrameworks")),
numProcessors(1),
isSilent(false),
numProcessors(Poco::Environment::processorCount()),
isSilent(true),
useDistccServer(false),
cxx(""),
cc("")
Expand Down
5 changes: 4 additions & 1 deletion scripts/build_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,16 @@ cd data/Projects

echo `pwd`

# remove any built project apps
rm -rf $(find . -name *.app)
rm -rf $(find . -name obj)
rm -rf $(find . -name *App)
rm -rf $(find . -name libs)

cd ../..

echo `pwd`

rm -rf $(find . -name obj)
rm -rf $(find . -name .git*)
rm -rf $(find . -name .DS_Store)

Expand Down

0 comments on commit ddc2bb9

Please sign in to comment.